2018-09-02 13:36:49 +02:00
|
|
|
package it.cavallium.warppi.math.functions.equations;
|
2018-09-02 12:45:51 +02:00
|
|
|
|
2018-09-02 13:36:49 +02:00
|
|
|
import it.cavallium.warppi.gui.expression.blocks.Block;
|
|
|
|
import it.cavallium.warppi.math.Function;
|
|
|
|
import it.cavallium.warppi.math.FunctionDynamic;
|
|
|
|
import it.cavallium.warppi.math.MathContext;
|
2018-09-12 22:16:33 +02:00
|
|
|
import it.cavallium.warppi.util.Error;
|
2017-05-16 22:02:44 +02:00
|
|
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
|
|
|
|
2017-02-14 20:02:03 +01:00
|
|
|
public class EquationsSystem extends FunctionDynamic {
|
2016-09-12 16:30:51 +02:00
|
|
|
static final int spacing = 2;
|
2017-01-17 22:32:40 +01:00
|
|
|
|
2018-09-22 11:17:30 +02:00
|
|
|
public EquationsSystem(final MathContext root) {
|
2017-01-17 22:32:40 +01:00
|
|
|
super(root);
|
2016-09-12 16:30:51 +02:00
|
|
|
}
|
2017-01-31 22:29:49 +01:00
|
|
|
|
2018-09-22 11:17:30 +02:00
|
|
|
public EquationsSystem(final MathContext root, final Function value) {
|
2017-01-31 22:29:49 +01:00
|
|
|
super(root, new Function[] { value });
|
2016-09-12 16:30:51 +02:00
|
|
|
}
|
2017-01-31 22:29:49 +01:00
|
|
|
|
2018-09-22 11:17:30 +02:00
|
|
|
public EquationsSystem(final MathContext root, final Function[] value) {
|
2017-01-17 22:32:40 +01:00
|
|
|
super(root, value);
|
2016-09-12 16:30:51 +02:00
|
|
|
}
|
|
|
|
|
2018-10-16 19:33:44 +02:00
|
|
|
@Override
|
|
|
|
public boolean equals(final Object o) {
|
2019-10-25 22:30:10 +02:00
|
|
|
if (!(o instanceof EquationsSystem)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
final FunctionDynamic f = (FunctionDynamic) o;
|
|
|
|
|
|
|
|
if (functions.length != f.getParametersLength()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < functions.length; i++) {
|
|
|
|
if (!functions[i].equals(f.getParameter(i))) {
|
2018-10-16 19:33:44 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2019-10-25 22:30:10 +02:00
|
|
|
|
|
|
|
return true;
|
2018-10-16 19:33:44 +02:00
|
|
|
}
|
|
|
|
|
2016-09-12 16:30:51 +02:00
|
|
|
@Override
|
2017-03-03 23:06:43 +01:00
|
|
|
public EquationsSystem clone() {
|
2018-10-04 23:39:19 +02:00
|
|
|
Function[] newFuncs = functions.clone();
|
|
|
|
for (int i = 0; i < newFuncs.length; i++) {
|
|
|
|
newFuncs[i] = newFuncs[i].clone();
|
|
|
|
}
|
|
|
|
return new EquationsSystem(root, newFuncs);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public EquationsSystem clone(MathContext c) {
|
|
|
|
Function[] newFuncs = new Function[this.functions.length];
|
|
|
|
for (int i = 0; i < newFuncs.length; i++) {
|
|
|
|
newFuncs[i] = this.functions[i] == null ? null : this.functions[i].clone(c);
|
|
|
|
}
|
|
|
|
return new EquationsSystem(c, newFuncs);
|
2016-09-12 16:30:51 +02:00
|
|
|
}
|
2017-04-10 22:50:43 +02:00
|
|
|
|
2017-05-26 22:37:18 +02:00
|
|
|
@Override
|
2018-09-22 11:17:30 +02:00
|
|
|
public ObjectArrayList<Block> toBlock(final MathContext context) throws Error {
|
2017-05-26 22:37:18 +02:00
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2018-10-06 10:31:34 +02:00
|
|
|
@Override
|
2019-08-10 20:51:29 +02:00
|
|
|
public <Argument, Result> Result accept(final Function.Visitor<Argument, Result> visitor, final Argument argument) {
|
|
|
|
return visitor.visit(this, argument);
|
2018-10-06 10:31:34 +02:00
|
|
|
}
|
2016-09-12 16:30:51 +02:00
|
|
|
}
|