Skip to content

mp_units::numeric_field

Customization point: whether a representation type is real or complex

Synopsis

Declared in <mp-units/framework/customization_points.h>

template<typename T>
constexpr utility::unspecified_t numeric_field;

Description

A scalar is complex when real() and imag() can be called on it, as members or as free functions found by ADL. A vector or tensor takes the field of its element, so a real matrix that provides element-wise real() and imag(), as Eigen's and Blaze's do, stays real. A vector or tensor of complex elements is complex only when its own type provides real() and imag() too. Otherwise it has no field, and isn't a representation, until it is specialized.

A real scalar that provides real() and imag(), so that code written for complex numbers accepts it, is specialized back to real:

class measured_value;  // a real number with `real()` and `imag()`, for generic complex code

template<>
inline constexpr quantity_field mp_units::numeric_field<measured_value> = quantity_field::real;

Template Parameters

NameDescription
Ta representation type

See Also