Package org.oristool.math.expression
Class Expolynomial
java.lang.Object
org.oristool.math.expression.Expolynomial
A sum of
Exmonomial terms.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBuilds an empty expolynomial.Expolynomial(Expolynomial expol) Builds the copy of an expolynomial. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(Expolynomial other) Adds another expolynomial.voidaddExmonomial(Exmonomial exmon) Adds an exmonomial to the sum.voiddivide(BigDecimal k) Divides by a constant.Evaluates the expolynomial.evaluate(Variable base, boolean sign1, Variable offset1, boolean sign2, Variable offset2, BigDecimal constant) Replacesbasewith +/-offset1+/-offset2+constant.evaluate(Variable base, boolean sign, Variable offset, BigDecimal constant) Replacesbasewith +/-offset+constant.evaluate(Variable var, OmegaBigDecimal value) Replaces a variable with its value.static ExpolynomialfromString(String string) Builds an exponential from a string.Returns the constant value of this expolynomial of throws anIllegalStateExceptionexception if the expolynomial is not constant.The exponential rate of the single exponential term contained in this expolynomial.Returns all the variables used in this expolynomial.Computes the primitive function of this expolynomial.integrate(Variable var, OmegaBigDecimal lower, OmegaBigDecimal upper) Integrates this expolynomial over an interval.booleanChecks if this expolynomial is constant.booleanChecks if this expolynomial contains a single exponential term.static booleanChecks if the input string is a valid expolynomial expression.voidMultiplies by a constant.voidmultiply(Expolynomial other) Multiplies by an expolynomial.static ExpolynomialBuilds a new instance equal to a given constant.static ExpolynomialBuilds a new instance equal to the constant 1.voidNormalizes the expolynomial, expanding all products and sums.voidpow(int n) Takes the n-th power of this expolynomial.voidReplacesbasewithbase+offset.voidsub(Expolynomial other) Subtracts another expolynomial.voidsubstitute(Variable oldVar, Variable newVar) ReplacesoldVarwithnewVar.toString()
-
Field Details
-
mathContext
-
-
Constructor Details
-
Expolynomial
public Expolynomial()Builds an empty expolynomial. -
Expolynomial
Builds the copy of an expolynomial.- Parameters:
expol- input expolynomial
-
-
Method Details
-
newOneInstance
Builds a new instance equal to the constant 1.- Returns:
- a constant expolynomial equal to 1
-
newConstantInstance
Builds a new instance equal to a given constant.- Parameters:
value- input value- Returns:
- a constant expolynomial equal to
value
-
getExmonomials
-
addExmonomial
Adds an exmonomial to the sum.- Parameters:
exmon- input exmonomial
-
getVariables
Returns all the variables used in this expolynomial.- Returns:
- set of variables
-
getConstant
Returns the constant value of this expolynomial of throws anIllegalStateExceptionexception if the expolynomial is not constant.- Returns:
- constant value of the expolynomial
- Throws:
IllegalStateException- if the expolynomial is not constant
-
normalize
public void normalize()Normalizes the expolynomial, expanding all products and sums. -
add
Adds another expolynomial.- Parameters:
other- input expolynomial
-
sub
Subtracts another expolynomial.- Parameters:
other- input expolynomial
-
multiply
Multiplies by an expolynomial.- Parameters:
other- input expolynomial
-
multiply
Multiplies by a constant.- Parameters:
k- constant
-
divide
Divides by a constant.- Parameters:
k- constant
-
substitute
ReplacesoldVarwithnewVar.- Parameters:
oldVar- variable to be replacednewVar- new variable
-
evaluate
Evaluates the expolynomial.- Parameters:
m- map with values for all the variables- Returns:
- expolynomial value
-
evaluate
Replaces a variable with its value.- Parameters:
var- variable to be replacedvalue- value of the variable- Returns:
- expolynomial after the substitution
-
evaluate
Replacesbasewith +/-offset+constant.- Parameters:
base- variable to be replacedsign- true if sign of the offset is positiveoffset- offset to be addedconstant- constant to be added- Returns:
- resulting
Expolynomial
-
evaluate
public Expolynomial evaluate(Variable base, boolean sign1, Variable offset1, boolean sign2, Variable offset2, BigDecimal constant) Replacesbasewith +/-offset1+/-offset2+constant.- Parameters:
base- variable to be replacedsign1- true if sign of the first offset is positiveoffset1- first offset to be addedsign2- true if sign of the second offset is positiveoffset2- second offset to be addedconstant- constant to be added- Returns:
- resulting
Expolynomial
-
shift
Replacesbasewithbase+offset.- Parameters:
base- variable to be replacedoffset- offset to be applied
-
integrate
Computes the primitive function of this expolynomial.- Parameters:
var- integration variable- Returns:
- primitive function
-
integrate
Integrates this expolynomial over an interval.- Parameters:
var- integration variablelower- lower boundupper- upper bound- Returns:
- resulting expolynomial
-
pow
public void pow(int n) Takes the n-th power of this expolynomial.- Parameters:
n- exponent
-
toString
-
isConstant
public boolean isConstant()Checks if this expolynomial is constant.- Returns:
- true if this expolynomial is constant.
-
isExponential
public boolean isExponential()Checks if this expolynomial contains a single exponential term.- Returns:
- true if this expolynomial contains a single exponential term
-
getExponentialRate
The exponential rate of the single exponential term contained in this expolynomial. If other terms are present, throws anIllegalStateException.- Returns:
- true if this expolynomial contains a single exponential term
- Throws:
IllegalStateException- if this is not a single exponential term
-
fromString
Builds an exponential from a string.- Parameters:
string- input string- Returns:
- exponential instantance
-
isValid
Checks if the input string is a valid expolynomial expression.- Parameters:
string- input string- Returns:
- true if the input string is a valid expolynomial expression.
-