Package jline.util.matrix
Class MatrixEquation
java.lang.Object
jline.util.matrix.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
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new MatrixEquation with an empty equation context.MatrixEquation(Object... args) Creates a new MatrixEquation and immediately aliases the provided variables.MatrixEquation(org.ejml.equation.Equation e) Creates a MatrixEquation wrapping an existing EJML Equation. -
Method Summary
Modifier and TypeMethodDescriptionvoidCreates aliases for variables that can be used in matrix equations.lookupSimple(String token) Retrieves a matrix result from the equation context by variable name.Processes a mathematical equation string and returns a new MatrixEquation containing the results.
-
Constructor Details
-
MatrixEquation
public MatrixEquation()Creates a new MatrixEquation with an empty equation context. -
MatrixEquation
public MatrixEquation(org.ejml.equation.Equation e) Creates a MatrixEquation wrapping an existing EJML Equation.- Parameters:
e- the EJML Equation to wrap
-
MatrixEquation
Creates a new MatrixEquation and immediately aliases the provided variables.- Parameters:
args- variable name and value pairs (must be even number of arguments)- Throws:
RuntimeException- if an odd number of arguments is provided
-
-
Method Details
-
alias
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, ...)- Throws:
RuntimeException- if an odd number of arguments is provided
-
lookupSimple
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
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., "C = A * B + I")- Returns:
- a new MatrixEquation containing the processed equation results
-