I've created a math compiler written entirely in C# called
dotMath. I'm thinking about releasing it under GPL, I'm in
the process of seeing how to release it and the associated pro's and
con's. I'd love to find someone who has done or is doing this and
blogging the experience.
The library is a two-pass compiler. Once the compilation phase
is complete, parsing is no longer needed to evaluate the
expression. The library offers roughly 100-fold speed improvement
over parsing-based evaluators.
The library can be used with variables and the API allows for full
discovery/setting of the variables. Here's sample code that uses
the library:
dotMath.CFuncCompiler oComp = new dotMath.CFuncCompiler( "(3*sin(x))/5");
oComp.Compile(); // normally set try..catch to trap syntax/expression errors
double dXValue = 10;
double dYValue = 0;
for( int i = 0; i < 100; i++)
{
oComp.SetValue("x", dXValue++ );
dYvalue = oComp.Evaluate();
// do something with y-value here
}
In addition, users may create and register their own functions
with the class thereby increasing the capabilities of the compiler
without dealing with the parsing and compilation details.
I'll keep blogging the experience of taking this public.... stay tuned! :)