Yet Another Math Parser
YAMP may be really helpful or really useless depending on your needs, dependencies and software stack. YAMP is completely built in C# and provides an easy, yet powerful approach to parse expressions in a syntax, that is comfortable and quite close to industry standards.
The parser is currently very stable. The drawback of the current release is the speed of the parser, which is faster than most other implementations, but slower than some. The good side is that everything is parsed in a standard way, so that you can easily perform (parse and interpret) thousands of queries within a second.
Features of YAMP is (complex) (matrix) numerics (scalars, vectors, matrices) with symbolic terms (constants, variables, functions) that can be customized. Even though the current release does not support adding your own operators (they can be added in the code within a few lines), it is easily possible. This allows operator overloading as well.
The current version number is 0.9.1. This version is still an incomplete alpha build. A NuGet package is available here. There are a lot of tests in the code - since the package aims to be cross platform (created with Mono), no particular unit testing framework has been chosen.
The console project (provided in the solution) gives you instant access to benchmarks, tests and your own trials. Parse equations as you want to. In the current release exceptions from the parser are catched in the console application. Currently the following builds are available:
- Debug: Contains the expression tests.
- Console: Contains a command line tool.
- Benchmark: Performs benchmarks for YAMP and three other C# only parsers.
- Release: Version to produce the NuGet library and other productive output.
- Added the "who()" command to view the current workspace
- Added a method called
LoadPlugin()to the Parser - now it should be easily possible to load libraries full of functions, operators and other YAMPy stuff
- Added more functions for async operations
- Improved the structure of the code, so that it is somehow more clear what must be done to write own YAMP libraries / plugins
- Added more tests
- Changed the license from the CPOL to the New BSD License
- Underscores can now also be used in symbol or function expressions
- Added a new help() method to provide help for included methods
ExampleAttributeclasses to write help messages
ArgumentFunctionderived types are now type-safe
- Included help for most non-trivial functions
- Fixed a bug concerning the
trace()method of the
- Included a class
AsyncTaskthat is used for async invoking
- Provided a method
ExecuteAsync()for async execution
- Added some simple integrators
- Added the GMRES(k) method for solving non-SPD matrices
- Introduced combined assignment operators (+=, -=, *=, ^=, /=, \=, ...)
- Added a function for setting the output precision (precision())
- Added the CG method and a proper (prelimary) solve() method
- Improved the ArgumentsFunction class to support optional arguments
- Added the possibility to specify the variables to load, save and clear in those functions
- Small changes in the code for more elegance
- Improved the performance of the parser
- Introduced logic operators (>, <, ==, ~=)
- Included logical subscripting (like x[x>0]=...)
- Improved the parser performance (factor 1.5)
- Improved the bracket expressions
- Added new linear algebra functions (inv(), trace())
- Added new Spectroscopy function (FFT)
- Added new tests
- Added new parsers for comparison (LL MP, MFP)
- Resorted the YAMP code (directory changes)
- Added new functions (trace, eig, ev, ...)
- Added some basic linear algebra functions
- Added dot operators (.^, ./, .*, .\)
- Added new exceptions
- Improved the exception handling in ArgumentFunctions
- Improved the parser by a factor of 5
- Fixed a small bug in the parser
- Introduced the YAMP.Numerics namespace with some stuff for numerical mathematics
- Added new tests
- Added new functions (load, save, eye, dim, length, ...)
- The power function can now work with matrices
- Added a datatype for Strings
- Added the range operator (including special notations like ":" and "end")
- The index operator now supports the range operator
- Added new random number generator (gaussian) and integer number generator
- Improved the parser (Unary operators)
- Added new tests
- Added new functions (arsinh, arcosh, artanh, arcoth, sinh, cosh, tanh, coth, ...)
- Improved the power functions
- Added an operator for left divisons (usual operator is for right divisions)
- Added new matrix functions (eye, zeros, ones, ...)
- Added random number generator (uniform)
- Assignment operator now works with indices
- Added new tests
- Functions can now either perform operations on whole matrices or on each sub-element
- Assignment operator has been introduced
- Fixed a bug concerning powers of purely imaginary numbers
- MatrixValue numerics have been improved
- VectorValue has been replaced completely by MatrixValue
- Improved the performance of the parser (factor 2)
- More sophisticated operators (transpose, faculty, ...) have been integrated
- Custom constants (symbols) and functions are now possible
- More sophisticated functions are now available
- VectorValue and MatrixValue numerics have been included
- Improved the stability of the parser
- The project has been created
- First version of the parser, Stack based
- First test cases have been stated
- Main operators and expressions have been included
- Constants have been introduced
- ScalarValue numerics and some basic functions (exp, sin, cos, ...) have been implemented
Where this parser is useful
- C# only projects
- Lightweight projects with a sophisticated, yet small and fast parser
- Customized mathematics that is regularly updated
- Easily plug-and extensible architecture for (numerical) mathematics
Participating in the project
If you know some feature that YAMP is currently missing, and you are willing to implement the feature, then your contribution is more than welcome! Also if you have a really cool idea - do not be shy, I'd like to hear it.
What the project could possibly achieve
From my current point of view there is no reason why YAMP should not be able to do more sophisticated (analytical) mathematics. Things like derivations or integrals with symbols could be possible. I've already implemented derivations before, with the parser already present this is highly possible. Including integrals is a different matter: I've spent some time in the past, thinking about a proper implementations. What I think right now is that the parser matters a lot. Once you normalize this process the integral implemention is just a big database (integral table), with some (only basic) rules defined.
What is more likely is that the project goes in direction of a C# kind of MATLAB (more lightweight). But time will tell!
Some legal stuff
Copyright (c) 2012, Florian Rappl. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the YAMP team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.