TDoubleValue *DefineDouble(const DewString &AVarName);
Defines new double variable.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | AVarName | const DewString & |
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.
Examples
#include "MtxParseClass.h"
#include "MtxParseExpr.h"
using namespace Dew;
using namespace Dew::Math;
void Example()
{
TMtxExpression* MyParser = new TMtxExpression();
// 1. Define variables
TDoubleValue* x = MyParser->DefineDouble("x");
TDoubleValue* y = MyParser->DefineDouble("y");
// 2. Set values
x->DoubleValue = 3.0;
y->DoubleValue = 4.0;
// 3. Add formula and evaluate,
MyParser->AddExpr("Sqrt(x*x+y*y)");
double res = MyParser->EvaluateDouble();
// res = 5
delete MyParser;
}
See Also: TMtxExpression::Undefine, TMtxExpression::VarByName, TMtxExpression::GetVarList, TMtxExpression::DefineVariable, TMtxExpression::DefineComplex, TMtxExpression::DefineVector, TMtxExpression::DefineMatrix, TMtxExpression::DefineFunction, TMtxExpression::DefineVaryingFunction, TMtxExpression::DefineOperator, TMtxExpression::DefineDoubleConstant, TMtxExpression::DefineComplexConstant
Declared in Dew::Math::TMtxExpression · Dew.Math/MtxParseExpr.h · Cross-compiler