Class Sum


public class Sum extends AssociativeOperation
This class models a sum of two terms.
Author:
Matthias Thimm
  • Constructor Details

    • Sum

      public Sum()
      Creates a new (empty) sum.
    • Sum

      public Sum(Term first, Term second)
      Creates a new sum with the given terms.
      Parameters:
      first - a term.
      second - a term.
    • Sum

      public Sum(Collection<? extends Term> terms)
      Creates a new sum with the given list of terms.
      Parameters:
      terms - a list of terms.
  • Method Details

    • value

      public Constant value()
      Description copied from class: Term
      Computes the actual value of this term if it contains no variables.
      Specified by:
      value in class Term
      Returns:
      the value of this term, either a float or an integer.
    • replaceTerm

      public Term replaceTerm(Term toSubstitute, Term substitution)
      Description copied from class: Term
      Replaces each occurrence of "toSubstitute" by "substitution" and return the new term.
      Specified by:
      replaceTerm in class Term
      Parameters:
      toSubstitute - the term to be substituted
      substitution - 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 class Term
    • toLinearForm

      public Sum toLinearForm() throws IllegalArgumentException
      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 class Term
      Returns:
      a term in linear normal form.
      Throws:
      IllegalArgumentException - if this term cannot be converted into a linear normal form.
    • toQuadraticForm

      public Sum toQuadraticForm() throws IllegalArgumentException
      Specified by:
      toQuadraticForm in class Term
      Throws:
      IllegalArgumentException
    • derive

      public Term derive(Variable v) throws NonDifferentiableException
      Description copied from class: Term
      Differentiates the term with respect to the given variable.
      Specified by:
      derive in class Term
      Parameters:
      v - a variable.
      Returns:
      the derivation of this term wrt. the given variable.
      Throws:
      NonDifferentiableException - if the term cannot be differentiated.
    • isContinuous

      public boolean isContinuous(Variable v)
      Description copied from class: Term
      Checks whether this term is continuous in v.
      Specified by:
      isContinuous in class Term
      Parameters:
      v - a variable
      Returns:
      "true" iff this term is continuous in v.
    • simplify

      public Term 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.
      Specified by:
      simplify in class Term
      Returns:
      the simplified term.
    • getSums

      public Set<Sum> getSums()
      Description copied from class: Term
      Returns all sums of this term.
      Overrides:
      getSums in class AssociativeOperation
      Returns:
      all sums of this term.
    • toString

      public String toString()
      Specified by:
      toString in class Term