Quantum Gate Decomposer  v1.3
Powerful decomposition of almost any unitary into U3 and CNOT gates
List of all members | Public Member Functions | Public Attributes | Protected Attributes
matrix_base< scalar > Class Template Reference

Base Class to store data of arrays and its properties. More...

#include <matrix_base.h>

Public Member Functions

void conjugate ()
 Call to conjugate (or un-conjugate) the matrix for CBLAS functions. More...
 
matrix_base< scalar > copy ()
 Call to create a copy of the matrix. More...
 
scalar * get_data ()
 Call to get the pointer to the stored data. More...
 
bool is_conjugated ()
 Call to get whether the matrix should be conjugated in CBLAS functions or not. More...
 
bool is_transposed ()
 Call to get whether the matrix should be conjugated in CBLAS functions or not. More...
 
 matrix_base ()
 Default constructor of the class. More...
 
 matrix_base (scalar *data_in, size_t rows_in, size_t cols_in)
 Constructor of the class. More...
 
 matrix_base (size_t rows_in, size_t cols_in)
 Constructor of the class. More...
 
 matrix_base (const matrix_base< scalar > &in)
 Copy constructor of the class. More...
 
void operator= (const matrix_base &mtx)
 Assignment operator. More...
 
scalar & operator[] (size_t idx)
 Operator [] to access elements in array style (does not check the boundaries of the stored array) More...
 
void print_matrix ()
 Call to prints the stored matrix on the standard output. More...
 
void release_data ()
 Call to release the data stored by the matrix. More...
 
void replace_data (scalar *data_in, bool owner_in)
 Call to replace the stored data by an another data array. More...
 
void set_owner (bool owner_in)
 Call to set the current class instance to be (or not to be) the owner of the stored data array. More...
 
size_t size ()
 Call to get the number of the allocated elements. More...
 
void transpose ()
 Call to transpose (or un-transpose) the matrix for CBLAS functions. More...
 
 ~matrix_base ()
 Destructor of the class. More...
 

Public Attributes

size_t cols
 The number of columns. More...
 
scalar * data
 pointer to the stored data More...
 
size_t rows
 The number of rows. More...
 

Protected Attributes

bool conjugated
 logical variable indicating whether the matrix needs to be conjugated in CBLAS operations More...
 
bool owner
 logical value indicating whether the class instance is the owner of the stored data or not. (If true, the data array is released in the destructor) More...
 
tbb::spin_mutex * reference_mutex
 mutual exclusion to count the references for class instances referring to the same data. More...
 
int64_t * references
 the number of the current references of the present object More...
 
bool transposed
 logical variable indicating whether the matrix needs to be transposed in CBLAS operations More...
 

Detailed Description

template<typename scalar>
class matrix_base< scalar >

Base Class to store data of arrays and its properties.

Definition at line 19 of file matrix_base.h.

Constructor & Destructor Documentation

◆ matrix_base() [1/4]

template<typename scalar>
matrix_base< scalar >::matrix_base ( )
inline

Default constructor of the class.

Returns
Returns with the instance of the class.

Definition at line 50 of file matrix_base.h.

◆ matrix_base() [2/4]

template<typename scalar>
matrix_base< scalar >::matrix_base ( scalar *  data_in,
size_t  rows_in,
size_t  cols_in 
)
inline

Constructor of the class.

By default the created class instance would not be owner of the stored data.

Parameters
data_inThe pointer pointing to the data
rows_inThe number of rows in the stored matrix
cols_inThe number of columns in the stored matrix
Returns
Returns with the instance of the class.

Definition at line 82 of file matrix_base.h.

◆ matrix_base() [3/4]

template<typename scalar>
matrix_base< scalar >::matrix_base ( size_t  rows_in,
size_t  cols_in 
)
inline

Constructor of the class.

Allocates data for matrix rows_in times cols_in. By default the created instance would be the owner of the stored data.

Parameters
rows_inThe number of rows in the stored matrix
cols_inThe number of columns in the stored matrix
Returns
Returns with the instance of the class.

Definition at line 114 of file matrix_base.h.

◆ matrix_base() [4/4]

template<typename scalar>
matrix_base< scalar >::matrix_base ( const matrix_base< scalar > &  in)
inline

Copy constructor of the class.

The new instance shares the stored memory with the input matrix. (Needed for TBB calls)

Parameters
Aninstance of class matrix to be copied.

Definition at line 147 of file matrix_base.h.

◆ ~matrix_base()

template<typename scalar>
matrix_base< scalar >::~matrix_base ( )
inline

Destructor of the class.

Definition at line 173 of file matrix_base.h.

Member Function Documentation

◆ conjugate()

template<typename scalar>
void matrix_base< scalar >::conjugate ( )
inline

Call to conjugate (or un-conjugate) the matrix for CBLAS functions.

Definition at line 188 of file matrix_base.h.

Here is the caller graph for this function:

◆ copy()

template<typename scalar>
matrix_base<scalar> matrix_base< scalar >::copy ( )
inline

