Computes the Euclidean (or, for a complex field, Hermitian) norm of a vector or tensor quantity.

Synopsis

Declared in <mp‐units/framework/quantity.h>

[[nodiscard]]
constexpr
Quantity auto
magnitude() const
requires (get_character(quantity_spec).order >= quantity_tensor_order::vector) && detail::HasMagnitude<rep>;

Description

The two‐part constraint is deliberate: order >= vector is the character guard (a scalar such as isq::speed has no magnitude, though the magnitude CPO would gladly run std::abs on its double), and HasMagnitude<rep> ensures the storage can deliver one.

Returning * unit drops the precise quantity_spec to the unit's kind: a V2 convenience, since V2 cannot name the right result type (a scalar‐magnitude spec like vec_mag<isq::force>[N] is a V3 feature). This does not fix the character in general ‐ it collapses to real_scalar only for units built from scalar base units (e.g. km/h); for one tied to a vector spec (e.g. N) the result keeps vector character, so one could even take the magnitude of a magnitude. A known V2 limitation.

Return Value

The norm of the numerical value, as a scalar quantity in the same unit.

Note

The return value should not be discarded.

Created with MrDocs