Package org.oristool.math.expression
Class Expolynomial
java.lang.Object
org.oristool.math.expression.Expolynomial
A sum of
Exmonomial
terms.-
Field Summary
-
Constructor Summary
ConstructorDescriptionBuilds an empty expolynomial.Expolynomial
(Expolynomial expol) Builds the copy of an expolynomial. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(Expolynomial other) Adds another expolynomial.void
addExmonomial
(Exmonomial exmon) Adds an exmonomial to the sum.void
divide
(BigDecimal k) Divides by a constant.Evaluates the expolynomial.evaluate
(Variable base, boolean sign1, Variable offset1, boolean sign2, Variable offset2, BigDecimal constant) Replacesbase
with +/-offset1
+/-offset2
+constant
.evaluate
(Variable base, boolean sign, Variable offset, BigDecimal constant) Replacesbase
with +/-offset
+constant
.evaluate
(Variable var, OmegaBigDecimal value) Replaces a variable with its value.static Expolynomial
fromString
(String string) Builds an exponential from a string.Returns the constant value of this expolynomial of throws anIllegalStateException
exception 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.boolean
Checks if this expolynomial is constant.boolean
Checks if this expolynomial contains a single exponential term.static boolean
Checks if the input string is a valid expolynomial expression.void
Multiplies by a constant.void
multiply
(Expolynomial other) Multiplies by an expolynomial.static Expolynomial
Builds a new instance equal to a given constant.static Expolynomial
Builds a new instance equal to the constant 1.void
Normalizes the expolynomial, expanding all products and sums.void
pow
(int n) Takes the n-th power of this expolynomial.void
Replacesbase
withbase
+offset
.void
sub
(Expolynomial other) Subtracts another expolynomial.void
substitute
(Variable oldVar, Variable newVar) ReplacesoldVar
withnewVar
.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 anIllegalStateException
exception 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
ReplacesoldVar
withnewVar
.- 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
Replacesbase
with +/-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) Replacesbase
with +/-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
Replacesbase
withbase
+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.
-