Call to create a copy of the matrix.

Returns
Returns with the instance of the class.

Definition at line 351 of file matrix_base.h.

◆ get_data()

template<typename scalar>
scalar* matrix_base< scalar >::get_data ( )
inline

Call to get the pointer to the stored data.

Definition at line 221 of file matrix_base.h.

Here is the caller graph for this function:

◆ is_conjugated()

template<typename scalar>
bool matrix_base< scalar >::is_conjugated ( )
inline

Call to get whether the matrix should be conjugated in CBLAS functions or not.

Returns
Returns with true if the matrix should be conjugated in CBLAS functions or false otherwise.

Definition at line 181 of file matrix_base.h.

Here is the caller graph for this function:

◆ is_transposed()

template<typename scalar>
bool matrix_base< scalar >::is_transposed ( )
inline

Call to get whether the matrix should be conjugated in CBLAS functions or not.

Returns
Returns with true if the matrix should be conjugated in CBLAS functions or false otherwise.

Definition at line 199 of file matrix_base.h.

Here is the caller graph for this function:

◆ operator=()

template<typename scalar>
void matrix_base< scalar >::operator= ( const matrix_base< scalar > &  mtx)
inline

Assignment operator.

Parameters
mtxAn instance of class matrix_base
Returns
Returns with the instance of the class.

Definition at line 306 of file matrix_base.h.

◆ operator[]()

template<typename scalar>
scalar& matrix_base< scalar >::operator[] ( size_t  idx)
inline

Operator [] to access elements in array style (does not check the boundaries of the stored array)

Parameters
idxthe index of the element
Returns
Returns with a reference to the idx-th element.

Definition at line 340 of file matrix_base.h.

◆ print_matrix()

template<typename scalar>
void matrix_base< scalar >::print_matrix ( )
inline

Call to prints the stored matrix on the standard output.

Definition at line 384 of file matrix_base.h.

◆ release_data()

template<typename scalar>
void matrix_base< scalar >::release_data ( )
inline

Call to release the data stored by the matrix.

(If the class instance was not the owner of the data, then the data pointer is simply set to NULL pointer.)

Definition at line 252 of file matrix_base.h.

Here is the caller graph for this function:

◆ replace_data()

template<typename scalar>
void matrix_base< scalar >::replace_data ( scalar *  data_in,
bool  owner_in 
)
inline

Call to replace the stored data by an another data array.

If the class was the owner of the original data array, then it is released.

Parameters
data_inThe data array to be set as a new storage.
owner_inSet true to set the current class instance to be the owner of the data array, or false otherwise.

Definition at line 233 of file matrix_base.h.

◆ set_owner()

template<typename scalar>
void matrix_base< scalar >::set_owner ( bool  owner_in)
inline

Call to set the current class instance to be (or not to be) the owner of the stored data array.

Parameters
owner_inSet true to set the current class instance to be the owner of the data array, or false otherwise.

Definition at line 295 of file matrix_base.h.

Here is the caller graph for this function:

◆ size()

template<typename scalar>
size_t matrix_base< scalar >::size ( )
inline

Call to get the number of the allocated elements.

Returns
Returns with the number of the allocated elements (rows*cols)

Definition at line 374 of file matrix_base.h.

Here is the caller graph for this function:

◆ transpose()

template<typename scalar>
void matrix_base< scalar >::transpose ( )
inline

Call to transpose (or un-transpose) the matrix for CBLAS functions.

Definition at line 209 of file matrix_base.h.

Here is the caller graph for this function:

Member Data Documentation

◆ cols

template<typename scalar>
size_t matrix_base< scalar >::cols

The number of columns.

Definition at line 25 of file matrix_base.h.

◆ conjugated

template<typename scalar>
bool matrix_base< scalar >::conjugated
protected

logical variable indicating whether the matrix needs to be conjugated in CBLAS operations

Definition at line 32 of file matrix_base.h.

◆ data

template<typename scalar>
scalar* matrix_base< scalar >::data

pointer to the stored data

Definition at line 27 of file matrix_base.h.

◆ owner

template<typename scalar>
bool matrix_base< scalar >::owner
protected

logical value indicating whether the class instance is the owner of the stored data or not. (If true, the data array is released in the destructor)

Definition at line 36 of file matrix_base.h.

◆ reference_mutex

template<typename scalar>
tbb::spin_mutex* matrix_base< scalar >::reference_mutex
protected

mutual exclusion to count the references for class instances referring to the same data.

Definition at line 38 of file matrix_base.h.

◆ references

template<typename scalar>
int64_t* matrix_base< scalar >::references
protected

the number of the current references of the present object

Definition at line 40 of file matrix_base.h.

◆ rows

template<typename scalar>
size_t matrix_base< scalar >::rows

The number of rows.

Definition at line 23 of file matrix_base.h.

◆ transposed

template<typename scalar>
bool matrix_base< scalar >::transposed
protected

logical variable indicating whether the matrix needs to be transposed in CBLAS operations

Definition at line 34 of file matrix_base.h.


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