27 #ifndef CDPL_MATH_MATRIX_HPP
28 #define CDPL_MATH_MATRIX_HPP
35 #include <unordered_map>
36 #include <type_traits>
38 #include <initializer_list>
74 typedef typename std::conditional<std::is_const<M>::value,
75 typename M::ConstReference,
123 return data.getSize1();
132 return data.getSize2();
141 return data.getMaxSize();
150 return data.getMaxSize1();
159 return data.getMaxSize2();
168 return data.isEmpty();
196 data.operator=(
r.data);
206 template <
typename E>
219 template <
typename E>
232 template <
typename E>
245 template <
typename T>
258 template <
typename T>
271 template <
typename E>
284 template <
typename E>
297 template <
typename E>
327 template <
typename T,
typename A>
329 template <
typename T,
typename A>
336 template <
typename T>
346 typedef typename InitializerListType::value_type::value_type
ValueType;
348 typedef typename InitializerListType::value_type::const_reference
ConstReference;
350 typedef typename InitializerListType::value_type::reference
Reference;
352 typedef typename InitializerListType::size_type
SizeType;
374 for (
const auto&
r : l)
375 size2 = std::max(size2,
r.size());
389 if (j >= (list.begin() + i)->size())
392 return *((list.begin() + i)->begin() + j);
406 if (j >= (list.begin() + i)->size())
409 return *((list.begin() + i)->begin() + j);
436 return (size2 == 0 || list.size() == 0);
445 template <
typename T>
453 template <
typename T,
typename A = std::vector<T> >
493 size1(0), size2(0), data() {}
501 size1(
m), size2(n), data(storageSize(
m, n)) {}
510 size1(
m), size2(n), data(storageSize(
m, n), v) {}
517 size1(
m.size1), size2(
m.size2), data(
m.data) {}
524 size1(0), size2(0), data()
538 size1(0), size2(0), data()
548 template <
typename E>
552 matrixAssignMatrix<ScalarAssignment>(*
this, e);
614 return data.max_size();
665 template <
typename C>
687 template <
typename E>
701 template <
typename C>
723 template <
typename E>
737 template <
typename C>
759 template <
typename E>
773 template <
typename T1>
776 matrixAssignScalar<ScalarMultiplicationAssignment>(*
this, t);
786 template <
typename T1>
789 matrixAssignScalar<ScalarDivisionAssignment>(*
this, t);
799 template <
typename E>
803 matrixAssignMatrix<ScalarAssignment>(*
this, e);
816 matrixAssignMatrix<ScalarAssignment>(*
this, ilm);
826 template <
typename E>
829 matrixAssignMatrix<ScalarAdditionAssignment>(*
this, e);
850 template <
typename E>
853 matrixAssignMatrix<ScalarSubtractionAssignment>(*
this, e);
875 std::swap(data,
m.data);
876 std::swap(size1,
m.size1);
877 std::swap(size2,
m.size2);
897 std::fill(data.begin(), data.end(), v);
909 if (size1 ==
m && size2 == n)
915 for (
SizeType i = 0, min_size1 = std::min(size1,
m); i < min_size1; i++)
916 for (
SizeType j = 0, min_size2 = std::min(size2, n); j < min_size2; j++)
917 tmp(i, j) = (*this)(i, j);
922 data.resize(storageSize(
m, n), v);
945 template <
typename T,
typename A = std::unordered_map<std::u
int64_t, T> >
987 size1(0), size2(0), data() {}
996 size1(
m), size2(n), data()
1006 size1(
m.size1), size2(
m.size2), data(
m.data) {}
1013 size1(0), size2(0), data()
1023 size1(0), size2(0), data()
1034 template <
typename E>
1039 matrixAssignMatrix<ScalarAssignment>(*
this, e);
1067 typename ArrayType::const_iterator it = data.find(makeKey(i, j));
1069 if (it == data.end())
1090 return (size1 == 0 || size2 == 0);
1117 return data.max_size();
1168 template <
typename C>
1190 template <
typename E>
1204 template <
typename C>
1226 template <
typename E>
1240 template <
typename C>
1262 template <
typename E>
1276 template <
typename T1>
1279 matrixAssignScalar<ScalarMultiplicationAssignment>(*
this, t);
1289 template <
typename T1>
1292 matrixAssignScalar<ScalarDivisionAssignment>(*
this, t);
1302 template <
typename E>
1306 matrixAssignMatrix<ScalarAssignment>(*
this, e);
1319 matrixAssignMatrix<ScalarAssignment>(*
this, ilm);
1329 template <
typename E>
1332 matrixAssignMatrix<ScalarAdditionAssignment>(*
this, e);
1353 template <
typename E>
1356 matrixAssignMatrix<ScalarSubtractionAssignment>(*
this, e);
1378 std::swap(data,
m.data);
1379 std::swap(size1,
m.size1);
1380 std::swap(size2,
m.size2);
1412 for (
typename ArrayType::iterator it = data.begin(); it != data.end();) {
1413 const KeyType& key = it->first;
1415 if (getRowIdx(key) >=
m || getColIdx(key) >= n)
1416 it = data.erase(it);
1433 return (key >> (
sizeof(
SizeType) * 8));
1447 template <
typename T,
typename A>
1450 template <
typename T, std::
size_t N>
1451 class BoundedVector;
1459 template <
typename T, std::
size_t M, std::
size_t N>
1508 size1(0), size2(0) {}
1540 size1(
m.size1), size2(
m.size2)
1542 for (
SizeType i = 0; i < size1; i++)
1543 std::copy(
m.data[i],
m.data[i] + size2, data[i]);
1563 template <
typename E>
1568 matrixAssignMatrix<ScalarAssignment>(*
this, e);
1603 return (size1 == 0 || size2 == 0);
1669 std::copy(
m.data[i],
m.data[i] +
m.size2, data[i]);
1684 template <
typename C>
1708 template <
typename E>
1721 template <
typename C>
1743 template <
typename E>
1756 template <
typename C>
1778 template <
typename E>
1791 template <
typename T1>
1794 matrixAssignScalar<ScalarMultiplicationAssignment>(*
this, v);
1804 template <
typename T1>
1807 matrixAssignScalar<ScalarDivisionAssignment>(*
this, v);
1818 template <
typename E>
1822 matrixAssignMatrix<ScalarAssignment>(*
this, e);
1836 matrixAssignMatrix<ScalarAssignment>(*
this, ilm);
1846 template <
typename E>
1849 matrixAssignMatrix<ScalarAdditionAssignment>(*
this, e);
1870 template <
typename E>
1873 matrixAssignMatrix<ScalarSubtractionAssignment>(*
this, e);
1895 SizeType max_size1 = std::max(size1,
m.size1);
1896 SizeType max_size2 = std::max(size2,
m.size2);
1898 for (
SizeType i = 0; i < max_size1; i++)
1899 std::swap_ranges(data[i], data[i] + max_size2,
m.data[i]);
1901 std::swap(size1,
m.size1);
1902 std::swap(size2,
m.size2);
1922 for (
SizeType i = 0; i < size1; i++)
1923 std::fill(data[i], data[i] + size2, v);
1954 SizeType min_size1 = std::min(size1,
m);
1956 for (
SizeType i = 0; i < min_size1; i++)
1957 std::fill(data[i] + size2, data[i] + n, v);
1962 std::fill(data[i], data[i] + n, v);
1974 template <
typename T, std::
size_t M, std::
size_t N>
1976 template <
typename T, std::
size_t M, std::
size_t N>
1985 template <
typename T, std::
size_t M, std::
size_t N>
2036 std::fill(data[i], data[i] +
N,
ValueType());
2046 std::fill(data[i], data[i] +
N, v);
2056 std::copy(
m.data[i],
m.data[i] +
N, data[i]);
2073 template <
typename E>
2076 matrixAssignMatrix<ScalarAssignment>(*
this, e);
2111 return (
M == 0 ||
N == 0);
2177 std::copy(
m.data[i],
m.data[i] +
N, data[i]);
2189 template <
typename C>
2200 template <
typename T1>
2212 template <
typename E>
2225 template <
typename C>
2247 template <
typename E>
2260 template <
typename C>
2282 template <
typename E>
2295 template <
typename T1>
2298 matrixAssignScalar<ScalarMultiplicationAssignment>(*
this, t);
2308 template <
typename T1>
2311 matrixAssignScalar<ScalarDivisionAssignment>(*
this, t);
2321 template <
typename E>
2324 matrixAssignMatrix<ScalarAssignment>(*
this, e);
2338 for (
SizeType i = 0; i < n_rows; i++) {
2339 const auto&
row = *(l.begin() + i);
2341 if (
row.size() <
N) {
2342 std::copy(
row.begin(),
row.end(), data[i]);
2347 std::copy(
row.begin(),
row.begin() +
N, data[i]);
2352 std::fill(data[i], data[i] +
N,
ValueType());
2363 template <
typename E>
2366 matrixAssignMatrix<ScalarAdditionAssignment>(*
this, e);
2387 template <
typename E>
2390 matrixAssignMatrix<ScalarSubtractionAssignment>(*
this, e);
2413 std::swap_ranges(data[i], data[i] +
N,
m.data[i]);
2434 std::fill(data[i], data[i] +
N, v);
2441 template <
typename T, std::
size_t M, std::
size_t N>
2443 template <
typename T, std::
size_t M, std::
size_t N>
2450 template <
typename T>
2480 size1(0), size2(0) {}
2488 size1(
m), size2(n) {}
2495 size1(
m.size1), size2(
m.size2) {}
2516 return (size1 == 0 || size2 == 0);
2543 return std::numeric_limits<SizeType>::max();
2552 return std::numeric_limits<SizeType>::max();
2577 std::swap(size1,
m.size1);
2578 std::swap(size2,
m.size2);
2609 template <
typename T>
2616 template <
typename T>
2646 size1(0), size2(0), value() {}
2655 size1(
m), size2(n), value(v) {}
2662 size1(
m.size1), size2(
m.size2), value(
m.value) {}
2683 return (size1 == 0 || size2 == 0);
2710 return std::numeric_limits<SizeType>::max();
2719 return std::numeric_limits<SizeType>::max();
2745 std::swap(size1,
m.size1);
2746 std::swap(size2,
m.size2);
2747 std::swap(value,
m.value);
2782 template <
typename T>
2812 size1(0), size2(0) {}
2820 size1(
m), size2(n) {}
2827 size1(
m.size1), size2(
m.size2) {}
2839 return (i == j ? one : zero);
2848 return (size1 == 0 || size2 == 0);
2875 return std::numeric_limits<SizeType>::max();
2884 return std::numeric_limits<SizeType>::max();
2909 std::swap(size1,
m.size1);
2910 std::swap(size2,
m.size2);
2942 template <
typename T>
2944 template <
typename T>
2951 template <
typename M>
2959 template <
typename M>
2967 template <
typename M>
2975 template <
typename M>
2985 template <
typename E>
2986 typename E::ValueType
2989 typedef typename E::ValueType ValueType;
2993 std::vector<SizeType> pv(lu.
getSize1());
2994 std::size_t num_row_swaps;
3001 for (SizeType i = 0; i < size; i++)
3004 return (num_row_swaps % 2 == 0 ? res : -res);
3013 template <
typename C>
3014 typename C::ValueType
3017 typedef typename C::ValueType ValueType;
3019 typedef typename CTemporaryType::SizeType SizeType;
3021 CTemporaryType lu(c);
3022 std::vector<SizeType> pv(lu.getSize1());
3023 std::size_t num_row_swaps;
3028 SizeType size = std::min(lu.getSize1(), lu.getSize2());
3030 for (SizeType i = 0; i < size; i++)
3033 return (num_row_swaps % 2 == 0 ? res : -res);
3044 template <
typename E,
typename C>
3048 typedef typename C::ValueType ValueType;
3050 typedef typename CTemporaryType::SizeType SizeType;
3052 CTemporaryType lu(e);
3053 std::vector<SizeType> pv(lu.getSize1());
3054 std::size_t num_row_swaps;
3070 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 capacities M N stored in a stack-allocated array.
Definition: Matrix.hpp:1461
BoundedMatrix & operator-=(InitializerListType l)
Subtracts the rows in l element-wise from this bounded matrix.
Definition: Matrix.hpp:1767
std::initializer_list< std::initializer_list< T > > InitializerListType
The initializer-list-of-rows type accepted by constructors and assignment.
Definition: Matrix.hpp:1497
SizeType getSize1() const
Returns the current row count.
Definition: Matrix.hpp:1610
T(* ArrayPointer)[N]
Pointer-to-row type for raw access to the element array.
Definition: Matrix.hpp:1479
SizeType getSize2() const
Returns the current column count.
Definition: Matrix.hpp:1619
BoundedMatrix(const BoundedMatrix &m)
Constructs a copy of the bounded matrix m.
Definition: Matrix.hpp:1539
T * Pointer
Pointer type to a single element.
Definition: Matrix.hpp:1483
friend void swap(BoundedMatrix &m1, BoundedMatrix &m2)
ADL-enabled free-function form of swap().
Definition: Matrix.hpp:1911
BoundedMatrix & operator=(InitializerListType l)
Assigns the rows in l to this bounded matrix (resizes to match, respecting the bounds).
Definition: Matrix.hpp:1696
void clear(const ValueType &v=ValueType())
Sets every element of the matrix to the value v (dimensions unchanged).
Definition: Matrix.hpp:1920
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:1722
void swap(BoundedMatrix &m)
Swaps the contents of this bounded matrix with those of m.
Definition: Matrix.hpp:1892
const MatrixReference< const SelfType > ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:1489
std::enable_if< IsScalar< T1 >::value, BoundedMatrix >::type & operator*=(const T1 &v)
Multiplies every element by the scalar v.
Definition: Matrix.hpp:1792
BoundedMatrix & minusAssign(InitializerListType l)
Subtracts the rows in l element-wise from this matrix without intermediate temporary.
Definition: Matrix.hpp:1882
std::enable_if< IsScalar< T1 >::value, BoundedMatrix >::type & operator/=(const T1 &v)
Divides every element by the scalar v.
Definition: Matrix.hpp:1805
std::size_t SizeType
The unsigned size type.
Definition: Matrix.hpp:1473
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:1779
static const SizeType MaxSize1
The compile-time maximum number of rows M.
Definition: Matrix.hpp:1500
BoundedMatrix & operator=(const MatrixExpression< E > &e)
Assigns the matrix expression e to this bounded matrix (via a temporary to handle aliasing).
Definition: Matrix.hpp:1709
const T & ConstReference
Constant reference type to an element.
Definition: Matrix.hpp:1471
const T(* ConstArrayPointer)[N]
Constant pointer-to-row type for raw access to the element array.
Definition: Matrix.hpp:1481
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:1744
std::shared_ptr< SelfType > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated BoundedMatrix instances.
Definition: Matrix.hpp:1495
BoundedMatrix(const MatrixExpression< E > &e)
Constructs a bounded matrix from the matrix expression e.
Definition: Matrix.hpp:1564
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:1757
ConstArrayPointer getData() const
Returns a const pointer-to-row to the contiguous 2D element array.
Definition: Matrix.hpp:1655
BoundedMatrix & plusAssign(const MatrixExpression< E > &e)
Adds the elements of the matrix expression e to this matrix without intermediate temporary.
Definition: Matrix.hpp:1847
T & Reference
Mutable reference type to an element.
Definition: Matrix.hpp:1469
BoundedMatrix & assign(const MatrixExpression< E > &e)
Resizes this matrix to match e and assigns its elements without intermediate temporary.
Definition: Matrix.hpp:1819
void resize(SizeType m, SizeType n, const ValueType &v)
Resizes the matrix to elements; newly added cells are set to v.
Definition: Matrix.hpp:1948
BoundedMatrix(SizeType m, SizeType n, const ValueType &v)
Constructs a bounded matrix of size with every element initialized to v.
Definition: Matrix.hpp:1529
BoundedMatrix & assign(InitializerListType l)
Resizes this matrix to match l and assigns its elements.
Definition: Matrix.hpp:1832
BoundedMatrix & operator+=(InitializerListType l)
Adds the rows in l element-wise to this bounded matrix.
Definition: Matrix.hpp:1732
T ValueType
The scalar value type.
Definition: Matrix.hpp:1467
const T * ConstPointer
Constant pointer type to a single element.
Definition: Matrix.hpp:1485
BoundedMatrix & plusAssign(InitializerListType l)
Adds the rows in l element-wise to this matrix without intermediate temporary.
Definition: Matrix.hpp:1858
Reference operator()(SizeType i, SizeType j)
Returns a mutable reference to the element at (i, j).
Definition: Matrix.hpp:1578
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to the element at (i, j).
Definition: Matrix.hpp:1591
SelfType MatrixTemporaryType
Concrete temporary matrix type used by expression-template machinery.
Definition: Matrix.hpp:1491
BoundedVector< T, M *N > VectorTemporaryType
Concrete temporary vector type used when assembling vectors from this matrix (a bounded vector of cap...
Definition: Matrix.hpp:1493
BoundedMatrix(InitializerListType l)
Constructs a bounded matrix from the initializer list of rows l.
Definition: Matrix.hpp:1551
BoundedMatrix()
Constructs an empty bounded matrix (zero rows, zero columns).
Definition: Matrix.hpp:1507
BoundedMatrix(SizeType m, SizeType n)
Constructs a bounded matrix of size with value-initialized elements.
Definition: Matrix.hpp:1516
static const SizeType MaxSize2
The compile-time maximum number of columns N.
Definition: Matrix.hpp:1502
ArrayPointer getData()
Returns a mutable pointer-to-row to the contiguous 2D element array.
Definition: Matrix.hpp:1646
SizeType getMaxSize2() const
Returns the compile-time maximum column count N.
Definition: Matrix.hpp:1637
void resize(SizeType m, SizeType n)
Resizes the matrix to elements (new elements are left value-uninitialized).
Definition: Matrix.hpp:1932
SizeType getMaxSize1() const
Returns the compile-time maximum row count M.
Definition: Matrix.hpp:1628
MatrixReference< SelfType > ClosureType
Closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:1487
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:1685
ValueType ArrayType[M][N]
The fixed-capacity 2D C-array type used for in-memory storage.
Definition: Matrix.hpp:1477
BoundedMatrix & operator=(const BoundedMatrix &m)
Copy-assigns the elements of m to this bounded matrix.
Definition: Matrix.hpp:1665
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Matrix.hpp:1475
BoundedMatrix & minusAssign(const MatrixExpression< E > &e)
Subtracts the elements of the matrix expression e from this matrix without intermediate temporary.
Definition: Matrix.hpp:1871
bool isEmpty() const
Tells whether the matrix is empty.
Definition: Matrix.hpp:1601
Variable-size vector with a fixed upper capacity N stored in a stack-allocated array.
Definition: Vector.hpp:1388
Fixed-size dense matrix of dimensions M N backed by a 2D C-array (no dynamic allocation).
Definition: Matrix.hpp:1987
MatrixReference< SelfType > ClosureType
Closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:2013
T * Pointer
Pointer type to a single element.
Definition: Matrix.hpp:2009
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:2261
CMatrix & operator=(InitializerListType l)
Assigns the rows in l to this fixed-size matrix (clipped or zero-padded to M N).
Definition: Matrix.hpp:2201
SizeType getSize2() const
Returns the fixed column count N.
Definition: Matrix.hpp:2127
CMatrix & assign(InitializerListType l)
Assigns the rows in l to this fixed-size matrix (clipped or zero-padded to M N).
Definition: Matrix.hpp:2334
ValueType ArrayType[M][N]
The fixed-size 2D C-array type used for in-memory storage of M N elements.
Definition: Matrix.hpp:2003
ConstArrayPointer getData() const
Returns a const pointer-to-row to the contiguous 2D element array.
Definition: Matrix.hpp:2163
ArrayPointer getData()
Returns a mutable pointer-to-row to the contiguous 2D element array.
Definition: Matrix.hpp:2154
std::initializer_list< std::initializer_list< T > > InitializerListType
The initializer-list-of-rows type accepted by constructors and assignment.
Definition: Matrix.hpp:2023
T(* ArrayPointer)[N]
Pointer-to-row type for raw access to the element array.
Definition: Matrix.hpp:2005
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:2248
BoundedVector< T, M *N > VectorTemporaryType
Concrete temporary vector type used when assembling vectors from this matrix.
Definition: Matrix.hpp:2019
CMatrix & minusAssign(const MatrixExpression< E > &e)
Subtracts the elements of the matrix expression e from this matrix without intermediate temporary.
Definition: Matrix.hpp:2388
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to the element at (i, j).
Definition: Matrix.hpp:2099
CMatrix(const ValueType &v)
Constructs an matrix with every element initialized to v.
Definition: Matrix.hpp:2043
CMatrix()
Constructs a zero-initialized matrix.
Definition: Matrix.hpp:2033
std::enable_if< IsScalar< T1 >::value, CMatrix >::type & operator*=(const T1 &t)
Multiplies every element by the scalar t.
Definition: Matrix.hpp:2296
Reference operator()(SizeType i, SizeType j)
Returns a mutable reference to the element at (i, j).
Definition: Matrix.hpp:2086
void clear(const ValueType &v=ValueType())
Sets every element of the matrix to the value v.
Definition: Matrix.hpp:2431
std::size_t SizeType
The unsigned size type.
Definition: Matrix.hpp:1999
CMatrix(const MatrixExpression< E > &e)
Constructs a fixed-size matrix from the matrix expression e.
Definition: Matrix.hpp:2074
CMatrix(InitializerListType l)
Constructs a fixed-size matrix with the contents of the initializer list of rows l.
Definition: Matrix.hpp:2063
CMatrix & operator-=(InitializerListType l)
Subtracts the rows in l element-wise from this fixed-size matrix.
Definition: Matrix.hpp:2271
bool isEmpty() const
Tells whether the matrix is empty (M or N is zero).
Definition: Matrix.hpp:2109
T ValueType
The scalar value type.
Definition: Matrix.hpp:1993
std::enable_if< IsScalar< T1 >::value, CMatrix >::type & operator/=(const T1 &t)
Divides every element by the scalar t.
Definition: Matrix.hpp:2309
const T * ConstPointer
Constant pointer type to a single element.
Definition: Matrix.hpp:2011
void swap(CMatrix &m)
Swaps the contents of this fixed-size matrix with those of m.
Definition: Matrix.hpp:2409
CMatrix & operator=(const CMatrix &m)
Copy-assigns the elements of m to this fixed-size matrix.
Definition: Matrix.hpp:2173
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:2190
const T(* ConstArrayPointer)[N]
Constant pointer-to-row type for raw access to the element array.
Definition: Matrix.hpp:2007
SizeType getMaxSize1() const
Returns the fixed row count M (capacity equals size for Math::CMatrix).
Definition: Matrix.hpp:2136
SizeType getMaxSize2() const
Returns the fixed column count N (capacity equals size for Math::CMatrix).
Definition: Matrix.hpp:2145
CMatrix & operator+=(InitializerListType l)
Adds the rows in l element-wise to this fixed-size matrix.
Definition: Matrix.hpp:2236
static const SizeType Size1
The compile-time fixed row count M.
Definition: Matrix.hpp:2026
CMatrix & plusAssign(InitializerListType l)
Adds the rows in l element-wise to this matrix without intermediate temporary.
Definition: Matrix.hpp:2375
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:2283
const T & ConstReference
Constant reference type to an element.
Definition: Matrix.hpp:1997
std::shared_ptr< SelfType > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated CMatrix instances.
Definition: Matrix.hpp:2021
CMatrix(const CMatrix &m)
Constructs a copy of the fixed-size matrix m.
Definition: Matrix.hpp:2053
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:2322
friend void swap(CMatrix &m1, CMatrix &m2)
ADL-enabled free-function form of swap().
Definition: Matrix.hpp:2422
const MatrixReference< const SelfType > ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:2015
SizeType getSize1() const
Returns the fixed row count M.
Definition: Matrix.hpp:2118
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:2226
T & Reference
Mutable reference type to an element.
Definition: Matrix.hpp:1995
BoundedMatrix< T, M, N > MatrixTemporaryType
Concrete temporary matrix type used by expression-template machinery (a Math::BoundedMatrix of equal ...
Definition: Matrix.hpp:2017
CMatrix & minusAssign(InitializerListType l)
Subtracts the rows in l element-wise from this matrix without intermediate temporary.
Definition: Matrix.hpp:2399
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:2213
CMatrix & plusAssign(const MatrixExpression< E > &e)
Adds the elements of the matrix expression e to this matrix without intermediate temporary.
Definition: Matrix.hpp:2364
static const SizeType Size2
The compile-time fixed column count N.
Definition: Matrix.hpp:2028
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Matrix.hpp:2001
Constant identity-matrix expression ( on the diagonal, elsewhere).
Definition: Matrix.hpp:2784
SizeType getMaxSize2() const
Returns the maximum representable column count.
Definition: Matrix.hpp:2882
T ValueType
The scalar value type.
Definition: Matrix.hpp:2790
IdentityMatrix & operator=(const IdentityMatrix &m)
Copy-assigns the dimensions from m.
Definition: Matrix.hpp:2892
const T & Reference
Reference type (always a const reference — elements are immutable).
Definition: Matrix.hpp:2792
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to either 1 (if i equals j) or 0.
Definition: Matrix.hpp:2836
void resize(SizeType m, SizeType n)
Resizes the dimensions to .
Definition: Matrix.hpp:2929
IdentityMatrix(SizeType m, SizeType n)
Constructs an identity matrix of size (1 on the diagonal, 0 elsewhere).
Definition: Matrix.hpp:2819
const MatrixReference< const SelfType > ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:2802
SizeType getMaxSize1() const
Returns the maximum representable row count.
Definition: Matrix.hpp:2873
bool isEmpty() const
Tells whether the matrix is empty.
Definition: Matrix.hpp:2846
MatrixReference< SelfType > ClosureType
Closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:2800
SizeType getSize1() const
Returns the logical number of rows.
Definition: Matrix.hpp:2855
friend void swap(IdentityMatrix &m1, IdentityMatrix &m2)
ADL-enabled free-function form of swap().
Definition: Matrix.hpp:2919
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Matrix.hpp:2798
IdentityMatrix()
Constructs an empty identity matrix.
Definition: Matrix.hpp:2811
Matrix< T > MatrixTemporaryType
Concrete temporary matrix type used by expression-template machinery.
Definition: Matrix.hpp:2804
IdentityMatrix(const IdentityMatrix &m)
Constructs a copy of the identity matrix m.
Definition: Matrix.hpp:2826
std::size_t SizeType
The unsigned size type.
Definition: Matrix.hpp:2796
void swap(IdentityMatrix &m)
Swaps the dimensions with m.
Definition: Matrix.hpp:2906
SizeType getSize2() const
Returns the logical number of columns.
Definition: Matrix.hpp:2864
const T & ConstReference
Constant reference type to an element.
Definition: Matrix.hpp:2794
Vector< T, std::vector< T > > VectorTemporaryType
Concrete temporary vector type used when assembling vectors from this matrix.
Definition: Matrix.hpp:2806
Lightweight matrix container that wraps a nested std::initializer_list of T values.
Definition: Matrix.hpp:338
Matrix< T, std::vector< T > > MatrixTemporaryType
Concrete temporary matrix type used by expression-template machinery.
Definition: Matrix.hpp:360
std::initializer_list< std::initializer_list< T > > InitializerListType
The nested std::initializer_list type wrapped by this matrix.
Definition: Matrix.hpp:344
SizeType getSize2() const
Returns the number of columns (the longest row length).
Definition: Matrix.hpp:425
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Matrix.hpp:354
Reference operator()(SizeType i, SizeType j)
Returns a mutable reference to the element at row i and column j.
Definition: Matrix.hpp:385
InitializerListType::value_type::reference Reference
Mutable reference type to an element.
Definition: Matrix.hpp:350
bool isEmpty() const
Tells whether the matrix is empty (zero rows or zero columns).
Definition: Matrix.hpp:434
InitListMatrix(InitializerListType l)
Constructs an InitListMatrix wrapping the nested initializer list l.
Definition: Matrix.hpp:371
InitListMatrix SelfType
Convenience alias for this instantiation.
Definition: Matrix.hpp:342
Vector< T, std::vector< T > > VectorTemporaryType
Concrete temporary vector type used by expression-template machinery.
Definition: Matrix.hpp:362
InitializerListType::value_type::const_reference ConstReference
Constant reference type to an element.
Definition: Matrix.hpp:348
SelfType ClosureType
Closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:356
const SelfType ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:358
InitializerListType::size_type SizeType
The unsigned size type.
Definition: Matrix.hpp:352
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to the element at row i and column j.
Definition: Matrix.hpp:402
InitializerListType::value_type::value_type ValueType
The scalar value type.
Definition: Matrix.hpp:346
SizeType getSize1() const
Returns the number of rows.
Definition: Matrix.hpp:416
Refinement of Math::MatrixExpression marking the derived type as a concrete (writable) matrix contain...
Definition: Expression.hpp:250
CRTP base class for all matrix expression types.
Definition: Expression.hpp:104
Lightweight matrix expression that proxies a reference to an underlying matrix container.
Definition: Matrix.hpp:64
M::ConstReference ConstReference
Constant reference type to an element.
Definition: Matrix.hpp:78
Reference operator()(SizeType i, SizeType j)
Returns a mutable reference to the element at (i, j).
Definition: Matrix.hpp:101
MatrixReference & operator=(const MatrixReference &r)
Copy-assigns the wrapped matrix from the matrix referenced by r.
Definition: Matrix.hpp:194
std::conditional< std::is_const< M >::value, typename M::ConstReference, typename M::Reference >::type Reference
Mutable reference type (degrades to ConstReference when the wrapped matrix is const).
Definition: Matrix.hpp:76
bool isEmpty() const
Tells whether the wrapped matrix is empty.
Definition: Matrix.hpp:166
MatrixReference & assign(const MatrixExpression< E > &e)
Assigns the matrix expression e to the wrapped matrix without intermediate temporary.
Definition: Matrix.hpp:272
const MatrixType & getData() const
Returns a const reference to the wrapped matrix.
Definition: Matrix.hpp:175
friend void swap(MatrixReference &r1, MatrixReference &r2)
ADL-enabled free-function form of swap().
Definition: Matrix.hpp:318
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:246
SizeType getMaxSize() const
Returns the wrapped matrix's maximum total element count.
Definition: Matrix.hpp:139
M::SizeType SizeType
The unsigned size type of the wrapped matrix.
Definition: Matrix.hpp:80
MatrixReference & operator-=(const MatrixExpression< E > &e)
Subtracts the matrix expression e element-wise from the wrapped matrix.
Definition: Matrix.hpp:233
SizeType getMaxSize1() const
Returns the wrapped matrix's maximum number of rows.
Definition: Matrix.hpp:148
MatrixReference & operator=(const MatrixExpression< E > &e)
Assigns the matrix expression e to the wrapped matrix.
Definition: Matrix.hpp:207
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:259
MatrixReference & operator+=(const MatrixExpression< E > &e)
Adds the matrix expression e element-wise to the wrapped matrix.
Definition: Matrix.hpp:220
SizeType getSize1() const
Returns the wrapped matrix's number of rows.
Definition: Matrix.hpp:121
const SelfType ConstClosureType
Constant closure type used when this proxy appears inside another expression.
Definition: Matrix.hpp:86
MatrixReference & minusAssign(const MatrixExpression< E > &e)
Subtracts the matrix expression e from the wrapped matrix without intermediate temporary.
Definition: Matrix.hpp:298
MatrixReference(MatrixType &m)
Constructs the reference proxy referring to m.
Definition: Matrix.hpp:92
SizeType getSize2() const
Returns the wrapped matrix's number of columns.
Definition: Matrix.hpp:130
MatrixReference & plusAssign(const MatrixExpression< E > &e)
Adds the matrix expression e to the wrapped matrix without intermediate temporary.
Definition: Matrix.hpp:285
SelfType ClosureType
Closure type used when this proxy appears inside another expression.
Definition: Matrix.hpp:84
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to the element at (i, j).
Definition: Matrix.hpp:112
M::ValueType ValueType
The element value type of the wrapped matrix.
Definition: Matrix.hpp:72
M MatrixType
The wrapped matrix type.
Definition: Matrix.hpp:70
void swap(MatrixReference &r)
Swaps the contents of the two wrapped matrices.
Definition: Matrix.hpp:308
M::DifferenceType DifferenceType
The signed difference type of the wrapped matrix.
Definition: Matrix.hpp:82
SizeType getMaxSize2() const
Returns the wrapped matrix's maximum number of columns.
Definition: Matrix.hpp:157
MatrixType & getData()
Returns a reference to the wrapped matrix.
Definition: Matrix.hpp:184
Dynamically-sized dense row-major matrix with configurable underlying storage.
Definition: Matrix.hpp:455
A::size_type SizeType
The unsigned size type used by the underlying storage container.
Definition: Matrix.hpp:467
MatrixReference< SelfType > ClosureType
Closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:477
Matrix(SizeType m, SizeType n, const ValueType &v)
Constructs an m × n matrix with every element initialized to v.
Definition: Matrix.hpp:509
std::enable_if< IsScalar< T1 >::value, Matrix >::type & operator/=(const T1 &t)
Divides every element by the scalar t.
Definition: Matrix.hpp:787
SizeType getSize2() const
Returns the number of columns.
Definition: Matrix.hpp:603
Matrix(const MatrixExpression< E > &e)
Constructs the matrix from the matrix expression e (materializing the expression result).
Definition: Matrix.hpp:549
Matrix & operator+=(InitializerListType l)
Adds the rows in l element-wise to this matrix.
Definition: Matrix.hpp:712
std::enable_if< IsScalar< T1 >::value, Matrix >::type & operator*=(const T1 &t)
Multiplies every element by the scalar t.
Definition: Matrix.hpp:774
SizeType getSize1() const
Returns the number of rows.
Definition: Matrix.hpp:594
bool isEmpty() const
Tells whether the matrix is empty.
Definition: Matrix.hpp:585
Matrix & operator=(const MatrixExpression< E > &e)
Assigns the matrix expression e to this matrix (via a temporary to handle aliasing).
Definition: Matrix.hpp:688
Matrix(Matrix &&m)
Move-constructs a matrix from m (m is left in a valid empty state).
Definition: Matrix.hpp:523
Matrix(const Matrix &m)
Constructs a copy of the matrix m.
Definition: Matrix.hpp:516
Matrix & assign(InitializerListType l)
Resizes this matrix to match l and assigns its elements.
Definition: Matrix.hpp:812
std::shared_ptr< SelfType > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated Matrix instances.
Definition: Matrix.hpp:485
Vector< T, A > VectorTemporaryType
Concrete temporary vector type compatible with this matrix's value type and storage.
Definition: Matrix.hpp:483
const ArrayType & getData() const
Returns a const reference to the underlying storage container (row-major linear layout).
Definition: Matrix.hpp:630
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:760
Matrix & operator=(const MatrixContainer< C > &c)
Assigns the contents of the matrix container c to this matrix (no alias check needed).
Definition: Matrix.hpp:666
Matrix()
Constructs an empty matrix (zero rows and zero columns).
Definition: Matrix.hpp:492
Matrix(InitializerListType l)
Constructs the matrix from a brace-initializer list of rows.
Definition: Matrix.hpp:537
const T & ConstReference
Constant reference type to an element.
Definition: Matrix.hpp:465
Matrix & plusAssign(InitializerListType l)
Adds the rows in l element-wise to this matrix without intermediate temporary.
Definition: Matrix.hpp:838
const T * ConstPointer
Constant pointer type for raw element access.
Definition: Matrix.hpp:475
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:738
SizeType getMaxSize() const
Returns the maximum total element count the underlying storage container can hold.
Definition: Matrix.hpp:612
T * Pointer
Pointer type for raw element access.
Definition: Matrix.hpp:473
Reference operator()(SizeType i, SizeType j)
Returns a mutable reference to the element at (i, j).
Definition: Matrix.hpp:562
SelfType MatrixTemporaryType
Concrete temporary matrix type used by expression-template machinery.
Definition: Matrix.hpp:481
friend void swap(Matrix &m1, Matrix &m2)
ADL-enabled free-function form of swap().
Definition: Matrix.hpp:886
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to the element at (i, j).
Definition: Matrix.hpp:575
void swap(Matrix &m)
Swaps the contents of this matrix with those of m.
Definition: Matrix.hpp:872
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:800
Matrix & operator-=(InitializerListType l)
Subtracts the rows in l element-wise from this matrix.
Definition: Matrix.hpp:748
Matrix & operator=(Matrix &&m)
Move-assigns the contents of m to this matrix.
Definition: Matrix.hpp:653
A ArrayType
The underlying storage container type (row-major linear storage).
Definition: Matrix.hpp:471
void resize(SizeType m, SizeType n, bool preserve=true, const ValueType &v=ValueType())
Resizes the matrix to elements.
Definition: Matrix.hpp:907
Matrix & operator=(const Matrix &m)
Copy-assigns the contents of m to this matrix.
Definition: Matrix.hpp:640
Matrix & operator=(InitializerListType l)
Assigns the rows in l to this matrix (resizes to match).
Definition: Matrix.hpp:676
const MatrixReference< const SelfType > ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:479
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:487
Matrix & plusAssign(const MatrixExpression< E > &e)
Adds the elements of the matrix expression e to this matrix without intermediate temporary.
Definition: Matrix.hpp:827
T & Reference
Mutable reference type to an element.
Definition: Matrix.hpp:463
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:724
T ValueType
The scalar value type stored in the matrix.
Definition: Matrix.hpp:461
Matrix(SizeType m, SizeType n)
Constructs an m × n matrix with default-initialized elements.
Definition: Matrix.hpp:500
ArrayType & getData()
Returns a mutable reference to the underlying storage container (row-major linear layout).
Definition: Matrix.hpp:621
Matrix & minusAssign(InitializerListType l)
Subtracts the rows in l element-wise from this matrix without intermediate temporary.
Definition: Matrix.hpp:862
A::difference_type DifferenceType
The signed difference type used by the underlying storage container.
Definition: Matrix.hpp:469
Matrix & minusAssign(const MatrixExpression< E > &e)
Subtracts the elements of the matrix expression e from this matrix without intermediate temporary.
Definition: Matrix.hpp:851
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:702
void clear(const ValueType &v=ValueType())
Sets every element of the matrix to the value v.
Definition: Matrix.hpp:895
Constant matrix expression in which every entry equals the same scalar value.
Definition: Matrix.hpp:2618
std::size_t SizeType
The unsigned size type.
Definition: Matrix.hpp:2630
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Matrix.hpp:2632
SizeType getMaxSize2() const
Returns the maximum representable column count.
Definition: Matrix.hpp:2717
SizeType getSize2() const
Returns the logical number of columns.
Definition: Matrix.hpp:2699
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to the common entry value.
Definition: Matrix.hpp:2671
const MatrixReference< const SelfType > ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:2636
ScalarMatrix(const ScalarMatrix &m)
Constructs a copy of the scalar matrix m.
Definition: Matrix.hpp:2661
void swap(ScalarMatrix &m)
Swaps the dimensions and common value with m.
Definition: Matrix.hpp:2742
const T & ConstReference
Constant reference type to the common value.
Definition: Matrix.hpp:2628
friend void swap(ScalarMatrix &m1, ScalarMatrix &m2)
ADL-enabled free-function form of swap().
Definition: Matrix.hpp:2756
SizeType getSize1() const
Returns the logical number of rows.
Definition: Matrix.hpp:2690
Vector< T, std::vector< T > > VectorTemporaryType
Concrete temporary vector type used when assembling vectors from this matrix.
Definition: Matrix.hpp:2640
SizeType getMaxSize1() const
Returns the maximum representable row count.
Definition: Matrix.hpp:2708
void resize(SizeType m, SizeType n)
Resizes the dimensions to .
Definition: Matrix.hpp:2766
T ValueType
The scalar value type.
Definition: Matrix.hpp:2624
bool isEmpty() const
Tells whether the matrix is empty.
Definition: Matrix.hpp:2681
ScalarMatrix()
Constructs an empty scalar matrix.
Definition: Matrix.hpp:2645
Matrix< T > MatrixTemporaryType
Concrete temporary matrix type used by expression-template machinery.
Definition: Matrix.hpp:2638
ScalarMatrix & operator=(const ScalarMatrix &m)
Copy-assigns the dimensions and common value from m.
Definition: Matrix.hpp:2727
ScalarMatrix(SizeType m, SizeType n, const ValueType &v=ValueType())
Constructs a scalar matrix of size in which every entry equals v.
Definition: Matrix.hpp:2654
MatrixReference< SelfType > ClosureType
Closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:2634
const T & Reference
Reference type (always a const reference — elements are immutable).
Definition: Matrix.hpp:2626
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:947
const MatrixReference< const SelfType > ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:973
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Matrix.hpp:963
ArrayType::size_type getMaxSize() const
Returns the maximum number of stored entries the underlying associative container can hold.
Definition: Matrix.hpp:1115
SparseMatrix & operator=(const MatrixExpression< E > &e)
Assigns the matrix expression e to this sparse matrix (via a temporary to handle aliasing).
Definition: Matrix.hpp:1191
std::enable_if< IsScalar< T1 >::value, SparseMatrix >::type & operator*=(const T1 &t)
Multiplies every stored entry by the scalar t.
Definition: Matrix.hpp:1277
const T * ConstPointer
Constant pointer type for raw access to stored entries.
Definition: Matrix.hpp:969
SparseContainerElement< SelfType > Reference
Mutable reference type (a proxy object that inserts on assignment to a previously-absent cell).
Definition: Matrix.hpp:957
SparseMatrix & operator=(const SparseMatrix &m)
Copy-assigns the contents of m to this sparse matrix.
Definition: Matrix.hpp:1143
T ValueType
The scalar value type.
Definition: Matrix.hpp:953
const T & ConstReference
Constant reference type to a stored element value.
Definition: Matrix.hpp:959
void resize(SizeType m, SizeType n)
Resizes the logical dimensions to , dropping any stored entries that fall outside the new bounds.
Definition: Matrix.hpp:1408
SparseMatrix & assign(InitializerListType l)
Resizes this matrix to match l and assigns its elements.
Definition: Matrix.hpp:1315
Reference operator()(SizeType i, SizeType j)
Returns a mutable proxy reference to the element at (i, j).
Definition: Matrix.hpp:1049
SparseMatrix()
Constructs an empty sparse matrix (zero rows, zero columns, no stored entries).
Definition: Matrix.hpp:986
void clear()
Removes all explicitly stored entries (the logical dimensions remain unchanged).
Definition: Matrix.hpp:1397
std::initializer_list< std::initializer_list< T > > InitializerListType
The initializer-list-of-rows type accepted by constructors and assignment.
Definition: Matrix.hpp:981
SizeType getSize1() const
Returns the logical number of rows.
Definition: Matrix.hpp:1097
SparseMatrix & operator=(SparseMatrix &&m)
Move-assigns the contents of m to this sparse matrix.
Definition: Matrix.hpp:1156
SelfType MatrixTemporaryType
Concrete temporary matrix type used by expression-template machinery.
Definition: Matrix.hpp:975
SparseMatrix & operator+=(InitializerListType l)
Adds the rows in l element-wise to this sparse matrix.
Definition: Matrix.hpp:1215
SparseMatrix & minusAssign(InitializerListType l)
Subtracts the rows in l element-wise from this matrix without intermediate temporary.
Definition: Matrix.hpp:1365
void swap(SparseMatrix &m)
Swaps the contents of this sparse matrix with those of m.
Definition: Matrix.hpp:1375
SparseMatrix(SizeType m, SizeType n)
Constructs a sparse matrix of size with no stored entries.
Definition: Matrix.hpp:995
std::enable_if< IsScalar< T1 >::value, SparseMatrix >::type & operator/=(const T1 &t)
Divides every stored entry by the scalar t.
Definition: Matrix.hpp:1290
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:1263
SparseMatrix(const SparseMatrix &m)
Constructs a copy of the sparse matrix m.
Definition: Matrix.hpp:1005
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to the element at (i, j).
Definition: Matrix.hpp:1063
SparseMatrix & assign(const MatrixExpression< E > &e)
Resizes this matrix to match e and assigns its elements without intermediate temporary.
Definition: Matrix.hpp:1303
const ArrayType & getData() const
Returns a const reference to the underlying associative container of stored entries.
Definition: Matrix.hpp:1133
SparseMatrix & operator-=(InitializerListType l)
Subtracts the rows in l element-wise from this sparse matrix.
Definition: Matrix.hpp:1251
SparseMatrix(SparseMatrix &&m)
Move-constructs a sparse matrix from m (m is left in a valid empty state).
Definition: Matrix.hpp:1012
A ArrayType
The underlying associative container type.
Definition: Matrix.hpp:965
SizeType getSize2() const
Returns the logical number of columns.
Definition: Matrix.hpp:1106
T * Pointer
Pointer type for raw access to stored entries.
Definition: Matrix.hpp:967
MatrixReference< SelfType > ClosureType
Closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:971
std::shared_ptr< SelfType > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated SparseMatrix instances.
Definition: Matrix.hpp:979
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:1241
SparseMatrix(InitializerListType l)
Constructs a sparse matrix from the initializer list of rows l.
Definition: Matrix.hpp:1022
SparseMatrix & operator=(InitializerListType l)
Assigns the rows in l to this sparse matrix (resizes to match).
Definition: Matrix.hpp:1179
SparseMatrix & plusAssign(const MatrixExpression< E > &e)
Adds the elements of the matrix expression e to this matrix without intermediate temporary.
Definition: Matrix.hpp:1330
SparseMatrix & plusAssign(InitializerListType l)
Adds the rows in l element-wise to this matrix without intermediate temporary.
Definition: Matrix.hpp:1341
friend void swap(SparseMatrix &m1, SparseMatrix &m2)
ADL-enabled free-function form of swap().
Definition: Matrix.hpp:1389
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:1205
SizeType getNumElements() const
Returns the number of explicitly stored (non-default) entries.
Definition: Matrix.hpp:1079
ArrayType & getData()
Returns a mutable reference to the underlying associative container of stored entries.
Definition: Matrix.hpp:1124
Vector< T, std::vector< T > > VectorTemporaryType
Concrete temporary vector type used when assembling vectors from this matrix.
Definition: Matrix.hpp:977
SparseMatrix(const MatrixExpression< E > &e)
Constructs a sparse matrix from the matrix expression e.
Definition: Matrix.hpp:1035
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:1227
SparseMatrix & minusAssign(const MatrixExpression< E > &e)
Subtracts the elements of the matrix expression e from this matrix without intermediate temporary.
Definition: Matrix.hpp:1354
bool isEmpty() const
Tells whether the matrix is empty (zero rows or zero columns).
Definition: Matrix.hpp:1088
A::key_type KeyType
The packed (row, column) key type used by the underlying associative container.
Definition: Matrix.hpp:955
std::uint32_t SizeType
The unsigned size type.
Definition: Matrix.hpp:961
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:1169
Dynamically-sized dense vector with configurable underlying storage.
Definition: Vector.hpp:430
Constant matrix expression whose entries are all zero.
Definition: Matrix.hpp:2452
friend void swap(ZeroMatrix &m1, ZeroMatrix &m2)
ADL-enabled free-function form of swap().
Definition: Matrix.hpp:2587
T ValueType
The scalar value type.
Definition: Matrix.hpp:2458
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Matrix.hpp:2466
const T & ConstReference
Constant reference type to the zero element.
Definition: Matrix.hpp:2462
SizeType getSize1() const
Returns the logical number of rows.
Definition: Matrix.hpp:2523
SizeType getMaxSize2() const
Returns the maximum representable column count.
Definition: Matrix.hpp:2550
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to the zero element.
Definition: Matrix.hpp:2504
Vector< T, std::vector< T > > VectorTemporaryType
Concrete temporary vector type used when assembling vectors from this matrix.
Definition: Matrix.hpp:2474
bool isEmpty() const
Tells whether the matrix is empty (either dimension is zero).
Definition: Matrix.hpp:2514
const T & Reference
Reference type (always a const reference — all elements are zero).
Definition: Matrix.hpp:2460
SizeType getSize2() const
Returns the logical number of columns.
Definition: Matrix.hpp:2532
void swap(ZeroMatrix &m)
Swaps the dimensions with m.
Definition: Matrix.hpp:2574
void resize(SizeType m, SizeType n)
Resizes the dimensions to .
Definition: Matrix.hpp:2597
const MatrixReference< const SelfType > ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:2470
ZeroMatrix & operator=(const ZeroMatrix &m)
Copy-assigns the dimensions from m.
Definition: Matrix.hpp:2560
Matrix< T > MatrixTemporaryType
Concrete temporary matrix type used by expression-template machinery.
Definition: Matrix.hpp:2472
SizeType getMaxSize1() const
Returns the maximum representable row count.
Definition: Matrix.hpp:2541
ZeroMatrix(const ZeroMatrix &m)
Constructs a copy of the zero matrix m.
Definition: Matrix.hpp:2494
ZeroMatrix()
Constructs an empty zero matrix.
Definition: Matrix.hpp:2479
MatrixReference< SelfType > ClosureType
Closure type used when this matrix appears inside another expression.
Definition: Matrix.hpp:2468
std::size_t SizeType
The unsigned size type.
Definition: Matrix.hpp:2464
ZeroMatrix(SizeType m, SizeType n)
Constructs a zero matrix of size .
Definition: Matrix.hpp:2487
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 2x2 matrix holding signed integers of type long.
Definition: Matrix.hpp:3190
CMatrix< float, 3, 3 > Matrix3F
Bounded 3x3 matrix holding floating point values of type float.
Definition: Matrix.hpp:3165
ZeroMatrix< double > DZeroMatrix
Memory-efficient immutable matrix where all elements have the value zero of type double.
Definition: Matrix.hpp:3085
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 3x3 matrix holding unsigned integers of type unsigned long.
Definition: Matrix.hpp:3210
Matrix< double > DMatrix
Unbounded dense matrix holding floating point values of type double..
Definition: Matrix.hpp:3145
ScalarMatrix< float > FScalarMatrix
Memory-efficient immutable matrix where all elements have the same value of type float.
Definition: Matrix.hpp:3100
ZeroMatrix< long > LZeroMatrix
Memory-efficient immutable matrix where all elements have the value zero of type long.
Definition: Matrix.hpp:3090
ScalarMatrix< double > DScalarMatrix
Memory-efficient immutable matrix where all elements have the same value of type double.
Definition: Matrix.hpp:3105
SparseMatrix< unsigned long > SparseULMatrix
Unbounded sparse matrix holding unsigned integers of type unsigned long.
Definition: Matrix.hpp:3235
ZeroMatrix< float > FZeroMatrix
Memory-efficient immutable matrix where all elements have the value zero of type float.
Definition: Matrix.hpp:3080
IdentityMatrix< double > DIdentityMatrix
Memory-efficient immutable identity matrix with element values of type double.
Definition: Matrix.hpp:3125
CMatrix< long, 3, 3 > Matrix3L
Bounded 3x3 matrix holding signed integers of type long.
Definition: Matrix.hpp:3195
Matrix< unsigned long > ULMatrix
Unbounded dense matrix holding unsigned integers of type unsigned long.
Definition: Matrix.hpp:3155
CMatrix< double, 2, 2 > Matrix2D
Bounded 2x2 matrix holding floating point values of type double.
Definition: Matrix.hpp:3175
SparseMatrix< float > SparseFMatrix
Unbounded sparse matrix holding floating point values of type float..
Definition: Matrix.hpp:3220
IdentityMatrix< long > LIdentityMatrix
Memory-efficient immutable identity matrix with element values of type long.
Definition: Matrix.hpp:3130
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:1231
E::ValueType det(const MatrixExpression< E > &e)
Returns the determinant of the matrix expression e.
Definition: Matrix.hpp:2987
CMatrix< unsigned long, 4, 4 > Matrix4UL
Bounded 4x4 matrix holding unsigned integers of type unsigned long.
Definition: Matrix.hpp:3215
CMatrix< double, 4, 4 > Matrix4D
Bounded 4x4 matrix holding floating point values of type double.
Definition: Matrix.hpp:3185
SparseMatrix< long > SparseLMatrix
Unbounded sparse matrix holding signed integers of type long.
Definition: Matrix.hpp:3230
CMatrix< float, 4, 4 > Matrix4F
Bounded 4x4 matrix holding floating point values of type float.
Definition: Matrix.hpp:3170
Matrix< long > LMatrix
Unbounded dense matrix holding signed integers of type long.
Definition: Matrix.hpp:3150
Matrix< float > FMatrix
Unbounded dense matrix holding floating point values of type float..
Definition: Matrix.hpp:3140
IdentityMatrix< unsigned long > ULIdentityMatrix
Memory-efficient immutable identity matrix with element values of type unsigned long.
Definition: Matrix.hpp:3135
ZeroMatrix< unsigned long > ULZeroMatrix
Memory-efficient immutable matrix where all elements have the value zero of type unsigned long.
Definition: Matrix.hpp:3095
CMatrix< long, 4, 4 > Matrix4L
Bounded 4x4 matrix holding signed integers of type long.
Definition: Matrix.hpp:3200
CMatrix< double, 3, 3 > Matrix3D
Bounded 3x3 matrix holding floating point values of type double.
Definition: Matrix.hpp:3180
SparseMatrix< double > SparseDMatrix
Unbounded sparse matrix holding floating point values of type double..
Definition: Matrix.hpp:3225
ScalarMatrix< unsigned long > ULScalarMatrix
Memory-efficient immutable matrix where all elements have the same value of type unsigned long.
Definition: Matrix.hpp:3115
IdentityMatrix< float > FIdentityMatrix
Memory-efficient immutable identity matrix with element values of type float.
Definition: Matrix.hpp:3120
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:3046
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 2x2 matrix holding unsigned integers of type unsigned long.
Definition: Matrix.hpp:3205
CMatrix< float, 2, 2 > Matrix2F
Bounded 2x2 matrix holding floating point values of type float.
Definition: Matrix.hpp:3160
ScalarMatrix< long > LScalarMatrix
Memory-efficient immutable matrix where all elements have the same value of type long.
Definition: Matrix.hpp:3110
The namespace of the Chemical Data Processing Library.
Selects a concrete temporary matrix type compatible with the matrix expression M.
Definition: TypeTraits.hpp:313
M::MatrixTemporaryType Type
The concrete temporary matrix type compatible with the matrix expression M.
Definition: TypeTraits.hpp:316
Selects a concrete temporary vector type compatible with the vector expression V.
Definition: TypeTraits.hpp:301