MatrixCSR.h
Go to the documentation of this file.
99 static_assert(std::is_floating_point<T>::value, "MatrixCSR only can be instantiated with floating point types");
145 MatrixCSR(const std::initializer_list<std::initializer_list<T>>& list, T epsilon = std::numeric_limits<T>::epsilon());
198 void Compress(const std::initializer_list<std::initializer_list<T>>& list, T epsilon = std::numeric_limits<T>::epsilon());
208 void Compress(const MatrixExpression<T, E>& other, T epsilon = std::numeric_limits<T>::epsilon());
234 bool IsSimilar(const MatrixCSR& other, double tol = std::numeric_limits<double>::epsilon()) const;
Vector expression for CSR matrix-vector multiplication.
Definition: MatrixCSR.h:31
void ISub(const T &s)
Subtracts input scalar from this matrix.
Definition: MatrixCSR-Impl.h:662
bool operator!=(const MatrixCSR &m) const
Returns true if is not equal to m.
Definition: MatrixCSR-Impl.h:924
MatrixCSR< U > CastTo() const
Type-casts to different value-typed matrix.
Definition: MatrixCSR-Impl.h:808
void Clear()
Clears the matrix and make it zero-dimensional.
Definition: MatrixCSR-Impl.h:142
const T & NonZero(size_t i) const
Returns i-th non-zero element.
Definition: MatrixCSR-Impl.h:432
Matrix expression for CSR matrix-matrix multiplication.
Definition: MatrixCSR.h:60
const size_t * RowPointersData() const
Returns constant pointer of the row pointers data.
Definition: MatrixCSR-Impl.h:468
T AbsMax() const
Returns absolute maximum among all elements.
Definition: MatrixCSR-Impl.h:771
MatrixCSR & operator+=(const T &s)
Addition assignment with input scalar.
Definition: MatrixCSR-Impl.h:855
bool IsEqual(const MatrixCSR &other) const
Definition: MatrixCSR-Impl.h:328
MatrixCSRMatrixMul(const MatrixCSR< T > &m1, const ME &m2)
Definition: MatrixCSR-Impl.h:58
size_t Cols() const
Number of columns.
Definition: MatrixCSR-Impl.h:77
std::vector< size_t > IndexContainerType
Definition: MatrixCSR.h:116
void IMul(const T &s)
Multiplies input scalar to this matrix.
Definition: MatrixCSR-Impl.h:674
const size_t * ColumnIndicesData() const
Returns constant pointer of the column indices data.
Definition: MatrixCSR-Impl.h:474
IndexIterator ColumnIndicesEnd()
Returns the end iterator of the column indices.
Definition: MatrixCSR-Impl.h:540
IndexContainerType::const_iterator ConstIndexIterator
Definition: MatrixCSR.h:118
T Min() const
Returns minimum among all elements.
Definition: MatrixCSR-Impl.h:717
T * NonZeroData()
Returns pointer of the non-zero elements data.
Definition: MatrixCSR-Impl.h:456
void IDiv(const T &s)
Divides this matrix with input scalar.
Definition: MatrixCSR-Impl.h:688
const size_t & RowPointer(size_t i) const
Returns i-th row pointer.
Definition: MatrixCSR-Impl.h:444
MatrixCSR Div(const T &s) const
Returns this matrix / input scalar.
Definition: MatrixCSR-Impl.h:602
bool IsSimilar(const MatrixCSR &other, double tol=std::numeric_limits< double >::epsilon()) const
Returns true if this matrix is similar to the input matrix within the given tolerance.
Definition: MatrixCSR-Impl.h:365
T operator[](size_t i) const
Returns vector element at i.
Definition: MatrixCSR-Impl.h:38
Size2 size() const
Returns the size of this matrix.
Definition: MatrixCSR-Impl.h:408
void Set(const T &s)
Sets whole matrix with input scalar.
Definition: MatrixCSR-Impl.h:152
MatrixCSR Add(const T &s) const
Returns this matrix + input scalar.
Definition: MatrixCSR-Impl.h:552
MatrixCSR Mul(const T &s) const
Returns this matrix * input scalar.
Definition: MatrixCSR-Impl.h:580
void AddElement(size_t i, size_t j, const T &value)
Adds non-zero element to (i, j).
Definition: MatrixCSR-Impl.h:243
void SetElement(size_t i, size_t j, const T &value)
Sets non-zero element to (i, j).
Definition: MatrixCSR-Impl.h:307
IndexContainerType::iterator IndexIterator
Definition: MatrixCSR.h:117
size_t Rows() const
Returns number of rows of this matrix.
Definition: MatrixCSR-Impl.h:414
Definition: pybind11Utils.h:24
bool IsSquare() const
Returns true if this matrix is a square matrix.
Definition: MatrixCSR-Impl.h:402
Size2 size() const
Size of the matrix.
Definition: MatrixCSR-Impl.h:65
IndexIterator ColumnIndicesBegin()
Returns the begin iterator of the column indices.
Definition: MatrixCSR-Impl.h:528
size_t NumberOfNonZeros() const
Returns the number of non-zero elements.
Definition: MatrixCSR-Impl.h:426
MatrixCSR Sub(const T &s) const
Returns this matrix - input scalar.
Definition: MatrixCSR-Impl.h:566
MatrixCSRVectorMul(const MatrixCSR< T > &m, const VE &v)
Definition: MatrixCSR-Impl.h:20
NonZeroIterator NonZeroEnd()
Returns the end iterator of the non-zero elements.
Definition: MatrixCSR-Impl.h:492
void Compress(const std::initializer_list< std::initializer_list< T >> &list, T epsilon=std::numeric_limits< T >::epsilon())
Compresses given initializer list list into a sparse matrix.
Definition: MatrixCSR-Impl.h:176
IndexIterator RowPointersEnd()
Returns the end iterator of the row pointers.
Definition: MatrixCSR-Impl.h:516
MatrixCSR RMul(const T &s) const
Returns input scalar * this matrix.
Definition: MatrixCSR-Impl.h:636
typename NonZeroContainerType::iterator NonZeroIterator
Definition: MatrixCSR.h:113
MatrixCSR & operator*=(const T &s)
Multiplication assignment with input scalar.
Definition: MatrixCSR-Impl.h:883
static MatrixCSR< T > MakeIdentity(size_t m)
Makes a m x m matrix with all diagonal elements to 1, and other elements to 0.
Definition: MatrixCSR-Impl.h:930
typename NonZeroContainerType::const_iterator ConstNonZeroIterator
Definition: MatrixCSR.h:114
MatrixCSR RAdd(const T &s) const
Returns input scalar + this matrix.
Definition: MatrixCSR-Impl.h:610
const MatrixCSRMatrixMul< T, ME > & operator()() const
Returns actual implementation (the subclass).
Definition: MatrixExpression-Impl.h:34
Definition: MatrixCSR.h:101
void Reserve(size_t rows, size_t cols, size_t numNonZeros)
Reserves memory space of this matrix.
Definition: MatrixCSR-Impl.h:167
void IAdd(const T &s)
Adds input scalar to this matrix.
Definition: MatrixCSR-Impl.h:650
T Max() const
Returns maximum among all elements.
Definition: MatrixCSR-Impl.h:736
size_t Rows() const
Number of rows.
Definition: MatrixCSR-Impl.h:71
size_t Cols() const
Returns number of columns of this matrix.
Definition: MatrixCSR-Impl.h:420
MatrixCSR & operator=(const E &m)
Compresses input (dense) matrix expression into a sparse matrix.
MatrixCSR & operator/=(const T &s)
Division assignment with input scalar.
Definition: MatrixCSR-Impl.h:898
MatrixCSR RDiv(const T &s) const
Returns input matrix / this scalar.
Definition: MatrixCSR-Impl.h:642
const size_t & ColumnIndex(size_t i) const
Returns i-th column index.
Definition: MatrixCSR-Impl.h:450
MatrixCSR & operator-=(const T &s)
Subtraction assignment with input scalar.
Definition: MatrixCSR-Impl.h:869
size_t size() const
Size of the vector.
Definition: MatrixCSR-Impl.h:32
MatrixCSR()
Constructs an empty matrix.
Definition: MatrixCSR-Impl.h:111
MatrixCSR RSub(const T &s) const
Returns input scalar - this matrix.
Definition: MatrixCSR-Impl.h:622
T Avg() const
Returns average of all elements.
Definition: MatrixCSR-Impl.h:711
bool operator==(const MatrixCSR &m) const
Returns true if is equal to m.
Definition: MatrixCSR-Impl.h:918
NonZeroIterator NonZeroBegin()
Returns the begin iterator of the non-zero elements.
Definition: MatrixCSR-Impl.h:480
T AbsMin() const
Returns absolute minimum among all elements.
Definition: MatrixCSR-Impl.h:755
void AddRow(const NonZeroContainerType &nonZeros, const IndexContainerType &columnIndices)
Definition: MatrixCSR-Impl.h:278
IndexIterator RowPointersBegin()
Returns the begin iterator of the row pointers.
Definition: MatrixCSR-Impl.h:504
std::vector< double > NonZeroContainerType
Definition: MatrixCSR.h:112