Abstract syntax tree (AST) based symbolic math system with an expression parser.
The library provides
- a tokenizer in
SymbolicMathTokenize
- an infix to prefix tree converter in
SymbolicMathParser
- an automatic differentiation component
- Just-in-time compilation
Build using
make
SymbolicMath features just-in-time (JIT) compilation of expression trees. Available JIT backends are:
Backend | Project | Description |
---|---|---|
llvmir |
LLVM | Builds LLVM intermediate representation, optimizes it, and compiles it with LLVM Orc JIT |
ccode |
- | Launches an external compiler to compile generated C code and links in the generated object using dlopen |
libjit |
GNU LibJIT | JIT library originally developed for the Mono project. Limited architecture support |
lightning |
GNU Lightning | Low level assembly generator. Good architecture support |
sljit |
SLJIT | Low level assembly generator. Broad architecture support, no external dependencies |
vm |
- | Builds byte code for a stack based virtual machine. This is a fallback backend in case none of the proper JIT backends work |
Research is ongoing as to which backend is best used. See performance comparison for details.
> ./mathparse 'a + b * (c - d'
a + b * (c - d
~~^~~
Unmatched opening bracket
./mathparse 'a + b * c) - d'
a + b * c) - d
~~^~~
Unmatched closing bracket
> ./mathparse 'a + b c - d'
a + b c - d
~~^~~
Operator expected here
> ./mathparse 'a + b - * d'
a + b - * d
~~^~~
Did not expect operator here
> ./mathparse 'a + b * c -= d'
a + b * c -= d
~~^~~
Unknown operator
> ./mathparse 'a + b * $ - d'
a + b * $ - d
~~^~~
Parse error
> ./mathparse 'a + sin()'
a + sin()
~~^~~
Function takes 1 argument(s), but none were given
> ./mathparse 'a + sin(1,3)'
a + sin(1,3)
~~^~~
Expected 1 argument(s) but found 2
> ./mathparse 'a - schwing(1,3,3)'
a - schwing(1,3,3)
~~^~~
Unknown function