imate
C++/CUDA Reference
cCSRMatrix< DataType > Class Template Reference

#include <c_csr_matrix.h>

Inheritance diagram for cCSRMatrix< DataType >:
Collaboration diagram for cCSRMatrix< DataType >:

Public Member Functions

 cCSRMatrix ()
 
 cCSRMatrix (const DataType *A_data_, const LongIndexType *A_indices_, const LongIndexType *A_index_pointer_, const LongIndexType num_rows_, const LongIndexType num_columns_)
 
virtual ~cCSRMatrix ()
 
virtual FlagType is_identity_matrix () const
 Checks whether the matrix is identity. More...
 
LongIndexType get_nnz () const
 Returns the number of non-zero elements of the sparse matrix. More...
 
virtual void dot (const DataType *vector, DataType *product)
 
virtual void dot_plus (const DataType *vector, const DataType alpha, DataType *product)
 
virtual void transpose_dot (const DataType *vector, DataType *product)
 
virtual void transpose_dot_plus (const DataType *vector, const DataType alpha, DataType *product)
 
- Public Member Functions inherited from cMatrix< DataType >
 cMatrix ()
 Default constructor. More...
 
virtual ~cMatrix ()
 
DataType get_eigenvalue (const DataType *known_parameters, const DataType known_eigenvalue, const DataType *inquiry_parameters) const
 This virtual function is implemented from its pure virtual function of the base class. In this class, this functio has no use and was only implemented so that this class be able to be instantiated (due to the pure virtual function). More...
 
- Public Member Functions inherited from cLinearOperator< DataType >
 cLinearOperator ()
 Default constructor. More...
 
 cLinearOperator (const LongIndexType num_rows_, const LongIndexType num_columns_)
 Constructor with setting num_rows and num_columns. More...
 
virtual ~cLinearOperator ()
 
LongIndexType get_num_rows () const
 
LongIndexType get_num_columns () const
 
void set_parameters (DataType *parameters_)
 Sets the scalar parameter this->parameters. Parameter is initialized to NULL. However, before calling dot or transpose_dot functions, the parameters must be set. More...
 
IndexType get_num_parameters () const
 
FlagType is_eigenvalue_relation_known () const
 Returns a flag that determines whether a relation between the parameters of the operator and its eigenvalue(s) is known. More...
 

Protected Attributes

const DataType * A_data
 
const LongIndexTypeA_indices
 
const LongIndexTypeA_index_pointer
 
- Protected Attributes inherited from cLinearOperator< DataType >
const LongIndexType num_rows
 
const LongIndexType num_columns
 
FlagType eigenvalue_relation_known
 
DataType * parameters
 
IndexType num_parameters
 

Detailed Description

template<typename DataType>
class cCSRMatrix< DataType >

Definition at line 29 of file c_csr_matrix.h.

Constructor & Destructor Documentation

◆ cCSRMatrix() [1/2]

template<typename DataType >
cCSRMatrix< DataType >::cCSRMatrix

Definition at line 26 of file c_csr_matrix.cpp.

26  :
27  A_data(NULL),
28  A_indices(NULL),
29  A_index_pointer(NULL)
30 {
31 }
const LongIndexType * A_index_pointer
Definition: c_csr_matrix.h:72
const DataType * A_data
Definition: c_csr_matrix.h:70
const LongIndexType * A_indices
Definition: c_csr_matrix.h:71

◆ cCSRMatrix() [2/2]

template<typename DataType >
cCSRMatrix< DataType >::cCSRMatrix ( const DataType *  A_data_,
const LongIndexType A_indices_,
const LongIndexType A_index_pointer_,
const LongIndexType  num_rows_,
const LongIndexType  num_columns_ 
)

Definition at line 39 of file c_csr_matrix.cpp.

44  :
45 
46  // Base class constructor
47  cLinearOperator<DataType>(num_rows_, num_columns_),
48 
49  // Initializer list
50  A_data(A_data_),
51  A_indices(A_indices_),
52  A_index_pointer(A_index_pointer_)
53 {
54 }
Base class for linear operators. This class serves as interface for all derived classes.

◆ ~cCSRMatrix()

template<typename DataType >
cCSRMatrix< DataType >::~cCSRMatrix
virtual

Definition at line 62 of file c_csr_matrix.cpp.

63 {
64 }

Member Function Documentation

◆ dot()

template<typename DataType >
void cCSRMatrix< DataType >::dot ( const DataType *  vector,
DataType *  product 
)
virtual

Implements cLinearOperator< DataType >.

Reimplemented in cuCSRMatrix< DataType >.

Definition at line 138 of file c_csr_matrix.cpp.

141 {
143  this->A_data,
144  this->A_indices,
145  this->A_index_pointer,
146  vector,
147  this->num_rows,
148  product);
149 }
const LongIndexType num_rows
static void csr_matvec(const DataType *A_data, const LongIndexType *A_column_indices, const LongIndexType *A_index_pointer, const DataType *b, const LongIndexType num_rows, DataType *c)
Computes where is compressed sparse row (CSR) matrix and is a dense vector. The output is a dense...

References cMatrixOperations< DataType >::csr_matvec().

Here is the call graph for this function:

◆ dot_plus()

