muParser - a fast math parser library
Version 2.1.0
My home
page
muParser
API-doc

### Introduction

About the parser
Release notes
News
Software using muParser
Licence

### Features

Features
Overview
Built in functions
Built in binary operators
Other operators

### Build instructions

Building on Win32
Building on BSD/Linux
Misc build instructions
Including the files
Compiler switches
Where to ask for help

### Math parser interface

Parser (de)initialization
Evaluating an expression
Single return value
Multiple return values
Bulk mode
Setting the expression
Defining identifier charsets
Defining parser variables
Explicit variable definition
Implicit variable definition
Defining constants
Adding functionand operators
Defining functions
Defining operators
Unary operators
Binary operators
Querying variables
Querying constants
Value recognition callbacks
Removing variables/constants
Localization
Error handling
Example code

### Current version

Benchmarks

## About the parser

Many applications require the parsing of mathematical expressions. The main objective of this library is to provide a fast and easy way of doing this. muParser is an extensible high performance math expression parser library written in C++. It works by transforming a mathematical expression into bytecode and precalculating constant parts of the expression.

muParser C# wrapper
a math parser for .NET
muParserX
a math parser with support for arrays, strings and complex numbers.
muParserSSE
a muParser version with a just in time compiler based on asmjit
The library was designed with portability in mind and should compile on every standard compliant C++ compiler. Wrapper for C and C# exist. The parser archive contains ready to use project and makefiles files for a variety of platforms. The code runs on both 32 bit and 64 bit architechtures and has been tested using MS VC++ V8.0 and GCC V4.4.1. Code samples are provided in order to help you understand its usage. The library is open source and distributed under the MIT license.

Before I go on, I'd like to thank SourceForge for hosting this project. This pages would not exist without the webspace provided by them and of course I'd like to thank CodeProject for hosting the original math parser article.

## Support this project

muParser is free software and anyone can use it free of charge for commercial and noncommercial purposes. If you wish you can support this project by making a small donation:
A project like muParser requires permanent maintanence in order to adopt to new platforms, new compiler version and for fixing bugs. So if you are using the library and find it useful i would like to encourage you to make a donation in order to help keeping the project up to date. I can officially guarantee that you make my day by donating even a small amount of money. In a way this is a "Wow the people actually really appreciate what i'm doing" kind of thing and that's whats driving me and ultimately this is what is keeping this project alive.

## Release Notes

#### Rev 2.1.0: 19.11.2011

This is a service release incorporating minor bugfixes.

- New feature
  - Function atan2 added.
- Bugfixes
  - Issue 3438380: Changed behaviour of tellg with GCC >4.6 led to failures in value detection callbacks.
  - Issue 3438715: only "double" is a valid MUP_BASETYPE MUP_BASETYPE can now be any of: float, double, long double, short, unsigned short, unsigned int, long, unsigned long. Previousely only floating point types were allowed. Using "int" is still not allowed!
  - Custom value recognotion callbacks added with AddValIdent had lower priority than built in ones. Consequently hex value recognition using IsHexVal would fail since the built in IsVal would read the "0" from the hex prefix "0x".

#### Rev 2.0.0: 04.09.2011

This release introduces a new version numbering scheme in order to make future changes in the ABI apparent to users of the library. The number is now based on the SONAME property as used by GNU/Linux.

- Changes
  - Beginning with this version all version numbers will be SONAME compliant.
  - Project files for MSVC2010 added.
  - Bytecode parsing engine cleaned up and rewritten.
  - Retrieving all results of expressions made up of comma separate subexpressions is now possible with a new Eval overload.
  - Callback functions with fixed number of arguments can now have up to 10 Parameters (previous limit was 5).
- New features
  - ternary if-then-else operator added (C++ like; "(...) ? ... : ..." )
  - new intrinsic binary operators: "&&", "||" (logical and, or)
  - A new bulkmode allows submitting large arrays as variables to compute large numbers of expressions with a single call. This can drastically improve parsing performance when interfacing the library from managed languages like C#. (It doesn't bring any performance benefit for C++ users though...)
- Removed features
  - Project files for MSVC2003 removed
  - intrinsic "and", "or" and "xor" operators have been removed. I'd like to let users the freedom of defining them on their own versions (either as logical or bitwise operators).
  - Implementation for complex numbers removed. This was merely a hack. If you need complex numbers try muParserX which provides native support for them. (see: muParserX)
