Getting started

Native example

This installed-package example constructs a MAT command, supplies matter inputs, and calls execute() to obtain a typed result:

#include <iostream>
#include <snt/api/mat_eval.h>

int main() {
    snt::api::MATSubstance command("H2O");
    command.argument_mass_density(snt::puq::Quantity(1.0, "g/cm3"));
    command.argument_volume(snt::puq::Quantity(1.0, "L"));
    const auto water = command.execute();
    std::cout << water.matter.mass->convert("g").to_string() << "\n";
    return 0;
}

The command facade uses the native MAT implementation and returns independent records. The supplied density and volume determine a mass of 1000 grams. PUQ and DIP command examples are covered in Workflows, including their source-checkout header prerequisites.

Build and run

Install the C++ package using Installation with the API and MAT modules enabled (ENABLE_API=ON and ENABLE_MAT=ON). Save the example above as main.cpp and create this CMakeLists.txt in the same directory:

cmake_minimum_required(VERSION 3.22)
project(snt_api_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-api)

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:

1e3*g

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 MAT and DIP commands, or go directly to the detailed PUQ commands, MAT commands, and DIP commands pages.