Class MatrixEquation

  • All Implemented Interfaces:

    
    public class MatrixEquation
    
                        

    A wrapper class that extends EJML's Equation functionality to work seamlessly with jline.util.matrix.Matrix objects.

    This class provides a bridge between the EJML equation parsing and evaluation system and the LINE matrix system. It automatically handles conversion between Matrix objects and EJML's internal representations, allowing for intuitive mathematical expressions to be evaluated using LINE matrices.

    Usage example:

    Matrix A = new Matrix(3, 3);
    Matrix B = new Matrix(3, 3);
    MatrixEquation eq = new MatrixEquation();
    eq.alias("A", A, "B", B);
    MatrixEquation result = eq.process("C = A * B + I");
    Matrix C = result.lookupSimple("C");
    
    Since:

    1.0

    Author:

    QORE Lab, Imperial College London

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      MatrixEquation() Creates a new MatrixEquation with an empty equation context.
      MatrixEquation(Equation e) Creates a MatrixEquation wrapping an existing EJML Equation.
      MatrixEquation(Array<Object> args) Creates a new MatrixEquation and immediately aliases the provided variables.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      void alias(Array<Object> args) Creates aliases for variables that can be used in matrix equations.
      Matrix lookupSimple(String token) Retrieves a matrix result from the equation context by variable name.
      MatrixEquation process(String equation) Processes a mathematical equation string and returns a new MatrixEquation containing the results.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MatrixEquation

        MatrixEquation()
        Creates a new MatrixEquation with an empty equation context.
      • MatrixEquation

        MatrixEquation(Equation e)
        Creates a MatrixEquation wrapping an existing EJML Equation.
        Parameters:
        e - the EJML Equation to wrap
      • MatrixEquation

        MatrixEquation(Array<Object> args)
        Creates a new MatrixEquation and immediately aliases the provided variables.
        Parameters:
        args - variable name and value pairs (must be even number of arguments)
    • Method Detail

      • alias

         void alias(Array<Object> args)

        Creates aliases for variables that can be used in matrix equations. Arguments should be provided in pairs: variable name followed by variable value. Matrix objects are automatically converted to EJML's sparse matrix format.

        Parameters:
        args - variable name and value pairs (name1, value1, name2, value2, ...
      • lookupSimple

         Matrix lookupSimple(String token)

        Retrieves a matrix result from the equation context by variable name. The returned matrix is automatically converted from EJML's SimpleMatrix format to the LINE Matrix format.

        Parameters:
        token - the variable name to look up
        Returns:

        the matrix associated with the given variable name

      • process

         MatrixEquation process(String equation)

        Processes a mathematical equation string and returns a new MatrixEquation containing the results. The equation can reference any variables that have been aliased in this context.

        Parameters:
        equation - the mathematical equation to process (e.g.
        Returns:

        a new MatrixEquation containing the processed equation results