imate
C++/CUDA Reference
Loading...
Searching...
No Matches
cCSCAffineMatrixFunction< DataType > Class Template Reference

Container for CSC affine matrix functions of one parameter. More...

#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_, const FlagType A_is_symmetric_)
 Default constructor.
 
 cCSCAffineMatrixFunction (const DataType *A_data_, const LongIndexType *A_indices_, const LongIndexType *A_index_pointer_, const LongIndexType num_rows_, const LongIndexType num_columns_, const FlagType A_is_symmetric_, const DataType *B_data_, const LongIndexType *B_indices_, const LongIndexType *B_index_pointer_, const FlagType B_is_symmetric_)
 Constructor.
 
virtual ~cCSCAffineMatrixFunction ()
 Destructor.
 
virtual void set_symmetry (const FlagType symmetric)
 Specify whether the matrices are symmetic or non-symmetric.
 
virtual void dot (const DataType *vector, DataType *product)
 Matrix vector product.
 
virtual void transpose_dot (const DataType *vector, DataType *product)
 Matrix vector product written in place.
 
- Public Member Functions inherited from cAffineMatrixFunction< DataType >
 cAffineMatrixFunction ()
 Constructor.
 
virtual ~cAffineMatrixFunction ()
 Virtual destructor.
 
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.
 
- Public Member Functions inherited from cLinearOperator< DataType >
 cLinearOperator ()
 Default constructor.
 
virtual ~cLinearOperator ()
 Destructor.
 
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.
 
- Public Member Functions inherited from cLinearOperatorBase
 cLinearOperatorBase ()
 Default constructor.
 
 cLinearOperatorBase (const LongIndexType num_rows_, const LongIndexType num_columns_)
 Constructor with setting num_rows and num_columns.
 
virtual ~cLinearOperatorBase ()
 Destructor.
 
LongIndexType get_num_rows () const
 Returns the number of rows of the matrix.
 
LongIndexType get_num_columns () const
 Returns the number of columns of the matrix.
 
IndexType get_num_parameters () const
 Returns the number of parameters of the linear operator.
 
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.
 

Protected Attributes

cCSCMatrix< DataType > A
 
cCSCMatrix< DataType > B
 
- Protected Attributes inherited from cAffineMatrixFunction< DataType >
bool B_is_identity
 
- Protected Attributes inherited from cLinearOperator< DataType >
DataType * parameters
 
- Protected Attributes inherited from cLinearOperatorBase
const LongIndexType num_rows
 
const LongIndexType num_columns
 
FlagType eigenvalue_relation_known
 
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.
 

Detailed Description

template<typename DataType>
class cCSCAffineMatrixFunction< DataType >

Container for CSC affine matrix functions of one parameter.

The cCSCAffineMatrixFunction contains two-dimensional compressed sparse column matrices A and B. This operoator can perofrom matrix-vector product and transposed matrix-vector product.

See also
cAffineMatrixFunction, cDenseMatrixFunction, cCSRMatrixFunction, cCSCMatrix, cuCSCAffineMatrixFunction

Definition at line 45 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_,
const FlagType  A_is_symmetric_ 
)

Default constructor.

Matrix B is assumed to be the identity matrix.

Parameters
[in]A_data_1D array of the data content of sparse matrix. The size of the array is the nnz of the matrix.
[in]A_indices_1D array indicating the column of each element in A_data_ . The size of this array is the nnz of the matrix.
[in]A_index_pointer_1D array pointing to the start of new rows in A_indices_ . The size of this array is num_rows+1 . The first element of this array is 0 and the last element of this array is the nnz of the matrix.
[in]num_rows_Number of rows of A
[in]num_columns_Number of columns of A
[in]A_is_symmetric_Boolean. If A is symmetric, set this value to 1, otherwise 0.

Definition at line 49 of file c_csc_affine_matrix_function.cpp.

55 :
56
57 // Base class constructor
58 cLinearOperatorBase(num_rows_, num_columns_),
59
60 // Initializer list
61 A(A_data_, A_indices_, A_index_pointer_, num_rows_, num_columns_,
62 A_is_symmetric_)
63{
64 // This constructor is called assuming B is identity
65 this->B_is_identity = true;
66
67 // When B is identity, the eigenvalues of A+tB are known for any t
69}
cLinearOperatorBase()
Default constructor.

References cAffineMatrixFunction< DataType >::B_is_identity, and cLinearOperatorBase::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_columns_,
const FlagType  A_is_symmetric_,
const DataType *  B_data_,
const LongIndexType B_indices_,
const LongIndexType B_index_pointer_,
const FlagType  B_is_symmetric_ 
)

Constructor.

Parameters
[in]A_data_1D array of the data content of sparse matrix. The size of the array is the nnz of the matrix.
[in]A_indices_1D array indicating the column of each element in A_data_ . The size of this array is the nnz of the matrix.
[in]A_index_pointer_1D array pointing to the start of new rows in A_indices_ . The size of this array is num_rows+1 . The first element of this array is 0 and the last element of this array is the nnz of the matrix.
[in]num_rows_Number of rows of A and B
[in]num_columns_Number of columns of A and B
[in]A_is_symmetric_Boolean. If A is symmetric, set this value to 1, otherwise 0.
[in]B_data_1D array of the data content of sparse matrix. The size of the array is the nnz of the matrix.
[in]B_indices_1D array indicating the column of each element in B_data_ . The size of this array is the nnz of the matrix.
[in]B_index_pointer_1D array pointing to the start of new rows in B_indices_ . The size of this array is num_rows+1 . The first element of this array is 0 and the last element of this array is the nnz of the matrix.
[in]B_is_symmetric_Boolean. If B is symmetric, set this value to 1, otherwise 0.

