Class AbstractVectorMatrixRule

java.lang.Object
com.singularsys.extensions.rewrite.AbstractRewrite
com.singularsys.extensions.rewrite.matrix.AbstractVectorMatrixRule
All Implemented Interfaces:
RewriteRuleI, JepComponent, Serializable
Direct Known Subclasses:
AddVectorMatrixRule, CrossProductRule, DotProductRule, MultiplyVectorMatrixRule, ScalarDivisionRule, ScalarMultiplicationRule, SubtractVectorMatrixRule

public abstract class AbstractVectorMatrixRule extends AbstractRewrite
Base class for rules which operate on vectors and matrices. Provides methods for converting constant vectors.
Since:
Jep 4.1 extension 2.2
See Also:
  • Field Details

    • dv

      protected DimensionVisitor dv
      A visitor for finding the dimensions of a node.
  • Constructor Details

    • AbstractVectorMatrixRule

      public AbstractVectorMatrixRule()
  • Method Details

    • init

      public void init(Jep jep)
      Description copied from interface: JepComponent
      Initialize the component. This method is called whenever a component is added to Jep. Hence, it allows components to keep track of the other components they may rely on.
      Specified by:
      init in interface JepComponent
      Overrides:
      init in class AbstractRewrite
      Parameters:
      jep - the current Jep instance
    • vectorToList

      public ASTOpNode vectorToList(VectorI v) throws ParseException
      Converts a VectorI to an ASTOpNode with a List operator.
      Parameters:
      v -
      Returns:
      Node representing the vector as a List.
      Throws:
      ParseException
    • matrixToListOfLists

      public ASTOpNode matrixToListOfLists(MatrixI m) throws ParseException
      Converts a MatrixI to an ASTOpNode with a List operator.
      Parameters:
      m -
      Returns:
      Node representing the matrix as a List of Lists.
      Throws:
      ParseException - if the matrix cannot be converted.
    • asList

      public ASTOpNode asList(Node n) throws ParseException
      Convert an object to a list. Assumes the object is a list or vector. For a VectorI calls vectorToList(VectorI), for an ASTOpNode with a list operator returns the node, otherwise returns null.
      Parameters:
      n - node to convert
      Returns:
      an ASTOpNode representing a list, or null if the object cannot be converted.
      Throws:
      ParseException - if the object cannot be converted.
    • asListOfLists

      public ASTOpNode asListOfLists(Node n) throws ParseException
      Converts a node to a list of lists. Assumes the node is a MatrixI or an ASTOpNode with a list of lists operator. If the node is a MatrixI calls matrixToListOfLists(MatrixI), if the node is an ASTOpNode with a list of lists operator returns the node.
      Parameters:
      n -
      Returns:
      an ASTOpNode representing a list of lists.
      Throws:
      ParseException - if the node cannot be converted.