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

#include <c_csc_affine_matrix_function.h>

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

Public Member Functions

 cCSCAffineMatrixFunction (const DataType *A_data_, const LongIndexType *A_indices_, const LongIndexType *A_index_pointer_, const LongIndexType num_rows_, const LongIndexType num_columns_)
 Constructor. Matrix B is assumed to be the identity matrix. More...
 
 cCSCAffineMatrixFunction (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_)
 
virtual ~cCSCAffineMatrixFunction ()
 
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 cAffineMatrixFunction< DataType >
 cAffineMatrixFunction (const LongIndexType num_rows_, const LongIndexType num_columns_)
 Constructor. More...
 
virtual ~cAffineMatrixFunction ()
 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 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

cCSCMatrix< DataType > A
 
cCSCMatrix< DataType > B
 
- Protected Attributes inherited from cAffineMatrixFunction< DataType >
bool B_is_identity
 
- 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 cAffineMatrixFunction< 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...
 

Detailed Description

template<typename DataType>
class cCSCAffineMatrixFunction< DataType >

Definition at line 30 of file c_csc_affine_matrix_function.h.

Constructor & Destructor Documentation

◆ cCSCAffineMatrixFunction() [1/2]

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

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

Definition at line 29 of file c_csc_affine_matrix_function.cpp.

34  :
35 
36  // Base class constructor
37  cAffineMatrixFunction<DataType>(num_rows_, num_columns_),
38 
39  // Initializer list
40  A(A_data_, A_indices_, A_index_pointer_, num_rows_, num_columns_)
41 {
42  // This constructor is called assuming B is identity
43  this->B_is_identity = true;
44 
45  // When B is identity, the eigenvalues of A+tB are known for any t
46  this->eigenvalue_relation_known = 1;
47 }
Base class for affine matrix functions of one parameter.
FlagType eigenvalue_relation_known

References cAffineMatrixFunction< DataType >::B_is_identity, and cLinearOperator< DataType >::eigenvalue_relation_known.

◆ cCSCAffineMatrixFunction() [2/2]

template<typename DataType >
cCSCAffineMatrixFunction< DataType >::cCSCAffineMatrixFunction ( 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_ 
)

Definition at line 55 of file c_csc_affine_matrix_function.cpp.

63  :
64 
65  // Base class constructor
66  cAffineMatrixFunction<DataType>(num_rows_, num_columns_),
67 
68  // Initializer list
69  A(A_data_, A_indices_, A_index_pointer_, num_rows_, num_columns_),
70  B(B_data_, B_indices_, B_index_pointer_, num_rows_, num_columns_)
71 {
72  // Matrix B is assumed to be non-zero. Check if it is identity or generic
73  if (this->B.is_identity_matrix())
74  {
75  this->B_is_identity = true;
76  this->eigenvalue_relation_known = 1;
77  }
78 }

References cCSCAffineMatrixFunction< DataType >::B, cAffineMatrixFunction< DataType >::B_is_identity, and cLinearOperator< DataType >::eigenvalue_relation_known.

◆ ~cCSCAffineMatrixFunction()

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

Definition at line 86 of file c_csc_affine_matrix_function.cpp.

87 {
88 }

Member Function Documentation

◆ dot()

template<typename DataType >
void cCSCAffineMatrixFunction< 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 112 of file c_csc_affine_matrix_function.cpp.

115 {
116  // Matrix A times vector
117  this->A.dot(vector, product);
118  LongIndexType min_vector_size;
119 
120  // Matrix B times vector to be added to the product
121  if (this->B_is_identity)
122  {
123  // Check parameter is set
124  assert((this->parameters != NULL) && "Parameter is not set.");
125 
126  // Find minimum of the number of rows and columns
127  min_vector_size = \
128  (this->num_rows < this->num_columns) ? \
129  this->num_rows : this->num_columns;
130 
131  // Adding input vector to product
132  this->_add_scaled_vector(vector, min_vector_size,
133  this->parameters[0], product);
134  }
135  else
136  {
137  // Check parameter is set
138  assert((this->parameters != NULL) && "Parameter is not set.");
139 
140  // Adding parameter times B times input vector to the product
141  this->B.dot_plus(vector, this->parameters[0], product);
142  }
143 }
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.
DataType * parameters
const LongIndexType num_rows
const LongIndexType num_columns
int LongIndexType
Definition: types.h:60

◆ transpose_dot()

template<typename DataType >
void cCSCAffineMatrixFunction< 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 168 of file c_csc_affine_matrix_function.cpp.

171 {
172  // Matrix A times vector
173  this->A.transpose_dot(vector, product);
174  LongIndexType min_vector_size;
175 
176  // Matrix B times vector to be added to the product
177  if (this->B_is_identity)
178  {
179  // Check parameter is set
180  assert((this->parameters != NULL) && "Parameter is not set.");
181 
182  // Find minimum of the number of rows and columns
183  min_vector_size = \
184  (this->num_rows < this->num_columns) ? \
185  this->num_rows : this->num_columns;
186 
187  // Adding input vector to product
188  this->_add_scaled_vector(vector, min_vector_size,
189  this->parameters[0], product);
190  }
191  else
192  {
193  // Check parameter is set
194  assert((this->parameters != NULL) && "Parameter is not set.");
195 
196  // Adding "parameter * B * input vector" to the product
197  this->B.transpose_dot_plus(vector, this->parameters[0], product);
198  }
199 }

Member Data Documentation

◆ A

template<typename DataType >
cCSCMatrix<DataType> cCSCAffineMatrixFunction< DataType >::A
protected

Definition at line 65 of file c_csc_affine_matrix_function.h.

◆ B

template<typename DataType >
cCSCMatrix<DataType> cCSCAffineMatrixFunction< DataType >::B
protected

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