com.accelad.math.nilgiri.autodiff.DifferentialFunction Maven / Gradle / Ivy
package com.accelad.math.nilgiri.autodiff;
import java.util.List;
import com.accelad.math.nilgiri.Field;
public abstract class DifferentialFunction>
implements Field>, Differential> {
protected DifferentialFunction() {
}
public abstract X getValue();
@Override
public abstract double getReal();
public abstract String getFormula(List> variables);
@Override
public abstract String toString();
public boolean isPrecisionOK(int precision) {
return (13 - precision) > Math.log10(getReal()) + 1;
}
public boolean isConstant() {
return false;
}
public boolean isVariable() {
return false;
}
@Override
public abstract DifferentialFunction diff(Variable i_v1);
@Override
public DifferentialFunction plus(DifferentialFunction i_v) {
return i_v.plused(this);
}
protected DifferentialFunction plused(DifferentialFunction i_v) {
return new Sum(i_v, this);
}
@Override
public DifferentialFunction minus(DifferentialFunction i_v) {
return plus(i_v.negate());
}
@Override
public DifferentialFunction mul(DifferentialFunction i_v) {
return i_v.muled(this);
}
protected DifferentialFunction muled(DifferentialFunction i_v) {
return new Product(i_v, this);
}
@Override
public DifferentialFunction div(DifferentialFunction i_v) {
return mul(i_v.inverse());
}
@Override
public DifferentialFunction inverse() {
return new Inverse(this);
}
@Override
public DifferentialFunction negate() {
return new Negative(this);
}
@Override
public DifferentialFunction mul(long i_n) {
return new PolynomialTerm(i_n, this, 1);
}
@Override
public DifferentialFunction pow(int i_n) {
return new PolynomialTerm(1L, this, i_n);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy