From 7f0dea9d1881ce919370d02b8e8accd7b9f2ee3a Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 19 Sep 2024 21:57:03 -0600 Subject: [PATCH] feat: `complex` quantity character added --- .../mp-units/framework/customization_points.h | 8 ++++++++ .../mp-units/framework/representation_concepts.h | 13 ++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/core/include/mp-units/framework/customization_points.h b/src/core/include/mp-units/framework/customization_points.h index 16a33a2b8..6b40e8333 100644 --- a/src/core/include/mp-units/framework/customization_points.h +++ b/src/core/include/mp-units/framework/customization_points.h @@ -64,6 +64,14 @@ constexpr bool treat_as_floating_point = treat_as_floating_point constexpr bool is_scalar = std::is_floating_point_v || (std::is_integral_v && !is_same_v); +/** + * @brief Specifies a type to have a complex character + * + * A complex is a physical quantity that has a complex representation type. + */ +template +constexpr bool is_complex = false; + /** * @brief Specifies a type to have a vector character * diff --git a/src/core/include/mp-units/framework/representation_concepts.h b/src/core/include/mp-units/framework/representation_concepts.h index 764edbc4b..3a19398ed 100644 --- a/src/core/include/mp-units/framework/representation_concepts.h +++ b/src/core/include/mp-units/framework/representation_concepts.h @@ -50,6 +50,8 @@ namespace mp_units { * * A scalar is a physical quantity that has magnitude but no direction. * + * A complex is a physical quantity that is represented with a complex number. + * * Vectors are physical quantities that possess both magnitude and direction * and whose operations obey the axioms of a vector space. * @@ -57,7 +59,7 @@ namespace mp_units { * For example, the Cauchy stress tensor possess magnitude, direction, * and orientation qualities. */ -MP_UNITS_EXPORT enum class quantity_character : std::int8_t { scalar, vector, tensor }; +MP_UNITS_EXPORT enum class quantity_character : std::int8_t { scalar, complex, vector, tensor }; namespace detail { @@ -86,11 +88,12 @@ concept WeaklyRegular = std::copyable && std::equality_comparable; MP_UNITS_EXPORT template concept Representation = - (is_scalar || is_vector || is_tensor) && detail::WeaklyRegular && detail::Scalable; + (is_scalar || is_complex || is_vector || is_tensor) && detail::WeaklyRegular && detail::Scalable; MP_UNITS_EXPORT template -concept RepresentationOf = Representation && ((Ch == quantity_character::scalar && is_scalar) || - (Ch == quantity_character::vector && is_vector) || - (Ch == quantity_character::tensor && is_tensor)); +concept RepresentationOf = + Representation && + ((Ch == quantity_character::scalar && is_scalar) || (Ch == quantity_character::complex && is_complex) || + (Ch == quantity_character::vector && is_vector) || (Ch == quantity_character::tensor && is_tensor)); } // namespace mp_units