Scalar and array values
Value containers, array shapes, and concrete value types.
The ArrayValue<std::string> implementation specialization is omitted;
use the ArrayValue template reference and the ArrayValueStr type.
-
template<typename T>
class ArrayValue : public snt::val::BaseArrayValue<T> - #include <values_number.h>
Numeric array value implementation for one scalar storage type.
Public Functions
-
inline ArrayValue(const T &val, const core::DataType dtype)
Create a scalar typed array value.
- Parameters:
val – Scalar value to store.
dtype – Data type tag exposed to callers.
-
inline ArrayValue(const std::vector<T> &arr, const Array::ShapeType &sh, const core::DataType dtype)
-
inline ArrayValue(const std::vector<T> &arr, const core::DataType dtype)
Create a one-dimensional typed array value.
- Parameters:
arr – Values to store; the shape is set to
{arr.size()}.dtype – Data type tag exposed to callers.
-
inline ArrayValue(const BaseValue *other, const core::DataType dtype)
Construct a typed array by converting an existing VAL value.
- Parameters:
other – Source value to convert.
dtype – Data type tag for the new value.
-
inline virtual BaseValue::PointerType clone() const override
-
inline virtual BaseValue::PointerType cast_as(core::DataType dt) const override
Convert the value to the requested data type.
- Parameters:
dt – Target data type flag.
-
inline virtual BaseValue::PointerType slice(const Array::RangeType &slice) override
Return the requested array slice.
- Parameters:
slice – Ranges selecting the requested elements.
-
inline virtual BaseValue::PointerType math_sin() const override
-
inline virtual BaseValue::PointerType math_cos() const override
-
inline virtual BaseValue::PointerType math_tan() const override
-
inline virtual BaseValue::PointerType math_log() const override
-
inline virtual BaseValue::PointerType math_log10() const override
-
inline virtual BaseValue::PointerType math_sqrt() const override
-
inline virtual BaseValue::PointerType math_cbrt() const override
-
inline virtual BaseValue::PointerType math_exp() const override
-
inline virtual BaseValue::PointerType math_floor() const override
-
inline virtual BaseValue::PointerType math_ceil() const override
-
inline virtual BaseValue::PointerType math_round() const override
-
inline virtual BaseValue::PointerType math_abs() const override
-
inline virtual BaseValue::PointerType math_neg() const override
-
inline virtual BaseValue::PointerType math_add(const BaseValue *other) const override
Add another value.
- Parameters:
other – Other value used in the operation.
-
inline virtual void math_add_equal(const BaseValue *other) override
Add another value in place.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType math_sub(const BaseValue *other) const override
Subtract another value.
- Parameters:
other – Other value used in the operation.
-
inline virtual void math_sub_equal(const BaseValue *other) override
Subtract another value in place.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType math_inv() const override
-
inline virtual BaseValue::PointerType math_mul(const BaseValue *other) const override
Multiply by another value.
- Parameters:
other – Other value used in the operation.
-
inline virtual void math_mul_equal(const BaseValue *other) override
Multiply by another value in place.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType math_div(const BaseValue *other) const override
Divide by another value.
- Parameters:
other – Other value used in the operation.
-
inline virtual void math_div_equal(const BaseValue *other) override
Divide by another value in place.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType math_pow(const BaseValue *other) const override
Raise the value to an element-wise exponent value.
- Parameters:
other – Exponent value represented as another VAL object.
-
inline virtual BaseValue::PointerType math_pow(const double exp) const override
-
inline virtual BaseValue::PointerType math_max(const BaseValue *other) const override
Return the element-wise maximum with another value.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType math_min(const BaseValue *other) const override
Return the element-wise minimum with another value.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType math_inf() const override
-
inline virtual BaseValue::PointerType logical_and(const BaseValue *other) const override
Apply a logical AND operation.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType logical_or(const BaseValue *other) const override
Apply a logical OR operation.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType logical_not() const override
-
inline virtual bool any_of() const override
-
inline virtual bool all_of() const override
-
inline virtual bool none_of() const override
-
inline virtual bool is_unity() const override
-
inline ArrayValue(const T &val, const core::DataType dtype)
-
class ArrayValueBool : public snt::val::ArrayValue<uint8_t>
- #include <values.h>
-
class ArrayValueChar : public snt::val::ArrayValue<int8_t>
- #include <values.h>
-
class ArrayValueFloat128 : public snt::val::ArrayValue<long double>
- #include <values.h>
-
class ArrayValueFloat32 : public snt::val::ArrayValue<double>
- #include <values.h>
Public Functions
-
inline ArrayValueFloat32(const float &val)
-
inline ArrayValueFloat32(const std::vector<float> &arr)
-
inline void get_data(std::vector<float> &output_value) const
Copy the stored values into an output container.
- Parameters:
output_value – Destination container receiving the converted values.
-
inline ArrayValueFloat32(const float &val)
-
class ArrayValueFloat64 : public snt::val::ArrayValue<double>
- #include <values.h>
-
class ArrayValueInt16 : public snt::val::ArrayValue<int64_t>
- #include <values.h>
-
class ArrayValueInt32 : public snt::val::ArrayValue<int64_t>
- #include <values.h>
-
class ArrayValueInt64 : public snt::val::ArrayValue<int64_t>
- #include <values.h>
-
class ArrayValueInt8 : public snt::val::ArrayValue<int64_t>
- #include <values.h>
Concrete value classes selected by the VAL data type.
-
class ArrayValueStr : public snt::val::ArrayValue<std::string>
- #include <values.h>
-
class ArrayValueUint16 : public snt::val::ArrayValue<uint64_t>
- #include <values.h>
-
class ArrayValueUint32 : public snt::val::ArrayValue<uint64_t>
- #include <values.h>
-
class ArrayValueUint64 : public snt::val::ArrayValue<uint64_t>
- #include <values.h>
-
class ArrayValueUint8 : public snt::val::ArrayValue<uint64_t>
- #include <values.h>
-
template<typename T>
class BaseArrayValue : public snt::val::BaseValue - #include <values_array.h>
Base class for all array values
- Template Parameters:
T – Data type of a values Typed array storage and arithmetic implementation.
Subclassed by snt::val::ArrayValue< uint8_t >, snt::val::ArrayValue< int8_t >, snt::val::ArrayValue< long double >, snt::val::ArrayValue< double >, snt::val::ArrayValue< int64_t >, snt::val::ArrayValue< uint64_t >, snt::val::ArrayValue< T >
Public Functions
-
inline BaseArrayValue(const T &val, const core::DataType dtype)
Base array value constructor from a scalar value
- Parameters:
val – Scalar value
dtype – Datatype flag
-
inline BaseArrayValue(const std::vector<T> &arr, const Array::ShapeType &sh, const core::DataType dtype)
Base array value constructor from a flattened vector of values and a shape
- Parameters:
arr – Vector of values
sh – Array shape
dtype – Datatype flag
-
inline BaseArrayValue(const BaseValue *other, const core::DataType dtype)
Base array value constructor from a BaseValue pointer
- Parameters:
other – Pointer to a BaseValue object
dtype – Datatype flag
-
inline virtual void print() override
Print object as a string
-
inline std::vector<T> get_values() const
Get copy of the array values
- Returns:
Flattened array of values
-
inline T get_value(const size_t index) const
Get copy of a particular value
- Parameters:
index – Index of a value
- Returns:
Single value
-
inline virtual size_t get_size() const override
Get size of an array
- Returns:
Size of the flattened array value
-
inline virtual std::string to_string(const core::StringFormatType &format = core::StringFormatType()) const override
Return string representation of this array object
- Parameters:
format – Object with an output string format
- Returns:
String representation
-
inline virtual BaseValue::PointerType compare_equal(const BaseValue *other) const override
Compare this value for equality.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType compare_not_equal(const BaseValue *other) const override
Compare this value for inequality.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType compare_less(const BaseValue *other) const override
Compare this value as less than another value.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType compare_greater(const BaseValue *other) const override
Compare this value as greater than another value.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType compare_less_equal(const BaseValue *other) const override
Compare this value as less than or equal to another value.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType compare_greater_equal(const BaseValue *other) const override
Compare this value as greater than or equal to another value.
- Parameters:
other – Other value used in the operation.
-
inline BaseValue::PointerType slice_value(const Array::RangeType &slice)
Create a value containing the selected array ranges.
- Parameters:
slice – Ranges selecting the requested elements.
-
inline virtual BaseValue::PointerType where(const BaseValue *condition, const BaseValue *other) const override
Select values according to a Boolean condition.
- Parameters:
condition – Boolean condition used to select the result.
other – Other value used in the operation.
Friends
-
inline friend std::ostream &operator<<(std::ostream &os, const ArrayValue<T> &val)
Print value into a string stream
- Parameters:
os – String stream
val – Value object
-
class BaseValue
- #include <value_base.h>
Polymorphic base class for scalar and array values.
Subclassed by snt::val::BaseArrayValue< std::string >, snt::val::BaseArrayValue< uint8_t >, snt::val::BaseArrayValue< int8_t >, snt::val::BaseArrayValue< long double >, snt::val::BaseArrayValue< double >, snt::val::BaseArrayValue< int64_t >, snt::val::BaseArrayValue< uint64_t >, snt::val::BaseArrayValue< T >
Public Functions
-
inline BaseValue(core::DataType dt, Array::ShapeType sh)
Initialize a value with its data type and shape.
- Parameters:
dt – Target data type flag.
sh – Array shape.
-
virtual ~BaseValue() = default
-
virtual void print() = 0
-
virtual std::string to_string(const core::StringFormatType &format = core::StringFormatType()) const = 0
Format the object as text.
- Parameters:
format – Formatting options controlling the textual representation.
-
virtual size_t get_size() const = 0
-
virtual BaseValue::PointerType clone() const = 0
-
virtual BaseValue::PointerType cast_as(core::DataType dt) const = 0
Convert the value to the requested data type.
- Parameters:
dt – Target data type flag.
-
virtual BaseValue::PointerType slice(const Array::RangeType &slice) = 0
Return the requested array slice.
- Parameters:
slice – Ranges selecting the requested elements.
-
inline virtual BaseValue::PointerType math_add(const BaseValue *other) const
Add another value.
- Parameters:
other – Other value used in the operation.
-
inline virtual void math_add_equal(const BaseValue *other)
Add another value in place.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType math_sub(const BaseValue *other) const
Subtract another value.
- Parameters:
other – Other value used in the operation.
-
inline virtual void math_sub_equal(const BaseValue *other)
Subtract another value in place.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType math_inv() const
-
inline virtual BaseValue::PointerType math_mul(const BaseValue *other) const
Multiply by another value.
- Parameters:
other – Other value used in the operation.
-
inline virtual void math_mul_equal(const BaseValue *other)
Multiply by another value in place.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType math_div(const BaseValue *other) const
Divide by another value.
- Parameters:
other – Other value used in the operation.
-
inline virtual void math_div_equal(const BaseValue *other)
Divide by another value in place.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType math_sin() const
-
inline virtual BaseValue::PointerType math_cos() const
-
inline virtual BaseValue::PointerType math_tan() const
-
inline virtual BaseValue::PointerType math_log() const
-
inline virtual BaseValue::PointerType math_log10() const
-
inline virtual BaseValue::PointerType math_sqrt() const
-
inline virtual BaseValue::PointerType math_cbrt() const
-
inline virtual BaseValue::PointerType math_exp() const
-
inline virtual BaseValue::PointerType math_floor() const
-
inline virtual BaseValue::PointerType math_ceil() const
-
inline virtual BaseValue::PointerType math_round() const
-
inline virtual BaseValue::PointerType math_abs() const
-
inline virtual BaseValue::PointerType math_neg() const
-
inline virtual BaseValue::PointerType math_pow(const BaseValue *other) const
Raise the value to an element-wise exponent value.
- Parameters:
other – Exponent value represented as another VAL object.
-
inline virtual BaseValue::PointerType math_pow(const double exp) const
-
inline virtual BaseValue::PointerType math_max(const BaseValue *other) const
Return the element-wise maximum with another value.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType math_min(const BaseValue *other) const
Return the element-wise minimum with another value.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType math_inf() const
-
inline virtual BaseValue::PointerType compare_equal(const BaseValue *other) const
Compare this value for equality.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType compare_not_equal(const BaseValue *other) const
Compare this value for inequality.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType compare_less(const BaseValue *other) const
Compare this value as less than another value.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType compare_greater(const BaseValue *other) const
Compare this value as greater than another value.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType compare_less_equal(const BaseValue *other) const
Compare this value as less than or equal to another value.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType compare_greater_equal(const BaseValue *other) const
Compare this value as greater than or equal to another value.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType logical_and(const BaseValue *other) const
Apply a logical AND operation.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType logical_or(const BaseValue *other) const
Apply a logical OR operation.
- Parameters:
other – Other value used in the operation.
-
inline virtual BaseValue::PointerType logical_not() const
-
virtual BaseValue::PointerType where(const BaseValue *condition, const BaseValue *other) const = 0
Select values according to a Boolean condition.
- Parameters:
condition – Boolean condition used to select the result.
other – Other value used in the operation.
-
virtual bool any_of() const = 0
-
virtual bool all_of() const = 0
-
virtual bool none_of() const = 0
-
virtual bool is_unity() const = 0
-
inline BaseValue(core::DataType dt, Array::ShapeType sh)
-
using snt::val::Array::StringType = std::vector<std::string>
Holds raw string values.
-
using snt::val::Array::RangeType = std::vector<RangeStruct>
Array dimension ranges.
-
using snt::val::Array::ShapeType = std::vector<size_t>
Array shape.
-
constexpr size_t snt::val::Array::max_range
Maximum size value indicates open range.
-
struct RangeStruct
- #include <array.h>
Array dimension range
Public Functions
-
inline bool operator==(const RangeStruct &other) const
Compare equalit of two ranges
- Parameters:
other – Other range that will be compared
-
inline bool operator==(const RangeStruct &other) const