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

### Introduction About the parser News Software using muParser Licence ### Features Features Overview Built in functions Built in binary operators ### Build instructions Building on Win32 Building on BSD/Linux Misc build instructions Including the files Where to ask for help ### Math parser interface Parser (de)initialization Evaluating an expression Setting the expression Defining identifier charsets Defining parser variables Explicit variable definition Implicit variable definition Defining constants 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 Release notes Benchmarks | ## Example code If you put all this together, you get the source code for a small application. The application defines a parser variables ("`a`") and adds a user defined functions named "`MyFunc`". When using the parser make sure that you don't forget to catch the `Parser::exception_type` in your application. It contains detailed information helping you to find syntax errors in your formula.
    #include <iostream>
    #include "muParser.h"

    // Function callback
    double MyFunction(double a_fVal)
    {
      return a_fVal*a_fVal;
    }

    // main program
    int main(int argc, char* argv[])
    {
      using namespace mu;

      try
      {
        double fVal = 1;
        Parser p;
        p.DefineVar("a", &fVal);
        p.DefineFun("MyFunc", MyFunction);
        p.SetExpr("MyFunc(a)*_pi+min(10,a)");
        std::cout << p.Eval() << std::endl;
      }
      catch (Parser::exception_type &e)
      {
        std::cout << e.GetMsg() << std::endl;
      }
      return 0;
    }
## Benchmarks Finally, I'd like to give you some benchmarks. The benchmarking was done on an Intel Pentium P-4 with 2.6 GHz, with a version compiled by using MSVC++ 7.1 (Standard edition). The diagram shows number of evaluations per seconds vs. expression length. I compared both the static lib and the dll version with two other parsers that are freely available on the net, very fast and have a similar set of features. One of them is a commercial product. A higher curve means better performance. Expressions were created randomly. They used only `sin` and `cos` functions and contained multiple variables and constants. In order to smoothen the curves each point represents the value of a running average over 10 sample expressions. ## Release Notes #### 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-2010 Ingo Berg | Privacy policy | ^ TOP