Workflows

VAL operations are used by PUQ, EXS, MAT, and DIP when they need a common value representation with shape and data-type metadata.

Apply array and scalar arithmetic

Binary operations return a new owned value and accept a value pointer:

#include <snt/val/values.h>

auto samples = std::make_unique<snt::val::ArrayValueFloat64>(
    std::vector<double>{1.0, 2.0, 3.0}
);
auto offset = std::make_unique<snt::val::ArrayValueFloat64>(2.0);

auto shifted = samples->math_add(offset.get());

The result retains the shape produced by the operation. The original values remain unchanged unless an in-place math_*_equal method is used.

Convert and inspect a value

Cast between supported data types and inspect the public metadata:

#include <snt/val/values.h>

auto values = std::make_unique<snt::val::ArrayValueFloat64>(
    std::vector<double>{1.2, 2.8, 3.4}
);

auto integers = values->cast_as(snt::core::DataType::Integer32);
const auto shape = integers->get_shape();
const auto dtype = integers->get_dtype();
const auto count = integers->get_size();

Use the concrete DataType when an API contract depends on the exact type; use the wider integer or float groups when only a compatible category matters.

Format a value for output

Pass formatting settings to to_string instead of duplicating delimiter and precision rules in the application:

#include <iostream>
#include <snt/core/string_format.h>

snt::core::StringFormatType format;
format.specifier = 'e';
format.valuePrecision = 4;
std::cout << values->to_string(format) << "\n";

The same formatting vocabulary is used by the higher-level quantity and parameter records.