27 #ifndef CDPL_MATH_MATRIX_HPP
28 #define CDPL_MATH_MATRIX_HPP
35 #include <unordered_map>
36 #include <type_traits>
38 #include <initializer_list>
82 typedef typename std::conditional<std::is_const<M>::value,
83 typename M::ConstReference,
146 return data.getSize1();
155 return data.getSize2();
164 return data.getMaxSize();
173 return data.getMaxSize1();
182 return data.getMaxSize2();
191 return data.isEmpty();
219 data.operator=(
r.data);
229 template <
typename E>
242 template <
typename E>
255 template <
typename E>
268 template <
typename T>
281 template <
typename T>
294 template <
typename E>
307 template <
typename E>
320 template <
typename E>
350 template <
typename T,
typename A>
352 template <
typename T,
typename A>
359 template <
typename T>
377 typedef typename InitializerListType::value_type::value_type
ValueType;
382 typedef typename InitializerListType::value_type::const_reference
ConstReference;
387 typedef typename InitializerListType::value_type::reference
Reference;
392 typedef typename InitializerListType::size_type
SizeType;
429 for (
const auto&
r : l)
430 size2 = std::max(size2,
r.size());
444 if (j >= (list.begin() + i)->size())
447 return *((list.begin() + i)->begin() + j);
461 if (j >= (list.begin() + i)->size())
464 return *((list.begin() + i)->begin() + j);
491 return (size2 == 0 || list.size() == 0);
500 template <
typename T>
508 template <
typename T,
typename A = std::vector<T> >
589 size1(0), size2(0), data() {}
597 size1(
m), size2(n), data(storageSize(
m, n)) {}
606 size1(
m), size2(n), data(storageSize(
m, n), v) {}
613 size1(
m.size1), size2(
m.size2), data(
m.data) {}
620 size1(0), size2(0), data()
634 size1(0), size2(0), data()
644 template <
typename E>
648 matrixAssignMatrix<ScalarAssignment>(*
this, e);
710 return data.max_size();
761 template <
typename C>
783 template <
typename E>
797 template <
typename C>
819 template <
typename E>
833 template <
typename C>
855 template <
typename E>
869 template <
typename T1>
872 matrixAssignScalar<ScalarMultiplicationAssignment>(*
this, t);
882 template <
typename T1>
885 matrixAssignScalar<ScalarDivisionAssignment>(*
this, t);
895 template <
typename E>
899 matrixAssignMatrix<ScalarAssignment>(*
this, e);
912 matrixAssignMatrix<ScalarAssignment>(*
this, ilm);
922 template <
typename E>
925 matrixAssignMatrix<ScalarAdditionAssignment>(*
this, e);
946 template <
typename E>
949 matrixAssignMatrix<ScalarSubtractionAssignment>(*
this, e);
971 std::swap(data,
m.data);
972 std::swap(size1,
m.size1);
973 std::swap(size2,
m.size2);
993 std::fill(data.begin(), data.end(), v);
1005 if (size1 ==
m && size2 == n)
1011 for (
SizeType i = 0, min_size1 = std::min(size1,
m); i < min_size1; i++)
1012 for (
SizeType j = 0, min_size2 = std::min(size2, n); j < min_size2; j++)
1013 tmp(i, j) = (*this)(i, j);
1018 data.resize(storageSize(
m, n), v);
1041 template <
typename T,
typename A = std::unordered_map<std::u
int64_t, T> >
1127 size1(0), size2(0), data() {}
1136 size1(
m), size2(n), data()
1146 size1(
m.size1), size2(
m.size2), data(
m.data) {}
1153 size1(0), size2(0), data()
1163 size1(0), size2(0), data()
1174 template <
typename E>
1179 matrixAssignMatrix<ScalarAssignment>(*
this, e);
1207 typename ArrayType::const_iterator it = data.find(makeKey(i, j));
1209 if (it == data.end())
1230 return (size1 == 0 || size2 == 0);
1257 return data.max_size();
1308 template <
typename C>
1330 template <
typename E>
1344 template <
typename C>
1366 template <
typename E>
1380 template <
typename C>
1402 template <
typename E>
1416 template <
typename T1>
1419 matrixAssignScalar<ScalarMultiplicationAssignment>(*
this, t);
1429 template <
typename T1>
1432 matrixAssignScalar<ScalarDivisionAssignment>(*
this, t);
1442 template <
typename E>
1446 matrixAssignMatrix<ScalarAssignment>(*
this, e);
1459 matrixAssignMatrix<ScalarAssignment>(*
this, ilm);
1469 template <
typename E>
1472 matrixAssignMatrix<ScalarAdditionAssignment>(*
this, e);
1493 template <
typename E>
1496 matrixAssignMatrix<ScalarSubtractionAssignment>(*
this, e);
1518 std::swap(data,
m.data);
1519 std::swap(size1,
m.size1);
1520 std::swap(size2,
m.size2);
1552 for (
typename ArrayType::iterator it = data.begin(); it != data.end();) {
1553 const KeyType& key = it->first;
1555 if (getRowIdx(key) >=
m || getColIdx(key) >= n)
1556 it = data.erase(it);
1573 return (key >> (
sizeof(
SizeType) * 8));
1587 template <
typename T,
typename A>
1590 template <
typename T, std::
size_t N>
1591 class BoundedVector;
1599 template <
typename T, std::
size_t M, std::
size_t N>
1701 size1(0), size2(0) {}
1733 size1(
m.size1), size2(
m.size2)
1735 for (
SizeType i = 0; i < size1; i++)
1736 std::copy(
m.data[i],
m.data[i] + size2, data[i]);
1756 template <
typename E>
1761 matrixAssignMatrix<ScalarAssignment>(*
this, e);
1796 return (size1 == 0 || size2 == 0);
1862 std::copy(
m.data[i],
m.data[i] +
m.size2, data[i]);
1877 template <
typename C>
1901 template <
typename E>
1914 template <
typename C>
1936 template <
typename E>
1949 template <
typename C>
1971 template <
typename E>
1984 template <
typename T1>
1987 matrixAssignScalar<ScalarMultiplicationAssignment>(*
this, v);
1997 template <
typename T1>
2000 matrixAssignScalar<ScalarDivisionAssignment>(*
this, v);
2011 template <
typename E>
2015 matrixAssignMatrix<ScalarAssignment>(*
this, e);
2029 matrixAssignMatrix<ScalarAssignment>(*
this, ilm);
2039 template <
typename E>
2042 matrixAssignMatrix<ScalarAdditionAssignment>(*
this, e);
2063 template <
typename E>
2066 matrixAssignMatrix<ScalarSubtractionAssignment>(*
this, e);
2088 SizeType max_size1 = std::max(size1,
m.size1);
2089 SizeType max_size2 = std::max(size2,
m.size2);
2091 for (
SizeType i = 0; i < max_size1; i++)
2092 std::swap_ranges(data[i], data[i] + max_size2,
m.data[i]);
2094 std::swap(size1,
m.size1);
2095 std::swap(size2,
m.size2);
2115 for (
SizeType i = 0; i < size1; i++)
2116 std::fill(data[i], data[i] + size2, v);
2147 SizeType min_size1 = std::min(size1,
m);
2149 for (
SizeType i = 0; i < min_size1; i++)
2150 std::fill(data[i] + size2, data[i] + n, v);
2155 std::fill(data[i], data[i] + n, v);
2167 template <
typename T, std::
size_t M, std::
size_t N>
2169 template <
typename T, std::
size_t M, std::
size_t N>
2178 template <
typename T, std::
size_t M, std::
size_t N>
2282 std::fill(data[i], data[i] +
N,
ValueType());
2292 std::fill(data[i], data[i] +
N, v);
2302 std::copy(
m.data[i],
m.data[i] +
N, data[i]);
2319 template <
typename E>
2322 matrixAssignMatrix<ScalarAssignment>(*
this, e);
2357 return (
M == 0 ||
N == 0);
2423 std::copy(
m.data[i],
m.data[i] +
N, data[i]);
2435 template <
typename C>
2446 template <
typename T1>
2458 template <
typename E>
2471 template <
typename C>
2493 template <
typename E>
2506 template <
typename C>
2528 template <
typename E>
2541 template <
typename T1>
2544 matrixAssignScalar<ScalarMultiplicationAssignment>(*
this, t);
2554 template <
typename T1>
2557 matrixAssignScalar<ScalarDivisionAssignment>(*
this, t);
2567 template <
typename E>
2570 matrixAssignMatrix<ScalarAssignment>(*
this, e);
2584 for (
SizeType i = 0; i < n_rows; i++) {
2585 const auto&
row = *(l.begin() + i);
2587 if (
row.size() <
N) {
2588 std::copy(
row.begin(),
row.end(), data[i]);
2593 std::copy(
row.begin(),
row.begin() +
N, data[i]);
2598 std::fill(data[i], data[i] +
N,
ValueType());
2609 template <
typename E>
2612 matrixAssignMatrix<ScalarAdditionAssignment>(*
this, e);
2633 template <
typename E>
2636 matrixAssignMatrix<ScalarSubtractionAssignment>(*
this, e);
2659 std::swap_ranges(data[i], data[i] +
N,
m.data[i]);
2680 std::fill(data[i], data[i] +
N, v);
2687 template <
typename T, std::
size_t M, std::
size_t N>
2689 template <
typename T, std::
size_t M, std::
size_t N>
2696 template <
typename T>
2752 size1(0), size2(0) {}
2760 size1(
m), size2(n) {}
2767 size1(
m.size1), size2(
m.size2) {}
2788 return (size1 == 0 || size2 == 0);
2815 return std::numeric_limits<SizeType>::max();
2824 return std::numeric_limits<SizeType>::max();
2849 std::swap(size1,
m.size1);
2850 std::swap(size2,
m.size2);
2881 template <
typename T>
2888 template <
typename T>
2944 size1(0), size2(0), value() {}
2953 size1(
m), size2(n), value(v) {}
2960 size1(
m.size1), size2(
m.size2), value(
m.value) {}
2981 return (size1 == 0 || size2 == 0);
3008 return std::numeric_limits<SizeType>::max();
3017 return std::numeric_limits<SizeType>::max();
3043 std::swap(size1,
m.size1);
3044 std::swap(size2,
m.size2);
3045 std::swap(value,
m.value);
3080 template <
typename T>
3136 size1(0), size2(0) {}
3144 size1(
m), size2(n) {}
3151 size1(
m.size1), size2(
m.size2) {}
3163 return (i == j ? one : zero);
3172 return (size1 == 0 || size2 == 0);
3199 return std::numeric_limits<SizeType>::max();
3208 return std::numeric_limits<SizeType>::max();
3233 std::swap(size1,
m.size1);
3234 std::swap(size2,
m.size2);
3266 template <
typename T>
3268 template <
typename T>
3275 template <
typename M>
3283 template <
typename M>
3291 template <
typename M>
3299 template <
typename M>
3309 template <
typename E>
3310 typename E::ValueType
3313 typedef typename E::ValueType ValueType;
3317 std::vector<SizeType> pv(lu.
getSize1());
3318 std::size_t num_row_swaps;
3325 for (SizeType i = 0; i < size; i++)
3328 return (num_row_swaps % 2 == 0 ? res : -res);
3337 template <
typename C>
3338 typename C::ValueType
3341 typedef typename C::ValueType ValueType;
3343 typedef typename CTemporaryType::SizeType SizeType;
3345 CTemporaryType lu(c);
3346 std::vector<SizeType> pv(lu.getSize1());
3347 std::size_t num_row_swaps;
3352 SizeType size = std::min(lu.getSize1(), lu.getSize2());
3354 for (SizeType i = 0; i < size; i++)
3357 return (num_row_swaps % 2 == 0 ? res : -res);
3368 template <
typename E,
typename C>
3372 typedef typename C::ValueType ValueType;
3374 typedef typename CTemporaryType::SizeType SizeType;
3376 CTemporaryType lu(e);
3377 std::vector<SizeType> pv(lu.getSize1());
3378 std::size_t num_row_swaps;
3394 template <
typename C>
Definition of exception classes.
Definition of various preprocessor macros for error checking.
#define CDPL_MATH_CHECK_MAX_SIZE(size, max_size, e)
Throws the exception e if size exceeds max_size, otherwise returns std::min(size, max_size).
Definition: Check.hpp:96
#define CDPL_MATH_CHECK(expr, msg, e)
Throws the exception e with message msg when the boolean expression expr evaluates to false.
Definition: Check.hpp:47
Definition of a proxy type for direct assignment of vector and matrix expressions.
Definition of various functors.
Implementation of matrix LU-decomposition and associated operations.
Implementation of matrix assignment routines.
Definition of various matrix expression types and operations.
Definition of an element proxy for sparse data types.
Definition of type traits.
Thrown to indicate that an index is out of range.
Definition: Base/Exceptions.hpp:152
Thrown to indicate that the size of a (multidimensional) array is not correct.
Definition: Base/Exceptions.hpp:133
Variable-size matrix with fixed upper dimension M×N backed by a stack-allocated array.
Definition: Matrix.hpp:1601
BoundedMatrix & operator-=(InitializerListType l)
Subtracts the rows in l element-wise from this bounded matrix.
Definition: Matrix.hpp:1960
std::initializer_list< std::initializer_list< T > > InitializerListType
The initializer list type accepted by constructors and assignment.
Definition: Matrix.hpp:1684
SizeType getSize1() const
Returns the current row count.
Definition: Matrix.hpp:1803
T(* ArrayPointer)[N]
Pointer-to-row type for raw access to the element array.
Definition: Matrix.hpp:1639
SizeType getSize2() const
Returns the current column count.
Definition: Matrix.hpp:1812
BoundedMatrix(const BoundedMatrix &m)
Constructs a copy of the bounded matrix m.
Definition: Matrix.hpp:1732
T * Pointer
Pointer type to a single element.
Definition: Matrix.hpp:1649
friend void swap(BoundedMatrix &m1, BoundedMatrix &m2)
ADL-enabled free-function form of swap().
Definition: Matrix.hpp:2104
BoundedMatrix & operator=(InitializerListType l)
Assigns the rows in l to this bounded matrix (resizes to match, respecting the bounds).
Definition: Matrix.hpp:1889
void clear(const ValueType &v=ValueType())
Sets every element of the matrix to the value v (dimensions unchanged).
Definition: Matrix.hpp:2113
BoundedMatrix & operator+=(const MatrixContainer< C > &c)
Adds the contents of the matrix container c element-wise to this bounded matrix (no alias check neede...
Definition: Matrix.hpp:1915
void swap(BoundedMatrix &m)
Swaps the contents of this bounded matrix with those of m.
Definition: Matrix.hpp:2085
const MatrixReference< const SelfType > ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:1664
std::enable_if< IsScalar< T1 >::value, BoundedMatrix >::type & operator*=(const T1 &v)
Multiplies every element by the scalar v.
Definition: Matrix.hpp:1985
BoundedMatrix & minusAssign(InitializerListType l)
Subtracts the rows in l element-wise from this matrix without intermediate temporary.
Definition: Matrix.hpp:2075
std::enable_if< IsScalar< T1 >::value, BoundedMatrix >::type & operator/=(const T1 &v)
Divides every element by the scalar v.
Definition: Matrix.hpp:1998
std::size_t SizeType
The unsigned size type.
Definition: Matrix.hpp:1624
BoundedMatrix & operator-=(const MatrixExpression< E > &e)
Subtracts the matrix expression e element-wise from this bounded matrix (via a temporary to handle al...
Definition: Matrix.hpp:1972
static const SizeType MaxSize1
The compile-time maximum number of rows M.
Definition: Matrix.hpp:1690
BoundedMatrix & operator=(const MatrixExpression< E > &e)
Assigns the matrix expression e to this bounded matrix (via a temporary to handle aliasing).
Definition: Matrix.hpp:1902
const T & ConstReference
Constant element reference type.
Definition: Matrix.hpp:1619
const T(* ConstArrayPointer)[N]
Constant pointer-to-row type for raw access to the element array.
Definition: Matrix.hpp:1644
BoundedMatrix & operator+=(const MatrixExpression< E > &e)
Adds the matrix expression e element-wise to this bounded matrix (via a temporary to handle aliasing)...
Definition: Matrix.hpp:1937
std::shared_ptr< SelfType > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated BoundedMatrix instances.
Definition: Matrix.hpp:1679
BoundedMatrix(const MatrixExpression< E > &e)
Constructs a bounded matrix from the matrix expression e.
Definition: Matrix.hpp:1757
BoundedMatrix & operator-=(const MatrixContainer< C > &c)
Subtracts the contents of the matrix container c element-wise from this bounded matrix (no alias chec...
Definition: Matrix.hpp:1950
ConstArrayPointer getData() const
Returns a const pointer-to-row to the contiguous 2D element array.
Definition: Matrix.hpp:1848
BoundedMatrix & plusAssign(const MatrixExpression< E > &e)
Adds the elements of the matrix expression e to this matrix without intermediate temporary.
Definition: Matrix.hpp:2040
T & Reference
Mutable element reference type.
Definition: Matrix.hpp:1614
BoundedMatrix & assign(const MatrixExpression< E > &e)
Resizes this matrix to match e and assigns its elements without intermediate temporary.
Definition: Matrix.hpp:2012
void resize(SizeType m, SizeType n, const ValueType &v)
Resizes the matrix to m×n elements (newly added elements are set to v).
Definition: Matrix.hpp:2141
BoundedMatrix(SizeType m, SizeType n, const ValueType &v)
Constructs a bounded matrix of size m×n with every element initialized to v.
Definition: Matrix.hpp:1722
BoundedMatrix & assign(InitializerListType l)
Resizes this matrix to match l and assigns its elements.
Definition: Matrix.hpp:2025
BoundedMatrix & operator+=(InitializerListType l)
Adds the rows in l element-wise to this bounded matrix.
Definition: Matrix.hpp:1925
T ValueType
The scalar value type.
Definition: Matrix.hpp:1609
const T * ConstPointer
Constant pointer type to a single element.
Definition: Matrix.hpp:1654
BoundedMatrix & plusAssign(InitializerListType l)
Adds the rows in l element-wise to this matrix without intermediate temporary.
Definition: Matrix.hpp:2051
Reference operator()(SizeType i, SizeType j)
Returns a mutable reference to the element at (i, j).
Definition: Matrix.hpp:1771
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to the element at (i, j).
Definition: Matrix.hpp:1784
SelfType MatrixTemporaryType
Concrete temporary matrix type used by expression template machinery.
Definition: Matrix.hpp:1669
BoundedVector< T, M *N > VectorTemporaryType
Concrete temporary vector type used when assembling vectors from this matrix (a bounded vector of cap...
Definition: Matrix.hpp:1674
BoundedMatrix(InitializerListType l)
Constructs a bounded matrix from the initializer list of rows l.
Definition: Matrix.hpp:1744
BoundedMatrix()
Constructs an empty bounded matrix (zero rows, zero columns).
Definition: Matrix.hpp:1700
BoundedMatrix(SizeType m, SizeType n)
Constructs a bounded matrix of size m×n with value-initialized elements.
Definition: Matrix.hpp:1709
static const SizeType MaxSize2
The compile-time maximum number of columns N.
Definition: Matrix.hpp:1695
ArrayPointer getData()
Returns a mutable pointer-to-row to the contiguous 2D element array.
Definition: Matrix.hpp:1839
SizeType getMaxSize2() const
Returns the compile-time maximum column count N.
Definition: Matrix.hpp:1830
void resize(SizeType m, SizeType n)
Resizes the matrix to m×n elements (new elements are left value-uninitialized).
Definition: Matrix.hpp:2125
SizeType getMaxSize1() const
Returns the compile-time maximum row count M.
Definition: Matrix.hpp:1821
MatrixReference< SelfType > ClosureType
Closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:1659
BoundedMatrix & operator=(const MatrixContainer< C > &c)
Assigns the contents of the matrix container c to this bounded matrix (no alias check needed).
Definition: Matrix.hpp:1878
ValueType ArrayType[M][N]
The fixed-capacity 2D C-array type used for in-memory storage.
Definition: Matrix.hpp:1634
BoundedMatrix & operator=(const BoundedMatrix &m)
Copy-assigns the elements of m to this bounded matrix.
Definition: Matrix.hpp:1858
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Matrix.hpp:1629
BoundedMatrix & minusAssign(const MatrixExpression< E > &e)
Subtracts the elements of the matrix expression e from this matrix without intermediate temporary.
Definition: Matrix.hpp:2064
bool isEmpty() const
Tells whether the matrix is empty.
Definition: Matrix.hpp:1794
Variable-size vector with a fixed upper capacity N stored in a stack-allocated array.
Definition: Vector.hpp:1518
Fixed-size dense matrix of dimension M×N backed by a stack-allocated array.
Definition: Matrix.hpp:2180
MatrixReference< SelfType > ClosureType
Closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:2238
T * Pointer
Pointer type to a single element.
Definition: Matrix.hpp:2228
CMatrix & operator-=(const MatrixContainer< C > &c)
Subtracts the contents of the matrix container c element-wise from this fixed-size matrix (no alias c...
Definition: Matrix.hpp:2507
CMatrix & operator=(InitializerListType l)
Assigns the rows in l to this fixed-size matrix (clipped or zero-padded to M×N).
Definition: Matrix.hpp:2447
SizeType getSize2() const
Returns the fixed column count N.
Definition: Matrix.hpp:2373
CMatrix & assign(InitializerListType l)
Assigns the rows in l to this fixed-size matrix (clipped or zero-padded to M×N).
Definition: Matrix.hpp:2580
ValueType ArrayType[M][N]
The fixed-size 2D C-array type used for in-memory storage of M×N elements.
Definition: Matrix.hpp:2213
ConstArrayPointer getData() const
Returns a const pointer-to-row to the contiguous 2D element array.
Definition: Matrix.hpp:2409
ArrayPointer getData()
Returns a mutable pointer-to-row to the contiguous 2D element array.
Definition: Matrix.hpp:2400
std::initializer_list< std::initializer_list< T > > InitializerListType
The initializer list type accepted by constructors and assignment.
Definition: Matrix.hpp:2263
T(* ArrayPointer)[N]
Pointer-to-row type for raw access to the element array.
Definition: Matrix.hpp:2218
CMatrix & operator+=(const MatrixExpression< E > &e)
Adds the matrix expression e element-wise to this fixed-size matrix (via a temporary to handle aliasi...
Definition: Matrix.hpp:2494
BoundedVector< T, M *N > VectorTemporaryType
Concrete temporary vector type used when assembling vectors from this matrix.
Definition: Matrix.hpp:2253
CMatrix & minusAssign(const MatrixExpression< E > &e)
Subtracts the elements of the matrix expression e from this matrix without intermediate temporary.
Definition: Matrix.hpp:2634
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to the element at (i, j).
Definition: Matrix.hpp:2345
CMatrix(const ValueType &v)
Constructs an M×N matrix with every element initialized to v.
Definition: Matrix.hpp:2289
CMatrix()
Constructs a zero-initialized M×N matrix.
Definition: Matrix.hpp:2279
std::enable_if< IsScalar< T1 >::value, CMatrix >::type & operator*=(const T1 &t)
Multiplies every element by the scalar t.
Definition: Matrix.hpp:2542
Reference operator()(SizeType i, SizeType j)
Returns a mutable reference to the element at (i, j).
Definition: Matrix.hpp:2332
void clear(const ValueType &v=ValueType())
Sets every element of the matrix to the value v.
Definition: Matrix.hpp:2677
std::size_t SizeType
The unsigned size type.
Definition: Matrix.hpp:2203
CMatrix(const MatrixExpression< E > &e)
Constructs a fixed-size matrix from the matrix expression e.
Definition: Matrix.hpp:2320
CMatrix(InitializerListType l)
Constructs a fixed-size matrix with the contents of the initializer list of rows l.
Definition: Matrix.hpp:2309
CMatrix & operator-=(InitializerListType l)
Subtracts the rows in l element-wise from this fixed-size matrix.
Definition: Matrix.hpp:2517
bool isEmpty() const
Tells whether the matrix is empty (M or N is zero).
Definition: Matrix.hpp:2355
T ValueType
The scalar value type.
Definition: Matrix.hpp:2188
std::enable_if< IsScalar< T1 >::value, CMatrix >::type & operator/=(const T1 &t)
Divides every element by the scalar t.
Definition: Matrix.hpp:2555
const T * ConstPointer
Constant pointer type to a single element.
Definition: Matrix.hpp:2233
void swap(CMatrix &m)
Swaps the contents of this fixed-size matrix with those of m.
Definition: Matrix.hpp:2655
CMatrix & operator=(const CMatrix &m)
Copy-assigns the elements of m to this fixed-size matrix.
Definition: Matrix.hpp:2419
CMatrix & operator=(const MatrixContainer< C > &c)
Assigns the contents of the matrix container c to this fixed-size matrix (no alias check needed).
Definition: Matrix.hpp:2436
const T(* ConstArrayPointer)[N]
Constant pointer-to-row type for raw access to the element array.
Definition: Matrix.hpp:2223
SizeType getMaxSize1() const
Returns the fixed row count M (capacity equals size for Math::CMatrix).
Definition: Matrix.hpp:2382
SizeType getMaxSize2() const
Returns the fixed column count N (capacity equals size for Math::CMatrix).
Definition: Matrix.hpp:2391
CMatrix & operator+=(InitializerListType l)
Adds the rows in l element-wise to this fixed-size matrix.
Definition: Matrix.hpp:2482
static const SizeType Size1
The compile-time fixed row count M.
Definition: Matrix.hpp:2269
CMatrix & plusAssign(InitializerListType l)
Adds the rows in l element-wise to this matrix without intermediate temporary.
Definition: Matrix.hpp:2621
CMatrix & operator-=(const MatrixExpression< E > &e)
Subtracts the matrix expression e element-wise from this fixed-size matrix (via a temporary to handle...
Definition: Matrix.hpp:2529
const T & ConstReference
Constant element reference type.
Definition: Matrix.hpp:2198
std::shared_ptr< SelfType > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated CMatrix instances.
Definition: Matrix.hpp:2258
CMatrix(const CMatrix &m)
Constructs a copy of the fixed-size matrix m.
Definition: Matrix.hpp:2299
CMatrix & assign(const MatrixExpression< E > &e)
Assigns the elements of the matrix expression e to this fixed-size matrix without intermediate tempor...
Definition: Matrix.hpp:2568
friend void swap(CMatrix &m1, CMatrix &m2)
ADL-enabled free-function form of swap().
Definition: Matrix.hpp:2668
const MatrixReference< const SelfType > ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:2243
SizeType getSize1() const
Returns the fixed row count M.
Definition: Matrix.hpp:2364
CMatrix & operator+=(const MatrixContainer< C > &c)
Adds the contents of the matrix container c element-wise to this fixed-size matrix (no alias check ne...
Definition: Matrix.hpp:2472
T & Reference
Mutable element reference type.
Definition: Matrix.hpp:2193
BoundedMatrix< T, M, N > MatrixTemporaryType
Concrete temporary matrix type used by expression template machinery (a Math::BoundedMatrix of equal ...
Definition: Matrix.hpp:2248
CMatrix & minusAssign(InitializerListType l)
Subtracts the rows in l element-wise from this matrix without intermediate temporary.
Definition: Matrix.hpp:2645
CMatrix & operator=(const MatrixExpression< E > &e)
Assigns the matrix expression e to this fixed-size matrix (via a temporary to handle aliasing).
Definition: Matrix.hpp:2459
CMatrix & plusAssign(const MatrixExpression< E > &e)
Adds the elements of the matrix expression e to this matrix without intermediate temporary.
Definition: Matrix.hpp:2610
static const SizeType Size2
The compile-time fixed column count N.
Definition: Matrix.hpp:2274
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Matrix.hpp:2208
Constant identity-matrix expression (1 on the diagonal, 0 elsewhere).
Definition: Matrix.hpp:3082
SizeType getMaxSize2() const
Returns the maximum representable column count.
Definition: Matrix.hpp:3206
T ValueType
The scalar value type.
Definition: Matrix.hpp:3090
IdentityMatrix & operator=(const IdentityMatrix &m)
Copy-assigns the dimensions from m.
Definition: Matrix.hpp:3216
const T & Reference
Reference type (always a const reference — elements are immutable).
Definition: Matrix.hpp:3095
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to either 1 (on the diagonal) or 0 (off the diagonal).
Definition: Matrix.hpp:3160
void resize(SizeType m, SizeType n)
Resizes the dimensions to m×n.
Definition: Matrix.hpp:3253
IdentityMatrix(SizeType m, SizeType n)
Constructs an identity matrix of size m×n (1 on the diagonal, 0 elsewhere).
Definition: Matrix.hpp:3143
const MatrixReference< const SelfType > ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:3120
SizeType getMaxSize1() const
Returns the maximum representable row count.
Definition: Matrix.hpp:3197
bool isEmpty() const
Tells whether the matrix is empty.
Definition: Matrix.hpp:3170
MatrixReference< SelfType > ClosureType
Closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:3115
SizeType getSize1() const
Returns the logical number of rows.
Definition: Matrix.hpp:3179
friend void swap(IdentityMatrix &m1, IdentityMatrix &m2)
ADL-enabled free-function form of swap().
Definition: Matrix.hpp:3243
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Matrix.hpp:3110
IdentityMatrix()
Constructs an empty identity matrix.
Definition: Matrix.hpp:3135
Matrix< T > MatrixTemporaryType
Concrete temporary matrix type used by expression template machinery.
Definition: Matrix.hpp:3125
IdentityMatrix(const IdentityMatrix &m)
Constructs a copy of the identity matrix m.
Definition: Matrix.hpp:3150
std::size_t SizeType
The unsigned size type.
Definition: Matrix.hpp:3105
void swap(IdentityMatrix &m)
Swaps the dimensions with m.
Definition: Matrix.hpp:3230
SizeType getSize2() const
Returns the logical number of columns.
Definition: Matrix.hpp:3188
const T & ConstReference
Constant element reference type.
Definition: Matrix.hpp:3100
Vector< T, std::vector< T > > VectorTemporaryType
Concrete temporary vector type used when assembling vectors from this matrix.
Definition: Matrix.hpp:3130
Lightweight matrix container that wraps a nested std::initializer_list of T values.
Definition: Matrix.hpp:361
Matrix< T, std::vector< T > > MatrixTemporaryType
Concrete temporary matrix type used by expression template machinery.
Definition: Matrix.hpp:412
std::initializer_list< std::initializer_list< T > > InitializerListType
The nested std::initializer_list type wrapped by this matrix.
Definition: Matrix.hpp:372
SizeType getSize2() const
Returns the number of columns (the longest row length).
Definition: Matrix.hpp:480
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Matrix.hpp:397
Reference operator()(SizeType i, SizeType j)
Returns a mutable reference to the element at row i and column j.
Definition: Matrix.hpp:440
InitializerListType::value_type::reference Reference
Mutable element reference type.
Definition: Matrix.hpp:387
bool isEmpty() const
Tells whether the matrix is empty (zero rows or zero columns).
Definition: Matrix.hpp:489
InitListMatrix(InitializerListType l)
Constructs an InitListMatrix wrapping the nested initializer list l.
Definition: Matrix.hpp:426
InitListMatrix SelfType
Convenience alias for this instantiation.
Definition: Matrix.hpp:367
Vector< T, std::vector< T > > VectorTemporaryType
Concrete temporary vector type used by expression template machinery.
Definition: Matrix.hpp:417
InitializerListType::value_type::const_reference ConstReference
Constant element reference type.
Definition: Matrix.hpp:382
SelfType ClosureType
Closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:402
const SelfType ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:407
InitializerListType::size_type SizeType
The unsigned size type.
Definition: Matrix.hpp:392
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to the element at row i and column j.
Definition: Matrix.hpp:457
InitializerListType::value_type::value_type ValueType
The scalar value type.
Definition: Matrix.hpp:377
SizeType getSize1() const
Returns the number of rows.
Definition: Matrix.hpp:471
Refinement of Math::MatrixExpression marking the derived type as a concrete (writable) matrix contain...
Definition: Expression.hpp:262
CRTP base class of all matrix expression types.
Definition: Expression.hpp:108
Lightweight matrix expression that proxies a reference to an underlying matrix container.
Definition: Matrix.hpp:64
M::ConstReference ConstReference
Constant element reference type.
Definition: Matrix.hpp:89
Reference operator()(SizeType i, SizeType j)
Returns a mutable reference to the element at (i, j).
Definition: Matrix.hpp:124
MatrixReference & operator=(const MatrixReference &r)
Copy-assigns the wrapped matrix from the matrix referenced by r.
Definition: Matrix.hpp:217
std::conditional< std::is_const< M >::value, typename M::ConstReference, typename M::Reference >::type Reference
Mutable element reference type (degrades to ConstReference when the wrapped matrix is const).
Definition: Matrix.hpp:84
bool isEmpty() const
Tells whether the wrapped matrix is empty.
Definition: Matrix.hpp:189
MatrixReference & assign(const MatrixExpression< E > &e)
Assigns the matrix expression e to the wrapped matrix without intermediate temporary.
Definition: Matrix.hpp:295
const MatrixType & getData() const
Returns a const reference to the wrapped matrix.
Definition: Matrix.hpp:198
friend void swap(MatrixReference &r1, MatrixReference &r2)
ADL-enabled free-function form of swap().
Definition: Matrix.hpp:341
std::enable_if< IsScalar< T >::value, MatrixReference >::type & operator*=(const T &t)
Multiplies every element of the wrapped matrix by the scalar t.
Definition: Matrix.hpp:269
SizeType getMaxSize() const
Returns the wrapped matrix's maximum total element count.
Definition: Matrix.hpp:162
M::SizeType SizeType
The unsigned size type of the wrapped matrix.
Definition: Matrix.hpp:94
MatrixReference & operator-=(const MatrixExpression< E > &e)
Subtracts the matrix expression e element-wise from the wrapped matrix.
Definition: Matrix.hpp:256
SizeType getMaxSize1() const
Returns the wrapped matrix's maximum number of rows.
Definition: Matrix.hpp:171
MatrixReference & operator=(const MatrixExpression< E > &e)
Assigns the matrix expression e to the wrapped matrix.
Definition: Matrix.hpp:230
std::enable_if< IsScalar< T >::value, MatrixReference >::type & operator/=(const T &t)
Divides every element of the wrapped matrix by the scalar t.
Definition: Matrix.hpp:282
MatrixReference & operator+=(const MatrixExpression< E > &e)
Adds the matrix expression e element-wise to the wrapped matrix.
Definition: Matrix.hpp:243
SizeType getSize1() const
Returns the wrapped matrix's number of rows.
Definition: Matrix.hpp:144
const SelfType ConstClosureType
Constant closure type used when this proxy appears inside another expression.
Definition: Matrix.hpp:109
MatrixReference & minusAssign(const MatrixExpression< E > &e)
Subtracts the matrix expression e from the wrapped matrix without intermediate temporary.
Definition: Matrix.hpp:321
MatrixReference(MatrixType &m)
Constructs the reference proxy referring to m.
Definition: Matrix.hpp:115
SizeType getSize2() const
Returns the wrapped matrix's number of columns.
Definition: Matrix.hpp:153
MatrixReference & plusAssign(const MatrixExpression< E > &e)
Adds the matrix expression e to the wrapped matrix without intermediate temporary.
Definition: Matrix.hpp:308
SelfType ClosureType
Closure type used when this proxy appears inside another expression.
Definition: Matrix.hpp:104
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to the element at (i, j).
Definition: Matrix.hpp:135
M::ValueType ValueType
The element value type of the wrapped matrix.
Definition: Matrix.hpp:77
M MatrixType
The wrapped matrix type.
Definition: Matrix.hpp:72
void swap(MatrixReference &r)
Swaps the contents of the two wrapped matrices.
Definition: Matrix.hpp:331
M::DifferenceType DifferenceType
The signed difference type of the wrapped matrix.
Definition: Matrix.hpp:99
SizeType getMaxSize2() const
Returns the wrapped matrix's maximum number of columns.
Definition: Matrix.hpp:180
MatrixType & getData()
Returns a reference to the wrapped matrix.
Definition: Matrix.hpp:207
Dynamically-sized dense row-major matrix with configurable underlying storage.
Definition: Matrix.hpp:510
A::size_type SizeType
The unsigned size type used by the underlying storage container.
Definition: Matrix.hpp:533
MatrixReference< SelfType > ClosureType
Closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:558
Matrix(SizeType m, SizeType n, const ValueType &v)
Constructs an m×n matrix with every element initialized to v.
Definition: Matrix.hpp:605
std::enable_if< IsScalar< T1 >::value, Matrix >::type & operator/=(const T1 &t)
Divides every element by the scalar t.
Definition: Matrix.hpp:883
SizeType getSize2() const
Returns the number of columns.
Definition: Matrix.hpp:699
Matrix(const MatrixExpression< E > &e)
Constructs the matrix from the matrix expression e (materializing the expression result).
Definition: Matrix.hpp:645
Matrix & operator+=(InitializerListType l)
Adds the rows in l element-wise to this matrix.
Definition: Matrix.hpp:808
std::enable_if< IsScalar< T1 >::value, Matrix >::type & operator*=(const T1 &t)
Multiplies every element by the scalar t.
Definition: Matrix.hpp:870
SizeType getSize1() const
Returns the number of rows.
Definition: Matrix.hpp:690
bool isEmpty() const
Tells whether the matrix is empty.
Definition: Matrix.hpp:681
Matrix & operator=(const MatrixExpression< E > &e)
Assigns the matrix expression e to this matrix (via a temporary to handle aliasing).
Definition: Matrix.hpp:784
Matrix(Matrix &&m)
Move-constructs a matrix from m (m is left in a valid empty state).
Definition: Matrix.hpp:619
Matrix(const Matrix &m)
Constructs a copy of the matrix m.
Definition: Matrix.hpp:612
Matrix & assign(InitializerListType l)
Resizes this matrix to match l and assigns its elements.
Definition: Matrix.hpp:908
std::shared_ptr< SelfType > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated Matrix instances.
Definition: Matrix.hpp:578
Vector< T, A > VectorTemporaryType
Concrete temporary vector type compatible with this matrix's value type and storage.
Definition: Matrix.hpp:573
const ArrayType & getData() const
Returns a const reference to the underlying storage container (row-major linear layout).
Definition: Matrix.hpp:726
Matrix & operator-=(const MatrixExpression< E > &e)
Subtracts the matrix expression e element-wise from this matrix (via a temporary to handle aliasing).
Definition: Matrix.hpp:856
Matrix & operator=(const MatrixContainer< C > &c)
Assigns the contents of the matrix container c to this matrix (no alias check needed).
Definition: Matrix.hpp:762
Matrix()
Constructs an empty matrix (zero rows and zero columns).
Definition: Matrix.hpp:588
Matrix(InitializerListType l)
Constructs the matrix from a brace-initializer list of rows.
Definition: Matrix.hpp:633
const T & ConstReference
Constant element reference type.
Definition: Matrix.hpp:528
Matrix & plusAssign(InitializerListType l)
Adds the rows in l element-wise to this matrix without intermediate temporary.
Definition: Matrix.hpp:934
const T * ConstPointer
Constant pointer type for raw element access.
Definition: Matrix.hpp:553
Matrix & operator-=(const MatrixContainer< C > &c)
Subtracts the contents of the matrix container c element-wise from this matrix (no alias check needed...
Definition: Matrix.hpp:834
SizeType getMaxSize() const
Returns the maximum total element count the underlying storage container can hold.
Definition: Matrix.hpp:708
T * Pointer
Pointer type for raw element access.
Definition: Matrix.hpp:548
Reference operator()(SizeType i, SizeType j)
Returns a mutable reference to the element at (i, j).
Definition: Matrix.hpp:658
SelfType MatrixTemporaryType
Concrete temporary matrix type used by expression template machinery.
Definition: Matrix.hpp:568
friend void swap(Matrix &m1, Matrix &m2)
ADL-enabled free-function form of swap().
Definition: Matrix.hpp:982
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to the element at (i, j).
Definition: Matrix.hpp:671
void swap(Matrix &m)
Swaps the contents of this matrix with those of m.
Definition: Matrix.hpp:968
Matrix & assign(const MatrixExpression< E > &e)
Resizes this matrix to match the dimensions of e and assigns its elements (without intermediate tempo...
Definition: Matrix.hpp:896
Matrix & operator-=(InitializerListType l)
Subtracts the rows in l element-wise from this matrix.
Definition: Matrix.hpp:844
Matrix & operator=(Matrix &&m)
Move-assigns the contents of m to this matrix.
Definition: Matrix.hpp:749
A ArrayType
The underlying storage container type (row-major linear storage).
Definition: Matrix.hpp:543
void resize(SizeType m, SizeType n, bool preserve=true, const ValueType &v=ValueType())
Resizes the matrix to m×n elements.
Definition: Matrix.hpp:1003
Matrix & operator=(const Matrix &m)
Copy-assigns the contents of m to this matrix.
Definition: Matrix.hpp:736
Matrix & operator=(InitializerListType l)
Assigns the rows in l to this matrix (resizes to match).
Definition: Matrix.hpp:772
const MatrixReference< const SelfType > ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:563
std::initializer_list< std::initializer_list< T > > InitializerListType
Type of the brace-initializer list of lists accepted by the corresponding constructor (one inner list...
Definition: Matrix.hpp:583
Matrix & plusAssign(const MatrixExpression< E > &e)
Adds the elements of the matrix expression e to this matrix without intermediate temporary.
Definition: Matrix.hpp:923
T & Reference
Mutable element reference type.
Definition: Matrix.hpp:523
Matrix & operator+=(const MatrixExpression< E > &e)
Adds the matrix expression e element-wise to this matrix (via a temporary to handle aliasing).
Definition: Matrix.hpp:820
T ValueType
The scalar value type stored in the matrix.
Definition: Matrix.hpp:518
Matrix(SizeType m, SizeType n)
Constructs an m×n matrix with default-initialized elements.
Definition: Matrix.hpp:596
ArrayType & getData()
Returns a mutable reference to the underlying storage container (row-major linear layout).
Definition: Matrix.hpp:717
Matrix & minusAssign(InitializerListType l)
Subtracts the rows in l element-wise from this matrix without intermediate temporary.
Definition: Matrix.hpp:958
A::difference_type DifferenceType
The signed difference type used by the underlying storage container.
Definition: Matrix.hpp:538
Matrix & minusAssign(const MatrixExpression< E > &e)
Subtracts the elements of the matrix expression e from this matrix without intermediate temporary.
Definition: Matrix.hpp:947
Matrix & operator+=(const MatrixContainer< C > &c)
Adds the contents of the matrix container c element-wise to this matrix (no alias check needed).
Definition: Matrix.hpp:798
void clear(const ValueType &v=ValueType())
Sets every element of the matrix to the value v.
Definition: Matrix.hpp:991
Constant matrix expression in which every entry equals the same scalar value.
Definition: Matrix.hpp:2890
std::size_t SizeType
The unsigned size type.
Definition: Matrix.hpp:2913
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Matrix.hpp:2918
SizeType getMaxSize2() const
Returns the maximum representable column count.
Definition: Matrix.hpp:3015
SizeType getSize2() const
Returns the logical number of columns.
Definition: Matrix.hpp:2997
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to the common entry value.
Definition: Matrix.hpp:2969
const MatrixReference< const SelfType > ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:2928
ScalarMatrix(const ScalarMatrix &m)
Constructs a copy of the scalar matrix m.
Definition: Matrix.hpp:2959
void swap(ScalarMatrix &m)
Swaps the dimensions and common value with m.
Definition: Matrix.hpp:3040
const T & ConstReference
Constant reference type to the common value.
Definition: Matrix.hpp:2908
friend void swap(ScalarMatrix &m1, ScalarMatrix &m2)
ADL-enabled free-function form of swap().
Definition: Matrix.hpp:3054
SizeType getSize1() const
Returns the logical number of rows.
Definition: Matrix.hpp:2988
Vector< T, std::vector< T > > VectorTemporaryType
Concrete temporary vector type used when assembling vectors from this matrix.
Definition: Matrix.hpp:2938
SizeType getMaxSize1() const
Returns the maximum representable row count.
Definition: Matrix.hpp:3006
void resize(SizeType m, SizeType n)
Resizes the dimensions to m×n.
Definition: Matrix.hpp:3064
T ValueType
The scalar value type.
Definition: Matrix.hpp:2898
bool isEmpty() const
Tells whether the matrix is empty.
Definition: Matrix.hpp:2979
ScalarMatrix()
Constructs an empty scalar matrix.
Definition: Matrix.hpp:2943
Matrix< T > MatrixTemporaryType
Concrete temporary matrix type used by expression template machinery.
Definition: Matrix.hpp:2933
ScalarMatrix & operator=(const ScalarMatrix &m)
Copy-assigns the dimensions and common value from m.
Definition: Matrix.hpp:3025
ScalarMatrix(SizeType m, SizeType n, const ValueType &v=ValueType())
Constructs a scalar matrix of size m×n in which every entry equals v.
Definition: Matrix.hpp:2952
MatrixReference< SelfType > ClosureType
Closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:2923
const T & Reference
Reference type (always a const reference — elements are immutable).
Definition: Matrix.hpp:2903
Proxy that exposes a single (key, value) entry of a sparse container as a writable reference.
Definition: SparseContainerElement.hpp:52
Sparse matrix that stores only non-default entries keyed by a packed (row, column) identifier.
Definition: Matrix.hpp:1043
const MatrixReference< const SelfType > ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:1101
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Matrix.hpp:1076
ArrayType::size_type getMaxSize() const
Returns the maximum number of stored entries the underlying associative container can hold.
Definition: Matrix.hpp:1255
SparseMatrix & operator=(const MatrixExpression< E > &e)
Assigns the matrix expression e to this sparse matrix (via a temporary to handle aliasing).
Definition: Matrix.hpp:1331
std::enable_if< IsScalar< T1 >::value, SparseMatrix >::type & operator*=(const T1 &t)
Multiplies every stored entry by the scalar t.
Definition: Matrix.hpp:1417
const T * ConstPointer
Constant pointer type for raw access to stored entries.
Definition: Matrix.hpp:1091
SparseContainerElement< SelfType > Reference
Mutable element reference type (a proxy object that inserts on assignment to a previously-absent elem...
Definition: Matrix.hpp:1061
SparseMatrix & operator=(const SparseMatrix &m)
Copy-assigns the contents of m to this sparse matrix.
Definition: Matrix.hpp:1283
T ValueType
The scalar value type.
Definition: Matrix.hpp:1051
const T & ConstReference
Constant element reference type.
Definition: Matrix.hpp:1066
void resize(SizeType m, SizeType n)
Resizes the logical dimensions to m×n, dropping any stored entries that fall outside the new bounds.
Definition: Matrix.hpp:1548
SparseMatrix & assign(InitializerListType l)
Resizes this matrix to match l and assigns its elements.
Definition: Matrix.hpp:1455
Reference operator()(SizeType i, SizeType j)
Returns a mutable proxy reference to the element at (i, j).
Definition: Matrix.hpp:1189
SparseMatrix()
Constructs an empty sparse matrix (zero rows, zero columns, no stored entries).
Definition: Matrix.hpp:1126
void clear()
Removes all explicitly stored entries (the logical dimensions remain unchanged).
Definition: Matrix.hpp:1537
std::initializer_list< std::initializer_list< T > > InitializerListType
The initializer list type accepted by constructors and assignment.
Definition: Matrix.hpp:1121
SizeType getSize1() const
Returns the logical number of rows.
Definition: Matrix.hpp:1237
SparseMatrix & operator=(SparseMatrix &&m)
Move-assigns the contents of m to this sparse matrix.
Definition: Matrix.hpp:1296
SelfType MatrixTemporaryType
Concrete temporary matrix type used by expression template machinery.
Definition: Matrix.hpp:1106
SparseMatrix & operator+=(InitializerListType l)
Adds the rows in l element-wise to this sparse matrix.
Definition: Matrix.hpp:1355
SparseMatrix & minusAssign(InitializerListType l)
Subtracts the rows in l element-wise from this matrix without intermediate temporary.
Definition: Matrix.hpp:1505
void swap(SparseMatrix &m)
Swaps the contents of this sparse matrix with those of m.
Definition: Matrix.hpp:1515
SparseMatrix(SizeType m, SizeType n)
Constructs a sparse matrix of size m×n with no stored entries.
Definition: Matrix.hpp:1135
std::enable_if< IsScalar< T1 >::value, SparseMatrix >::type & operator/=(const T1 &t)
Divides every stored entry by the scalar t.
Definition: Matrix.hpp:1430
SparseMatrix & operator-=(const MatrixExpression< E > &e)
Subtracts the matrix expression e element-wise from this sparse matrix (via a temporary to handle ali...
Definition: Matrix.hpp:1403
SparseMatrix(const SparseMatrix &m)
Constructs a copy of the sparse matrix m.
Definition: Matrix.hpp:1145
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to the element at (i, j).
Definition: Matrix.hpp:1203
SparseMatrix & assign(const MatrixExpression< E > &e)
Resizes this matrix to match e and assigns its elements without intermediate temporary.
Definition: Matrix.hpp:1443
const ArrayType & getData() const
Returns a const reference to the underlying associative container of stored entries.
Definition: Matrix.hpp:1273
SparseMatrix & operator-=(InitializerListType l)
Subtracts the rows in l element-wise from this sparse matrix.
Definition: Matrix.hpp:1391
SparseMatrix(SparseMatrix &&m)
Move-constructs a sparse matrix from m (m is left in a valid empty state).
Definition: Matrix.hpp:1152
A ArrayType
The underlying associative container type.
Definition: Matrix.hpp:1081
SizeType getSize2() const
Returns the logical number of columns.
Definition: Matrix.hpp:1246
T * Pointer
Pointer type for raw access to stored entries.
Definition: Matrix.hpp:1086
MatrixReference< SelfType > ClosureType
Closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:1096
std::shared_ptr< SelfType > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated SparseMatrix instances.
Definition: Matrix.hpp:1116
SparseMatrix & operator-=(const MatrixContainer< C > &c)
Subtracts the contents of the matrix container c element-wise from this sparse matrix (no alias check...
Definition: Matrix.hpp:1381
SparseMatrix(InitializerListType l)
Constructs a sparse matrix from the initializer list of rows l.
Definition: Matrix.hpp:1162
SparseMatrix & operator=(InitializerListType l)
Assigns the rows in l to this sparse matrix (resizes to match).
Definition: Matrix.hpp:1319
SparseMatrix & plusAssign(const MatrixExpression< E > &e)
Adds the elements of the matrix expression e to this matrix without intermediate temporary.
Definition: Matrix.hpp:1470
SparseMatrix & plusAssign(InitializerListType l)
Adds the rows in l element-wise to this matrix without intermediate temporary.
Definition: Matrix.hpp:1481
friend void swap(SparseMatrix &m1, SparseMatrix &m2)
ADL-enabled free-function form of swap().
Definition: Matrix.hpp:1529
SparseMatrix & operator+=(const MatrixContainer< C > &c)
Adds the contents of the matrix container c element-wise to this sparse matrix (no alias check needed...
Definition: Matrix.hpp:1345
SizeType getNumElements() const
Returns the number of explicitly stored (non-default) entries.
Definition: Matrix.hpp:1219
ArrayType & getData()
Returns a mutable reference to the underlying associative container of stored entries.
Definition: Matrix.hpp:1264
Vector< T, std::vector< T > > VectorTemporaryType
Concrete temporary vector type used when assembling vectors from this matrix.
Definition: Matrix.hpp:1111
SparseMatrix(const MatrixExpression< E > &e)
Constructs a sparse matrix from the matrix expression e.
Definition: Matrix.hpp:1175
SparseMatrix & operator+=(const MatrixExpression< E > &e)
Adds the matrix expression e element-wise to this sparse matrix (via a temporary to handle aliasing).
Definition: Matrix.hpp:1367
SparseMatrix & minusAssign(const MatrixExpression< E > &e)
Subtracts the elements of the matrix expression e from this matrix without intermediate temporary.
Definition: Matrix.hpp:1494
bool isEmpty() const
Tells whether the matrix is empty (zero rows or zero columns).
Definition: Matrix.hpp:1228
A::key_type KeyType
The packed (row, column) key type used by the underlying associative container.
Definition: Matrix.hpp:1056
std::uint32_t SizeType
The unsigned size type.
Definition: Matrix.hpp:1071
SparseMatrix & operator=(const MatrixContainer< C > &c)
Assigns the contents of the matrix container c to this sparse matrix (no alias check needed).
Definition: Matrix.hpp:1309
Dynamically-sized dense vector with configurable underlying storage.
Definition: Vector.hpp:480
Constant matrix expression whose entries are all zero.
Definition: Matrix.hpp:2698
friend void swap(ZeroMatrix &m1, ZeroMatrix &m2)
ADL-enabled free-function form of swap().
Definition: Matrix.hpp:2859
T ValueType
The scalar value type.
Definition: Matrix.hpp:2706
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Matrix.hpp:2726
const T & ConstReference
Constant reference type to the zero element.
Definition: Matrix.hpp:2716
SizeType getSize1() const
Returns the logical number of rows.
Definition: Matrix.hpp:2795
SizeType getMaxSize2() const
Returns the maximum representable column count.
Definition: Matrix.hpp:2822
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to the zero element.
Definition: Matrix.hpp:2776
Vector< T, std::vector< T > > VectorTemporaryType
Concrete temporary vector type used when assembling vectors from this matrix.
Definition: Matrix.hpp:2746
bool isEmpty() const
Tells whether the matrix is empty (either dimension is zero).
Definition: Matrix.hpp:2786
const T & Reference
Reference type (always a const reference — all elements are zero).
Definition: Matrix.hpp:2711
SizeType getSize2() const
Returns the logical number of columns.
Definition: Matrix.hpp:2804
void swap(ZeroMatrix &m)
Swaps the dimensions with m.
Definition: Matrix.hpp:2846
void resize(SizeType m, SizeType n)
Resizes the dimensions to m×n.
Definition: Matrix.hpp:2869
const MatrixReference< const SelfType > ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:2736
ZeroMatrix & operator=(const ZeroMatrix &m)
Copy-assigns the dimensions from m.
Definition: Matrix.hpp:2832
Matrix< T > MatrixTemporaryType
Concrete temporary matrix type used by expression template machinery.
Definition: Matrix.hpp:2741
SizeType getMaxSize1() const
Returns the maximum representable row count.
Definition: Matrix.hpp:2813
ZeroMatrix(const ZeroMatrix &m)
Constructs a copy of the zero matrix m.
Definition: Matrix.hpp:2766
ZeroMatrix()
Constructs an empty zero matrix.
Definition: Matrix.hpp:2751
MatrixReference< SelfType > ClosureType
Closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:2731
std::size_t SizeType
The unsigned size type.
Definition: Matrix.hpp:2721
ZeroMatrix(SizeType m, SizeType n)
Constructs a zero matrix of size m×n.
Definition: Matrix.hpp:2759
constexpr unsigned int A
Generic type that covers any element except hydrogen.
Definition: AtomType.hpp:637
constexpr unsigned int M
Generic type that covers any element that is a metal.
Definition: AtomType.hpp:657
constexpr unsigned int N
Specifies Nitrogen.
Definition: AtomType.hpp:97
constexpr unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
constexpr unsigned int r
Specifies that the stereocenter has r configuration.
Definition: CIPDescriptor.hpp:76
constexpr unsigned int m
Specifies that the stereocenter has m configuration.
Definition: CIPDescriptor.hpp:116
CMatrix< long, 2, 2 > Matrix2L
Bounded 2×2 matrix holding signed integers of type long.
Definition: Matrix.hpp:3514
CMatrix< float, 3, 3 > Matrix3F
Bounded 3×3 matrix holding floating-point values of type float.
Definition: Matrix.hpp:3489
ZeroMatrix< double > DZeroMatrix
Memory-efficient immutable matrix where all elements have the value zero of type double.
Definition: Matrix.hpp:3409
bool luSubstitute(const MatrixExpression< E1 > &lu, VectorExpression< E2 > &b)
Solves for b in place, given the LU decomposition lu (without pivoting).
Definition: LUDecomposition.hpp:195
CMatrix< unsigned long, 3, 3 > Matrix3UL
Bounded 3×3 matrix holding unsigned integers of type unsigned long.
Definition: Matrix.hpp:3534
Matrix< double > DMatrix
Unbounded dense matrix holding floating-point values of type double..
Definition: Matrix.hpp:3469
ScalarMatrix< float > FScalarMatrix
Memory-efficient immutable matrix where all elements have the same value of type float.
Definition: Matrix.hpp:3424
ZeroMatrix< long > LZeroMatrix
Memory-efficient immutable matrix where all elements have the value zero of type long.
Definition: Matrix.hpp:3414
ScalarMatrix< double > DScalarMatrix
Memory-efficient immutable matrix where all elements have the same value of type double.
Definition: Matrix.hpp:3429
SparseMatrix< unsigned long > SparseULMatrix
Unbounded sparse matrix holding unsigned integers of type unsigned long.
Definition: Matrix.hpp:3559
ZeroMatrix< float > FZeroMatrix
Memory-efficient immutable matrix where all elements have the value zero of type float.
Definition: Matrix.hpp:3404
IdentityMatrix< double > DIdentityMatrix
Memory-efficient immutable identity matrix with element values of type double.
Definition: Matrix.hpp:3449
CMatrix< long, 3, 3 > Matrix3L
Bounded 3×3 matrix holding signed integers of type long.
Definition: Matrix.hpp:3519
Matrix< unsigned long > ULMatrix
Unbounded dense matrix holding unsigned integers of type unsigned long.
Definition: Matrix.hpp:3479
CMatrix< double, 2, 2 > Matrix2D
Bounded 2×2 matrix holding floating-point values of type double.
Definition: Matrix.hpp:3499
SparseMatrix< float > SparseFMatrix
Unbounded sparse matrix holding floating-point values of type float..
Definition: Matrix.hpp:3544
IdentityMatrix< long > LIdentityMatrix
Memory-efficient immutable identity matrix with element values of type long.
Definition: Matrix.hpp:3454
MatrixRow< M > row(MatrixExpression< M > &e, typename MatrixRow< M >::SizeType i)
Returns a mutable row proxy for row i of the matrix expression e.
Definition: MatrixProxy.hpp:1372
E::ValueType det(const MatrixExpression< E > &e)
Returns the determinant of the matrix expression e.
Definition: Matrix.hpp:3311
CMatrix< unsigned long, 4, 4 > Matrix4UL
Bounded 4×4 matrix holding unsigned integers of type unsigned long.
Definition: Matrix.hpp:3539
CMatrix< double, 4, 4 > Matrix4D
Bounded 4×4 matrix holding floating-point values of type double.
Definition: Matrix.hpp:3509
SparseMatrix< long > SparseLMatrix
Unbounded sparse matrix holding signed integers of type long.
Definition: Matrix.hpp:3554
CMatrix< float, 4, 4 > Matrix4F
Bounded 4×4 matrix holding floating-point values of type float.
Definition: Matrix.hpp:3494
Matrix< long > LMatrix
Unbounded dense matrix holding signed integers of type long.
Definition: Matrix.hpp:3474
Matrix< float > FMatrix
Unbounded dense matrix holding floating-point values of type float..
Definition: Matrix.hpp:3464
IdentityMatrix< unsigned long > ULIdentityMatrix
Memory-efficient immutable identity matrix with element values of type unsigned long.
Definition: Matrix.hpp:3459
ZeroMatrix< unsigned long > ULZeroMatrix
Memory-efficient immutable matrix where all elements have the value zero of type unsigned long.
Definition: Matrix.hpp:3419
CMatrix< long, 4, 4 > Matrix4L
Bounded 4×4 matrix holding signed integers of type long.
Definition: Matrix.hpp:3524
CMatrix< double, 3, 3 > Matrix3D
Bounded 3×3 matrix holding floating-point values of type double.
Definition: Matrix.hpp:3504
SparseMatrix< double > SparseDMatrix
Unbounded sparse matrix holding floating-point values of type double..
Definition: Matrix.hpp:3549
ScalarMatrix< unsigned long > ULScalarMatrix
Memory-efficient immutable matrix where all elements have the same value of type unsigned long.
Definition: Matrix.hpp:3439
IdentityMatrix< float > FIdentityMatrix
Memory-efficient immutable identity matrix with element values of type float.
Definition: Matrix.hpp:3444
bool invert(const MatrixExpression< E > &e, MatrixContainer< C > &c)
Computes the inverse of the matrix expression e and stores it in c.
Definition: Matrix.hpp:3370
E::SizeType luDecompose(MatrixExpression< E > &e)
Computes an in-place LU decomposition of the matrix e without partial pivoting.
Definition: LUDecomposition.hpp:51
CMatrix< unsigned long, 2, 2 > Matrix2UL
Bounded 2×2 matrix holding unsigned integers of type unsigned long.
Definition: Matrix.hpp:3529
CMatrix< float, 2, 2 > Matrix2F
Bounded 2×2 matrix holding floating-point values of type float.
Definition: Matrix.hpp:3484
ScalarMatrix< long > LScalarMatrix
Memory-efficient immutable matrix where all elements have the same value of type long.
Definition: Matrix.hpp:3434
The namespace of the Chemical Data Processing Library.
Selects a concrete temporary matrix type compatible with the matrix expression M.
Definition: TypeTraits.hpp:337
M::MatrixTemporaryType Type
The concrete temporary matrix type compatible with the matrix expression M.
Definition: TypeTraits.hpp:342
Selects a concrete temporary vector type compatible with the vector expression V.
Definition: TypeTraits.hpp:323