|
stator
A math, geometry, and utility library
|
Stator is a Computer Algebra System (CAS) which focuses on using compile-time (template metaprogramming) or runtime stack-allocated algorithms. This means it is really, really, fast (zero overhead, or even a speed-up thanks to compile-time cancellation of terms, when compared to hand coded expressions). Its not as fully featured as a full CAS (such as Mathematica) though yet.
Not convinced? Take a look at the compile-time example below:
As everything is performed by the compiler via template metaprogramming, only the last substitution can incur any run-time cost. In fact, all of the code above has the same computational cost as writing:
Most modern compilers will also eliminate the cost of this too, leading to zero run-time cost.
As we have a symbolic representation of the function we transform it. Taking the derivative is also carried out at compile time:
Basic functionality like this also allows more complex operations, such as creating a truncated sym::taylor_series:
This creates a sym::Polynomial type, which is a std::array of the coefficients again at compile time; however, solving for the roots for a 5th order polynomial like this one requires iterations thus it must be done at run time; however, both are carried out without dynamic allocation and thus are very fast on any modern compiler.
This can all be carried out at runtime too:
See the guide to the symbolic library for more details on how to use the library.
First, you will need a modern compiler to use stator. In fact, you will need a version of GCC >= 6, clang >= 3.6, and MSVC >= 2015 for all of the library to work. The MSVC compiler has difficulties with deeply templated expressions thus it is not recommended for use with this library.
The current compiler support on Linux is available at the Travis CI page.
Stator is a header-only C++11 library. In many places it builds upon the Eigen 3 library (http://eigen.tuxfamily.org/), so to use it you must have both added to your compiler include path. For example, on linux
1.8.13