Sequential Quantum Gate Decomposer  v1.9.6
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 #include "matrix_float.h"
24 
25 #ifndef CPYTHON
26 #include <tbb/tbb.h>
27 #endif
28 
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #endif
33 
36 
38 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,
39  const void *alpha, const void *A, const int lda, const void *B, const int ldb, const void *beta, void *C, const int ldc);
40 
42 void cblas_cgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, const int M, const int N, const int K,
43  const void *alpha, const void *A, const int lda, const void *B, const int ldb, const void *beta, void *C, const int ldc);
44 
46 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,
47  const void *X, const int incX, const void *beta, void *Y, const int incY);
48 
49 
50 #if BLAS==1 // MKL
51 
53 void vzConj(int num, QGD_Complex16* input, QGD_Complex16* output);
54 
55 #endif
56 
57 #ifdef __cplusplus
58 }
59 #endif
60 
61 
62 
63 
64 
71 Matrix dot( Matrix &A, Matrix &B );
72 
80 
81 
82 
89 bool check_matrices( Matrix &A, Matrix &B );
90 
91 
92 
98 void get_cblas_transpose( Matrix &A, CBLAS_TRANSPOSE &transpose );
99 
100 // relieve Python extension from TBB functionalities
101 #ifndef CPYTHON
102 
107 struct row_indices {
108 
114  int Arows;
120  int Brows;
126  int Crows;
127 };
128 
133 struct col_indices {
139  int Acols;
145  int Bcols;
151  int Ccols;
152 };
153 
154 
155 
156 
160 class zgemm_Task_serial : public logging {
161 
162 public:
175 
176 
177 
178 
179 public:
180 
181 
188 zgemm_Task_serial( Matrix &A_in, Matrix &B_in, Matrix &C_in);
189 
198 zgemm_Task_serial( Matrix &A_in, Matrix &B_in, Matrix &C_in, row_indices& rows_in, col_indices& cols_in);
199 
203 void zgemm_chunk();
204 
205 }; // zgemm_Task_serial
206 
207 
208 
213 
214 
215 
216 public:
217 
218 
225 zgemm_Task( Matrix &A_in, Matrix &B_in, Matrix &C_in);
226 
235 zgemm_Task( Matrix &A_in, Matrix &B_in, Matrix &C_in, row_indices& rows_in, col_indices& cols_in);
236 
237 
238 
243 void execute(tbb::task_group &g);
244 
245 
246 
247 }; // zgemm_Task
248 
249 
250 #endif // CPYTHON
251 
252 
253 #endif //Dot_H
Matrix B
The matrix B.
Definition: dot.h:166
CBLAS_ORDER order
CBLAS storage order.
Definition: dot.h:174
Header file of single-precision complex array storage with automatic and thread safe reference counti...
Definition: X.h:11
CBLAS_TRANSPOSE
Definition: dot.h:35
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:160
void cblas_cgemm(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 cgemm function from CBLAS (single-precision complex matrix multiply) ...
int Ccols
The number of cols in matrix C participating in the multiplication sub-problem.
Definition: dot.h:151
row_indices rows
Structure containing row limits for the partitioning of the matrix product calculations.
Definition: dot.h:170
Matrix A
The matrix A.
Definition: dot.h:164
int Arows_end
The last row in matrix A participating in the multiplication sub-problem. (The rows are picked from a...
Definition: dot.h:112
int Arows
The number of rows in matrix A participating in the multiplication sub-problem.
Definition: dot.h:114
int Crows_start
The firs row in matrix C participating in the multiplication sub-problem.
Definition: dot.h:122
Class to calculate a matrix product C=A*B in parallel.
Definition: dot.h:212
int Acols_start
The firs col in matrix A participating in the multiplication sub-problem.
Definition: dot.h:135
Structure containing row limits for the partitioning of the matrix product calculations.
Definition: dot.h:107
int Brows_start
The firs row in matrix B participating in the multiplication sub-problem.
Definition: dot.h:116
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:133
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:126
A class containing basic methods for setting up the verbosity level.
Definition: logging.h:43
CBLAS_ORDER
Definition: dot.h:34
Matrix C
The matrix C.
Definition: dot.h:168
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:141
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:139
int Acols_end
The last col in matrix A participating in the multiplication sub-problem. (The cols are picked from a...
Definition: dot.h:137
int Crows_end
The last row in matrix C participating in the multiplication sub-problem. (The rows are picked from a...
Definition: dot.h:124
Double-precision complex matrix (float64).
Definition: matrix.h:38
Definition: Y.h:11
Single-precision complex matrix (float32).
Definition: matrix_float.h:41
col_indices cols
Structure containing column limits for the partitioning of the matrix product calculations.
Definition: dot.h:172
Definition: dot.h:35
int Brows
The number of rows in matrix B participating in the multiplication sub-problem.
Definition: dot.h:120
int Bcols
The number of cols in matrix B participating in the multiplication sub-problem.
Definition: dot.h:145
int Ccols_start
The firs col in matrix C participating in the multiplication sub-problem.
Definition: dot.h:147
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:110
int Ccols_end
The last col in matrix C participating in the multiplication sub-problem. (The col are picked from a ...
Definition: dot.h:149
int Brows_end
The last row in matrix B participating in the multiplication sub-problem. (The rows are picked from a...
Definition: dot.h:118
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:143
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