wuzp
Wrong Unit? Zero Points! Compile-time checks for units, coordinate systems and points vs. vectors.
Loading...
Searching...
No Matches
ValueMatrix.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <algorithm>
4#include <cmath>
5#include <cstdlib>
6#include <limits>
7#include <tuple>
8#include <type_traits>
9#include <utility>
10
11#include <blitz/array.h>
12#include <blitz/range.h>
13
19#include "wuzp/core/helpers.hpp"
20#include "wuzp/core/internal/operator_traits.hpp"
21#include "wuzp/core/traits.hpp"
22
23namespace wuzp_blitz {
24
25template <typename ValueT_, int RowsV_, int ColsV_>
26using ValueMatrix = wuzp::ValuesWrapper<wuzp::MatrixSize<RowsV_, ColsV_>, ValueT_, blitz::Array<ValueT_, 2>>;
27
28template <int RowsV_, int ColsV_>
30template <int RowsV_, int ColsV_>
32template <int RowsV_, int ColsV_>
34
35template <typename ValueT_, int RowsV_>
37
38template <int RowsV_>
40template <int RowsV_>
42template <int RowsV_>
44
45template <typename ValueT_>
47
51
53template <typename UnitT_>
55template <typename UnitT_>
57template <typename UnitT_>
59
60namespace internal {
61
62template <typename T>
63struct IsBlitzArray : std::false_type {};
64template <typename ValueT_>
65struct IsBlitzArray<blitz::Array<ValueT_, 2>> : std::true_type {};
66template <typename ExpressionT_>
67struct IsBlitzArray<blitz::_bz_ArrayExpr<ExpressionT_>> : std::true_type {};
68
70template <typename ImplementationT_>
71using ArrayOf = blitz::Array<typename ImplementationT_::T_numtype, 2>;
72
73template <typename ImplementationT_>
74inline constexpr bool isArray = std::is_same_v<ImplementationT_, ArrayOf<ImplementationT_>>;
75
79template <typename ImplementationT_>
80ArrayOf<ImplementationT_> copyToArray(const ImplementationT_& impl) {
81 // The values are assigned to a new array of the same extents, which stores them row by row, like all other arrays of the
82 // backend. impl.copy() would keep the storage order of a transposed view, and the constructor from an expression derives the
83 // storage order from the operands and evaluates the expression into a temporary array that it then references, which costs
84 // about as much as evaluating a small expression (#58).
85 ArrayOf<ImplementationT_> result(impl.ubound(0) - impl.lbound(0) + 1, impl.ubound(1) - impl.lbound(1) + 1);
86 result = impl;
87 return result;
88}
89
92template <typename ImplementationT_>
93decltype(auto) asArray(const ImplementationT_& impl) {
94 if constexpr (isArray<ImplementationT_>) {
95 return (impl);
96 } else {
97 return copyToArray(impl);
98 }
99}
100
102template <typename ValueT_>
103void swapRows(blitz::Array<ValueT_, 2>& matrix, const int row, const int otherRow) {
104 for (int col = 0; col < matrix.extent(1); ++col) {
105 std::swap(matrix(row, col), matrix(otherRow, col));
106 }
107}
108
122template <typename WorkT_, typename ImplementationT_>
123std::pair<blitz::Array<WorkT_, 2>, WorkT_> gaussJordan(const ImplementationT_& impl) {
124 const auto& matrix = asArray(impl);
125 const int size = matrix.extent(0);
126 blitz::Array<WorkT_, 2> reduced(size, size);
127 reduced = blitz::cast<WorkT_>(matrix);
128 blitz::Array<WorkT_, 2> inverse(size, size);
129 inverse = WorkT_{0};
130 for (int index = 0; index < size; ++index) {
131 inverse(index, index) = WorkT_{1};
132 }
133 WorkT_ determinant{1};
134 for (int col = 0; col < size; ++col) {
135 int pivot = col;
136 for (int row = col + 1; row < size; ++row) {
137 if (std::abs(reduced(row, col)) > std::abs(reduced(pivot, col))) {
138 pivot = row;
139 }
140 }
141 if (reduced(pivot, col) == WorkT_{0}) {
142 inverse = std::numeric_limits<WorkT_>::quiet_NaN();
143 return {inverse, WorkT_{0}};
144 }
145 if (pivot != col) {
146 swapRows(reduced, pivot, col);
147 swapRows(inverse, pivot, col);
148 determinant = -determinant;
149 }
150 const WorkT_ pivotValue = reduced(col, col);
151 determinant *= pivotValue;
152 // The columns before col are those of the identity already.
153 for (int otherCol = col; otherCol < size; ++otherCol) {
154 reduced(col, otherCol) /= pivotValue;
155 }
156 for (int otherCol = 0; otherCol < size; ++otherCol) {
157 inverse(col, otherCol) /= pivotValue;
158 }
159 for (int row = 0; row < size; ++row) {
160 if (row != col) {
161 const WorkT_ factor = reduced(row, col);
162 for (int otherCol = col; otherCol < size; ++otherCol) {
163 reduced(row, otherCol) -= factor * reduced(col, otherCol);
164 }
165 for (int otherCol = 0; otherCol < size; ++otherCol) {
166 inverse(row, otherCol) -= factor * inverse(col, otherCol);
167 }
168 }
169 }
170 }
171 return {inverse, determinant};
172}
173
174} // namespace internal
175
179template <typename T>
180concept BlitzArray = internal::IsBlitzArray<T>::value;
181
182} // namespace wuzp_blitz
183
184namespace wuzp {
185
186template <wuzp_blitz::BlitzArray ImplementationT_, int... SizesV_>
187struct ReserveMemory<ImplementationT_, MatrixSize<SizesV_...>> {
188 static void run(ImplementationT_& impl) { impl.resize(SizesV_...); }
189};
190
191template <wuzp_blitz::BlitzArray ImplementationT_, typename Arg0T_, typename... ArgsT_>
192struct Initialize<ImplementationT_, std::tuple<Arg0T_, ArgsT_...>> {
193 static void run(ImplementationT_& impl, Arg0T_&& arg0, ArgsT_&&... args) {
194 applyCommas((impl = std::forward<Arg0T_>(arg0)), std::forward<ArgsT_>(args)...);
195 }
196};
197
198// All matrices are two-dimensional arrays, whose size is only known at run time.
199template <wuzp_blitz::BlitzArray ImplementationT_, typename ValueT_, int RowsV_, int ColsV_>
200struct Rebind<AccessImplementation<ImplementationT_>, ValueT_, RowsV_, ColsV_> {
201 using type = blitz::Array<ValueT_, 2>;
202};
203
204// Blitz++ accesses elements with the parenthesis operator (see "Indexing" in
205// https://github.com/blitzpp/blitz/blob/main/doc/arrays-slicing.texi).
206template <wuzp_blitz::BlitzArray ImplementationT_>
207struct Coefficient<AccessImplementation<ImplementationT_>> {
208 static auto get(const ImplementationT_& impl, const int row, const int col) { return impl(row, col); }
209 // Only arrays are assigned to: the core rejects assigning to unevaluated values, i.e. expressions.
210 static void set(ImplementationT_& impl, const int row, const int col, const typename ImplementationT_::T_numtype value) {
211 impl(row, col) = value;
212 }
213};
214
215template <wuzp_blitz::BlitzArray ImplementationLhsT_, wuzp_blitz::BlitzArray ImplementationRhsT_>
216struct Comparison<AccessImplementation<ImplementationLhsT_>, AccessImplementation<ImplementationRhsT_>> {
217 static bool equal(const ImplementationLhsT_& lhs, const ImplementationRhsT_& rhs) {
218 return blitz::all(blitz::Array<bool, 2>(lhs == rhs));
219 }
220 // Relative comparison, like Eigen's isApprox: |lhs - rhs| <= tolerance * min(|lhs|, |rhs|), with the Frobenius norm.
221 static bool approxEqual(const ImplementationLhsT_& lhs, const ImplementationRhsT_& rhs,
222 const typename ImplementationLhsT_::T_numtype tolerance) {
223 const auto differenceNorm = std::sqrt(blitz::sum(blitz::pow2(lhs - rhs)));
224 const auto lhsNorm = std::sqrt(blitz::sum(blitz::pow2(lhs)));
225 const auto rhsNorm = std::sqrt(blitz::sum(blitz::pow2(rhs)));
226 return differenceNorm <= tolerance * std::min(lhsNorm, rhsNorm);
227 }
228};
229
230// Blitz++'s copy constructor shares the values of an array, so arrays are copied into new arrays. Copies of expressions refer
231// to the same operands, like the expressions themselves.
232template <wuzp_blitz::BlitzArray ImplementationT_>
233struct Copy<AccessImplementation<ImplementationT_>> {
234 static ImplementationT_ value(const ImplementationT_& impl) {
235 if constexpr (wuzp_blitz::internal::isArray<ImplementationT_>) {
236 return wuzp_blitz::internal::copyToArray(impl);
237 } else {
238 return impl;
239 }
240 }
241};
242
243// Blitz++ arrays cannot be moved, and their copy constructor shares the values: the moved array takes over the values with
244// the copy constructor, which references them like reference(), and the moved-from array is emptied with free() (see "Array
245// members" in https://github.com/blitzpp/blitz/blob/main/doc/arrays-members.texi), so that no two arrays share the values. Unlike
246// a default constructed array that references them, the copy does not set up the storage of an empty array first.
247template <wuzp_blitz::BlitzArray ImplementationT_>
248struct Move<AccessImplementation<ImplementationT_>> {
249 static ImplementationT_ construct(ImplementationT_& source) {
250 if constexpr (wuzp_blitz::internal::isArray<ImplementationT_>) {
251 ImplementationT_ result(source);
252 source.free();
253 return result;
254 } else {
255 return source;
256 }
257 }
258 // Only arrays are assigned: the core rejects assigning to unevaluated values, i.e. expressions.
259 static void assign(ImplementationT_& target, ImplementationT_& source) {
260 target.reference(source);
261 source.free();
262 }
263};
264
265template <wuzp_blitz::BlitzArray ImplementationT_>
266struct Transpose<AccessImplementation<ImplementationT_>> {
267 // Blitz++'s transpose() is a view that shares the values of the array, so the transpose is copied: it does not change with the
268 // original. Expressions have no transpose(), so they are evaluated first.
269 static auto value(const ImplementationT_& impl) {
270 return wuzp_blitz::internal::copyToArray(wuzp_blitz::internal::asArray(impl).transpose(1, 0));
271 }
272 // Not lazy, see above.
273 using type = decltype(value(std::declval<const ImplementationT_>()));
274};
275
276template <wuzp_blitz::BlitzArray ImplementationLhsT_, wuzp_blitz::BlitzArray ImplementationRhsT_>
277struct Sum<AccessImplementation<ImplementationLhsT_>, AccessImplementation<ImplementationRhsT_>>
278 : internal::OperatorSum<ImplementationLhsT_, ImplementationRhsT_> {};
279
280template <wuzp_blitz::BlitzArray ImplementationLhsT_, wuzp_blitz::BlitzArray ImplementationRhsT_>
281struct Difference<AccessImplementation<ImplementationLhsT_>, AccessImplementation<ImplementationRhsT_>>
282 : internal::OperatorDifference<ImplementationLhsT_, ImplementationRhsT_> {};
283
284template <wuzp_blitz::BlitzArray ImplementationT_>
285struct Negation<AccessImplementation<ImplementationT_>> : internal::OperatorNegation<ImplementationT_> {};
286
287template <wuzp_blitz::BlitzArray ImplementationLhsT_, ArithmeticValue ValueRhsT_>
288struct Product<AccessImplementation<ImplementationLhsT_>, ValueRhsT_> : internal::OperatorProduct<ImplementationLhsT_, ValueRhsT_> {};
289template <wuzp_blitz::BlitzArray ImplementationLhsT_, wuzp_blitz::BlitzArray ImplementationRhsT_>
290struct Product<AccessImplementation<ImplementationLhsT_>, AccessImplementation<ImplementationRhsT_>>
291 : internal::OperatorProduct<ImplementationLhsT_, ImplementationRhsT_> {};
292
293template <wuzp_blitz::BlitzArray ImplementationLhsT_, wuzp_blitz::BlitzArray ImplementationRhsT_>
294struct InnerProduct<AccessImplementation<ImplementationLhsT_>, AccessImplementation<ImplementationRhsT_>> {
295 static auto value(const ImplementationLhsT_& implLhs, const ImplementationRhsT_& implRhs) {
296 // Blitz++ widens sums (e.g. of int to long). Keep the value type that ValuesWrapper declares for products, like Eigen.
297 using ValueT =
298 typename Product<ValueType<typename ImplementationLhsT_::T_numtype>, ValueType<typename ImplementationRhsT_::T_numtype>>::type;
299 // The result is evaluated: Blitz++'s lazy reduction leaves a member uninitialized until it is evaluated, so copying it
300 // reads an uninitialized value (GCC warns about this in optimized builds).
301 // Expressions are evaluated first, for their extents and the index placeholders.
302 const auto& lhs = wuzp_blitz::internal::asArray(implLhs);
303 const auto& rhs = wuzp_blitz::internal::asArray(implRhs);
304 blitz::Array<ValueT, 2> result(lhs.extent(0), rhs.extent(1));
305 result = blitz::cast<ValueT>(
306 blitz::sum(lhs(blitz::tensor::i, blitz::tensor::k) * rhs(blitz::tensor::k, blitz::tensor::j), blitz::tensor::k));
307 return result;
308 }
309 // Not lazy, see above.
310 using type = decltype(value(std::declval<const ImplementationLhsT_>(), std::declval<const ImplementationRhsT_>()));
311};
312
313template <wuzp_blitz::BlitzArray ImplementationLhsT_, wuzp_blitz::BlitzArray ImplementationRhsT_>
314struct OuterProduct<AccessImplementation<ImplementationLhsT_>, AccessImplementation<ImplementationRhsT_>> {
315 static auto value(const ImplementationLhsT_& implLhs, const ImplementationRhsT_& implRhs) {
316 return implLhs(blitz::tensor::i, blitz::tensor::j) * implRhs(blitz::tensor::i, blitz::tensor::j);
317 }
318 // Use decltype/declval to allow for lazy evaluation.
319 using type = decltype(value(std::declval<const ImplementationLhsT_>(), std::declval<const ImplementationRhsT_>()));
320};
321
322template <wuzp_blitz::BlitzArray ImplementationLhsT_, wuzp_blitz::BlitzArray ImplementationRhsT_>
323struct CrossProduct<AccessImplementation<ImplementationLhsT_>, AccessImplementation<ImplementationRhsT_>> {
324 static auto value(const ImplementationLhsT_& implLhs, const ImplementationRhsT_& implRhs) {
325 static_assert(std::is_same_v<typename ImplementationLhsT_::T_numtype, typename ImplementationRhsT_::T_numtype>,
326 "Numeric types do not match.");
327 // The core only calls this for 3x1 matrices: CrossProduct<MatrixSize> rejects other sizes at compile time. Expressions are
328 // evaluated first, for the element access.
329 const auto& lhs = wuzp_blitz::internal::asArray(implLhs);
330 const auto& rhs = wuzp_blitz::internal::asArray(implRhs);
331 blitz::Array<typename ImplementationLhsT_::T_numtype, 2> result{3, 1};
332 result(0, 0) = lhs(1, 0) * rhs(2, 0) - lhs(2, 0) * rhs(1, 0);
333 result(1, 0) = lhs(2, 0) * rhs(0, 0) - lhs(0, 0) * rhs(2, 0);
334 result(2, 0) = lhs(0, 0) * rhs(1, 0) - lhs(1, 0) * rhs(0, 0);
335 return result;
336 }
337 // Use decltype/declval to allow for lazy evaluation.
338 using type = decltype(value(std::declval<const ImplementationLhsT_>(), std::declval<const ImplementationRhsT_>()));
339};
340
341template <wuzp_blitz::BlitzArray ImplementationLhsT_, wuzp_blitz::BlitzArray ImplementationRhsT_>
342struct Division<AccessImplementation<ImplementationLhsT_>, AccessImplementation<ImplementationRhsT_>>
343 : internal::OperatorDivision<ImplementationLhsT_, ImplementationRhsT_> {};
344template <wuzp_blitz::BlitzArray ImplementationLhsT_, ArithmeticValue ValueRhsT_>
345struct Division<AccessImplementation<ImplementationLhsT_>, ValueRhsT_> : internal::OperatorDivision<ImplementationLhsT_, ValueRhsT_> {};
346
347template <wuzp_blitz::BlitzArray ImplementationT_>
348struct Norm<AccessImplementation<ImplementationT_>> {
349 static auto value(const ImplementationT_& impl) {
350 // Keep the value type, like Eigen: std::sqrt returns double for integers.
351 return static_cast<typename ImplementationT_::T_numtype>(std::sqrt(SquaredNorm<AccessImplementation<ImplementationT_>>::value(impl)));
352 }
353 // Use decltype/declval to allow for lazy evaluation.
354 using type = decltype(value(std::declval<const ImplementationT_>()));
355};
356
357template <wuzp_blitz::BlitzArray ImplementationT_>
358struct SquaredNorm<AccessImplementation<ImplementationT_>> {
359 static auto value(const ImplementationT_& impl) {
360 // Keep the value type, like Eigen: Blitz++ widens sums, e.g. of int to long and of float to double.
361 return static_cast<typename ImplementationT_::T_numtype>(blitz::sum(impl * impl));
362 }
363 // Use decltype/declval to allow for lazy evaluation.
364 using type = decltype(value(std::declval<const ImplementationT_>()));
365};
366
367// Blitz++ provides neither determinants nor matrix inverses, so the backend computes them by Gauss-Jordan elimination (see
368// internal::gaussJordan()).
369
370// The determinant of an integer matrix is an integer, like Eigen's: it is computed in double and rounded to the nearest integer,
371// which is exact as long as the rounding errors of the elimination stay below 1/2, e.g. for small matrices of small integers.
372template <wuzp_blitz::BlitzArray ImplementationT_>
373struct Determinant<AccessImplementation<ImplementationT_>> {
374 static auto value(const ImplementationT_& impl) {
375 using ValueT = typename ImplementationT_::T_numtype;
376 if constexpr (std::is_floating_point_v<ValueT>) {
377 return wuzp_blitz::internal::gaussJordan<ValueT>(impl).second;
378 } else {
379 return static_cast<ValueT>(std::llround(wuzp_blitz::internal::gaussJordan<double>(impl).second));
380 }
381 }
382 using type = decltype(value(std::declval<const ImplementationT_>()));
383};
384
385// The matrix inverse. The core rejects the inverses of integer matrices (see ValuesWrapper::inverse()).
386template <wuzp_blitz::BlitzArray ImplementationT_>
387struct Inverse<AccessImplementation<ImplementationT_>> {
388 static auto value(const ImplementationT_& impl) {
389 return wuzp_blitz::internal::gaussJordan<typename ImplementationT_::T_numtype>(impl).first;
390 }
391 // Not lazy: the elimination computes the inverse into a new array.
392 using type = decltype(value(std::declval<const ImplementationT_>()));
393};
394
395template <wuzp_blitz::BlitzArray ImplementationT_>
396struct CwiseInverse<AccessImplementation<ImplementationT_>> {
397 static auto value(const ImplementationT_& impl) { return static_cast<typename ImplementationT_::T_numtype>(1) / impl; }
398 // Use decltype/declval to allow for lazy evaluation.
399 using type = decltype(value(std::declval<const ImplementationT_>()));
400};
401
402// Blitz++ applies a function object to the elements of an expression only if its class declares it with the macro
403// BZ_DECLARE_FUNCTOR (blitz/array/functorExpr.h), which lambdas cannot, so the function is applied element by element, into a new
404// array.
405template <wuzp_blitz::BlitzArray ImplementationT_, typename FunctionT_>
406struct CwiseFunction<AccessImplementation<ImplementationT_>, FunctionT_> {
407 static auto value(const ImplementationT_& impl, const FunctionT_& function) {
408 // Expressions are evaluated first, for the element access.
409 const auto& array = wuzp_blitz::internal::asArray(impl);
410 wuzp_blitz::internal::ArrayOf<ImplementationT_> result(array.extent(0), array.extent(1));
411 for (int row = 0; row < array.extent(0); ++row) {
412 for (int col = 0; col < array.extent(1); ++col) {
413 result(row, col) = function(array(row, col));
414 }
415 }
416 return result;
417 }
418 // Not lazy, see above.
419 using type = decltype(value(std::declval<const ImplementationT_>(), std::declval<const FunctionT_>()));
420};
421
422template <wuzp_blitz::BlitzArray ImplementationT_, int BlockRowIdV_, int BlockColIdV_, int BlockRowsV_, int BlockColsV_>
423struct Block<AccessImplementation<ImplementationT_>, BlockRowIdV_, BlockColIdV_, BlockRowsV_, BlockColsV_> {
424 // A slice of an array is a view that shares its values, like transpose(), so the block is copied.
425 static auto value(const ImplementationT_& impl) {
426 return wuzp_blitz::internal::copyToArray(wuzp_blitz::internal::asArray(impl)(
427 blitz::Range(BlockRowIdV_, BlockRowIdV_ + BlockRowsV_ - 1), blitz::Range(BlockColIdV_, BlockColIdV_ + BlockColsV_ - 1)));
428 }
429 // Not lazy, see above.
430 using type = decltype(value(std::declval<const ImplementationT_>()));
431};
432
433template <wuzp_blitz::BlitzArray ImplementationT_>
434struct Zero<AccessImplementation<ImplementationT_>> {
435 static void run(ImplementationT_& impl) { impl = 0; }
436};
437
438template <wuzp_blitz::BlitzArray ImplementationT_>
439struct Random<AccessImplementation<ImplementationT_>> {
440 // Uniformly distributed in [-1, 1], like Eigen's setRandom().
441 static void run(ImplementationT_& impl) {
442 using ValueT = typename ImplementationT_::T_numtype;
443 for (int row = 0; row < impl.rows(); ++row) {
444 for (int col = 0; col < impl.cols(); ++col) {
445 impl(row, col) =
446 static_cast<ValueT>(-1) + static_cast<ValueT>(2) * static_cast<ValueT>(std::rand()) / static_cast<ValueT>(RAND_MAX);
447 }
448 }
449 }
450};
451
452template <wuzp_blitz::BlitzArray ImplementationT_>
453struct Evaluate<AccessImplementation<ImplementationT_>> {
454 // A new array, also for an array: the result of evaluate() does not share the values of the original.
455 static auto value(const ImplementationT_& impl) { return wuzp_blitz::internal::copyToArray(impl); }
456 using type = decltype(value(std::declval<const ImplementationT_>()));
457};
458
459} // namespace wuzp
Wrapper for the actual implementation of a value container.
The implementation types of the backend: Blitz++'s two-dimensional arrays and the expressions of arra...
wuzp::Quantity< ValueF, UnitT_ > QuantityF
ValueMatrix< double, RowsV_, ColsV_ > ValueMatrixD
Value< float > ValueF
Value< double > ValueD
wuzp::ValuesWrapper< wuzp::MatrixSize< RowsV_, ColsV_ >, ValueT_, blitz::Array< ValueT_, 2 > > ValueMatrix
ValueMatrix< int, RowsV_, ColsV_ > ValueMatrixI
Value< int > ValueI
ValueMatrix< ValueT_, 1, 1 > Value
wuzp::Quantity< ValueI, UnitT_ > QuantityI
A quantity with a value of this backend, e.g. QuantityD<wuzp_units::Length>.
ValueVector< double, RowsV_ > ValueVectorD
ValueVector< int, RowsV_ > ValueVectorI
ValueMatrix< float, RowsV_, ColsV_ > ValueMatrixF
ValueMatrix< ValueT_, RowsV_, 1 > ValueVector
ValueVector< float, RowsV_ > ValueVectorF
wuzp::Quantity< ValueD, UnitT_ > QuantityD
Quantities< ValueT_, TypeMatrixImpl< MatrixSize< 1, 1 >, std::tuple< UnitT_ > > > Quantity
Container to store a single quantity.
Definition Quantity.hpp:29
void applyCommas(First &&first, Rest &&... rest)
Applies the comma operator from left to right: applyCommas(a, b, c) evaluates ((a,...
Definition helpers.hpp:134
Type wrapper which is used to access traits partially specialized in the implementation header files.
Definition helpers.hpp:114
static auto get(const ImplementationT_ &impl, const int row, const int col)
static void set(ImplementationT_ &impl, const int row, const int col, const typename ImplementationT_::T_numtype value)
Element access of a matrix of a value matrix backend: get(impl, row, col) returns an element,...
Definition traits.hpp:321
static bool equal(const ImplementationLhsT_ &lhs, const ImplementationRhsT_ &rhs)
static bool approxEqual(const ImplementationLhsT_ &lhs, const ImplementationRhsT_ &rhs, const typename ImplementationLhsT_::T_numtype tolerance)
static ImplementationT_ value(const ImplementationT_ &impl)
static auto value(const ImplementationLhsT_ &implLhs, const ImplementationRhsT_ &implRhs)
decltype(value(std::declval< const ImplementationLhsT_ >(), std::declval< const ImplementationRhsT_ >())) type
static auto value(const ImplementationT_ &impl, const FunctionT_ &function)
decltype(value(std::declval< const ImplementationT_ >(), std::declval< const FunctionT_ >())) type
A function applied to every element of a matrix, like Eigen's DenseBase::unaryExpr(): value(impl,...
Definition traits.hpp:203
decltype(value(std::declval< const ImplementationT_ >())) type
The elementwise reciprocal of a matrix, like Eigen's ArrayBase::inverse() or cwiseInverse().
Definition traits.hpp:194
static auto value(const ImplementationT_ &impl)
decltype(value(std::declval< const ImplementationT_ >())) type
static auto value(const ImplementationT_ &impl)
typename Rebind< AccessImplementation< ImplementationT_ >, typename ImplementationT_::Scalar, ImplementationT_::RowsAtCompileTime, ImplementationT_::ColsAtCompileTime >::type type
static type value(const ImplementationT_ &impl)
static void run(ImplementationT_ &impl, Arg0T_ &&arg0, ArgsT_ &&... args)
decltype(value(std::declval< const ImplementationLhsT_ >(), std::declval< const ImplementationRhsT_ >())) type
static auto value(const ImplementationLhsT_ &implLhs, const ImplementationRhsT_ &implRhs)
static auto value(const ImplementationT_ &impl)
decltype(value(std::declval< const ImplementationT_ >())) type
The inverse: the matrix inverse of a matrix, like Eigen's MatrixBase::inverse(), and the reciprocal o...
Definition traits.hpp:188
static void assign(ImplementationT_ &target, ImplementationT_ &source)
static ImplementationT_ construct(ImplementationT_ &source)
The negation is performed elementwise.
Definition traits.hpp:101
static auto value(const ImplementationT_ &impl)
decltype(value(std::declval< const ImplementationT_ >())) type
static auto value(const ImplementationLhsT_ &implLhs, const ImplementationRhsT_ &implRhs)
decltype(value(std::declval< const ImplementationLhsT_ >(), std::declval< const ImplementationRhsT_ >())) type
static auto value(const ImplementationT_ &impl)
decltype(value(std::declval< const ImplementationT_ >())) type
decltype(value(std::declval< const ImplementationT_ >())) type
static auto value(const ImplementationT_ &impl)
Wrapper for partial specializations of trait for values types.
Definition helpers.hpp:110