.. _val-workflows: 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: .. code-block:: cpp #include auto samples = std::make_unique( std::vector{1.0, 2.0, 3.0} ); auto offset = std::make_unique(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: .. code-block:: cpp #include auto values = std::make_unique( std::vector{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: .. code-block:: cpp #include #include 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.