template<typename DataType >
void cCSRMatrix< DataType >::dot_plus ( const DataType *  vector,
const DataType  alpha,
DataType *  product 
)
virtual

Implements cMatrix< DataType >.

Reimplemented in cuCSRMatrix< DataType >.

Definition at line 157 of file c_csr_matrix.cpp.

161 {
163  this->A_data,
164  this->A_indices,
165  this->A_index_pointer,
166  vector,
167  alpha,
168  this->num_rows,
169  product);
170 }
static void csr_matvec_plus(const DataType *A_data, const LongIndexType *A_column_indices, const LongIndexType *A_index_pointer, const DataType *b, const DataType alpha, const LongIndexType num_rows, DataType *c)
Computes where is compressed sparse row (CSR) matrix and is a dense vector. The output is a dense...

References cMatrixOperations< DataType >::csr_matvec_plus().

Here is the call graph for this function:

◆ get_nnz()

template<typename DataType >
LongIndexType cCSRMatrix< DataType >::get_nnz

Returns the number of non-zero elements of the sparse matrix.

The nnz of a CSR matrix can be obtained from the last element of A_index_pointer. The size of array A_index_pointer is one plus the number of rows of the matrix.

Returns
The nnz of the matrix.

Definition at line 127 of file c_csr_matrix.cpp.

128 {
129  return this->A_index_pointer[this->num_rows];
130 }

◆ is_identity_matrix()

template<typename DataType >
FlagType cCSRMatrix< DataType >::is_identity_matrix
virtual

Checks whether the matrix is identity.

The identity check is primarily performed in the cAffineMatrixFunction class.

Returns
Returns 1 if the input matrix is identity, and 0 otherwise.
See also
cAffineMatrixFunction

Implements cMatrix< DataType >.

Definition at line 81 of file c_csr_matrix.cpp.

82 {
83  FlagType matrix_is_identity = 1;
84  LongIndexType index_pointer;
85  LongIndexType column;
86 
87  // Check matrix element-wise
88  for (LongIndexType row=0; row < this->num_rows; ++row)
89  {
90  for (index_pointer=this->A_index_pointer[row];
91  index_pointer < this->A_index_pointer[row+1];
92  ++index_pointer)
93  {
94  column = this->A_indices[index_pointer];
95 
96  if ((row == column) && \
97  (this->A_data[index_pointer] != 1.0))
98  {
99  matrix_is_identity = 0;
100  return matrix_is_identity;
101  }
102  else if (this->A_data[index_pointer] != 0.0)
103  {
104  matrix_is_identity = 0;
105  return matrix_is_identity;
106  }
107  }
108  }
109 
110  return matrix_is_identity;
111 }
int LongIndexType
Definition: types.h:60
int FlagType
Definition: types.h:68

◆ transpose_dot()

template<typename DataType >
void cCSRMatrix< DataType >::transpose_dot ( const DataType *  vector,
DataType *  product 
)
virtual

Implements cLinearOperator< DataType >.

Reimplemented in cuCSRMatrix< DataType >.

Definition at line 178 of file c_csr_matrix.cpp.

181 {
183  this->A_data,
184  this->A_indices,
185  this->A_index_pointer,
186  vector,
187  this->num_rows,
188  this->num_columns,
189  product);
190 }
const LongIndexType num_columns
static void csr_transposed_matvec(const DataType *A_data, const LongIndexType *A_column_indices, const LongIndexType *A_index_pointer, const DataType *b, const LongIndexType num_rows, const LongIndexType num_columns, DataType *c)
Computes where is compressed sparse row (CSR) matrix and is a dense vector. The output is a dense...

References cMatrixOperations< DataType >::csr_transposed_matvec().

Here is the call graph for this function:

◆ transpose_dot_plus()

template<typename DataType >
void cCSRMatrix< DataType >::transpose_dot_plus ( const DataType *  vector,
const DataType  alpha,
DataType *  product 
)
virtual

Implements cMatrix< DataType >.

Reimplemented in cuCSRMatrix< DataType >.

Definition at line 198 of file c_csr_matrix.cpp.

202 {
204  this->A_data,
205  this->A_indices,
206  this->A_index_pointer,
207  vector,
208  alpha,
209  this->num_rows,
210  product);
211 }
static void csr_transposed_matvec_plus(const DataType *A_data, const LongIndexType *A_column_indices, const LongIndexType *A_index_pointer, const DataType *b, const DataType alpha, const LongIndexType num_rows, DataType *c)
Computes where is compressed sparse row (CSR) matrix and is a dense vector. The output is a dense...

References cMatrixOperations< DataType >::csr_transposed_matvec_plus().

Here is the call graph for this function:

Member Data Documentation

◆ A_data

template<typename DataType >
const DataType* cCSRMatrix< DataType >::A_data
protected

Definition at line 70 of file c_csr_matrix.h.

◆ A_index_pointer

template<typename DataType >
const LongIndexType* cCSRMatrix< DataType >::A_index_pointer
protected

Definition at line 72 of file c_csr_matrix.h.

◆ A_indices

template<typename DataType >
const LongIndexType* cCSRMatrix< DataType >::A_indices
protected

Definition at line 71 of file c_csr_matrix.h.


The documentation for this class was generated from the following files: