|
wuzp
Wrong Unit? Zero Points! Compile-time checks for units, coordinate systems and points vs. vectors.
|
Wrapper for the actual implementation of a value container. More...
#include <wuzp/core/ValuesWrapper.hpp>
Public Types | |
| using | MatrixSizeT = MatrixSizeT_ |
| using | ValueT = ValueT_ |
| using | ImplementationT = std::decay_t<ImplementationT_> |
| using | ThisT = ValuesWrapper<MatrixSizeT, ValueT, ImplementationT> |
Public Member Functions | |
| ValuesWrapper () | |
| ValuesWrapper (const ValuesWrapper &other) | |
| Copies the values. | |
| ValuesWrapper (ValuesWrapper &&other) noexcept | |
| Moves the values. | |
| ValuesWrapper & | operator= (const ValuesWrapper &other) |
| Only evaluated values can be assigned to: an unevaluated value, e.g. the lazy sum of two matrices of the backend, refers to its operands, so assigning to it would write into them (Blitz++) or does not compile (Eigen). | |
| ValuesWrapper & | operator= (ValuesWrapper &&other) noexcept |
| ~ValuesWrapper ()=default | |
| template<typename T0, typename... Ts> requires (!IsSpecialization<T0, Tag>::value && !CopiesOrMoves<ValuesWrapper, T0, Ts...>) | |
| explicit (!IsValidConversion< ThisT, std::remove_cvref_t< T0 >, std::remove_cvref_t< Ts >... >::value) ValuesWrapper(T0 &&t0 | |
| Ts Ts | std::forward (t0) |
| Ts Ts | std::forward (ts)...) |
| template<int RowIdV_, int ColIdV_> | |
| auto | get () const |
| The element in the row RowIdV_ and the column ColIdV_, which are checked at compile time. | |
| template<int IdV_> requires (Dimension<ThisT>::value <= 1) | |
| auto | get () const |
| The element with the single index IdV_ of values of dimension 0 or 1: the row of a column, the column of a row, or 0 for 1x1 values (see internal::vectorElementRowId()). | |
| auto | get () const |
| auto | get (int rowId, int colId) const |
| auto | get (int id) const |
| The element with the single index id of values of dimension 0 or 1, like get<IdV_>(), but with an index known at run time. | |
| template<int RowIdV_, int ColIdV_, typename ValueOtherT_> | |
| ThisT & | set (ValueOtherT_ value) |
| Sets the element in the row RowIdV_ and the column ColIdV_, which are checked at compile time, and converts it like set(rowId, colId, value). | |
| template<int IdV_, typename ValueOtherT_> requires (Dimension<ThisT>::value <= 1) | |
| ThisT & | set (ValueOtherT_ value) |
| Sets the element with the single index IdV_ of values of dimension 0 or 1 (see get<IdV_>()), which is checked at compile time, and converts it like set(rowId, colId, value). | |
| template<typename ValueOtherT_> requires (Dimension<ThisT>::value == 0) | |
| ThisT & | set (ValueOtherT_ value) |
| template<typename ValueOtherT_> | |
| ThisT & | set (int rowId, int colId, ValueOtherT_ value) |
| Sets an element. | |
| template<typename ValueOtherT_> requires (Dimension<ThisT>::value <= 1) | |
| ThisT & | set (int id, ValueOtherT_ value) |
| Sets the element with the single index id of values of dimension 0 or 1, like set<IdV_>(value), but with an index known at run time. | |
| operator typename GetValue< ThisT >::type () const | |
| template<typename MatrixSizeOtherT_, typename ValueOtherT_, typename ImplementationOtherT_> | |
| bool | isApprox (const ValuesWrapper< MatrixSizeOtherT_, ValueOtherT_, ImplementationOtherT_ > &other, const ValueT precision=Precision< ValueT >::value()) const |
| Whether the values are approximately equal to the other values: relatively, like Eigen's isApprox(), ||a - b|| <= precision min(||a||, ||b||) in the Frobenius norm (see Comparison::approxEqual()). | |
| template<int BlockRowIdV_, int BlockColIdV_, int BlockRowsV_, int BlockColsV_> | |
| auto | getBlock () const |
| auto | transpose () const |
| template<typename MatrixSizeOtherT_, typename ValueOtherT_, typename ImplementationOtherT_> | |
| auto | innerProduct (const ValuesWrapper< MatrixSizeOtherT_, ValueOtherT_, ImplementationOtherT_ > &other) const |
| template<typename MatrixSizeOtherT_, typename ValueOtherT_, typename ImplementationOtherT_> | |
| auto | outerProduct (const ValuesWrapper< MatrixSizeOtherT_, ValueOtherT_, ImplementationOtherT_ > &other) const |
| template<typename MatrixSizeOtherT_, typename ValueOtherT_, typename ImplementationOtherT_> | |
| auto | dotProduct (const ValuesWrapper< MatrixSizeOtherT_, ValueOtherT_, ImplementationOtherT_ > &other) const |
| template<typename MatrixSizeOtherT_, typename ValueOtherT_, typename ImplementationOtherT_> | |
| auto | crossProduct (const ValuesWrapper< MatrixSizeOtherT_, ValueOtherT_, ImplementationOtherT_ > &other) const |
| auto | norm () const |
| auto | squaredNorm () const |
| auto | determinant () const |
| auto | inverse () const |
| The matrix inverse of a square matrix, like Eigen's MatrixBase::inverse(). | |
| auto | cwiseInverse () const |
| The elementwise reciprocal, like Eigen's ArrayBase::inverse() or MatrixBase::cwiseInverse(). | |
| template<typename FunctionT_> | |
| auto | cwiseFunction (const FunctionT_ &function) const |
| The function applied to every element, like Eigen's DenseBase::unaryExpr(): the values function(value), of the same value type and size. | |
| ThisT & | setImplementation (const ImplementationT &implementation) |
| ImplementationT & | implementation () |
| const ImplementationT & | getImplementation () const |
| auto | evaluate () const & |
| auto | evaluate () && |
| Evaluated values of a temporary, e.g. of the result of an operation: if they are evaluated already, they are moved. | |
Static Public Member Functions | |
| static ThisT | zero () |
| Values that are all zero. | |
| static ThisT | random () |
| Random values, uniformly distributed in [-1, 1]. | |
Public Attributes | |
| Ts && | ts: ValuesWrapper(typename GetTag<ThisT |
| Ts | T0 |
Wrapper for the actual implementation of a value container.
This is required as some libraries, e.g. Eigen, use different types for matrices and expressions, but we want a single trait specialization to catch all of them. We cannot use CRTP, as we need this wrapper for unambiguous template specialization.
| ImplementationT_ | ImplementationT of the values. |
Definition at line 22 of file ValuesWrapper.hpp.
| using wuzp::ValuesWrapper< MatrixSizeT_, ValueT_, ImplementationT_ >::ImplementationT = std::decay_t<ImplementationT_> |
Definition at line 26 of file ValuesWrapper.hpp.
| using wuzp::ValuesWrapper< MatrixSizeT_, ValueT_, ImplementationT_ >::MatrixSizeT = MatrixSizeT_ |
Definition at line 24 of file ValuesWrapper.hpp.
| using wuzp::ValuesWrapper< MatrixSizeT_, ValueT_, ImplementationT_ >::ThisT = ValuesWrapper<MatrixSizeT, ValueT, ImplementationT> |
Definition at line 27 of file ValuesWrapper.hpp.
| using wuzp::ValuesWrapper< MatrixSizeT_, ValueT_, ImplementationT_ >::ValueT = ValueT_ |
Definition at line 25 of file ValuesWrapper.hpp.
|
inline |
Definition at line 29 of file ValuesWrapper.hpp.
|
inline |
Copies the values.
The copy never shares them with the original, also with backends whose matrices share their values when they are copy constructed, e.g. Blitz++ (see Copy).
Definition at line 33 of file ValuesWrapper.hpp.
|
inlinenoexcept |
Moves the values.
A moved-from object may be empty with some backends, e.g. Blitz++ (see Move): it can only be assigned to or destroyed.
Definition at line 36 of file ValuesWrapper.hpp.
|
default |
|
inline |
Definition at line 218 of file ValuesWrapper.hpp.
|
inline |
The function applied to every element, like Eigen's DenseBase::unaryExpr(): the values function(value), of the same value type and size.
The function, e.g. a lambda, maps a value of the value type to a value of the value type (see CwiseFunction).
Definition at line 242 of file ValuesWrapper.hpp.
|
inline |
The elementwise reciprocal, like Eigen's ArrayBase::inverse() or MatrixBase::cwiseInverse().
Definition at line 236 of file ValuesWrapper.hpp.
|
inline |
Definition at line 227 of file ValuesWrapper.hpp.
|
inline |
Definition at line 211 of file ValuesWrapper.hpp.
|
inline |
Evaluated values of a temporary, e.g. of the result of an operation: if they are evaluated already, they are moved.
Definition at line 259 of file ValuesWrapper.hpp.
|
inline |
Definition at line 257 of file ValuesWrapper.hpp.
| wuzp::ValuesWrapper< MatrixSizeT_, ValueT_, ImplementationT_ >::explicit | ( | !IsValidConversion< ThisT, std::remove_cvref_t< T0 >, std::remove_cvref_t< Ts >... >::value | ) | && |
|
inline |
Definition at line 95 of file ValuesWrapper.hpp.
|
inline |
The element with the single index IdV_ of values of dimension 0 or 1: the row of a column, the column of a row, or 0 for 1x1 values (see internal::vectorElementRowId()).
It is checked at compile time, like the row and the column of get<RowIdV_, ColIdV_>().
Definition at line 89 of file ValuesWrapper.hpp.
|
inline |
The element in the row RowIdV_ and the column ColIdV_, which are checked at compile time.
Definition at line 80 of file ValuesWrapper.hpp.
|
inline |
The element with the single index id of values of dimension 0 or 1, like get<IdV_>(), but with an index known at run time.
Definition at line 104 of file ValuesWrapper.hpp.
|
inline |
Definition at line 101 of file ValuesWrapper.hpp.
|
inline |
Definition at line 184 of file ValuesWrapper.hpp.
|
inline |
Definition at line 255 of file ValuesWrapper.hpp.
|
inline |
Definition at line 254 of file ValuesWrapper.hpp.
|
inline |
Definition at line 195 of file ValuesWrapper.hpp.
|
inline |
The matrix inverse of a square matrix, like Eigen's MatrixBase::inverse().
It is rejected for integer matrices, whose inverse is not an integer matrix in general: a backend would truncate it, e.g. Eigen divides integers (see "Inverses and determinants" in DESIGN.md), by Inverse<ValuesWrapper<...>>.
Definition at line 232 of file ValuesWrapper.hpp.
|
inline |
Whether the values are approximately equal to the other values: relatively, like Eigen's isApprox(), ||a - b|| <= precision min(||a||, ||b||) in the Frobenius norm (see Comparison::approxEqual()).
Integers compare exactly, whatever the precision, like with Eigen's isApprox() (isApprox_selector in https://gitlab.com/libeigen/eigen/-/blob/master/Eigen/src/Core/Fuzzy.h): the squares of their differences, which the relative comparison sums, overflow, e.g. 65536^2 is 0 in 32-bit unsigned integers, so that 0 and 65536 would be approximately equal. Values of different types, which only some backends accept, e.g. Blitz++, compare exactly if either of them is an integer.
Definition at line 170 of file ValuesWrapper.hpp.
|
inline |
Definition at line 225 of file ValuesWrapper.hpp.
|
inline |
Definition at line 155 of file ValuesWrapper.hpp.
|
inline |
Only evaluated values can be assigned to: an unevaluated value, e.g. the lazy sum of two matrices of the backend, refers to its operands, so assigning to it would write into them (Blitz++) or does not compile (Eigen).
Definition at line 40 of file ValuesWrapper.hpp.
|
inlinenoexcept |
Definition at line 46 of file ValuesWrapper.hpp.
|
inline |
Definition at line 203 of file ValuesWrapper.hpp.
|
inlinestatic |
Random values, uniformly distributed in [-1, 1].
Definition at line 71 of file ValuesWrapper.hpp.
|
inline |
Sets the element with the single index id of values of dimension 0 or 1, like set<IdV_>(value), but with an index known at run time.
Definition at line 148 of file ValuesWrapper.hpp.
|
inline |
Sets an element.
Like the elements of the constructor, it is converted into the value type only if their common type is the value type (see isConvertedToValueType), e.g. an int for double values, but not a double for int values, which could truncate it.
Definition at line 138 of file ValuesWrapper.hpp.
|
inline |
Definition at line 128 of file ValuesWrapper.hpp.
|
inline |
Sets the element with the single index IdV_ of values of dimension 0 or 1 (see get<IdV_>()), which is checked at compile time, and converts it like set(rowId, colId, value).
Definition at line 121 of file ValuesWrapper.hpp.
|
inline |
Sets the element in the row RowIdV_ and the column ColIdV_, which are checked at compile time, and converts it like set(rowId, colId, value).
Definition at line 113 of file ValuesWrapper.hpp.
|
inline |
Definition at line 250 of file ValuesWrapper.hpp.
|
inline |
Definition at line 226 of file ValuesWrapper.hpp.
| Ts Ts wuzp::ValuesWrapper< MatrixSizeT_, ValueT_, ImplementationT_ >::std::forward | ( | t0 | ) |
|
inline |
Definition at line 61 of file ValuesWrapper.hpp.
|
inline |
Definition at line 190 of file ValuesWrapper.hpp.
|
inlinestatic |
Values that are all zero.
Definition at line 64 of file ValuesWrapper.hpp.
| Ts wuzp::ValuesWrapper< MatrixSizeT_, ValueT_, ImplementationT_ >::T0 |
Definition at line 61 of file ValuesWrapper.hpp.
| Ts&& wuzp::ValuesWrapper< MatrixSizeT_, ValueT_, ImplementationT_ >::ts |
Definition at line 60 of file ValuesWrapper.hpp.