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

#include <c_dense_affine_matrix_function.h>

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

Public Member Functions

 cDenseAffineMatrixFunction (const DataType *A_, const FlagType A_is_row_major_, const LongIndexType num_rows_, const LongIndexType num_colums_)
 Constructor. Matrix B is assumed to be the identity matrix. More...
 
 cDenseAffineMatrixFunction (const DataType *A_, const FlagType A_is_row_major_, const LongIndexType num_rows_, const LongIndexType num_columns_, const DataType *B_, const FlagType B_is_row_major_)
 
virtual ~cDenseAffineMatrixFunction ()
 
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

cDenseMatrix< DataType > A
 
cDenseMatrix< 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 cDenseAffineMatrixFunction< DataType >

Definition at line 30 of file c_dense_affine_matrix_function.h.

Constructor & Destructor Documentation

◆ cDenseAffineMatrixFunction() [1/2]

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

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

Definition at line 29 of file c_dense_affine_matrix_function.cpp.

33  :
34 
35  // Base class constructor
36  cAffineMatrixFunction<DataType>(num_rows_, num_columns_),
37 
38  // Initializer list
39  A(A_, num_rows_, num_columns_, A_is_row_major_)
40 {
41  // This constructor is called assuming B is identity
42  this->B_is_identity = true;
43 
44  // When B is identity, the eigenvalues of A+tB are known for any t
45  this->eigenvalue_relation_known = 1;
46 }
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.

◆ cDenseAffineMatrixFunction() [2/2]

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

Definition at line 54 of file c_dense_affine_matrix_function.cpp.

60  :
61 
62  // Base class constructor
63  cAffineMatrixFunction<DataType>(num_rows_, num_columns_),
64 
65  // Initializer list
66  A(A_, num_rows_, num_columns_, A_is_row_major_),
67  B(B_, num_rows_, num_columns_, B_is_row_major_)
68 {
69  // Matrix B is assumed to be non-zero. Check if it is identity or generic
70  if (this->B.is_identity_matrix())
71  {
72  this->B_is_identity = true;
73  this->eigenvalue_relation_known = 1;
74  }
75 }

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

◆ ~cDenseAffineMatrixFunction()

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

Definition at line 83 of file c_dense_affine_matrix_function.cpp.

84 {
85 }

Member Function Documentation

◆ dot()

template<typename DataType >
void cDenseAffineMatrixFunction< 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 109 of file c_dense_affine_matrix_function.cpp.

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

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

Member Data Documentation

◆ A

template<typename DataType >
cDenseMatrix<DataType> cDenseAffineMatrixFunction< DataType >::A
protected

Definition at line 62 of file c_dense_affine_matrix_function.h.

◆ B

template<typename DataType >
cDenseMatrix<DataType> cDenseAffineMatrixFunction< DataType >::B
protected

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