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

#include <cu_csc_affine_matrix_function.h>

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

Public Member Functions

 cuCSCAffineMatrixFunction (const DataType *A_data_, const LongIndexType *A_indices_, const LongIndexType *A_index_pointer_, const LongIndexType num_rows_, const LongIndexType num_columns_, const int num_gpu_devices_)
 Constructor. Matrix B is assumed to be the identity matrix. More...
 
 cuCSCAffineMatrixFunction (const DataType *A_data_, const LongIndexType *A_indices_, const LongIndexType *A_index_pointer_, const LongIndexType num_rows_, const LongIndexType num_colums_, const DataType *B_data_, const LongIndexType *B_indices_, const LongIndexType *B_index_pointer_, const int num_gpu_devices_)
 
virtual ~cuCSCAffineMatrixFunction ()
 
virtual void dot (const DataType *vector, DataType *product)
 Computes the matrix vector product: More...
 
virtual void transpose_dot (const DataType *vector, DataType *product)
 Computes the matrix vector product: More...
 
- Public Member Functions inherited from cuAffineMatrixFunction< DataType >
 cuAffineMatrixFunction ()
 Constructor. More...
 
virtual ~cuAffineMatrixFunction ()
 Virtual destructor. More...
 
void set_parameters (DataType *t)
 
DataType get_eigenvalue (const DataType *known_parameters, const DataType known_eigenvalue, const DataType *inquiry_parameters) const
 This function defines an analytic relationship between a given set of parameters and the corresponding eigenvalue of the operator. Namely, given a set of parameters and a known eigenvalue of the operator for that specific set of parameters, this function obtains the eigenvalue of the operator for an other given set of parameters. More...
 
- Public Member Functions inherited from cuLinearOperator< DataType >
 cuLinearOperator ()
 
 cuLinearOperator (int num_gpu_devices_)
 Constructor with setting num_rows and num_columns. More...
 
virtual ~cuLinearOperator ()
 
cublasHandle_t get_cublas_handle () const
 This function returns a reference to the cublasHandle_t object. The object will be created, if it is not created already. 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

cuCSCMatrix< DataType > A
 
cuCSCMatrix< DataType > B
 
- Protected Attributes inherited from cuAffineMatrixFunction< DataType >
bool B_is_identity
 
- Protected Attributes inherited from cuLinearOperator< DataType >
int num_gpu_devices
 
bool copied_host_to_device
 
cublasHandle_t * cublas_handle
 
cusparseHandle_t * cusparse_handle
 
- Protected Attributes inherited from cLinearOperator< DataType >
const LongIndexType num_rows
 
const LongIndexType num_columns
 
FlagType eigenvalue_relation_known
 
DataType * parameters
 
IndexType num_parameters
 

Additional Inherited Members

- Protected Member Functions inherited from cuAffineMatrixFunction< DataType >
void _add_scaled_vector (const DataType *input_vector, const LongIndexType vector_size, const DataType scale, DataType *output_vector) const
 Performs the operation \( \boldsymbol{c} = \boldsymbol{c} + \alpha * \boldsymbol{b} \), where \( \boldsymbol{b} \) is an input vector scaled by \( \alpha \) and \( \boldsymbol{c} \) it the output vector. More...
 
- Protected Member Functions inherited from cuLinearOperator< DataType >
int query_gpu_devices () const
 Before any numerical computation, this method chechs if any gpu device is available on the machine, or notifies the user if nothing was found. More...
 
void initialize_cublas_handle ()
 Creates a cublasHandle_t object, if not created already. More...
 
void initialize_cusparse_handle ()
 Creates a cusparseHandle_t object, if not created already. More...
 

Detailed Description

template<typename DataType>
class cuCSCAffineMatrixFunction< DataType >

Definition at line 30 of file cu_csc_affine_matrix_function.h.

Constructor & Destructor Documentation

◆ cuCSCAffineMatrixFunction() [1/2]

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

Constructor. Matrix B is assumed to be the identity matrix.

Definition at line 30 of file cu_csc_affine_matrix_function.cu.

36  :
37 
38  // Base class constructor
39  cLinearOperator<DataType>(num_rows_, num_columns_),
40 
41  // Initializer list
42  A(A_data_, A_indices_, A_index_pointer_, num_rows_, num_columns_,
43  num_gpu_devices_)
44 {
45  // This constructor is called assuming B is identity
46  this->B_is_identity = true;
47 
48  // When B is identity, the eigenvalues of A+tB are known for any t
49  this->eigenvalue_relation_known = 1;
50 
51  // Set gpu device
53 }
Base class for linear operators. This class serves as interface for all derived classes.
FlagType eigenvalue_relation_known
void initialize_cusparse_handle()
Creates a cusparseHandle_t object, if not created already.

References cuAffineMatrixFunction< DataType >::B_is_identity, cLinearOperator< DataType >::eigenvalue_relation_known, and cuLinearOperator< DataType >::initialize_cusparse_handle().

Here is the call graph for this function:

◆ cuCSCAffineMatrixFunction() [2/2]

template<typename DataType >
cuCSCAffineMatrixFunction< DataType >::cuCSCAffineMatrixFunction ( const DataType *  A_data_,
const LongIndexType A_indices_,
const LongIndexType A_index_pointer_,
const LongIndexType  num_rows_,
const LongIndexType  num_colums_,
const DataType *  B_data_,
const LongIndexType B_indices_,
const LongIndexType B_index_pointer_,
const int  num_gpu_devices_ 
)

Definition at line 61 of file cu_csc_affine_matrix_function.cu.

70  :
71 
72  // Base class constructor
73  cLinearOperator<DataType>(num_rows_, num_columns_),
74 
75  // Initializer list
76  A(A_data_, A_indices_, A_index_pointer_, num_rows_, num_columns_,
77  num_gpu_devices_),
78  B(B_data_, B_indices_, B_index_pointer_, num_rows_, num_columns_,
79  num_gpu_devices_)
80 {
81  // Matrix B is assumed to be non-zero. Check if it is identity or generic
82  if (this->B.is_identity_matrix())
83  {
84  this->B_is_identity = true;
85  this->eigenvalue_relation_known = 1;
86  }
87 
88  // Set gpu device
90 }

References cuCSCAffineMatrixFunction< DataType >::B, cuAffineMatrixFunction< DataType >::B_is_identity, cLinearOperator< DataType >::eigenvalue_relation_known, and cuLinearOperator< DataType >::initialize_cusparse_handle().

Here is the call graph for this function:

◆ ~cuCSCAffineMatrixFunction()

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

Definition at line 98 of file cu_csc_affine_matrix_function.cu.

99 {
100 }

Member Function Documentation

◆ dot()

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

Computes the matrix vector product:

\[ \boldsymbol{c} = (\mathbf{A} + t \mathbf{B}) \boldsymbol{b}. \]

Parameters
[in]vectorThe input vector :math:\\boldsymbol{b} is given by vector. If \( \mathbf{A} \) and \( \mathbf{B} \) are \( m \times n \) matrices, the length of input c vector is n.
[out]productThe output of the product, \( \boldsymbol{c} \), is written in-place into this array. Let
m be the number of rows of \( \mathbf{A} \) and \( \mathbf{B} \), then, the output vector product is 1D column array of length m.

Implements cLinearOperator< DataType >.

Definition at line 124 of file cu_csc_affine_matrix_function.cu.

127 {
128  // Matrix A times vector
129  this->A.dot(vector, product);
130  LongIndexType min_vector_size;
131 
132  // Matrix B times vector to be added to the product
133  if (this->B_is_identity)
134  {
135  // Check parameter is set
136  ASSERT((this->parameters != NULL), "Parameter is not set.");
137 
138  // Find minimum of the number of rows and columns
139  min_vector_size = \
140  (this->num_rows < this->num_columns) ? \
141  this->num_rows : this->num_columns;
142 
143  // Adding input vector to product
144  this->_add_scaled_vector(vector, min_vector_size,
145  this->parameters[0], product);
146  }
147  else
148  {
149  // Check parameter is set
150  ASSERT((this->parameters != NULL), "Parameter is not set.");
151 
152  // Adding parameter times B times input vector to the product
153  this->B.dot_plus(vector, this->parameters[0], product);
154  }
155 }
DataType * parameters
const LongIndexType num_rows
const LongIndexType num_columns
void _add_scaled_vector(const DataType *input_vector, const LongIndexType vector_size, const DataType scale, DataType *output_vector) const
Performs the operation , where is an input vector scaled by and it the output vector.
#define ASSERT(condition, message)
Definition: debugging.h:20
int LongIndexType
Definition: types.h:60

References ASSERT.

◆ transpose_dot()

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

Computes the matrix vector product:

\[ \boldsymbol{c} = (\mathbf{A} + t \mathbf{B})^{\intercal} \boldsymbol{b}. \]

Parameters
[in]vectorThe input vector \( \boldsymbol{b} \) is given by vector. If \( \mathbf{A} \) and \( \mathbf{B} \) are \( m \times n \) matrices, the length of input vector is n.
[out]productThe output of the product, \( \boldsymbol{c} \), is written in-place into this array. Let n be the number of columns of \( \mathbf{A} \) and \( \mathbf{B} \), then, the output vector product is 1D column array of length m.

Implements cLinearOperator< DataType >.

Definition at line 180 of file cu_csc_affine_matrix_function.cu.

183 {
184  // Matrix A times vector
185  this->A.transpose_dot(vector, product);
186  LongIndexType min_vector_size;
187 
188  // Matrix B times vector to be added to the product
189  if (this->B_is_identity)
190  {
191  // Check parameter is set
192  ASSERT((this->parameters != NULL), "Parameter is not set.");
193 
194  // Find minimum of the number of rows and columns
195  min_vector_size = \
196  (this->num_rows < this->num_columns) ? \
197  this->num_rows : this->num_columns;
198 
199  // Adding input vector to product
200  this->_add_scaled_vector(vector, min_vector_size,
201  this->parameters[0], product);
202  }
203  else
204  {
205  // Check parameter is set
206  ASSERT((this->parameters != NULL), "Parameter is not set.");
207 
208  // Adding "parameter * B * input vector" to the product
209  this->B.transpose_dot_plus(vector, this->parameters[0], product);
210  }
211 }

References ASSERT.

Member Data Documentation

◆ A

template<typename DataType >
cuCSCMatrix<DataType> cuCSCAffineMatrixFunction< DataType >::A
protected

Definition at line 67 of file cu_csc_affine_matrix_function.h.

◆ B

template<typename DataType >
cuCSCMatrix<DataType> cuCSCAffineMatrixFunction< DataType >::B
protected

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