Package org.tweetyproject.math.term
Class Sum
java.lang.Object
org.tweetyproject.math.term.Term
org.tweetyproject.math.term.AssociativeOperation
org.tweetyproject.math.term.Sum
This class models a sum of two terms.
- Author:
- Matthias Thimm
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionDifferentiates the term with respect to the given variable.void
This method expands all associative operations appearing in this term, e.g.getSums()
Returns all sums of this term.boolean
Checks whether this term is continuous in v.replaceTerm
(Term toSubstitute, Term substitution) Replaces each occurrence of "toSubstitute" by "substitution" and return the new term.simplify()
Simplifies this term in an equivalent way:
- Replaces products that contain a zero by the constant zero
- Removes a term one from products
- Removes a term zero from sums
- Aggregates constants in sums, products, and minimums
- Evaluates functional terms on constants
- Simplifies fractions where possible.Converts this term into a linear normal form, i.e.Return a quadratic formtoString()
value()
Computes the actual value of this term if it contains no variables.Methods inherited from class org.tweetyproject.math.term.AssociativeOperation
addAllTerm, addTerm, collapseAssociativeOperations, getAbsoluteValues, getMaximums, getMinimums, getProducts, getTerms, getVariables, isInteger, removeTerm, size
Methods inherited from class org.tweetyproject.math.term.Term
add, doubleValue, evaluateMatrix, evaluateVector, evaluateVector, isContinuous, isLinear, isQuadratic, min, minus, mult, replaceAllTerms, replaceAllTerms
-
Constructor Details
-
Sum
public Sum()Creates a new (empty) sum. -
Sum
-
Sum
Creates a new sum with the given list of terms.- Parameters:
terms
- a list of terms.
-
-
Method Details
-
value
-
replaceTerm
Description copied from class:Term
Replaces each occurrence of "toSubstitute" by "substitution" and return the new term.- Specified by:
replaceTerm
in classTerm
- Parameters:
toSubstitute
- the term to be substitutedsubstitution
- the new term- Returns:
- this term where "toSubstitute" is replaced by "substitution"
-
expandAssociativeOperations
public void expandAssociativeOperations()Description copied from class:Term
This method expands all associative operations appearing in this term, e.g. every min{a,b,c} becomes min{min{a,b},c}.- Specified by:
expandAssociativeOperations
in classTerm
-
toLinearForm
Description copied from class:Term
Converts this term into a linear normal form, i.e. into a sum of products of a constant and a variable.- Specified by:
toLinearForm
in classTerm
- Returns:
- a term in linear normal form.
- Throws:
IllegalArgumentException
- if this term cannot be converted into a linear normal form.
-
toQuadraticForm
Description copied from class:Term
Return a quadratic form- Specified by:
toQuadraticForm
in classTerm
- Returns:
- a quadratic form
- Throws:
IllegalArgumentException
- error
-
derive
Description copied from class:Term
Differentiates the term with respect to the given variable.- Specified by:
derive
in classTerm
- Parameters:
v
- a variable.- Returns:
- the derivation of this term wrt. the given variable.
- Throws:
NonDifferentiableException
- if the term cannot be differentiated.
-
isContinuous
Description copied from class:Term
Checks whether this term is continuous in v.- Specified by:
isContinuous
in classTerm
- Parameters:
v
- a variable- Returns:
- "true" iff this term is continuous in v.
-
simplify
Description copied from class:Term
Simplifies this term in an equivalent way:
- Replaces products that contain a zero by the constant zero
- Removes a term one from products
- Removes a term zero from sums
- Aggregates constants in sums, products, and minimums
- Evaluates functional terms on constants
- Simplifies fractions where possible. -
getSums
Description copied from class:Term
Returns all sums of this term.- Overrides:
getSums
in classAssociativeOperation
- Returns:
- all sums of this term.
-
toString
-