mp_units::magnitude¶
Customization point object: the magnitude of a vector or tensor, as a non-negative scalar
Synopsis¶
Declared in <mp-units/framework/representation_concepts.h>
inline constexpr /* implementation-defined */ magnitude;
Description¶
Calls vec.magnitude() or magnitude(vec) when the type provides one. Otherwise a vector or tensor uses its norm(), as linear algebra libraries name it, a real scalar its absolute value, and a complex scalar its modulus. So a scalar is treated as a one-dimensional vector, and one call covers every representation of a vector quantity:
#include <mp-units/utility/cartesian_vector.h>
double from_vector = mp_units::magnitude(utility::cartesian_vector{3., 4., 0.}); // 5
double from_real = mp_units::magnitude(-5.); // 5
double from_complex = mp_units::magnitude(std::complex{3., 4.}); // 5
The magnitude() member function of a vector quantity calls it on the quantity's value.
Return Value¶
the magnitude of vec, a non-negative scalar
Parameters¶
| Name | Description |
|---|---|
| vec | a vector, a tensor, or a scalar |
See Also¶
- Representation Types in the User's Guide