Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
N_Qubit_Decomposition_Cost_Function.h
Go to the documentation of this file.
1 /*
2 Created on Fri Jun 26 14:13:26 2020
3 Copyright 2020 Peter Rakyta, Ph.D.
4 
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8 
9  http://www.apache.org/licenses/LICENSE-2.0
10 
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 
17 @author: Peter Rakyta, Ph.D.
18 */
23 #ifndef N_Qubit_Decomposition_Cost_Function_H
24 #define N_Qubit_Decomposition_Cost_Function_H
25 
26 #include "common.h"
27 #include "matrix_real.h"
28 #include "matrix_real_float.h"
29 #include "matrix_float.h"
30 #include <tbb/combinable.h>
31 #include "logging.h"
32 
33 
39 double get_cost_function(const Matrix& matrix, int trace_offset=0);
40 double get_cost_function(const Matrix_float& matrix, int trace_offset=0);
41 
42 
49 Matrix_real get_cost_function_with_correction(const Matrix& matrix, int qbit_num, int trace_offset=0);
50 Matrix_real_float get_cost_function_with_correction(const Matrix_float& matrix, int qbit_num, int trace_offset=0);
51 
52 
59 Matrix_real get_cost_function_with_correction2(const Matrix& matrix, int qbit_num, int trace_offset=0);
60 Matrix_real_float get_cost_function_with_correction2(const Matrix_float& matrix, int qbit_num, int trace_offset=0);
61 
64 
72 
73 
80 double get_hilbert_schmidt_test(Matrix& matrix);
82 
89 double get_infidelity(Matrix& matrix);
90 double get_infidelity(Matrix_float& matrix);
91 
99 
100 
108 
112 class functor_cost_fnc : public logging {
113 
114 protected:
115 
121  tbb::combinable<double>* partial_cost_functions;
122 
123 public:
124 
131 functor_cost_fnc( Matrix matrix_in, tbb::combinable<double>* partial_cost_functions_in );
132 
137 void operator()( tbb::blocked_range<int> r ) const;
138 
139 };
140 
141 
142 std::pair<int, double> operator_schmidt_rank(const Matrix& U, int n,
143  const std::vector<int>& A_qubits,
144  double Fnorm, double tol = 1e-10);
145 std::pair<int, double> operator_schmidt_rank(const Matrix_float& U, int n,
146  const std::vector<int>& A_qubits,
147  double Fnorm, double tol = 1e-10);
148 std::vector<std::vector<int>> unique_cuts(int n);
149 double get_osr_entanglement_test(Matrix& matrix, std::vector<std::vector<int>> &use_cuts, int rank=-1, bool use_softmax=false);
150 double get_osr_entanglement_test(Matrix_float& matrix, std::vector<std::vector<int>> &use_cuts, int rank=-1, bool use_softmax=false);
151 Matrix get_deriv_osr_entanglement(Matrix &matrix, std::vector<std::vector<int>> &use_cuts, int rank=-1, bool use_softmax=false);
152 Matrix_float get_deriv_osr_entanglement(Matrix_float &matrix, std::vector<std::vector<int>> &use_cuts, int rank=-1, bool use_softmax=false);
153 double real_trace_conj_dot(Matrix& A, Matrix& B);
155 
156 #endif
157 
158 
159 
Header file of single-precision complex array storage with automatic and thread safe reference counti...
Class to store single-precision real arrays and properties.
std::vector< std::vector< int > > unique_cuts(int n)
QGD_Complex16 * data
Pointer to the data stored in the matrix.
Matrix_real get_cost_function_with_correction(const Matrix &matrix, int qbit_num, int trace_offset=0)
Call co calculate the cost function of the optimization process, and the first correction to the cost...
Matrix get_deriv_sum_of_squares(Matrix &matrix)
double get_osr_entanglement_test(Matrix &matrix, std::vector< std::vector< int >> &use_cuts, int rank=-1, bool use_softmax=false)
Header file for a class containing basic methods for setting up the verbosity level.
Matrix_real get_cost_function_with_correction2(const Matrix &matrix, int qbit_num, int trace_offset=0)
Call co calculate the cost function of the optimization process, and the first correction to the cost...
A class containing basic methods for setting up the verbosity level.
Definition: logging.h:43
QGD_Complex16 get_trace(Matrix &matrix)
Call to calculate the real and imaginary parts of the trace.
double get_infidelity(Matrix &matrix)
Call to calculate infidelity.
Function operator class to calculate the partial cost function of the final optimization process...
std::pair< int, double > operator_schmidt_rank(const Matrix &U, int n, const std::vector< int > &A_qubits, double Fnorm, double tol=1e-10)
Matrix matrix
Array stroing the matrix.
Matrix get_deriv_osr_entanglement(Matrix &matrix, std::vector< std::vector< int >> &use_cuts, int rank=-1, bool use_softmax=false)
functor_cost_fnc(Matrix matrix_in, tbb::combinable< double > *partial_cost_functions_in)
Constructor of the class.
double real_trace_conj_dot(Matrix &A, Matrix &B)
void operator()(tbb::blocked_range< int > r) const
Operator to calculate the partial cost function derived from the row of the matrix labeled by row_idx...
Structure type representing complex numbers in the SQUANDER package.
Definition: QGDTypes.h:38
Double-precision complex matrix (float64).
Definition: matrix.h:38
Matrix get_trace_with_correction(Matrix &matrix, int qbit_num)
Call co calculate the Hilbert Schmidt testof the optimization process, and the first correction to th...
double get_cost_function(const Matrix &matrix, int trace_offset=0)
Call co calculate the cost function during the final optimization process.
Single-precision complex matrix (float32).
Definition: matrix_float.h:41
double get_cost_function_sum_of_squares(Matrix &matrix)
Header file for commonly used functions and wrappers to CBLAS functions.
Matrix get_trace_with_correction2(Matrix &matrix, int qbit_num)
Call co calculate the Hilbert Schmidt testof the optimization process, and the first correction to th...
Class to store data of complex arrays and its properties.
Definition: matrix_real.h:41
double get_hilbert_schmidt_test(Matrix &matrix)
Call co calculate the cost function of the optimization process according to https://arxiv.org/pdf/2210.09191.pdf.
tbb::combinable< double > * partial_cost_functions
array storing the partial cost functions