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>
77 cMatrix<DataType>(A_is_symmetric_),
81 A_is_row_major(A_is_row_major_)
93template <
typename DataType>
112template <
typename DataType>
116 DataType matrix_element;
117 const DataType diagonal = 1.0;
118 const DataType off_diagonal = 0.0;
121 if (this->A_is_row_major)
127 #if defined(USE_OPENMP) && (USE_OPENMP == 1)
128 #pragma omp parallel for \
130 if (!omp_in_parallel()) \
132 shared(matrix_is_identity, diagonal, off_diagonal) \
133 private(column, num_checking_columns, matrix_element)
137 if (matrix_is_identity)
139 if (this->A_is_symmetric)
142 num_checking_columns = row + 1;
146 num_checking_columns = this->num_columns;
149 for (column=0; column < num_checking_columns; ++column)
152 matrix_element = this->A[row * this->num_columns + column];
155 if (((row == column) && \
158 ((row != column) && \
162 #if defined(USE_OPENMP) && (USE_OPENMP == 1)
163 #pragma omp atomic write
165 matrix_is_identity = 0;
179 #if defined(USE_OPENMP) && (USE_OPENMP == 1)
180 #pragma omp parallel for \
182 if (!omp_in_parallel()) \
184 shared(matrix_is_identity, diagonal, off_diagonal) \
185 private(row, num_checking_rows, matrix_element)
187 for (
LongIndexType column=0; column < this-> num_columns; ++column)
189 if (matrix_is_identity)
191 if (this->A_is_symmetric)
194 num_checking_rows = column + 1;
198 num_checking_rows = this->num_rows;
201 for (row=0; row < num_checking_rows; ++row)
204 matrix_element = this->A[column * this->num_rows + row];
207 if (((row == column) && \
210 ((row != column) && \
214 #if defined(USE_OPENMP) && (USE_OPENMP == 1)
215 #pragma omp atomic write
217 matrix_is_identity = 0;
226 return matrix_is_identity;
251template <
typename DataType>
253 const DataType* vector,
261 this->A_is_row_major,
262 this->A_is_symmetric,
289template <
typename DataType>
291 const DataType* vector,
292 const DataType alpha,
301 this->A_is_row_major,
302 this->A_is_symmetric,
328template <
typename DataType>
330 const DataType* vector,
338 this->A_is_row_major,
339 this->A_is_symmetric,
367template <
typename DataType>
369 const DataType* vector,
370 const DataType alpha,
379 this->A_is_row_major,
380 this->A_is_symmetric,
Container for dense matrices.
virtual ~cDenseMatrix()
Destructor.
virtual void transpose_dot_plus(const DataType *vector, const DataType alpha, DataType *product)
Transposed-matrix vector product written in place.
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.
virtual void transpose_dot(const DataType *vector, DataType *product)
Transposed-matrix vector product.
cDenseMatrix()
Default constructor.
virtual void dot(const DataType *vector, DataType *product)
Matrix vector product.
Base class for cLinearOperator and cuLinearOperator . This class is not templated so that both cpp an...
static void dense_matvec(const DataType *RESTRICT A, const DataType *RESTRICT b, const LongIndexType num_rows, const LongIndexType num_columns, const FlagType A_is_row_major, const FlagType A_is_symmetric, DataType *RESTRICT c)
Computes the matrix vector multiplication where is a dense matrix.
static void dense_matvec_plus(const DataType *RESTRICT A, const DataType *RESTRICT b, const DataType alpha, const LongIndexType num_rows, const LongIndexType num_columns, const FlagType A_is_row_major, const FlagType A_is_symmetric, DataType *RESTRICT c)
Computes the operation where is a dense matrix.
static void dense_transposed_matvec(const DataType *RESTRICT A, const DataType *RESTRICT b, const LongIndexType num_rows, const LongIndexType num_columns, const FlagType A_is_row_major, const FlagType A_is_symmetric, DataType *RESTRICT c)
Computes matrix vector multiplication where is dense, and is the transpose of the matrix .
static void dense_transposed_matvec_plus(const DataType *RESTRICT A, const DataType *RESTRICT b, const DataType alpha, const LongIndexType num_rows, const LongIndexType num_columns, const FlagType A_is_row_major, const FlagType A_is_symmetric, DataType *RESTRICT c)
Computes where is dense, and is the transpose of the matrix .
Base class for constant matrices.
bool is_equal(DataType x, DataType y)
Check if two floating point numbers are equal within a tolerance.