Skip to content
/ semt Public
forked from st-gille/semt

compile time symbolic differentiation via C++ template expressions

License

Notifications You must be signed in to change notification settings

maierbn/semt

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

  • partial differentiation
  • easy-to-use objects for multi-valued functions
  • basic expression substitution that will simplify generated expressions
  • advanced facilities to create expressions

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:

  • semt_examples - These are used in the documentation.
  • semt_speed - A test run on a mapping R^10 -> R^10.
  • semt_newton - Implementation of Newton's method.
  • semt_check - Some crude tests.

You can run make [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.

About

compile time symbolic differentiation via C++ template expressions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 81.7%
  • C 14.9%
  • Makefile 2.2%
  • Shell 1.2%