TMtxExpression.DefineMatrix Method

Overload List

#SignatureDescription
1TMatrixValue DefineMatrix(String AVarName)Use internal matrix.
2TMatrixValue DefineMatrix(String AVarName, TMtx mtx)DefineMatrix defines new matrix variable.

Overload 1: TMatrixValue DefineMatrix(String AVarName)

Use internal matrix.

#NameTypeDescription
1AVarNameString

Returns: TMatrixValue

Overload 2: TMatrixValue DefineMatrix(String AVarName, TMtx mtx)

DefineMatrix defines new matrix variable.

#NameTypeDescription
1AVarNameString
2mtxTMtxsource 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
using Dew.Math;
using Dew.Math.Units;

namespace Dew.Examples
{
    void Example(TMtxExpression MyParser)
    {
        // 1. Define variables
        TMatrixValue A = MyParser.DefineMatrix("A");
        TMatrixValue B = MyParser.DefineDouble("B");

        // 2. Set values
        A.Value.SetIt(2,2, false,new double[] {2,1,3,0});
        B.Value.SetIt(2,2, false,new double[] {1,0,1,1});

        // 3. Add formula and evaluate,
        MyParser.AddExpr("A+2*B");
        Matrix res = new Matrix(false,0,0)
        res = MyParser.EvaluateMatrix;
        // res = (4,1; 5,2)
    }
}
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