Definition at line 112 of file c_csc_affine_matrix_function.cpp.

122 :
123
124 // Base class constructor
125 cLinearOperatorBase(num_rows_, num_columns_),
126
127 // Initializer list
128 A(A_data_, A_indices_, A_index_pointer_, num_rows_, num_columns_,
129 A_is_symmetric_),
130 B(B_data_, B_indices_, B_index_pointer_, num_rows_, num_columns_,
131 B_is_symmetric_)
132{
133 // Matrix B is assumed to be non-zero. Check if it is identity or generic
134 if (this->B.is_identity_matrix())
135 {
136 this->B_is_identity = true;
138 }
139}

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

◆ ~cCSCAffineMatrixFunction()

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

Destructor.

Definition at line 150 of file c_csc_affine_matrix_function.cpp.

151{
152}

Member Function Documentation

◆ dot()

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

Matrix vector product.

Performs the matrix vector product \( \boldsymbol{y} = (\mathbf{A} + t \mathbf{B}) \boldsymbol{x} \).

Parameters
[in]vectorA one-dimensional input vector \( \boldsymbol{x} \) with size the of the number of columns of the matrix \( \mathbf{A} \).
[out]productA one-dimensional output vector \( \boldsymbol{y} \) with the size of the number of rows of \( \mathbf{A} \). This vector will be overwritten.
See also
cCSCAffineMatrixFunction::transpose_dot

Implements cLinearOperator< DataType >.

Definition at line 208 of file c_csc_affine_matrix_function.cpp.

211{
212 // Matrix A times vector
213 this->A.dot(vector, product);
214 LongIndexType min_vector_size;
215
216 // Matrix B times vector to be added to the product
217 if (this->B_is_identity)
218 {
219 // Check parameter is set
220 assert((this->parameters != NULL) && "Parameter is not set.");
221
222 // Find minimum of the number of rows and columns
223 min_vector_size = \
224 (this->num_rows < this->num_columns) ? \
225 this->num_rows : this->num_columns;
226
227 // Adding input vector to product
228 this->_add_scaled_vector(vector, min_vector_size,
229 this->parameters[0], product);
230 }
231 else
232 {
233 // Check parameter is set
234 assert((this->parameters != NULL) && "Parameter is not set.");
235
236 // Adding parameter times B times input vector to the product
237 this->B.dot_plus(vector, this->parameters[0], product);
238 }
239}
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.
const LongIndexType num_rows
const LongIndexType num_columns
int LongIndexType
Definition types.h:60

◆ set_symmetry()

template<typename DataType >
void cCSCAffineMatrixFunction< DataType >::set_symmetry ( const FlagType  symmetric)
virtual

Specify whether the matrices are symmetic or non-symmetric.

This function overwrites the symmetry status that has been set by the constructor. Note that the symmetry status of both matrices \( \mathbf{A} \) and \( \mathbf{B} \) in the linear operator \( \mathbf{A} + t \mathbf{B} \) will be set together.

Parameters
[in]symmetricBoolean. If set to 1, the matrix is assumed to be symmetric. Otherwiese non-symmetric.

Implements cAffineMatrixFunction< DataType >.

Definition at line 172 of file c_csc_affine_matrix_function.cpp.

174{
175 if (symmetric == 1)
176 {
177 this->A.set_symmetry(1);
178 this->B.set_symmetry(1);
179 }
180 else
181 {
182 this->A.set_symmetry(0);
183 this->B.set_symmetry(0);
184 }
185}

References cLinearOperatorBase::set_symmetry().

Here is the call graph for this function:

◆ transpose_dot()

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

Matrix vector product written in place.

Performs the matrix vector product \( \boldsymbol{y} = (\mathbf{A} + t \mathbf{B})^{\intercal} \boldsymbol{x} \).

Parameters
[in]vectorA one-dimensional input vector \( \boldsymbol{x} \) with size the of the number of columns of the matrix \( \mathbf{A} \).
[out]productA one-dimensional output vector \( \boldsymbol{y} \) with the size of the number of rows of \( \mathbf{A} \).
See also
cCSCAffineMatrixFunction::dot

Implements cLinearOperator< DataType >.

Definition at line 261 of file c_csc_affine_matrix_function.cpp.

264{
265 // Matrix A times vector
266 this->A.transpose_dot(vector, product);
267 LongIndexType min_vector_size;
268
269 // Matrix B times vector to be added to the product
270 if (this->B_is_identity)
271 {
272 // Check parameter is set
273 assert((this->parameters != NULL) && "Parameter is not set.");
274
275 // Find minimum of the number of rows and columns
276 min_vector_size = \
277 (this->num_rows < this->num_columns) ? \
278 this->num_rows : this->num_columns;
279
280 // Adding input vector to product
281 this->_add_scaled_vector(vector, min_vector_size,
282 this->parameters[0], product);
283 }
284 else
285 {
286 // Check parameter is set
287 assert((this->parameters != NULL) && "Parameter is not set.");
288
289 // Adding "parameter * B * input vector" to the product
290 this->B.transpose_dot_plus(vector, this->parameters[0], product);
291 }
292}

Member Data Documentation

◆ A

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

Definition at line 85 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: