|
dot-xx
A personal collection of small C++ modules
|
The main namespace of the dxx::math module. More...
Namespaces | |
| namespace | container_traits |
| Advanced type traits for containers. | |
| namespace | norms |
| Built-in norms. | |
| namespace | operators |
| The namespace that collects all operators defined by dxx.math.* modules. | |
| namespace | vector_operators |
| Operations on vectors. Read the description. | |
Classes | |
| struct | Norm |
| Defines a norm. Only norm field is required, all other fields can be assigned a nullptr. More... | |
| struct | Sub |
| Default difference is subtraction. More... | |
Concepts | |
| concept | vector |
| We can treat any input range as a vector. | |
| concept | mut_vector |
| A vector for which the elements can be written to. | |
| concept | vector_like |
| Vector for which the element type is convertible to a target vector's type. | |
| concept | mut_vector_like |
| Similar to vector_like, but also satisfies mut_vector. | |
Typedefs | |
| template<typename T> | |
| using | RealOf = detail::RealOf<T>::Type |
| (Non-cv-qualified) Real type of the linalg type | |
Enumerations | |
| enum class | Sign : int { Positive = 1 , Zero = 0 , Negative = -1 } |
| Return type of sign. Use std::to_underlying to convert to int. | |
Functions | |
| template<mut_vector Out, vector_like< Out > U, vector_like< Out > V> | |
| constexpr void | add (U &&u, V &&v, Out &out) |
| Element-wise vector addition. Result via output parameter. | |
| template<container_traits::returnable Out, vector_like< Out > U, vector_like< Out > V> | |
| constexpr Out | add (U &&u, V &&v) |
| Element-wise vector addition. Result in return value of a user-provided type. | |
|
template<vector U, vector_like< U > V> requires container_traits::returnable<std::remove_cvref_t<U>> | |
| constexpr std::remove_cvref_t< U > | add (U &&u, V &&v) |
| Element-wise vector addition. Result in return value of automatically selected type. | |
| template<mut_vector Out, vector_like< Out > U, std::convertible_to< RealOf< Out > > Scalar> | |
| constexpr void | add (U &&u, const Scalar &scalar, Out &out) |
| Element-wise addition of vector elements with a scalar. Result via output parameter. | |
| template<container_traits::returnable Out, vector_like< Out > U, std::convertible_to< RealOf< Out > > Scalar> | |
| constexpr Out | add (U &&u, const Scalar &scalar) |
| Element-wise addition of vector elements with a scalar. Result in return value of a user-provided type. | |
| template<vector U, std::convertible_to< RealOf< U > > Scalar> | |
| constexpr std::remove_cvref_t< U > | add (U &&u, const Scalar &scalar) |
| Element-wise addition of vector elements with a scalar. Result in return value of automatically selected type. | |
| template<mut_vector Out, std::convertible_to< RealOf< Out > > Scalar, vector_like< Out > U> | |
| constexpr void | add (const Scalar &scalar, U &&u, Out &out) |
| Element-wise addition of scalar with vector elements. Result via output parameter. | |
| template<container_traits::returnable Out, std::convertible_to< RealOf< Out > > Scalar, vector_like< Out > U> | |
| constexpr Out | add (const Scalar &scalar, U &&u) |
| Element-wise addition of scalar with vector elements. Result in return value of a user-provided type. | |
| template<vector U, std::convertible_to< RealOf< U > > Scalar> | |
| constexpr std::remove_cvref_t< U > | add (const Scalar &scalar, U &&u) |
| Element-wise addition of vector elements with a scalar. Result in return value of automatically selected type. | |
| template<mut_vector Out, vector_like< Out > U, vector_like< Out > V> | |
| constexpr void | sub (U &&u, V &&v, Out &out) |
| Element-wise vector subtraction. Result via output parameter. | |
| template<container_traits::returnable Out, vector_like< Out > U, vector_like< Out > V> | |
| constexpr Out | sub (U &&u, V &&v) |
| Element-wise vector subtraction. Result in return value of a user-provided type. | |
|
template<vector U, vector_like< U > V> requires container_traits::returnable<std::remove_cvref_t<U>> | |
| constexpr std::remove_cvref_t< U > | sub (U &&u, V &&v) |
| Element-wise vector subtraction. Result in return value of automatically selected type. | |
| template<mut_vector Out, vector_like< Out > U, std::convertible_to< RealOf< Out > > Scalar> | |
| constexpr void | sub (U &&u, const Scalar &scalar, Out &out) |
| Element-wise subtraction of vector elements with a scalar. Result via output parameter. | |
| template<container_traits::returnable Out, vector_like< Out > U, std::convertible_to< RealOf< Out > > Scalar> | |
| constexpr Out | sub (U &&u, const Scalar &scalar) |
| Element-wise subtraction of vector elements with a scalar. Result in return value of a user-provided type. | |
| template<vector U, std::convertible_to< RealOf< U > > Scalar> | |
| constexpr std::remove_cvref_t< U > | sub (U &&u, const Scalar &scalar) |
| Element-wise subtraction of vector elements with a scalar. Result in return value of automatically selected type. | |
| template<mut_vector Out, std::convertible_to< RealOf< Out > > Scalar, vector_like< Out > U> | |
| constexpr void | sub (const Scalar &scalar, U &&u, Out &out) |
| Element-wise subtraction of scalar with vector elements. Result via output parameter. | |
| template<container_traits::returnable Out, std::convertible_to< RealOf< Out > > Scalar, vector_like< Out > U> | |
| constexpr Out | sub (const Scalar &scalar, U &&u) |
| Element-wise subtraction of scalar with vector elements. Result in return value of a user-provided type. | |
| template<vector U, std::convertible_to< RealOf< U > > Scalar> | |
| constexpr std::remove_cvref_t< U > | sub (const Scalar &scalar, U &&u) |
| Element-wise subtraction of vector elements with a scalar. Result in return value of automatically selected type. | |
| template<mut_vector Out, vector_like< Out > U, vector_like< Out > V> | |
| constexpr void | mul (U &&u, V &&v, Out &out) |
| Element-wise vector multiplication. Result via output parameter. | |
| template<container_traits::returnable Out, vector_like< Out > U, vector_like< Out > V> | |
| constexpr Out | mul (U &&u, V &&v) |
| Element-wise vector multiplication. Result in return value of a user-provided type. | |
|
template<vector U, vector_like< U > V> requires container_traits::returnable<std::remove_cvref_t<U>> | |
| constexpr std::remove_cvref_t< U > | mul (U &&u, V &&v) |
| Element-wise vector multiplication. Result in return value of automatically selected type. | |
| template<mut_vector Out, vector_like< Out > U, std::convertible_to< RealOf< Out > > Scalar> | |
| constexpr void | mul (U &&u, const Scalar &scalar, Out &out) |
| Element-wise multiplication of vector elements with a scalar. Result via output parameter. | |
| template<container_traits::returnable Out, vector_like< Out > U, std::convertible_to< RealOf< Out > > Scalar> | |
| constexpr Out | mul (U &&u, const Scalar &scalar) |
| Element-wise multiplication of vector elements with a scalar. Result in return value of a user-provided type. | |
| template<vector U, std::convertible_to< RealOf< U > > Scalar> | |
| constexpr std::remove_cvref_t< U > | mul (U &&u, const Scalar &scalar) |
| Element-wise multiplication of vector elements with a scalar. Result in return value of automatically selected type. | |
| template<mut_vector Out, std::convertible_to< RealOf< Out > > Scalar, vector_like< Out > U> | |
| constexpr void | mul (const Scalar &scalar, U &&u, Out &out) |
| Element-wise multiplication of scalar with vector elements. Result via output parameter. | |
| template<container_traits::returnable Out, std::convertible_to< RealOf< Out > > Scalar, vector_like< Out > U> | |
| constexpr Out | mul (const Scalar &scalar, U &&u) |
| Element-wise multiplication of scalar with vector elements. Result in return value of a user-provided type. | |
| template<vector U, std::convertible_to< RealOf< U > > Scalar> | |
| constexpr std::remove_cvref_t< U > | mul (const Scalar &scalar, U &&u) |
| Element-wise multiplication of vector elements with a scalar. Result in return value of automatically selected type. | |
| template<mut_vector Out, vector_like< Out > U, vector_like< Out > V> | |
| constexpr void | div (U &&u, V &&v, Out &out) |
| Element-wise vector division. Result via output parameter. | |
| template<container_traits::returnable Out, vector_like< Out > U, vector_like< Out > V> | |
| constexpr Out | div (U &&u, V &&v) |
| Element-wise vector division. Result in return value of a user-provided type. | |
|
template<vector U, vector_like< U > V> requires container_traits::returnable<std::remove_cvref_t<U>> | |
| constexpr std::remove_cvref_t< U > | div (U &&u, V &&v) |
| Element-wise vector division. Result in return value of automatically selected type. | |
| template<mut_vector Out, vector_like< Out > U, std::convertible_to< RealOf< Out > > Scalar> | |
| constexpr void | div (U &&u, const Scalar &scalar, Out &out) |
| Element-wise division of vector elements with a scalar. Result via output parameter. | |
| template<container_traits::returnable Out, vector_like< Out > U, std::convertible_to< RealOf< Out > > Scalar> | |
| constexpr Out | div (U &&u, const Scalar &scalar) |
| Element-wise division of vector elements with a scalar. Result in return value of a user-provided type. | |
| template<vector U, std::convertible_to< RealOf< U > > Scalar> | |
| constexpr std::remove_cvref_t< U > | div (U &&u, const Scalar &scalar) |
| Element-wise division of vector elements with a scalar. Result in return value of automatically selected type. | |
| template<mut_vector Out, std::convertible_to< RealOf< Out > > Scalar, vector_like< Out > U> | |
| constexpr void | div (const Scalar &scalar, U &&u, Out &out) |
| Element-wise division of scalar with vector elements. Result via output parameter. | |
| template<container_traits::returnable Out, std::convertible_to< RealOf< Out > > Scalar, vector_like< Out > U> | |
| constexpr Out | div (const Scalar &scalar, U &&u) |
| Element-wise division of scalar with vector elements. Result in return value of a user-provided type. | |
| template<vector U, std::convertible_to< RealOf< U > > Scalar> | |
| constexpr std::remove_cvref_t< U > | div (const Scalar &scalar, U &&u) |
| Element-wise division of vector elements with a scalar. Result in return value of automatically selected type. | |
| template<mut_vector Out, vector_like< Out > U, vector_like< Out > V> | |
| void | cross (const U &u, const V &v, Out &out) |
| Cross product of two 3D vectors (via out parameter). | |
| template<container_traits::returnable Out, vector_like< Out > U, vector_like< Out > V> | |
| constexpr Out | cross (const U &u, const V &v) |
| Cross product of two 3D vectors (via return value). | |
| template<container_traits::returnable U, vector_like< U > V> | |
| constexpr U | cross (const U &u, const V &v) |
| Cross product of two 3D vectors (via return value of default type). | |
| template<vector U, vector_like< U > V> | |
| constexpr RealOf< U > | dot (const U &u, const V &v) |
| Vector dot product. | |
| template<Norm t_norm = norms::euclidean, vector V> | |
| constexpr RealOf< V > | norm (const V &v) |
| Calculates norm t_norm for vector v. | |
| template<Norm t_norm = norms::euclidean, vector V> | |
| constexpr RealOf< V > | sq_norm (const V &v) |
| Calculates the square of the norm t_norm for vector v. | |
| template<Norm t_norm = norms::euclidean, vector V, vector_like< V > U> | |
| constexpr RealOf< V > | dist (const V &v, const U &u) |
| Calculates the distance between vector v and u according to norm t_norm. | |
| template<Norm t_norm = norms::euclidean, vector V, vector_like< V > U> | |
| constexpr RealOf< V > | sq_dist (const V &v, const U &u) |
| Calculates the square of the distance between vector v and u according to norm t_norm. | |
| template<typename T, typename Compare = std::less<T>, typename Diff = Sub> | |
| constexpr T | abs_diff (const T &a, const T &b, Compare comp={}, Diff diff={}) |
| Underflow-safe absolute difference between two numbers. | |
| template<typename T, typename Less = std::less<T>> | |
| constexpr Sign | sign (T t, Less less={}, T zero={}) |
| Gets the sign of a number. | |
The main namespace of the dxx::math module.
|
inlinenodiscardconstexprexport |
Underflow-safe absolute difference between two numbers.
Inspired by ARM's vabdq_u8 instruction and copied from https://www.open-std.org/JTC1/SC22/WG21/docs/papers/2014/n4318.pdf