Sequential Quantum Gate Decomposer  v1.9.3
Powerful decomposition of general unitarias into one- and two-qubit gates gates
dot.h
Go to the documentation of this file.
1 /*
2 Copyright 2020 Peter Rakyta, Ph.D.
3 
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16 
17 #ifndef Dot_H
18 #define Dot_H
19 
20 
21 #include "matrix.h"
22 #include "logging.h"
23 
24 #ifndef CPYTHON
25 #include <tbb/tbb.h>
26 #endif
27 
28 #ifdef __cplusplus
29 extern "C"
30 {
31 #endif
32 
35 
37 void cblas_zgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, const int M, const int N, const int K,
38  const void *alpha, const void *A, const int lda, const void *B, const int ldb, const void *beta, void *C, const int ldc);
39 
41 void cblas_zgemv(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const int M, const int N, const void *alpha, const void *A, const int lda,
42  const void *X, const int incX, const void *beta, void *Y, const int incY);
43 
44 
45 #if BLAS==1 // MKL
46 
48 void vzConj(int num, QGD_Complex16* input, QGD_Complex16* output);
49 
50 #endif
51 
52 #ifdef __cplusplus
53 }
54 #endif
55 
56 
57 
58 
59 
66 Matrix dot( Matrix &A, Matrix &B );
67 
68 
69 
76 bool check_matrices( Matrix &A, Matrix &B );
77 
78 
79 
85 void get_cblas_transpose( Matrix &A, CBLAS_TRANSPOSE &transpose );
86 
87 // relieve Python extension from TBB functionalities
88 #ifndef CPYTHON
89 
94 struct row_indices {
95 
99  int Arows_end;
101  int Arows;
107  int Brows;
113  int Crows;
114 };
115 
120 struct col_indices {
126  int Acols;
132  int Bcols;
138  int Ccols;
139 };
140 
141 
142 
143 
147 class zgemm_Task_serial : public logging {
148 
149 public:
162 
163 
164 
165 
166 public:
167 
168 
175 zgemm_Task_serial( Matrix &A_in, Matrix &B_in, Matrix &C_in);
176 
185 zgemm_Task_serial( Matrix &A_in, Matrix &B_in, Matrix &C_in, row_indices& rows_in, col_indices& cols_in);
186 
190 void zgemm_chunk();
191 
192 }; // zgemm_Task_serial
193 
194 
195 
200 
201 
202 
203 public:
204 
205 
212 zgemm_Task( Matrix &A_in, Matrix &B_in, Matrix &C_in);
213 
222 zgemm_Task( Matrix &A_in, Matrix &B_in, Matrix &C_in, row_indices& rows_in, col_indices& cols_in);
223 
224 
225 
230 void execute(tbb::task_group &g);
231 
232 
233 
234 }; // zgemm_Task
235 
236 
237 #endif // CPYTHON
238 
239 
240 #endif //Dot_H
Matrix B
The matrix B.
Definition: dot.h:153
CBLAS_ORDER order
CBLAS storage order.
Definition: dot.h:161
A class representing a U3 gate.
Definition: X.h:36
CBLAS_TRANSPOSE
Definition: dot.h:34
void cblas_zgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, const int M, const int N, const int K, const void *alpha, const void *A, const int lda, const void *B, const int ldb, const void *beta, void *C, const int ldc)
Definition of the zgemm function from CBLAS.
Class to calculate a matrix product C=A*B in serial.
Definition: dot.h:147
int Ccols
The number of cols in matrix C participating in the multiplication sub-problem.
Definition: dot.h:138
row_indices rows
Structure containing row limits for the partitioning of the matrix product calculations.
Definition: dot.h:157
Matrix A
The matrix A.
Definition: dot.h:151
int Arows_end
The last row in matrix A participating in the multiplication sub-problem. (The rows are picked from a...
Definition: dot.h:99
int Arows
The number of rows in matrix A participating in the multiplication sub-problem.
Definition: dot.h:101
int Crows_start
The firs row in matrix C participating in the multiplication sub-problem.
Definition: dot.h:109
Class to calculate a matrix product C=A*B in parallel.
Definition: dot.h:199
int Acols_start
The firs col in matrix A participating in the multiplication sub-problem.
Definition: dot.h:122
Structure containing row limits for the partitioning of the matrix product calculations.
Definition: dot.h:94
int Brows_start
The firs row in matrix B participating in the multiplication sub-problem.
Definition: dot.h:103
Header file for a class containing basic methods for setting up the verbosity level.
Structure containing column limits for the partitioning of the matrix product calculations.
Definition: dot.h:120
bool check_matrices(Matrix &A, Matrix &B)
Call to check the shape of the matrices for method dot.
Definition: dot.cpp:132
int Crows
The number of rows in matrix C participating in the multiplication sub-problem.
Definition: dot.h:113
A class containing basic methods for setting up the verbosity level.
Definition: logging.h:43
CBLAS_ORDER
Definition: dot.h:33
Matrix C
The matrix C.
Definition: dot.h:155
Header file of complex array storage array with automatic and thread safe reference counting...
int Bcols_start
The firs col in matrix B participating in the multiplication sub-problem.
Definition: dot.h:128
Structure type representing complex numbers in the SQUANDER package.
Definition: QGDTypes.h:38
int Acols
The number of cols in matrix A participating in the multiplication sub-problem.
Definition: dot.h:126
int Acols_end
The last col in matrix A participating in the multiplication sub-problem. (The cols are picked from a...
Definition: dot.h:124
int Crows_end
The last row in matrix C participating in the multiplication sub-problem. (The rows are picked from a...
Definition: dot.h:111
Class to store data of complex arrays and its properties.
Definition: matrix.h:38
A class representing a U3 gate.
Definition: Y.h:36
col_indices cols
Structure containing column limits for the partitioning of the matrix product calculations.
Definition: dot.h:159
Definition: dot.h:34
int Brows
The number of rows in matrix B participating in the multiplication sub-problem.
Definition: dot.h:107
int Bcols
The number of cols in matrix B participating in the multiplication sub-problem.
Definition: dot.h:132
int Ccols_start
The firs col in matrix C participating in the multiplication sub-problem.
Definition: dot.h:134
void cblas_zgemv(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const int M, const int N, const void *alpha, const void *A, const int lda, const void *X, const int incX, const void *beta, void *Y, const int incY)
Definition of the zgemv function from CBLAS to calculate matrix-vector product.
int Arows_start
The firs row in matrix A participating in the multiplication sub-problem.
Definition: dot.h:97
int Ccols_end
The last col in matrix C participating in the multiplication sub-problem. (The col are picked from a ...
Definition: dot.h:136
int Brows_end
The last row in matrix B participating in the multiplication sub-problem. (The rows are picked from a...
Definition: dot.h:105
Matrix dot(Matrix &A, Matrix &B)
Call to calculate the product of two complex matrices by calling method zgemm3m from the CBLAS librar...
Definition: dot.cpp:38
int Bcols_end
The last col in matrix B participating in the multiplication sub-problem. (The cols are picked from a...
Definition: dot.h:130
void get_cblas_transpose(Matrix &A, CBLAS_TRANSPOSE &transpose)
Call to get the transpose properties of the input matrix for CBLAS calculations.
Definition: dot.cpp:202