Function Parser for C++ v4.5.1

What is this library?

This C++ library offers a class which can be used to parse and evaluate a mathematical function from a string (which might be eg. requested from the user). The syntax of the function string is similar to mathematical expressions written in C/C++ (the exact syntax is specified in the documentation below). The function can then be evaluated with different values of variables.

For example, a function like "sin(sqrt(x*x+y*y))" can be parsed from a string (either std::string or a C-style string) and then evaluated with different values of x and y. This library can be useful for evaluating user-inputted functions, or in some cases interpreting mathematical expressions in a scripting language.

This library aims for maximum speed in both parsing and evaluation, while keeping maximum portability. The library should compile and work with any standard-conforming C++ compiler.

Different numerical types are supported: double, float, long double, long int, std::complex (of types double, float and long double), multiple-precision floating point numbers using the MPFR library, and arbitrary precision integers using the GMP library. (Note that it's not necessary for these two libraries to exist in the system in order to use the Function Parser library with the other numerical types. Support for these libraries is optionally compiled in using preprocessor settings.)

This Library is distributed under the Lesser General Public License (LGPL) version 3.

Full HTML documentation.

Simple example program.

Some speed tests.

Download

Download fparser4.5.1.zip v4.5.1 (released 11 Nov 2012)

(Older versions: v4.4.3, v4.3, v4.2, v4.1, v4.0.5, v3.3.2, v3.2.1, v3.1.5, v3.0.3, v2.84, v2.8, v2.71, v2.63, v2.51, v2.4, v2.3, v2.22)

Note that the library uses a few advanced (but still standard-conforming) C++ techniques which might make it difficult if not impossible to compile it with some old C++ compilers with poorer support for C++ features. The library has been successfully tested with gcc 4.3.x and MS Visual C++ 2005. Some very old compilers are known to have problems compiling the library (such as C++ Builder 6 and older, and gcc 2.x.)

Development version

The basic library package above contains the bare minimum files intended for the usage of the library in C++ applications. If you want to simply use the library in your program, then download the package above.

The development version of the library is intended for those who want to modify and enhance the library. Besides the files contained in the basic package above, the development version contains the full optimizer sources, optimizer rule generation tools, an extensive automatic regression testbed, a Makefile and other tools.

Download the development package: fparser4.5.1_devel.tar.bz2

What's new?

What's new in v4.5.1

What's new in v4.5

You can also view the full version history.

Some software which use this library

Function Viewer: A small program I made to demonstrate the function parser.