com.accelad.math.nilgiri.autodiff.Product Maven / Gradle / Ivy
package com.accelad.math.nilgiri.autodiff;
import java.util.List;
import com.accelad.math.nilgiri.Field;
public class Product> extends AbstractBinaryFunction {
public Product(DifferentialFunction i_v1, DifferentialFunction i_v2) {
super(i_v1, i_v2);
}
@Override
public X getValue() {
return larg().getValue().mul(rarg().getValue());
}
@Override
public double getReal() {
return larg().getReal() * rarg().getReal();
}
@Override
public DifferentialFunction diff(Variable i_v1) {
return (larg() == rarg()) ? larg().diff(i_v1).mul(rarg()).mul(2L) // Field
// is
// commutative
// with
// respect
// to
// multiplication.
: (larg().diff(i_v1).mul(rarg())).plus(larg().mul(rarg().diff(i_v1)));
}
@Override
public String toString() {
return "(" + larg().toString() + "*" + rarg().toString() + ")";
}
@Override
public String getFormula(List> variables) {
return "(" + larg().getFormula(variables) + "*" + rarg().getFormula(variables) + ")";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy