Skip to content

Scientific Numerical Tools v3 - C++ version of the original scinumtools Python project featuring EXpression Solver (EXS), Physical Units and Quantities (PUQ) and Dimensional Input Parameters (DIP)

License

Notifications You must be signed in to change notification settings

vrtulka23/scinumtools3

Repository files navigation

Scientific Numerical Tools v3 (SNT)

A modern C++ toolkit for scientific computations with units, expressions, and dimensional parameters.

C/C++ CI Linux Build License: MIT GitHub release C++20 GCC Clang


Overview

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.


Features

  • 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)

Installation

Download and install

  1. 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
  2. Using setup script

    sudo ./setup.sh -b -t -i  # build, run tests, install

Link scinumtools3 in your CMAKE project

  1. 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)

Quick Example

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
}

Documentation

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.


Contributing

Contributions are welcome — please follow these guidelines:

  1. Fork the repo and create a feature branch:

    git clone https://github.com/vrtulka23/scinumtools3.git
    git checkout -b feature/my-feature
  2. Follow the coding style (.clang-format) and use modern C++ (C++17+).

  3. Add unit tests for new features or bug fixes (see gtest/).

  4. Build and run tests locally:

    ./setup.sh -b -t   # build, run tests
  5. Open a Pull Request with a clear description and link to any related issues.

See CONTRIBUTING.md for full instructions.


License

This project is licensed under the MIT License. See the LICENSE file for full text.


Contact / Issues

Found a bug or have a feature request? Open an issue at: https://github.com/vrtulka23/scinumtools3/issues

About

Scientific Numerical Tools v3 - C++ version of the original scinumtools Python project featuring EXpression Solver (EXS), Physical Units and Quantities (PUQ) and Dimensional Input Parameters (DIP)

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published