Sequential Quantum Gate Decomposer  v1.9.3
Powerful decomposition of general unitarias into one- and two-qubit gates gates
List of all members | Public Member Functions | Public Attributes | Protected Attributes | Private Attributes
GrayCode_base< intType > Class Template Reference

Copyright 2021 Budapest Quantum Computing Group. More...

#include <GrayCode_base.hpp>

Inheritance diagram for GrayCode_base< intType >:
Inheritance graph
[legend]

Public Member Functions

GrayCode_base add_Digit (const intType n_ary_limit) const
 Call to add a new digit to the Gray code. More...
 
void conjugate ()
 Call to conjugate (or un-conjugate) the matrix for CBLAS functions. More...
 
GrayCode_base copy () const
 Call to create a copy of the state. More...
 
void ensure_aligned ()
 
intType * get_data () const
 Call to get the pointer to the stored data. More...
 
matrix_base< intType > get_Limits () const
 Call to get the n-ary limits of the Gray code. More...
 
 GrayCode_base ()
 Default constructor of the class. More...
 
 GrayCode_base (intType *data_in, matrix_base< intType > n_ary_limits_)
 Constructor of the class. More...
 
 GrayCode_base (matrix_base< intType > n_ary_limits_)
 Constructor of the class. More...
 
 GrayCode_base (intType value, matrix_base< intType > &n_ary_limits_)
 Constructor of the class. More...
 
 GrayCode_base (const GrayCode_base &in)
 Copy constructor of the class. 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...
 
void operator= (const GrayCode_base &gcode)
 Overloaded assignment operator to create a copy of the state. More...
 
bool operator== (const GrayCode_base &gcode) const
 Operator to compare two keys made of PicState_base class instances. More...
 
intType & operator[] (size_t idx)
 Operator [] to access elements in array style. More...
 
const intType & operator[] (size_t idx) const
 Operator [] to access a constant element in array style of constant instance. More...
 
intType & operator[] (int idx) const
 Operator [] to access elements in array style (does not check the boundaries of the stored array) More...
 
void print_matrix () const
 Call to prints the stored matrix on the standard output. More...
 
void release_data ()
 Call to release the data stored by the matrix. More...
 
GrayCode_base remove_Digit (const int idx) const
 Call to add a new digit to the Gray code. More...
 
