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_