18#include "../_definitions/definitions.h"
19#if defined(USE_OPENMP) && (USE_OPENMP == 1)
22#include "../_c_arithmetics/c_arithmetics.h"
23#include "../_c_basic_algebra/c_matrix_operations.h"
33template <
typename DataType>
67template <
typename DataType>
69 const DataType* A_data_,
78 cMatrix<DataType>(A_is_symmetric_),
82 A_indices(A_indices_),
83 A_index_pointer(A_index_pointer_)
95template <
typename DataType>
114template <
typename DataType>
120 DataType matrix_element;
121 const DataType diagonal = 1.0;
122 const DataType off_diagonal = 0.0;
125 #if defined(USE_OPENMP) && (USE_OPENMP == 1)
126 #pragma omp parallel for \
128 if (!omp_in_parallel()) \
130 shared(matrix_is_identity, diagonal, off_diagonal) \
131 private(index_pointer, row, matrix_element)
133 for (
LongIndexType column=0; column < this->num_columns; ++column)
135 if (matrix_is_identity)
137 for (index_pointer=this->A_index_pointer[column];
138 index_pointer < this->A_index_pointer[column+1];
141 row = this->A_indices[index_pointer];
143 if (!((this->A_is_symmetric) && (column >= row)))
145 matrix_element = this->A_data[index_pointer];
147 if (((row == column) && \
150 ((row != column) && \
154 #if defined(USE_OPENMP) && (USE_OPENMP == 1)
155 #pragma omp atomic write
157 matrix_is_identity = 0;
166 return matrix_is_identity;
182template <
typename DataType>
185 return this->A_index_pointer[this->num_columns];
210template <
typename DataType>
212 const DataType* vector,
218 this->A_index_pointer,
219 this->A_is_symmetric,
249template <
typename DataType>
251 const DataType* vector,
252 const DataType alpha,
258 this->A_index_pointer,
259 this->A_is_symmetric,
288template <
typename DataType>
290 const DataType* vector,
296 this->A_index_pointer,
326template <
typename DataType>
328 const DataType* vector,
329 const DataType alpha,
335 this->A_index_pointer,
Container for CSC matrices.
LongIndexType get_nnz() const
Returns the number of non-zero elements of the sparse matrix.
virtual void transpose_dot(const DataType *vector, DataType *product)
Transposed-matrix vector product.
virtual ~cCSCMatrix()
Destructor.
virtual void dot(const DataType *vector, DataType *product)
Matrix vector product.
virtual FlagType is_identity_matrix() const
Checks whether the matrix is identity.
virtual void dot_plus(const DataType *vector, const DataType alpha, DataType *product)
Matrix vector product written in place.
cCSCMatrix()
Default constructor.
virtual void transpose_dot_plus(const DataType *vector, const DataType alpha, DataType *product)
Transposed-matrix vector product written in place.
Base class for cLinearOperator and cuLinearOperator . This class is not templated so that both cpp an...
static void csc_transposed_matvec(const DataType *RESTRICT A_data, const LongIndexType *RESTRICT A_row_indices, const LongIndexType *RESTRICT A_index_pointer, const DataType *RESTRICT b, const LongIndexType num_columns, DataType *RESTRICT c)
Computes where is compressed sparse column (CSC) matrix and is a dense vector. The output is a de...
static void csc_transposed_matvec_plus(const DataType *RESTRICT A_data, const LongIndexType *RESTRICT A_row_indices, const LongIndexType *RESTRICT A_index_pointer, const DataType *RESTRICT b, const DataType alpha, const LongIndexType num_columns, DataType *RESTRICT c)
Computes where is compressed sparse column (CSC) matrix and is a dense vector. The output is a de...
static void csc_matvec_plus(const DataType *RESTRICT A_data, const LongIndexType *RESTRICT A_row_indices, const LongIndexType *RESTRICT A_index_pointer, const FlagType A_is_symmetric, const DataType *RESTRICT b, const DataType alpha, const LongIndexType num_columns, DataType *RESTRICT c)
Computes where is compressed sparse column (CSC) matrix and is a dense vector. The output is a de...
static void csc_matvec(const DataType *RESTRICT A_data, const LongIndexType *RESTRICT A_row_indices, const LongIndexType *RESTRICT A_index_pointer, const FlagType A_is_symmetric, const DataType *RESTRICT b, const LongIndexType num_rows, const LongIndexType num_columns, DataType *RESTRICT c)
Computes where is compressed sparse column (CSC) matrix and is a dense vector. The output is a de...
Base class for constant matrices.
bool is_equal(DataType x, DataType y)
Check if two floating point numbers are equal within a tolerance.