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

#include <c_csc_matrix.h>

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

Public Member Functions

 cCSCMatrix ()
 
 cCSCMatrix (const DataType *A_data_, const LongIndexType *A_indices_, const LongIndexType *A_index_pointer_, const LongIndexType num_rows_, const LongIndexType num_columns_)
 
virtual ~cCSCMatrix ()
 
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 cCSCMatrix< DataType >

Definition at line 29 of file c_csc_matrix.h.

Constructor & Destructor Documentation

◆ cCSCMatrix() [1/2]

template<typename DataType >
cCSCMatrix< DataType >::cCSCMatrix

Definition at line 26 of file c_csc_matrix.cpp.

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

◆ cCSCMatrix() [2/2]

template<typename DataType >
cCSCMatrix< DataType >::cCSCMatrix ( 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_csc_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.

◆ ~cCSCMatrix()

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

Definition at line 62 of file c_csc_matrix.cpp.

63 {
64 }

Member Function Documentation

◆ dot()

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

Implements cLinearOperator< DataType >.

Reimplemented in cuCSCMatrix< DataType >.

Definition at line 139 of file c_csc_matrix.cpp.

142 {
144  this->A_data,
145  this->A_indices,
146  this->A_index_pointer,
147  vector,
148  this->num_rows,
149  this->num_columns,
150  product);
151 }
const LongIndexType num_rows
const LongIndexType num_columns
static void csc_matvec(const DataType *A_data, const LongIndexType *A_row_indices, const LongIndexType *A_index_pointer, const DataType *b, const LongIndexType num_rows, const LongIndexType num_columns, DataType *c)
Computes where is compressed sparse column (CSC) matrix and is a dense vector. The output is a de...

References cMatrixOperations< DataType >::csc_matvec().

Here is the call graph for this function:

◆ dot_plus()

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

Implements cMatrix< DataType >.

Reimplemented in cuCSCMatrix< DataType >.

Definition at line 159 of file c_csc_matrix.cpp.

163 {
165  this->A_data,
166  this->A_indices,
167  this->A_index_pointer,
168  vector,
169  alpha,
170  this->num_columns,
171  product);
172 }
static void csc_matvec_plus(const DataType *A_data, const LongIndexType *A_row_indices, const LongIndexType *A_index_pointer, const DataType *b, const DataType alpha, const LongIndexType num_columns, DataType *c)
Computes where is compressed sparse column (CSC) matrix and is a dense vector. The output is a de...

References cMatrixOperations< DataType >::csc_matvec_plus().

Here is the call graph for this function:

◆ get_nnz()

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

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

The nnz of a CSC 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 columns of the matrix.

Returns
The nnz of the matrix.

Definition at line 128 of file c_csc_matrix.cpp.

129 {
130  return this->A_index_pointer[this->num_columns];
131 }

◆ is_identity_matrix()

template<typename DataType >
FlagType cCSCMatrix< 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_csc_matrix.cpp.

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

◆ transpose_dot()

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

Implements cLinearOperator< DataType >.

Reimplemented in cuCSCMatrix< DataType >.

Definition at line 180 of file c_csc_matrix.cpp.

183 {
185  this->A_data,
186  this->A_indices,
187  this->A_index_pointer,
188  vector,
189  this->num_columns,
190  product);
191 }
static void csc_transposed_matvec(const DataType *A_data, const LongIndexType *A_row_indices, const LongIndexType *A_index_pointer, const DataType *b, const LongIndexType num_columns, DataType *c)
Computes where is compressed sparse column (CSC) matrix and is a dense vector. The output is a de...

References cMatrixOperations< DataType >::csc_transposed_matvec().

Here is the call graph for this function:

◆ transpose_dot_plus()

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

Implements cMatrix< DataType >.

Reimplemented in cuCSCMatrix< DataType >.

Definition at line 199 of file c_csc_matrix.cpp.

203 {
205  this->A_data,
206  this->A_indices,
207  this->A_index_pointer,
208  vector,
209  alpha,
210  this->num_columns,
211  product);
212 }
static void csc_transposed_matvec_plus(const DataType *A_data, const LongIndexType *A_row_indices, const LongIndexType *A_index_pointer, const DataType *b, const DataType alpha, const LongIndexType num_columns, DataType *c)
Computes where is compressed sparse column (CSC) matrix and is a dense vector. The output is a de...

References cMatrixOperations< DataType >::csc_transposed_matvec_plus().

Here is the call graph for this function:

Member Data Documentation

◆ A_data

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

Definition at line 70 of file c_csc_matrix.h.

◆ A_index_pointer

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

Definition at line 72 of file c_csc_matrix.h.

◆ A_indices

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

Definition at line 71 of file c_csc_matrix.h.


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