GitHub - st-gille/semt: compile time symbolic differentiation via C++ template expressions (original) (raw)

SEMT - Compile-time symbolic differentiation via C++ templates

The SEMT library provides an easy way to define arbitrary functions and obtain their derivatives via C++ expression templates.

This is an extension of Zvi Guttermans original work accompanying his master thesis"Symbolic Pre-computation for Numerical Applications".

Additional features include:

Because of this origin, all code is free, see the LICENSE file for details.

Simple example

DVAR(x, 0);
auto f = pow(x, INT(3)) + sin(x);
cout << f << endl;
cout << deriv_t(f, x) << endl;

will print

((x0)^(3) + sin(x0))
((3 * (x0)^(2)) + cos(x0))

to your console.

Usage

Run make doc to create the documentation with doxygen. You can view the documentation here or download it here. There you will find an introductory example and the comprehensive API documentation.

There are several example programs:

You can runmake [release | gprof | gcov] <binary>to compile a corresponding binary.

Using release mode enables compiler optimizations and places the binary in the Release folder.

Using gprof creates a call graph and with timings in gprof/<binary>_<arguments>, where you can supply arguments via the ${ARGS} make variable.

Using gcov outputs coverage results into gcov.

Contact me at gille@numasoft.de for any questions.