I evaluate Math.NET Symbolics for use in our application, where we want a simple math analyzer to allow the user to compute user equations from our measurement data. Our data is presented as Complex .
For testing, I use the following code snippet in LINQPad:
var complexA = new Complex(1, 1);
var complexB = new Complex(1, 2);
var symbols = new Dictionary<string, FloatingPoint>()
{
{ "a", complexA },
{ "b", complexB }
};
Evaluate.Evaluate(symbols, Infix.ParseOrUndefined("1/(a*b)+cos(b)")).ComplexValue.Dump();
This works fine, but I could not find the following operators:
How can we get the REAL or IMAGINARY part of the characters?
I tried real(b)
and imag(b)
but it did not work.
As a workaround, I could also do the following, but I would prefer that the operator kind of abs(b)
get me a value:
var complexA = new Complex(1, 1);
var complexB = new Complex(1, 2);
var symbols = new Dictionary<string, FloatingPoint>()
{
{ "a", complexA },
{ "b", complexB },
{ "b_REAL", complexB.Real },
{ "b_IMAG", complexB.Imaginary }
};
Evaluate.Evaluate(symbols, Infix.ParseOrUndefined("1/(a*b)+b_REAL")).ComplexValue.Dump();
P.S.: , , .