{"id":16568580,"url":"https://github.com/hmenke/boost_matheval","last_synced_at":"2025-03-21T11:33:38.660Z","repository":{"id":149619184,"uuid":"109774348","full_name":"hmenke/boost_matheval","owner":"hmenke","description":"Evaluate mathematical expressions using Boost.Spirit","archived":false,"fork":false,"pushed_at":"2022-11-05T14:57:38.000Z","size":300,"stargazers_count":31,"open_issues_count":1,"forks_count":8,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-10-12T21:11:02.583Z","etag":null,"topics":["boost-libraries","c-plus-plus"],"latest_commit_sha":null,"homepage":"https://hmenke.github.io/boost_matheval/doxygen/html/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hmenke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE_1_0.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-11-07T02:07:38.000Z","updated_at":"2024-10-02T10:08:22.000Z","dependencies_parsed_at":"2023-07-13T22:00:31.415Z","dependency_job_id":null,"html_url":"https://github.com/hmenke/boost_matheval","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmenke%2Fboost_matheval","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmenke%2Fboost_matheval/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmenke%2Fboost_matheval/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmenke%2Fboost_matheval/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hmenke","download_url":"https://codeload.github.com/hmenke/boost_matheval/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221815036,"owners_count":16885099,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boost-libraries","c-plus-plus"],"created_at":"2024-10-11T21:11:03.531Z","updated_at":"2024-10-28T10:06:10.108Z","avatar_url":"https://github.com/hmenke.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Boost Matheval\n\n[![Linux](https://github.com/hmenke/boost_matheval/actions/workflows/linux.yml/badge.svg)](https://github.com/hmenke/boost_matheval/actions/workflows/linux.yml)\n[![Windows](https://github.com/hmenke/boost_matheval/actions/workflows/windows.yml/badge.svg)](https://github.com/hmenke/boost_matheval/actions/workflows/windows.yml)\n[Documentation](https://hmenke.github.io/boost_matheval/doxygen/html/)\n[Coverage](https://hmenke.github.io/boost_matheval/coverage/html/)\n\nThis library uses [Boost.Spirit](http://www.boost.org/libs/spirit/index.html)\n(QI for C++98 and X3 for C++14) and\n[Boost.Fusion](http://www.boost.org/libs/fusion/index.html) (and\n[Boost.Phoenix](http://www.boost.org/libs/phoenix/index.html) with C++98) to\nparse and evaluate mathematical expressions.\n\nThe examples below use the X3 variant of Boost Matheval.\n\n### Motivating example 1\n\n```cpp\n#include \u003ciostream\u003e\n#include \"matheval.hpp\"\n\nint main() {\n    std::cout \u003c\u003c matheval::parse(\"1+1\") \u003c\u003c '\\n';\n}\n```\nOutputs\n```\n2\n```\n\n### Motivating example 2\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cmap\u003e\n#include \"matheval.hpp\"\n\nint main() {\n    std::map\u003cstd::string,double\u003e symtab;\n    symtab.emplace(std::make_pair(\"x\",  2));\n    symtab.emplace(std::make_pair(\"y\", -1));\n    std::cout \u003c\u003c matheval::parse(\"cbrt(x/2 + sqrt(x**2/4 + y**3/24))\",symtab) \u003c\u003c '\\n';\n}\n```\nOutputs\n```\n1.25548\n```\n\n### Motivating example 3\n\nWe can also evaluate an expression multiple times without paying the\ncost of parsing again.\n```cpp\n#include \u003ciostream\u003e\n#include \u003cmap\u003e\n#include \"matheval.hpp\"\n\nint main() {\n    matheval::Parser parser;\n    parser.parse(\"x + 1\");\n    std::cout \u003c\u003c parser.evaluate({std::make_pair(\"x\",1)}) \u003c\u003c ' '\n              \u003c\u003c parser.evaluate({std::make_pair(\"x\",2)}) \u003c\u003c '\\n';\n}\n```\nOutputs\n```\n2 3\n```\n\n### Build instructions\n\nTo build Boost Matheval, just follow the usual CMake workflow.\n```bash\nmkdir build\ncd build\ncmake ..\nmake         # build the library and the examples\nmake check   # build and run the tests\n```\n\n### Requirements and Limitations\n\nGeneral:\n\n* C++14 compatible compiler, i.e. GCC \u003e= 4.8, Clang, Visual Studio 2015.\n* Boost.Spirit, Boost.Phoenix, and Boost.MathConstants.\n* No support for ternary functions (e.g. `if`).\n* No support for complex numbers.\n\n### Alternatives\n\n* [GNU libmatheval](https://www.gnu.org/software/libmatheval/) is a C\n  library built using the parser generator YACC with about the same\n  scope as Boost Matheval.\n* [ExprTk](http://www.partow.net/programming/exprtk/) is a true\n  monster with almost 40000 lines in a single header file.  It\n  implements a complete state machine including things like logical\n  operations, control structures, and even file IO.  Compilation time\n  is even longer than with Boost Matheval.\n\n### License\n\nDistributed under the [Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmenke%2Fboost_matheval","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhmenke%2Fboost_matheval","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmenke%2Fboost_matheval/lists"}