5 enum StorageType { eCSR, eCSC };
9 SPARSEMATRIXN(StorageType s,
unsigned m,
unsigned n,
const std::map<std::pair<unsigned, unsigned>, REAL>& values);
10 SPARSEMATRIXN(StorageType s,
unsigned m,
unsigned n, boost::shared_array<unsigned> ptr, boost::shared_array<unsigned> indices, boost::shared_array<REAL> data);
22 unsigned rows()
const {
return _rows; }
23 unsigned columns()
const {
return _columns; }
29 const unsigned* get_indices()
const {
return _indices.get(); }
30 const unsigned* get_ptr()
const {
return _ptr.get(); }
31 const REAL* get_data()
const {
return _data.get(); }
42 void set_capacities(
unsigned nnz_capacity,
unsigned ptr_capacity,
bool preserve);
43 void get_values(std::map<std::pair<unsigned, unsigned>, REAL>& values)
const;
58 unsigned*
get_ptr() {
return _ptr.get(); }
69 boost::shared_array<unsigned> _indices;
70 boost::shared_array<unsigned> _ptr;
71 boost::shared_array<REAL> _data;
75 unsigned _nnz_capacity;
76 unsigned _ptr_capacity;
80 void set(
unsigned rows,
unsigned columns,
const std::map<std::pair<unsigned, unsigned>, REAL>& values);
83 std::ostream& operator<<(std::ostream& out,
const SPARSEMATRIXN& s);
SPARSEMATRIXN & operator-=(const SPARSEMATRIXN &m)
Subtracts a sparse matrix from this one – attempts to do it in place.
Definition: SparseMatrixN.cpp:1152
SPARSEVECTORN & get_row(unsigned i, SPARSEVECTORN &row) const
Gets a row of the sparse matrix as a sparse vector.
Definition: SparseMatrixN.cpp:655
VECTORN & mult(const VECTORN &x, VECTORN &result) const
Multiplies this sparse matrix by a dense vector.
Definition: SparseMatrixN.cpp:946
SPARSEVECTORN & get_column(unsigned i, SPARSEVECTORN &column) const
Gets a column of the sparse matrix as a sparse vector.
Definition: SparseMatrixN.cpp:542
VECTORN & transpose_mult(const VECTORN &x, VECTORN &result) const
Multiplies the transpose of this sparse matrix by a dense vector.
Definition: SparseMatrixN.cpp:986
SPARSEMATRIXN & operator*=(REAL scalar)
Multiplies a sparse matrix by a scalar.
Definition: SparseMatrixN.cpp:1277
void set_column(unsigned i, const VECTORN &v)
Sets the column with the particular index.
Definition: SparseMatrixN.cpp:285
MATRIXN & to_dense(MATRIXN &m) const
Gets a dense matrix from this sparse matrix.
Definition: SparseMatrixN.cpp:1130
static SPARSEMATRIXN & outer_square(const VECTORN &g, SPARSEMATRIXN &result)
Calculates the outer product of a vector with itself and stores the result in a sparse matrix...
Definition: SparseMatrixN.cpp:1360
MATRIXN & mult_transpose(const MATRIXN &m, MATRIXN &result) const
Multiplies this matrix by the transpose of a dense matrix.
Definition: SparseMatrixN.cpp:1051
void set_capacities(unsigned nnz_capacity, unsigned ptr_capacity, bool preserve)
Sets the capacities of the arrays.
Definition: SparseMatrixN.cpp:864
SPARSEMATRIXN & operator=(const SPARSEMATRIXN &m)
Copies a sparse matrix to this.
Definition: SparseMatrixN.cpp:1228
A generic, possibly non-square matrix.
Definition: MatrixN.h:18
A sparse vector represented in 'CSR' format.
Definition: SparseVectorN.h:6
A sparse matrix.
Definition: SparseMatrixN.h:2
SPARSEMATRIXN get_sub_mat(unsigned rstart, unsigned rend, unsigned cstart, unsigned cend) const
Gets a submatrix of the sparse matrix.
Definition: SparseMatrixN.cpp:767
StorageType get_storage_type() const
Gets the storage type.
Definition: SparseMatrixN.h:46
REAL norm_inf() const
Computes the infinity norm of this sparse matrix.
Definition: SparseMatrixN.cpp:181
static SPARSEMATRIXN identity(unsigned n)
Sets up an identity matrix from a sparse matrix.
Definition: SparseMatrixN.cpp:190
A generic N-dimensional floating point vector.
Definition: VectorN.h:16
SPARSEMATRIXN & negate()
Negates this sparse matrix.
Definition: SparseMatrixN.cpp:1284
SPARSEMATRIXN & operator+=(const SPARSEMATRIXN &m)
Adds a sparse matrix to this one – attempts to do it in place.
Definition: SparseMatrixN.cpp:1190
unsigned * get_ptr()
Gets the row (column, if CSC) pointers.
Definition: SparseMatrixN.h:58
MATRIXN & transpose_mult_transpose(const MATRIXN &m, MATRIXN &result) const
Multiplies the transpose of this sparse matrix by the transpose of a dense matrix.
Definition: SparseMatrixN.cpp:1092
REAL * get_data()
Gets the array of nonzeros (sized get_nnz())
Definition: SparseMatrixN.h:61
void set_row(unsigned i, const VECTORN &v)
Sets the row with the particular index.
Definition: SparseMatrixN.cpp:369
unsigned * get_indices()
Gets the column (row, if CSC) indices of the nonzeros (sized get_nnz()
Definition: SparseMatrixN.h:49
unsigned get_nnz() const
Gets the number of nonzeros.
Definition: SparseMatrixN.h:64