TMtxExpression.DefineVector Method

Overload List

#SignatureDescription
1function DefineVector(const AVarName: string): TVectorValue;Use internal vector.
2function DefineVector(const AVarName: string; const Vec: TVec): TVectorValue;Defines new vector variable.

Overload 1: function DefineVector(const AVarName: string): TVectorValue;

Use internal vector.

#NameTypeDescription
1AVarNamestring

Returns: TVectorValue

Overload 2: function DefineVector(const AVarName: string; const Vec: TVec): TVectorValue;

Defines new vector variable.

#NameTypeDescription
1AVarNamestring
2VecTVec

Returns: TVectorValue

Remarks:

If variable with name AVarName already was definded, it is redefined and all expressions which contain the symbol AVarName will be recompiled before the next evaluation. External vector may be assigned as values holder. If external vector is not assigned, internal vector will be used.

Examples
uses MtxParseExpr, MtxExpr, MtxParseClass;

procedure Example(MyParser: TMtxExpression);
var x: TVectorValue;
s: TDoubleValue;
res: Vector;
begin
    // 1. Define variables
    x := MyParser.DefineVector('x');
    s := MyParser.DefineDouble('s');

    // 2. Set values
    x.Value.SetIt(false,[1,-1,1]);
    s.DoubleValue := 0.5;

    // 3. Add formula and evaluate,
    MyParser.AddExpr('-s*x');
    res := MyParser.EvaluateVector;
    // res = (-0.5,0.5, -0.5)
end;
See Also: TMtxExpression.Undefine, TMtxExpression.VarByName, TMtxExpression.GetVarList, TMtxExpression.DefineVariable, TMtxExpression.DefineDouble, TMtxExpression.DefineComplex, TMtxExpression.DefineMatrix, TMtxExpression.DefineFunction, TMtxExpression.DefineVaryingFunction, TMtxExpression.DefineOperator, TMtxExpression.DefineDoubleConstant, TMtxExpression.DefineComplexConstant