A modern C++ toolkit for scientific computations with units, expressions, and dimensional parameters.
scinumtools3, or simply snt, is a C++ library that helps scientists and engineers write safer, clearer numerical code by providing:
- Expression Solver (EXS) — parse and evaluate mathematical, logical, or custom expressions at runtime.
- Physical Units & Quantities (PUQ) — represent values with units and perform unit-aware arithmetic.
- Dimensional Input Parameters (DIP) — declare and validate parameter inputs with type & unit checks.
This project is the C++ counterpart to the original Python scinumtools, focused on performance and strong typing.
- Expression parsing & evaluation
- Strong SI unit support (units, prefixes, conversions, other unit systems e.g. CGS, AU)
- Compile-time / runtime dimensional checks for parameters
- Small, easy-to-integrate headers and CMake-friendly build
- Unit tests included (GoogleTest)
-
Manually
# download repository git clone https://github.com/vrtulka23/scinumtools3.git cd scinumtools3 # compile cmake -B build cd build make # run tests ctest # install sudo make install
-
Using setup script
sudo ./setup.sh -b -t -i # build, run tests, install
-
Find the package
# find the `SNT` package find_package(snt REQUIRED) # link to your executable add_executable(${EXEC_NAME} ${SOURCE_FILES}) target_link_libraries(${EXEC_NAME} PRIVATE snt-exs snt-puq snt-dip)
Below is a quick example how to use the core functionality of scinumtools3.
For more examples and patterns please look into the gtest and exec folders.
#include <snt/exs.h>
#include <snt/val.h>
#include <snt/puq.h>
#include <snt/dip.h>
#include <iostream>
using namespace snt;
int main() {
exs::Solver<exs::Atom> solver;
exs::Atom atom = solver.solve("23 * 34.5 + 4");
std::cout << atom.to_string() << std::endl;
// 797.5
val::ArrayValue<double> value({1.23, 4.56e7});
std::cout << value.to_string() << std::endl;
// [1.23, 4.56e7]
puq::Quantity length("1*m");
length = length.convert("km");
std::cout << length.to_string() << std::endl;
// 1e-3*km
dip::DIP d;
d.add_string("foo int m");
d.add_string("foo = 3 km");
dip::Environment env = d.parse();
dip::ValueNode::PointerType vnode = env.nodes.at(0);
std::cout << vnode->value->to_string() << std::endl;
// 3000
}API reference and guides are available in the docs/ directory.
To generate Doxigen + breathe + Sphinx documentation:
-
Using the setup script
./setup.sh -d # build documentation -
Manually
cd docs make html
See docs/README.md for more information.
Contributions are welcome — please follow these guidelines:
-
Fork the repo and create a feature branch:
git clone https://github.com/vrtulka23/scinumtools3.git git checkout -b feature/my-feature
-
Follow the coding style (
.clang-format) and use modern C++ (C++17+). -
Add unit tests for new features or bug fixes (see
gtest/). -
Build and run tests locally:
./setup.sh -b -t # build, run tests -
Open a Pull Request with a clear description and link to any related issues.
See CONTRIBUTING.md for full instructions.
This project is licensed under the MIT License. See the LICENSE file for full text.
Found a bug or have a feature request? Open an issue at: https://github.com/vrtulka23/scinumtools3/issues