Getting started

Native example

The default solver evaluates numeric expressions with the built-in atom and operator registry:

#include <snt/exs/solver.h>

int main() {
    snt::exs::Solver<snt::exs::Atom> solver;
    auto result = solver.eval("23 * 34.5 + 4");
    result.print();  // 797.5
    return 0;
}

eval tokenizes the expression, converts operands through Atom::from_string, applies the configured reduction steps, and returns the final atom. Link an application that uses this API against snt-exs.

Build and run

Install the C++ package using Installation with the EXS module enabled. Save the example above as main.cpp and create this CMakeLists.txt in the same directory:

cmake_minimum_required(VERSION 3.22)
project(snt_exs_example LANGUAGES C CXX)

find_package(snt CONFIG REQUIRED)
add_executable(application main.cpp)
target_compile_features(application PRIVATE cxx_std_17)
target_link_libraries(application PRIVATE snt-exs)

Configure with the installed package prefix, build, and run:

cmake -S . -B build -DCMAKE_PREFIX_PATH=/path/to/snt
cmake --build build
./build/application

Expected output:

797.5

Replace /path/to/snt with the installation prefix; omit that option if CMake already finds SNT. C is enabled for discovery of HDF5 in packages built with DIP support. See Using SciNumTools from CMake for package discovery details.

Continue with Workflows for composition graphs and solver customization. The detailed evaluation path is in Solver usage and composition graphs.