void replace_data (intType *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...
 
int size () const
 Call to get the number of the allocated elements. More...
 
void transpose ()
 Call to transpose (or un-transpose) the matrix for CBLAS functions. More...
 

Public Attributes

int cols
 The number of columns. More...
 
intType * data
 pointer to the stored data More...
 
int rows
 The number of rows. More...
 
int stride
 The column stride of the array. (The array elements in one row are a_0, a_1, ... a_{cols-1}, 0, 0, 0, 0. The number of zeros is stride-cols) 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...
 

Private Attributes

matrix_base< intType > n_ary_limits
 the limits of the gray code digits More...
 
uint8_t padding [CACHELINE-sizeof(matrix_base< intType >) -sizeof(intType)]
 padding class object to cache line borders More...
 

Detailed Description

template<typename intType>
class GrayCode_base< intType >

Copyright 2021 Budapest Quantum Computing Group.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Class to store one-dimensional state vectors and their additional properties.

Definition at line 29 of file GrayCode_base.hpp.

Constructor & Destructor Documentation

◆ GrayCode_base() [1/5]

template<typename intType>
GrayCode_base< intType >::GrayCode_base ( )
inline

Default constructor of the class.

Returns
Returns with the instance of the class.

Definition at line 49 of file GrayCode_base.hpp.

Here is the caller graph for this function:

◆ GrayCode_base() [2/5]

template<typename intType>
GrayCode_base< intType >::GrayCode_base ( intType *  data_in,
matrix_base< intType >  n_ary_limits_ 
)
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
cols_inThe number of columns in the stored matrix
Returns
Returns with the instance of the class.

Definition at line 62 of file GrayCode_base.hpp.

◆ GrayCode_base() [3/5]

template<typename intType>
GrayCode_base< intType >::GrayCode_base ( matrix_base< intType >  n_ary_limits_)
inline

Constructor of the class.

Allocates data for the state of elements cols. By default the created instance would be the owner of the stored data.

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

Definition at line 74 of file GrayCode_base.hpp.

◆ GrayCode_base() [4/5]

template<typename intType>
GrayCode_base< intType >::GrayCode_base ( intType  value,
matrix_base< intType > &  n_ary_limits_ 
)
inline

Constructor of the class.

Allocates data for the state of elements cols and set the values to value. By default the created instance would be the owner of the stored data.

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

Definition at line 86 of file GrayCode_base.hpp.

◆ GrayCode_base() [5/5]

template<typename intType>
GrayCode_base< intType >::GrayCode_base ( const GrayCode_base< intType > &  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 106 of file GrayCode_base.hpp.

Member Function Documentation

◆ add_Digit()

template<typename intType>
GrayCode_base GrayCode_base< intType >::add_Digit ( const intType  n_ary_limit) const
inline

Call to add a new digit to the Gray code.

Parameters
n_ary_limitThe limit of the new digit
Returns
Returns with the extended Gray code

Definition at line 224 of file GrayCode_base.hpp.

Here is the caller graph for this function:

◆ conjugate()

void matrix_base< intType >::conjugate ( )
inlineinherited

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

Definition at line 271 of file matrix_base.hpp.

◆ copy()

template<typename intType>
GrayCode_base GrayCode_base< intType >::copy ( ) const
inline

Call to create a copy of the state.

By default the created instance would be the owner of the stored array.

Returns
Returns with the instance of the class.

Definition at line 182 of file GrayCode_base.hpp.

Here is the caller graph for this function:

◆ ensure_aligned()

void matrix_base< intType >::ensure_aligned ( )
inlineinherited

Definition at line 457 of file matrix_base.hpp.

◆ get_data()

intType * matrix_base< intType >::get_data ( ) const
inlineinherited

Call to get the pointer to the stored data.

Definition at line 304 of file matrix_base.hpp.

◆ get_Limits()

template<typename intType>
matrix_base<intType> GrayCode_base< intType >::get_Limits ( ) const
inline

Call to get the n-ary limits of the Gray code.

Returns
Returns with the instance of the class.

Definition at line 210 of file GrayCode_base.hpp.

Here is the caller graph for this function:

◆ is_conjugated()

bool matrix_base< intType >::is_conjugated ( )
inlineinherited

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 264 of file matrix_base.hpp.

◆ is_transposed()

bool matrix_base< intType >::is_transposed ( )
inlineinherited

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 282 of file matrix_base.hpp.

◆ operator=()

template<typename intType>
void GrayCode_base< intType >::operator= ( const GrayCode_base< intType > &  gcode)
inline

Overloaded assignment operator to create a copy of the state.

Parameters
stateAn instance of PicState_base
Returns
Returns with the instance of the class.

Definition at line 168 of file GrayCode_base.hpp.

◆ operator==()

template<typename intType>
bool GrayCode_base< intType >::operator== ( const GrayCode_base< intType > &  gcode) const
inline

Operator to compare two keys made of PicState_base class instances.

Parameters
stateAn instance of an implemented class of PicState_base
Returns
Returns with true if the two keys are equal, or false otherwise

Definition at line 118 of file GrayCode_base.hpp.

◆ operator[]() [1/3]

template<typename intType>
intType& GrayCode_base< intType >::operator[] ( size_t  idx)
inline

Operator [] to access elements in array style.

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

Definition at line 146 of file GrayCode_base.hpp.

◆ operator[]() [2/3]

template<typename intType>
const intType& GrayCode_base< intType >::operator[] ( size_t  idx) const
inline

Operator [] to access a constant element in array style of constant instance.

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

Definition at line 156 of file GrayCode_base.hpp.

◆ operator[]() [3/3]

intType & matrix_base< intType >::operator[] ( int  idx) const
inlineinherited

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 423 of file matrix_base.hpp.

◆ print_matrix()

void matrix_base< intType >::print_matrix ( ) const
inlineinherited

Call to prints the stored matrix on the standard output.

Definition at line 480 of file matrix_base.hpp.

◆ release_data()

void matrix_base< intType >::release_data ( )
inlineinherited

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 333 of file matrix_base.hpp.

◆ remove_Digit()

template<typename intType>
GrayCode_base GrayCode_base< intType >::remove_Digit ( const int  idx) const
inline

Call to add a new digit to the Gray code.

Parameters
idxthe index of the digit to be removed
Returns
Returns with the shrinked Gray code

Definition at line 249 of file GrayCode_base.hpp.

Here is the caller graph for this function:

◆ replace_data()

void matrix_base< intType >::replace_data ( intType *  data_in,
bool  owner_in 
)
inlineinherited

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 316 of file matrix_base.hpp.

◆ set_owner()

void matrix_base< intType >::set_owner ( bool  owner_in)
inlineinherited

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 376 of file matrix_base.hpp.

◆ size()

int matrix_base< intType >::size ( ) const
inlineinherited

Call to get the number of the allocated elements.

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

Definition at line 470 of file matrix_base.hpp.

◆ transpose()

void matrix_base< intType >::transpose ( )
inlineinherited

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

Definition at line 292 of file matrix_base.hpp.

Member Data Documentation

◆ cols

int matrix_base< intType >::cols
inherited

The number of columns.

Definition at line 44 of file matrix_base.hpp.

◆ conjugated

bool matrix_base< intType >::conjugated
protectedinherited

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

Definition at line 53 of file matrix_base.hpp.

◆ data

intType * matrix_base< intType >::data
inherited

pointer to the stored data

Definition at line 48 of file matrix_base.hpp.

◆ n_ary_limits

template<typename intType>
matrix_base<intType> GrayCode_base< intType >::n_ary_limits
private

the limits of the gray code digits

Definition at line 40 of file GrayCode_base.hpp.

◆ owner

bool matrix_base< intType >::owner
protectedinherited

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 57 of file matrix_base.hpp.

◆ padding

template<typename intType>
uint8_t GrayCode_base< intType >::padding[CACHELINE-sizeof(matrix_base< intType >) -sizeof(intType)]
private

padding class object to cache line borders

Definition at line 36 of file GrayCode_base.hpp.

◆ reference_mutex

tbb::spin_mutex* matrix_base< intType >::reference_mutex
protectedinherited

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

Definition at line 59 of file matrix_base.hpp.

◆ references

int64_t* matrix_base< intType >::references
protectedinherited

the number of the current references of the present object

Definition at line 61 of file matrix_base.hpp.

◆ rows

int matrix_base< intType >::rows
inherited

The number of rows.

Definition at line 42 of file matrix_base.hpp.

◆ stride

int matrix_base< intType >::stride
inherited

The column stride of the array. (The array elements in one row are a_0, a_1, ... a_{cols-1}, 0, 0, 0, 0. The number of zeros is stride-cols)

Definition at line 46 of file matrix_base.hpp.

◆ transposed

bool matrix_base< intType >::transposed
protectedinherited

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

Definition at line 55 of file matrix_base.hpp.


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