Overload List
| # | Signature | Description |
|---|---|---|
| 1 | function DefineMatrix(const AVarName: string): TMatrixValue; | Use internal matrix. |
| 2 | function DefineMatrix(const AVarName: string; const mtx: TMtx): TMatrixValue; | DefineMatrix defines new matrix variable. |
Overload 1: function DefineMatrix(const AVarName: string): TMatrixValue;
Use internal matrix.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | AVarName | string |
Returns: TMatrixValue
Overload 2: function DefineMatrix(const AVarName: string; const mtx: TMtx): TMatrixValue;
DefineMatrix defines new matrix variable.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | AVarName | string | |
| 2 | mtx | TMtx |
Returns: TMatrixValue
Remarks:
If variable with name AVarName already was definded, it will be redefined and all expressions which contain the symbol AVarName will be recompiled before the next evaluation. External matrix may be assigned as values holder. If external matrix is not assigned, internal matrix will be used.
Examples
uses MtxParseExpr, MtxExpr, MtxParseClass;
procedure Example(MyParser: TMtxExpression);
var A,B: TMatrixValue;
res: Matrix;
begin
// 1. Define variables
A := MyParser.DefineMatrix('A');
B := MyParser.DefineDouble('B');
// 2. Set values
A.Value.SetIt(2,2, false, [2,1,3,0]);
B.Value.SetIt(2,2, false, [1,0,1,1]);
// 3. Add formula and evaluate,
MyParser.AddExpr('A+2*B');
res := MyParser.EvaluateMatrix;
// res = (4,1; 5,2)
end;
See Also: TMtxExpression.Undefine, TMtxExpression.VarByName, TMtxExpression.GetVarList, TMtxExpression.DefineVariable, TMtxExpression.DefineDouble, TMtxExpression.DefineInteger, TMtxExpression.DefineBool, TMtxExpression.DefineComplex, TMtxExpression.DefineVector, TMtxExpression.DefineIntVector, TMtxExpression.DefineFunction, TMtxExpression.DefineVaryingFunction, TMtxExpression.DefineOperator, TMtxExpression.DefineDoubleConstant, TMtxExpression.DefineComplexConstant