Class AbstrctPolynomialRewriter

java.lang.Object
com.singularsys.extensions.polynomials.AbstrctPolynomialRewriter
Direct Known Subclasses:
ComplexPolynomialRewriter

public class AbstrctPolynomialRewriter extends Object
A base class for polynomial rewriters. The default implementation calls the rewrite method for each node, and returns a copy of the original.
Since:
Jep 4.1, extension 2.2
  • Constructor Details

  • Method Details

    • rewrite

      public PNodeI rewrite(PNodeI node) throws ParseException
      Rewrite a node. The default implementation calls the rewrite method for each node type, and returns a copy of the original.
      Parameters:
      node - the node to rewrite
      Returns:
      a new node
      Throws:
      ParseException
    • rewrite

      protected PNodeI rewrite(PFunction fun) throws ParseException
      Rewrite a function. The default implementation creates a new PFunction with the same name and pfmc, but with the arguments rewritten.
      Parameters:
      fun - the function to rewrite
      Returns:
      a new PFunction
      Throws:
      ParseException
    • rewrite

      protected PConstant rewrite(PConstant c) throws ParseException
      Rewrite a constant. The default implementation returns a new constant with the same value.
      Parameters:
      c - the constant to rewrite
      Returns:
      the same constant
      Throws:
      ParseException
    • rewrite

      protected PNodeI rewrite(Monomial m) throws ParseException
      Rewrite a monomial. The default implementation creates a new MutableMonomial with the rewritten of the coefficient, variables and powers. The new monomial is then rewritten using the rewrite(MutableMonomial) method.
      Parameters:
      m - the monomial to rewrite
      Returns:
      a new monomial
      Throws:
      ParseException
    • rewrite

      protected PNodeI rewrite(MutableMonomial mm) throws ParseException
      Rewrite a mutable monomial. The default implementation simply returns mm.toNode() creating new monomial with the same coefficient, variables and powers.
      Parameters:
      mm - the mutable monomial to rewrite
      Returns:
      a new monomial
      Throws:
      ParseException
    • rewrite

      protected PNodeI rewrite(POperator op) throws ParseException
      Rewrite an operator. The default implementation returns the same operator.
      Parameters:
      op - the operator to rewrite
      Returns:
      the same operator
      Throws:
      ParseException
    • rewrite

      protected PNodeI rewrite(PVariable v) throws ParseException
      Rewrite a variable. The default implementation creates a new PVariable with the same Jep variable.
      Parameters:
      v - the variable to rewrite
      Returns:
      the same variable
      Throws:
      ParseException
    • rewrite

      protected PNodeI rewrite(Polynomial p) throws ParseException
      Rewrite a polynomial. The default implementation creates a new MutablePolynomial with rewritten versions of each terms. The new polynomial is then rewritten using the rewrite(MutablePolynomial) method.
      Parameters:
      p - the polynomial to rewrite
      Returns:
      a new polynomial
      Throws:
      ParseException
    • rewrite

      protected PNodeI rewrite(MutablePolynomial mp) throws ParseException
      Rewrite a mutable polynomial. The default implementation simply returns mp.toNode() creating new polynomial with the same terms.
      Parameters:
      mp - the mutable polynomial to rewrite
      Returns:
      a new polynomial
      Throws:
      ParseException