Skip to content

mp_units::modulus

Customization point object: the modulus of a complex scalar

Synopsis

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

inline constexpr /* implementation-defined */ modulus;

Description

Calls the first of clx.modulus(), modulus(clx), clx.abs() and abs(clx) that exists, with the free functions found by ADL, and accepts only a real scalar result. So std::complex works through its abs, and a type that names the operation modulus works too:

// the length of a vector of complex components, such as a Jones vector in optics
template<typename Complex, std::size_t N>
auto hermitian_norm(const std::array<Complex, N>& components)
{
  auto sum = mp_units::modulus(components[0]) * mp_units::modulus(components[0]);
  for (std::size_t index = 1; index < N; ++index)
    sum += mp_units::modulus(components[index]) * mp_units::modulus(components[index]);
  return std::sqrt(sum);
}

Return Value

the modulus of clx, a real scalar

Parameters

NameDescription
clxa complex scalar

See Also