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

#include <c_dense_matrix.h>

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

Public Member Functions

 cDenseMatrix ()
 
 cDenseMatrix (const DataType *A_, const LongIndexType num_rows_, const LongIndexType num_columns_, const FlagType A_is_row_major_)
 
virtual ~cDenseMatrix ()
 
virtual FlagType is_identity_matrix () const
 Checks whether the matrix is identity. 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
 
const FlagType A_is_row_major
 
- 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 cDenseMatrix< DataType >

Definition at line 29 of file c_dense_matrix.h.

Constructor & Destructor Documentation

◆ cDenseMatrix() [1/2]

template<typename DataType >
cDenseMatrix< DataType >::cDenseMatrix

Definition at line 26 of file c_dense_matrix.cpp.

26  :
27  A(NULL),
29 {
30 }
const FlagType A_is_row_major
const DataType * A

◆ cDenseMatrix() [2/2]

template<typename DataType >
cDenseMatrix< DataType >::cDenseMatrix ( const DataType *  A_,
const LongIndexType  num_rows_,
const LongIndexType  num_columns_,
const FlagType  A_is_row_major_ 
)

Definition at line 38 of file c_dense_matrix.cpp.

42  :
43 
44  // Base class constructor
45  cLinearOperator<DataType>(num_rows_, num_columns_),
46 
47  // Initializer list
48  A(A_),
49  A_is_row_major(A_is_row_major_)
50 {
51 }
Base class for linear operators. This class serves as interface for all derived classes.

◆ ~cDenseMatrix()

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

Definition at line 60 of file c_dense_matrix.cpp.

61 {
62 }

Member Function Documentation

◆ dot()

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

Implements cLinearOperator< DataType >.

Reimplemented in cuDenseMatrix< DataType >.

Definition at line 122 of file c_dense_matrix.cpp.

125 {
127  this->A,
128  vector,
129  this->num_rows,
130  this->num_columns,
131  this->A_is_row_major,
132  product);
133 }
const LongIndexType num_rows
const LongIndexType num_columns
static void dense_matvec(const DataType *A, const DataType *b, const LongIndexType num_rows, const LongIndexType num_columns, const FlagType A_is_row_major, DataType *c)
Computes the matrix vector multiplication where is a dense matrix.

References cMatrixOperations< DataType >::dense_matvec().

Here is the call graph for this function:

◆ dot_plus()

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

Implements cMatrix< DataType >.

Reimplemented in cuDenseMatrix< DataType >.

Definition at line 141 of file c_dense_matrix.cpp.

145 {
147  this->A,
148  vector,
149  alpha,
150  this->num_rows,
151  this->num_columns,
152  this->A_is_row_major,
153  product);
154 }
static void dense_matvec_plus(const DataType *A, const DataType *b, const DataType alpha, const LongIndexType num_rows, const LongIndexType num_columns, const FlagType A_is_row_major, DataType *c)
Computes the operation where is a dense matrix.

References cMatrixOperations< DataType >::dense_matvec_plus().

Here is the call graph for this function:

◆ is_identity_matrix()

template<typename DataType >
FlagType cDenseMatrix< 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 79 of file c_dense_matrix.cpp.

80 {
81  FlagType matrix_is_identity = 1;
82  DataType matrix_element;
83 
84  // Check matrix element-wise
85  for (LongIndexType row=0; row < this->num_rows; ++row)
86  {
87  for (LongIndexType column=0; column < this-> num_columns; ++column)
88  {
89  // Get an element of the matrix
90  if (this->A_is_row_major)
91  {
92  matrix_element = this->A[row * this->num_columns + column];
93  }
94  else
95  {
96  matrix_element = this->A[column * this->num_rows + row];
97  }
98 
99  // Check the value of element with identity matrix
100  if ((row == column) && (matrix_element != 1.0))
101  {
102  matrix_is_identity = 0;
103  return matrix_is_identity;
104  }
105  else if (matrix_element != 0.0)
106  {
107  matrix_is_identity = 0;
108  return matrix_is_identity;
109  }
110  }
111  }
112 
113  return matrix_is_identity;
114 }
int LongIndexType
Definition: types.h:60
int FlagType
Definition: types.h:68

◆ transpose_dot()

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

Implements cLinearOperator< DataType >.

Reimplemented in cuDenseMatrix< DataType >.

Definition at line 162 of file c_dense_matrix.cpp.

165 {
167  this->A,
168  vector,
169  this->num_rows,
170  this->num_columns,
171  this->A_is_row_major,
172  product);
173 }
static void dense_transposed_matvec(const DataType *A, const DataType *b, const LongIndexType num_rows, const LongIndexType num_columns, const FlagType A_is_row_major, DataType *c)
Computes matrix vector multiplication where is dense, and is the transpose of the matrix .

References cMatrixOperations< DataType >::dense_transposed_matvec().

Here is the call graph for this function:

◆ transpose_dot_plus()

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

Implements cMatrix< DataType >.

Reimplemented in cuDenseMatrix< DataType >.

Definition at line 181 of file c_dense_matrix.cpp.

185 {
187  this->A,
188  vector,
189  alpha,
190  this->num_rows,
191  this->num_columns,
192  this->A_is_row_major,
193  product);
194 }
static void dense_transposed_matvec_plus(const DataType *A, const DataType *b, const DataType alpha, const LongIndexType num_rows, const LongIndexType num_columns, const FlagType A_is_row_major, DataType *c)
Computes where is dense, and is the transpose of the matrix .

References cMatrixOperations< DataType >::dense_transposed_matvec_plus().

Here is the call graph for this function:

Member Data Documentation

◆ A

template<typename DataType >
const DataType* cDenseMatrix< DataType >::A
protected

Definition at line 67 of file c_dense_matrix.h.

◆ A_is_row_major

template<typename DataType >
const FlagType cDenseMatrix< DataType >::A_is_row_major
protected

Definition at line 68 of file c_dense_matrix.h.


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