- Bugfixes
  - User defined operators could collide with built in operators that entirely contained their identifier. i.e. user defined "&" would not work with the built in "&&" operator since the user defined operator was detected with a higher priority resulting in a syntax error.
  - Detection of unknown variables did not work properly in case a postfix operator was defined which was part of the undefined variable. i.e. If a postfix operator "m" was defined expressions like "multi*1.0" did not detect "multi" as an undefined variable. (Reference: see bug tracker)
  - Postfix operators sharing the first few characters were causing bogus parsing exception. (Reference: see bug tracker)

#### Rev 1.34: 04.09.2010

This is the second service release of 2010.

- Changes
  - The prefix needed for parsing hex values is now "0x" and no longer "$".
  - AddValIdent reintroduced into the DLL interface.
- New features
  - The associativity of binary operators can now be changed. The pow operator is now right associative. (This is what mathematica is using)
  - Seperator can now be used outside of functions. This allows compund expressions like: "a=10,b=20,c=a*b" The last "argument" will be taken as the return value
- Bugfixes
  - The copy constructor did not copy binary operator definitions. Those were lost in the copied parser instance.
  - Mixing special characters and alphabetic characters in binary operator names led to inconsistent parsing behaviour when parsing expressions like "a ++ b" and "a++b" when "++" is defined as a binary operator. Binary operators must now consist entirely of special characters or of alphabetic ones. ( original bug report)
  - User defined operators were not exactly handled like built in operators. This led to inconsistencies in expression evaluation when using them. The results differed due to slightly different precedence rules.
  - Using empty string arguments ("") would cause a crash of muParser

#### Rev 1.32: 30.01.2010

This is a service release to fix problems with modern compilers.

- Changes
  - Added a function for retrieving the Version number of muparser.
  - example3 renamed to example2
  - Project files for bcb and msvc6 removed (include the source directly into your projects)
  - Project files for msvc2003, msvc2005 and msvc2008 added
- Bugfixes
  - Deprecated feature warnings removed for gcc
  - example1 changed to get rid of memory leaks. Added code for memory leak detection (VisualStudio only)
  - Changes to allow compilation with msvc10 beta2
  - gcc versions >4.0 were not able to run with a customized locale (resulted in std::bad_cast exception)

#### Rev 1.30: 09.06.2008

This is a service release with minor extensions and bugfixes.

- Changes
  - Epsilon of the numerical differentiation algorithm changed to allow greater accuracy.
- New features
  - Setting thousands separator and decimal separator is now possible
- Bugfixes
  - The dll interface did not provide a callback for functions without any arguments.

#### Rev 1.28: 02.07.2007

- Library changes
  - Interface for the dynamic library changed and extended to create an interface using pure C functions only.
  - mupInit() removed
- New features
  - Functions without parameters added
- Build system
  - MSVC7 Project files removed in favor of MSVC8.
- Bugfixes
  - The dynamic library did not build on other systems than linux due to a misplaced preprocessor definition. This is fixed now.

#### Rev 1.2: 14.04.2005

First of all the interface has changed so this version is not backwards compatible. After receiving a couple of questions about it, this version features support for user defined binary operators. Consequently the built in operators can now be turned off, thus you can deactivate them and write complete customized parser subclasses that only contain the functionality you want. Other new feature is the introduction of callback functions taking string arguments, implicit generation of variables and the Assignement operator.

- Functionality
  - New built in operator: `xor`; Logical xor.
  - New built in operator: Assignement operator; Defining variables in terms of other variables/constants
  - New feature: Strings as arguments for callback functions
  - New feature: User defined binary operators
  - New feature: `ParserInt` a class with a sample implementation for integer numbers.
  - New feature: Callbacks to value regognition functions.
  - Removed: all predefined postfix operators have been removed.
  - New project file: Now comes with a ready to use windows DLL.
  - New project file: Makefile for cygwin now included.
  - New example: Example3 shows usage of the DLL.
- Interface changes
  - New member function: `DefineOprt` For adding user defined binary operators.
  - New member function: `EnableBuiltInOprt(bool)` Enables/Disables built in binary operators.
  - New member function: `AddValIdent(...)` to add callbacks for custom value recognition functions.
  - Removed: `SetVar()`, `SetConst()`.
  - Renamed: Most interface functions have been renamed
  - Changed: The type for multiargument callbacks `multfun_type` has changed. It no longer takes a std::vector as input.
- Internal changes
  - new class muParserTokenReader.h encapsulates the token identification and token assignement.
  - Internal handling of function callbacks unified as a result the performance of the bytecode evaluation increased.

© 2005-2011 Ingo Berg | ^ TOP