Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aiekick/ezexpr
Easy to use and flexible math expression parser / evaluator in a one file header only
https://github.com/aiekick/ezexpr
cpp11 custom-functions easy expression-evaluator expression-parser math modern powerfull
Last synced: 4 months ago
JSON representation
Easy to use and flexible math expression parser / evaluator in a one file header only
- Host: GitHub
- URL: https://github.com/aiekick/ezexpr
- Owner: aiekick
- License: mit
- Created: 2024-08-08T14:55:05.000Z (6 months ago)
- Default Branch: master
- Last Pushed: 2024-08-30T00:09:13.000Z (5 months ago)
- Last Synced: 2024-10-12T16:41:08.003Z (4 months ago)
- Topics: cpp11, custom-functions, easy, expression-evaluator, expression-parser, math, modern, powerfull
- Language: C++
- Homepage:
- Size: 1.87 MB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EzExpr
EzExpr is a easy to use and flexible expression parser / evaluator
in a one file header only style for cpp11 at least# Quick Start
```cpp
ez::Expr ev;
auto result0 = ev.parse("x + 2.5 * d").set("x", 0.5).set("d", 1.5).eval().getResult();
auto result1 = ev.set("x", 10.5).eval().getResult();
auto result2 = ev.set("d", 2.5).eval().getResult();
``````cpp
ez::Expr ev;
ev.addFunction("fma", [](double a, double b, double c) { return a*b+c; }); // ternary function
auto result0 = ev.parse("floor(fma(x,y,k))").set("x", 0.5).set("y", 1.5).set("k", 3.2).eval().getResult();
```# Features
* Modern use
* One header file only
* Parsing and evaluation on separated calls
* User can easily add their custom Unary/Binary/Ternary Function
* Cpp11 compatible at least
* Can identify and return to user the variables
* Many exceptions are emited for many not conformant issue during parsing and during evaluation
* Use their own String class for faster response
* all numbers and computation are in double precision# Builtins
```cpp
+ - * / ^ %
! (factorielle : N!)
```## Constants
* pi
* e## Unary function
* abs, floor, ceil, round, fract, sign
* sin, cos, tan
* asin, acos, atan
* sinh, cosh, tanh
* asinh, acosh, atanh
* ln, log, log1p, logb, log2, log10
* exp
* sqrt## Binary function
* mod, atan2, min, max, step, hypot, smoothabs
## Ternary function
* clamp, mis, smoothstep (glsl functions)
* saturate, lerp (hlsl functions)