Skip to content

Commit

Permalink
feat: complex quantity character added
Browse files Browse the repository at this point in the history
  • Loading branch information
mpusz committed Sep 20, 2024
1 parent 696f789 commit 7f0dea9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/core/include/mp-units/framework/customization_points.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ constexpr bool treat_as_floating_point<Rep> = treat_as_floating_point<wrapped_ty
template<typename Rep>
constexpr bool is_scalar = std::is_floating_point_v<Rep> || (std::is_integral_v<Rep> && !is_same_v<Rep, bool>);

/**
* @brief Specifies a type to have a complex character
*
* A complex is a physical quantity that has a complex representation type.
*/
template<typename Rep>
constexpr bool is_complex = false;

/**
* @brief Specifies a type to have a vector character
*
Expand Down
13 changes: 8 additions & 5 deletions src/core/include/mp-units/framework/representation_concepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ 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.
*
* Tensors can be used to describe more general physical quantities.
* 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 {

Expand Down Expand Up @@ -86,11 +88,12 @@ concept WeaklyRegular = std::copyable<T> && std::equality_comparable<T>;

MP_UNITS_EXPORT template<typename T>
concept Representation =
(is_scalar<T> || is_vector<T> || is_tensor<T>) && detail::WeaklyRegular<T> && detail::Scalable<T>;
(is_scalar<T> || is_complex<T> || is_vector<T> || is_tensor<T>) && detail::WeaklyRegular<T> && detail::Scalable<T>;

MP_UNITS_EXPORT template<typename T, quantity_character Ch>
concept RepresentationOf = Representation<T> && ((Ch == quantity_character::scalar && is_scalar<T>) ||
(Ch == quantity_character::vector && is_vector<T>) ||
(Ch == quantity_character::tensor && is_tensor<T>));
concept RepresentationOf =
Representation<T> &&
((Ch == quantity_character::scalar && is_scalar<T>) || (Ch == quantity_character::complex && is_complex<T>) ||
(Ch == quantity_character::vector && is_vector<T>) || (Ch == quantity_character::tensor && is_tensor<T>));

} // namespace mp_units

0 comments on commit 7f0dea9

Please sign in to comment.