mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-02 03:44:27 +02:00
style: small cleanup of representation concepts
This commit is contained in:
@@ -240,21 +240,27 @@ concept Vector = (!disable_vector<T>) && WeaklyRegular<T> && requires(const T a,
|
|||||||
::mp_units::magnitude(a);
|
::mp_units::magnitude(a);
|
||||||
requires ScalableWith<T, decltype(::mp_units::magnitude(a))>;
|
requires ScalableWith<T, decltype(::mp_units::magnitude(a))>;
|
||||||
// TODO should we also check for the below (e.g., when `size() > 1` or `2`)
|
// TODO should we also check for the below (e.g., when `size() > 1` or `2`)
|
||||||
// { zero_vector<T>() } -> Vector;
|
// ::mp_units::zero_vector<T>();
|
||||||
// { unit_vector(a) } -> Vector;
|
// ::mp_units::unit_vector(a);
|
||||||
// { scalar_product(a, b) } -> Scalar;
|
// ::mp_units::scalar_product(a, b);
|
||||||
// { vector_product(a, b) } -> Vector;
|
// ::mp_units::vector_product(a, b);
|
||||||
// { tensor_product(a, b) } -> Tensor2;
|
// ::mp_units::tensor_product(a, b);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
// MP_UNITS_EXPORT template<typename T>
|
||||||
|
// constexpr bool disable_tensor = false;
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
// TODO provide when some actual operations will be required
|
// TODO provide when some actual operations will be required
|
||||||
// template<typename T>
|
// template<typename T>
|
||||||
// concept Tensor = is_tensor<T> && WeaklyRegular<T>; // && requires(T a, T b) {
|
// concept Tensor = (!disable_tensor<T>) && WeaklyRegular<T> && requires(const T a, const T b) {
|
||||||
// // tensor operations
|
// ::mp_units::tensor_product(a, b);
|
||||||
// // { tensor_product(a, b) } -> Tensor4;
|
// ::mp_units::inner_product(a, b);
|
||||||
// // { inner_product(a, b) } -> Tensor2;
|
// ::mp_units::scalar_product(a, b);
|
||||||
// // { scalar_product(a, b) } -> Scalar;
|
// };
|
||||||
// //};
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr bool is_quantity = false;
|
constexpr bool is_quantity = false;
|
||||||
@@ -294,17 +300,21 @@ concept VectorRepresentation = (!is_quantity<T>) && Vector<T> && requires(const
|
|||||||
// template<typename T>
|
// template<typename T>
|
||||||
// concept TensorRepresentation = (!is_quantity<T>) && Tensor<T>;
|
// concept TensorRepresentation = (!is_quantity<T>) && Tensor<T>;
|
||||||
|
|
||||||
template<typename T, quantity_character Ch>
|
|
||||||
concept IsOfCharacter =
|
|
||||||
(Ch == quantity_character::scalar && Scalar<T>) || (Ch == quantity_character::complex && Complex<T>) ||
|
|
||||||
(Ch == quantity_character::vector && Vector<T>); // || (Ch == quantity_character::tensor && Tensor<T>);
|
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
MP_UNITS_EXPORT template<typename T>
|
MP_UNITS_EXPORT template<typename T>
|
||||||
concept Representation = detail::ScalarRepresentation<T> || detail::ComplexRepresentation<T> ||
|
concept Representation = detail::ScalarRepresentation<T> || detail::ComplexRepresentation<T> ||
|
||||||
detail::VectorRepresentation<T>; // || detail::TensorRepresentation<T>;
|
detail::VectorRepresentation<T>; // || detail::TensorRepresentation<T>;
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
|
template<typename T, quantity_character Ch>
|
||||||
|
concept IsOfCharacter =
|
||||||
|
(Ch == quantity_character::scalar && Scalar<T>) || (Ch == quantity_character::complex && Complex<T>) ||
|
||||||
|
(Ch == quantity_character::vector && Vector<T>); // || (Ch == quantity_character::tensor && Tensor<T>);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
MP_UNITS_EXPORT template<typename T, auto V>
|
MP_UNITS_EXPORT template<typename T, auto V>
|
||||||
concept RepresentationOf =
|
concept RepresentationOf =
|
||||||
Representation<T> &&
|
Representation<T> &&
|
||||||
|
Reference in New Issue
Block a user