10 #ifndef SPARSE_MATRIX_OPERATOR_H_
11 #define SPARSE_MATRIX_OPERATOR_H_
20 template<
class T>
class SGVector;
21 template<
class T>
class SGSparseMatrix;
43 m_ptr(new int32_t*[num_rows]())
47 index_t current_index=row_offsets[i];
48 index_t new_index=row_offsets[i+1];
49 index_t length_row=(new_index-current_index);
51 m_ptr[i]=
new int32_t[length_row+1]();
52 m_ptr[i][0]=length_row;
54 for (
index_t j=1; j<=length_row; ++j)
55 m_ptr[i][j]=column_indices[current_index++];
73 SG_SPRINT(
"Row number %d. Number of Non-zeros %d. Colums ", i, nnzs);
101 typedef bool supports_complex128_t;
155 template<
class Scalar>
158 REQUIRE(m_operator.sparse_matrix,
"Matrix is not initialized!\n");
162 vector* rows=SG_MALLOC(vector, m_operator.num_vectors);
164 for (
index_t i=0; i<m_operator.num_vectors; ++i)
166 entry* features=SG_MALLOC(entry, m_operator[i].num_feat_entries);
167 for (
index_t j=0; j<m_operator[i].num_feat_entries; ++j)
169 features[j].feat_index=m_operator[i].features[j].feat_index;
170 features[j].entry=
static_cast<Scalar
>(m_operator[i].features[j].entry);
172 rows[i].features=features;
173 rows[i].num_feat_entries=m_operator[i].num_feat_entries;
187 return "SparseMatrixOperator";
200 #endif // SPARSE_MATRIX_OPERATOR_H_
SparsityStructure * get_sparsity_structure(int64_t power=1) const
template class SGSparseMatrix
SparsityStructure(index_t *row_offsets, index_t *column_indices, index_t num_rows)
SGSparseMatrix< T > get_matrix_operator() const
virtual SGVector< T > get_diagonal() const
virtual const char * get_name() const
virtual SGVector< T > apply(SGVector< T > b) const
index_t num_features
total number of features
SGSparseVector< T > * sparse_matrix
array of sparse vectors of size num_vectors
virtual void set_diagonal(SGVector< T > diag)
Struct that represents the sparsity structure of the Sparse Matrix in CRS. Implementation has been ad...
all of classes and functions are contained in the shogun namespace
Class that represents a sparse-matrix linear operator. It computes matrix-vector product in its appl...
template class SGSparseVectorEntry
template class SGSparseVector The assumtion is that the stored SGSparseVectorEntry* vector is orde...
void display_sparsity_structure()
Abstract base class that represents a matrix linear operator. It provides an interface to computes ma...
index_t num_vectors
total number of vectors