tensor-0.1.0
|
A sparse matrix. More...
Public Member Functions | |
index | columns () const |
Number of columns. | |
index | dimension (int which) const |
Length of a given Sparse matrix index. More... | |
const Indices & | dimensions () const |
Return Sparse matrix dimensions. More... | |
bool | is_empty () const |
Empty matrix? | |
index | length () const |
Number of nonzero elements. More... | |
elt_t | operator() (index row, index col) const |
Return an element of the sparse matrix. More... | |
Sparse & | operator= (const Sparse< elt_t > &s) |
Assignment operator. More... | |
index | rows () const |
Number of rows. More... | |
Sparse () | |
Build an empty matrix. More... | |
Sparse (index rows, index cols, index nonzero=0) | |
Create a matrix with all elements set to zero. More... | |
Sparse (const Indices &row_indices, const Indices &column_indices, const Vector< elt_t > &data, index rows=0, index columns=0) | |
Create a sparse matrix from the coordinates and values. More... | |
Sparse (const Tensor< elt_t > &tensor) | |
Convert a tensor to sparse form. More... | |
Sparse (const Sparse< elt_t > &s) | |
Copy constructor. More... | |
Static Public Member Functions | |
static Sparse< elt_t > | eye (index rows, index cols) |
Identity matrix in sparse form. More... | |
static Sparse< elt_t > | eye (index rows) |
Identity matrix in sparse form. More... | |
static Sparse< elt_t > | random (index rows, index columns, double density=0.2) |
Return a random sparse matrix. More... | |
Data Fields | |
Indices | column_ |
Gives for each data_ entry the column in the matrix. More... | |
Vector< elt_t > | data_ |
The single data entries. More... | |
Indices | dims_ |
The dimensions (rows and columns) of the sparse matrix. More... | |
Indices | row_start_ |
Gives for each row of the matrix at which index the column_/data_ entries start. More... | |
A sparse matrix.
A sparse matrix is a compact representation of two-dimensional tensors that have a lot of zero elements. Our implementation behaves much like Matlab's sparse matrices, in the sense that one can build them up from 2D tensors, preallocate them, perform matrix multiplication with mmult(), etc, etc.
tensor::Sparse< elt >::Sparse | ( | ) |
Build an empty matrix.
tensor::Sparse< elt >::Sparse | ( | index | rows, |
index | cols, | ||
index | nonzero = 0 |
||
) |
Create a matrix with all elements set to zero.
tensor::Sparse< elt >::Sparse | ( | const Indices & | row_indices, |
const Indices & | column_indices, | ||
const Vector< elt_t > & | data, | ||
index | rows = 0 , |
||
index | columns = 0 |
||
) |
Create a sparse matrix from the coordinates and values.
|
explicit |
Convert a tensor to sparse form.
tensor::Sparse< elt >::Sparse | ( | const Sparse< elt_t > & | s | ) |
Copy constructor.
index tensor::Sparse< elt >::dimension | ( | int | which | ) | const |
Length of a given Sparse matrix index.
|
inline |
|
static |
Identity matrix in sparse form.
|
inlinestatic |
|
inline |
elt_t tensor::Sparse< elt >::operator() | ( | index | row, |
index | col | ||
) | const |
Return an element of the sparse matrix.
Sparse& tensor::Sparse< elt >::operator= | ( | const Sparse< elt_t > & | s | ) |
Assignment operator.
|
static |
Return a random sparse matrix.
|
inline |
Indices tensor::Sparse< elt >::column_ |
Vector<elt_t> tensor::Sparse< elt >::data_ |
Indices tensor::Sparse< elt >::dims_ |
Indices tensor::Sparse< elt >::row_start_ |