You are here: Symbol Reference > MtxParseExpr Namespace > Classes > TMtxExpression Class > public > EvaluateMatrix Method > TMtxExpression.EvaluateMatrix Method ()
MtxVec VCL
ContentsIndex
PreviousUpNext
TMtxExpression.EvaluateMatrix Method ()

Evaluates all expressions from the list.

Pascal
function EvaluateMatrix: TMtx; overload;

result of the latest expression as matrix value.

Use parser to evaluate the "A+2*B" formula where A=(2,1; 3, 0) B=(1,0; 1,1) are 2x2 matrices.

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;
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!