Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
Gates_block.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 GATES_BLOCK_H
24 #define GATES_BLOCK_H
25 
26 #include <vector>
27 #include <map>
28 #include <tbb/spin_mutex.h>
29 #include "common.h"
30 #include "matrix_real.h"
31 #include "matrix_real_any.h"
32 #include "matrix_any.h"
33 #include "CROT.h"
34 #include "Gate.h"
35 #include "utils.hpp"
36 
37 #ifdef __DFE__
38 #include "common_DFE.h"
39 #endif
40 
44 class Gates_block : public Gate {
45 
46 
47 protected:
49  std::vector<Gate*> gates;
51  int layer_num;
52 
53 
59  mutable std::vector<int> involved_qubits_cache;
60  mutable std::vector<int> involved_target_qubits_cache;
61  mutable std::shared_ptr<tbb::spin_mutex> involved_qubits_cache_mutex;
62 
64 
65 public:
66 
70 Gates_block();
71 
76 Gates_block(int qbit_num_in);
77 
78 
82 ~Gates_block() override;
83 
87 void release_gates();
88 
92 void release_gate( int idx);
93 
100 
107 Matrix get_matrix( Matrix_real& parameters, int parallel ) override;
108 
110 
111 Matrix_float get_matrix( Matrix_real_float& parameters, int parallel ) override;
112 
113 
120 void apply_to_list( Matrix_real& parameters, std::vector<Matrix>& inputs, int parallel ) override;
121 
122 void apply_to_list( Matrix_real_float& parameters, std::vector<Matrix_float>& inputs, int parallel ) override;
123 
130 virtual void apply_to( Matrix_real& parameters_mtx, Matrix& input, int parallel=0 ) override;
131 
132 virtual void apply_to_inner( Matrix_real& parameters_mtx, const Matrix_real& precomputed_sincos, Matrix& input, int parallel=0 ) override;
133 
134 virtual void apply_to( Matrix_float& input, int parallel=0 ) override;
135 
136 virtual void apply_to( Matrix_real_float& parameters_mtx, Matrix_float& input, int parallel=0 ) override;
137 
138 virtual void apply_to_inner( Matrix_real_float& parameters_mtx, const Matrix_real_float& precomputed_sincos, Matrix_float& input, int parallel=0 ) override;
139 
146 virtual void apply_to( Matrix_real_any& parameters_mtx, Matrix_any& input, int parallel=0 );
147 
148 
149 
150 
155 virtual void apply_from_right( Matrix_real& parameters_mtx, Matrix& input ) override;
156 
157 virtual void apply_from_right_inner( Matrix_real& parameters_mtx, const Matrix_real& precomputed_sincos, Matrix& input ) override;
158 
159 virtual void apply_from_right( Matrix_real_float& parameters_mtx, Matrix_float& input ) override;
160 
161 virtual void apply_from_right_inner( Matrix_real_float& parameters_mtx, const Matrix_real_float& precomputed_sincos, Matrix_float& input ) override;
162 
163 
170 virtual std::vector<Matrix> apply_derivate_to( Matrix_real& parameters_mtx, Matrix& input, int parallel ) override;
171 
172 virtual void apply_derivate_to( Matrix_real& parameters_mtx, Matrix& input, int parallel, std::vector<Matrix>& output ) override;
173 
174 void apply_derivate_to( Matrix_real& parameters_mtx, Matrix& input, int parallel, std::vector<Matrix>& output, size_t output_offset, bool resize_output );
175 
176 virtual std::vector<Matrix_float> apply_derivate_to( Matrix_real_float& parameters_mtx, Matrix_float& input, int parallel ) override;
177 
178 virtual void apply_derivate_to( Matrix_real_float& parameters_mtx, Matrix_float& input, int parallel, std::vector<Matrix_float>& output ) override;
179 
180 void apply_derivate_to( Matrix_real_float& parameters_mtx, Matrix_float& input, int parallel, std::vector<Matrix_float>& output, size_t output_offset, bool resize_output );
181 
182 virtual std::vector<Matrix> apply_to_combined( Matrix_real& parameters_mtx, Matrix& input, int parallel ) override;
183 
184 virtual void apply_to_combined( Matrix_real& parameters_mtx, Matrix& input, int parallel, std::vector<Matrix>& output ) override;
185 
186 virtual std::vector<Matrix> apply_to_combined_inner( Matrix_real& parameters_mtx, const Matrix_real& precomputed_sincos, Matrix& input, int parallel ) override;
187 
188 virtual void apply_to_combined_inner( Matrix_real& parameters_mtx, const Matrix_real& precomputed_sincos, Matrix& input, int parallel, std::vector<Matrix>& output ) override;
189 
190 virtual std::vector<Matrix_float> apply_to_combined( Matrix_real_float& parameters_mtx, Matrix_float& input, int parallel ) override;
191 
192 virtual void apply_to_combined( Matrix_real_float& parameters_mtx, Matrix_float& input, int parallel, std::vector<Matrix_float>& output ) override;
193 
194 virtual std::vector<Matrix_float> apply_to_combined_inner( Matrix_real_float& parameters_mtx, const Matrix_real_float& precomputed_sincos, Matrix_float& input, int parallel ) override;
195 
196 virtual void apply_to_combined_inner( Matrix_real_float& parameters_mtx, const Matrix_real_float& precomputed_sincos, Matrix_float& input, int parallel, std::vector<Matrix_float>& output ) override;
197 
202 void add_u1(int target_qbit);
203 
208 void add_u1_to_front(int target_qbit);
209 
214 void add_u2(int target_qbit);
215 
220 void add_u2_to_front(int target_qbit);
221 
229 void add_u3(int target_qbit);
230 
238 void add_u3_to_front(int target_qbit);
239 
244 void add_rx(int target_qbit);
245 
250 void add_rx_to_front(int target_qbit);
251 
256 void add_rxx(std::vector<int> target_qbits);
257 
262 void add_rxx_to_front(std::vector<int> target_qbits);
263 
268 void add_ryy(std::vector<int> target_qbits);
269 
274 void add_ryy_to_front(std::vector<int> target_qbits);
275 
280 void add_rzz(std::vector<int> target_qbits);
281 
286 void add_rzz_to_front(std::vector<int> target_qbits);
291 void add_r(int target_qbit);
292 
297 void add_r_to_front(int target_qbit);
298 
303 void add_ry(int target_qbit);
304 
309 void add_ry_to_front(int target_qbit);
310 
311 
312 
313 
319 void add_cry(int target_qbit, int control_qbit);
320 
327 
333 void add_crx(int target_qbit, int control_qbit);
334 
341 
347 void add_crz(int target_qbit, int control_qbit);
348 
355 
361 void add_cp(int target_qbit, int control_qbit);
362 
369 
370 
376 void add_cr(int target_qbit, int control_qbit);
377 
384 
389 void add_rz(int target_qbit);
390 
395 void add_rz_to_front(int target_qbit);
396 
397 
398 
399 
405 void add_cnot( int target_qbit, int control_qbit);
406 
407 
408 
415 
416 
422 void add_crot( int target_qbit, int control_qbit);
423 
424 
425 
432 
438 void add_cz( int target_qbit, int control_qbit);
439 
440 
441 
447 void add_cz_to_front( int target_qbit, int control_qbit );
448 
449 
455 void add_ch( int target_qbit, int control_qbit);
456 
457 
458 
464 void add_ch_to_front( int target_qbit, int control_qbit );
465 
471 void add_cu( int target_qbit, int control_qbit);
472 
473 
474 
480 void add_cu_to_front( int target_qbit, int control_qbit );
481 
487 void add_ccx( int target_qbit, const std::vector<int>& control_qbits);
488 
494 void add_ccx_to_front( int target_qbit, const std::vector<int>& control_qbits );
495 
500 void add_swap( const std::vector<int>& target_qbits);
501 
506 void add_swap_to_front( const std::vector<int>& target_qbits );
507 
513 void add_cswap( const std::vector<int>& target_qbits, const std::vector<int>& control_qbits);
514 
520 void add_cswap_to_front( const std::vector<int>& target_qbits, const std::vector<int>& control_qbits );
521 
526 void add_h(int target_qbit);
527 
532 void add_h_to_front(int target_qbit);
533 
534 
539 void add_x(int target_qbit);
540 
545 void add_x_to_front(int target_qbit);
546 
547 
552 void add_y(int target_qbit);
553 
558 void add_y_to_front(int target_qbit);
559 
560 
565 void add_z(int target_qbit);
566 
571 void add_z_to_front(int target_qbit);
572 
573 
578 void add_s(int target_qbit);
579 
584 void add_s_to_front(int target_qbit);
585 
586 
591 void add_sdg(int target_qbit);
592 
597 void add_sdg_to_front(int target_qbit);
598 
599 
604 void add_t(int target_qbit);
605 
610 void add_t_to_front(int target_qbit);
611 
612 
617 void add_tdg(int target_qbit);
618 
623 void add_tdg_to_front(int target_qbit);
624 
625 
630 void add_sx(int target_qbit);
631 
636 void add_sx_to_front(int target_qbit);
637 
642 void add_sxdg(int target_qbit);
643 
649 
655 void add_syc( int target_qbit, int control_qbit);
656 
657 
658 
664 void add_syc_to_front( int target_qbit, int control_qbit );
665 
666 
667 
668 
674 void add_adaptive(int target_qbit, int control_qbit);
675 
682 
683 
688 void add_gates( std::vector<Gate*> gates_in );
689 
690 
695 void add_gates_to_front( std::vector<Gate*> gates_in );
696 
697 
702 void add_gate( Gate* gate );
703 
711  const Matrix& operation_mtx,
712  const std::vector<int>& target_qbits = std::vector<int>(),
713  const std::vector<int>& control_qbits = std::vector<int>()
714 );
715 
720 void add_gate_to_front( Gate* gate );
721 
722 
728 void insert_gate( Gate* gate, int idx );
729 
730 
735 void add_gate_nums( std::map<std::string, int>& gate_nums );
736 
737 
742 std::map<std::string, int> get_gate_nums();
743 
744 
749 int get_parameter_num() override;
750 
751 
752 
757 int get_gate_num();
758 
759 
765 void list_gates( const Matrix_real &parameters, int start_index );
766 
767 
773 Gates_block* create_remapped_circuit( const std::map<int, int>& qbit_map );
774 
775 
782 Gates_block* create_remapped_circuit( const std::map<int, int>& qbit_map, const int qbit_num_ );
783 
784 
789 virtual void reorder_qubits( std::vector<int> qbit_list ) override;
790 
791 
796 std::vector<int> get_involved_qubits(bool only_target=false) override;
797 
802 std::vector<Gate*> get_gates();
803 
804 
809 Gate* get_gate(int idx);
810 
815 void combine(Gates_block* op_block);
816 
817 
818 
819 void set_min_fusion( int min_fusion );
820 
825 virtual void set_qbit_num( int qbit_num_in ) override;
826 
827 
832 virtual Gates_block* clone() override;
833 
839 int extract_gates( Gates_block* op_block );
840 
841 
842 
848 
854 bool contains_adaptive_gate(int idx);
855 
856 
857 
865 Matrix get_reduced_density_matrix( Matrix_real& parameters_mtx, Matrix& input_state, matrix_base<int>& qbit_list_subset );
866 
867 
868 
876 double get_second_Renyi_entropy( Matrix_real& parameters_mtx, Matrix& input_state, matrix_base<int>& qbit_list );
877 
878 
879 
884 void determine_parents( Gate* gate );
885 
886 
891 void determine_children( Gate* gate );
892 
893 
894 
896 
897 void fragment_circuit();
898 void get_parameter_max(Matrix_real &range_max);
899 
901 
902 #ifdef __DFE__
903 
908 DFEgate_kernel_type* convert_to_DFE_gates_with_derivates( Matrix_real& parameters_mtx, int& gatesNum, int& gateSetNum, int& redundantGateSets, bool only_derivates=false );
909 
914 void adjust_parameters_for_derivation( DFEgate_kernel_type* DFEgates, const int gatesNum, int& gate_idx, int& gate_set_index );
915 
920 DFEgate_kernel_type* convert_to_batched_DFE_gates( std::vector<Matrix_real>& parameters_mtx_vec, int& gatesNum, int& gateSetNum, int& redundantGateSets );
921 
922 
923 
928 DFEgate_kernel_type* convert_to_DFE_gates( Matrix_real& parameters_mtx, int& gatesNum );
929 
934 void convert_to_DFE_gates( const Matrix_real& parameters_mtx, DFEgate_kernel_type* DFEgates, int& start_index );
935 
936 #endif
937 
938 
939 #ifdef __GROQ__
940 
941 void extract_gate_kernels_target_and_control_qubits(std::vector<Matrix> &u3_qbit, std::vector<int> &target_qbit, std::vector<int> &control_qbit, Matrix_real& parameters_mtx);
942 
943 #endif
944 
945 
950 
951 
952 
957 
958 
963 
964 
971 
972 };
973 
974 
975 
980 void export_gate_list_to_binary(Matrix_real& parameters, Gates_block* gates_block, const std::string& filename, int verbosity=3);
981 
986 void export_gate_list_to_binary(Matrix_real& parameters, Gates_block* gates_block, FILE* pFile, int verbosity=3);
987 
988 
993 Gates_block* import_gate_list_from_binary(Matrix_real& parameters, const std::string& filename, int verbosity=3);
994 
995 
1000 Gates_block* import_gate_list_from_binary(Matrix_real& parameters, FILE* pFile, int verbosity=3);
1001 
1003 bool is_qbit_present(std::vector<int> involved_qbits, int new_qbit, int num_of_qbits);
1005 
1006 
1007 
1014 Matrix_real reverse_parameters( const Matrix_real& v_in, std::vector<Gate*>::iterator gates_it, int num_of_gates );
1015 
1016 
1023 Matrix_real inverse_reverse_parameters( const Matrix_real& v_in, std::vector<Gate*>::iterator gates_it, int num_of_gates );
1024 
1025 #endif //GATES_BLOCK,
void add_crz(int target_qbit, int control_qbit)
Append a CRY gate to the list of gates.
Gates_block * get_flat_circuit()
Method to generate a flat circuit.
void add_swap_to_front(const std::vector< int > &target_qbits)
Add a SWAP gate to the front of the list of gates.
virtual void reorder_qubits(std::vector< int > qbit_list) override
Call to reorder the qubits in the matrix of the gates (Obsolete function)
void add_adaptive(int target_qbit, int control_qbit)
Append a Adaptive gate to the list of gates.
void add_cu(int target_qbit, int control_qbit)
Append a CU gate (i.e.
void add_rxx_to_front(std::vector< int > target_qbits)
Add a RXX gate to the front of the list of gates.
void add_rxx(std::vector< int > target_qbits)
Append a RXX gate to the list of gates.
Header file for a class for the representation of general gate operations.
Class to store single-precision real arrays and properties.
void release_gate(int idx)
Call to release one gate in the list.
void determine_parents(Gate *gate)
Call to obtain the parent gates in the circuit.
void add_cswap(const std::vector< int > &target_qbits, const std::vector< int > &control_qbits)
Append a CSWAP gate (Controlled SWAP) to the list of gates.
void add_z_to_front(int target_qbit)
Add a Z gate to the front of the list of gates.
void add_h(int target_qbit)
Append a Hadamard gate to the list of gates.
void add_sdg_to_front(int target_qbit)
Add a Sdg gate to the front of the list of gates.
virtual Matrix get_matrix()
Retrieve the gate matrix for zero-parameter gates (no parameters).
Definition: Gate.cpp:283
std::map< std::string, int > get_gate_nums()
Call to get the number of the individual gate types in the list of gates.
Matrix_real reverse_parameters(const Matrix_real &v_in, std::vector< Gate *>::iterator gates_it, int num_of_gates)
Call to reverse the order of the parameters in an array.
void fragment_circuit()
std::shared_ptr< tbb::spin_mutex > involved_qubits_cache_mutex
Definition: Gates_block.h:61
std::vector< int > target_qbits
Vector of target qubit indices (for multi-qubit gates)
Definition: Gate.h:102
void add_x(int target_qbit)
Append a X gate to the list of gates.
void add_sdg(int target_qbit)
Append a Sdg gate to the list of gates.
int control_qbit
The index of the qubit which acts as a control qubit (control_qbit >= 0) in controlled operations...
Definition: Gate.h:100
void add_gate(Gate *gate)
Append a general gate to the list of gates.
void add_u2(int target_qbit)
Append a U2 gate to the list of gates.
void add_cp(int target_qbit, int control_qbit)
Append a CRY gate to the list of gates.
void add_cnot_to_front(int target_qbit, int control_qbit)
Add a C_NOT gate gate to the front of the list of gates.
void add_u1(int target_qbit)
Append a U1 gate to the list of gates.
Header file for a class representing a controlled rotation gate around the Y axis.
int target_qbit
The index of the qubit on which the operation acts (target_qbit >= 0)
Definition: Gate.h:98
std::vector< Gate * > get_gates()
Call to get the gates stored in the class.
Gates_block * create_remapped_circuit(const std::map< int, int > &qbit_map)
Call to create a new circuit with remapped qubits.
void release_gates()
Call to release the stored gates.
void add_cswap_to_front(const std::vector< int > &target_qbits, const std::vector< int > &control_qbits)
Add a CSWAP gate (Controlled SWAP) to the front of the list of gates.
void add_general_operation(const Matrix &operation_mtx, const std::vector< int > &target_qbits=std::vector< int >(), const std::vector< int > &control_qbits=std::vector< int >())
Append a GENERAL_OPERATION gate with an explicitly provided matrix.
void get_parameter_max(Matrix_real &range_max)
void add_r(int target_qbit)
Append a R gate to the list of gates.
virtual Gates_block * clone() override
Create a clone of the present class.
int layer_num
number of gate layers
Definition: Gates_block.h:51
void add_cnot(int target_qbit, int control_qbit)
Append a CNOT gate gate to the list of gates.
void add_cr(int target_qbit, int control_qbit)
Append a CR gate to the list of gates.
Gates_block * import_gate_list_from_binary(Matrix_real &parameters, const std::string &filename, int verbosity=3)
?????????
virtual void set_qbit_num(int qbit_num_in) override
Set the number of qubits spanning the matrix of the gates stored in the block of gates.
void add_cz_to_front(int target_qbit, int control_qbit)
Add a CZ gate gate to the front of the list of gates.
void apply_to_list(Matrix_real &parameters, std::vector< Matrix > &inputs, int parallel) override
Call to apply the gate on the input array/matrix by U3*input.
void add_ryy(std::vector< int > target_qbits)
Append a RYY gate to the list of gates.
bool involved_qubits_cache_valid
Definition: Gates_block.h:57
void add_rz_to_front(int target_qbit)
Add a RZ gate to the front of the list of gates.
Non-owning carrier that references either Matrix (complex128) or Matrix_float (complex64) without dat...
Definition: matrix_any.h:30
void add_r_to_front(int target_qbit)
Add a R gate to the front of the list of gates.
int get_gate_num()
Call to get the number of gates grouped in the class.
void add_crx_to_front(int target_qbit, int control_qbit)
Add a CRY gate to the front of the list of gates.
void add_h_to_front(int target_qbit)
Add a Hadamard gate to the front of the list of gates.
void add_ccx_to_front(int target_qbit, const std::vector< int > &control_qbits)
Add a CCX gate (i.e.
Non-owning carrier that can reference either Matrix_real or Matrix_real_float.
std::vector< Gate * > gates
The list of stored gates.
Definition: Gates_block.h:49
void add_x_to_front(int target_qbit)
Add a X gate to the front of the list of gates.
void add_sx_to_front(int target_qbit)
Add a SX gate to the front of the list of gates.
std::vector< int > involved_target_qubits_cache
Definition: Gates_block.h:60
void add_sxdg(int target_qbit)
Append a SXdg gate to the list of gates.
~Gates_block() override
Destructor of the class.
void add_y_to_front(int target_qbit)
Add a Y gate to the front of the list of gates.
void add_syc(int target_qbit, int control_qbit)
Append a Sycamore gate (i.e.
double get_second_Renyi_entropy(Matrix_real &parameters_mtx, Matrix &input_state, matrix_base< int > &qbit_list)
Call to evaluate the seconf Rényi entropy.
void add_syc_to_front(int target_qbit, int control_qbit)
Add a Sycamore gate (i.e.
void add_ch(int target_qbit, int control_qbit)
Append a CH gate (i.e.
void add_s_to_front(int target_qbit)
Add a S gate to the front of the list of gates.
void add_ch_to_front(int target_qbit, int control_qbit)
Add a CH gate (i.e.
void add_u2_to_front(int target_qbit)
Add a U2 gate to the front of the list of gates.
void add_u3(int target_qbit)
Append a U3 gate to the list of gates.
void add_rz(int target_qbit)
Append a RZ gate to the list of gates.
void add_y(int target_qbit)
Append a Y gate to the list of gates.
void reset_dependency_graph()
Method to reset the dependency graph of the gates in the circuit.
void combine(Gates_block *op_block)
Call to append the gates of an gate block to the current block.
void add_ry(int target_qbit)
Append a RY gate to the list of gates.
virtual void apply_from_right(Matrix_real &parameters_mtx, Matrix &input) override
Call to apply the gate on the input array/matrix by input*CNOT.
bool involved_target_qubits_cache_valid
Definition: Gates_block.h:58
std::vector< int > involved_qubits_cache
Definition: Gates_block.h:59
virtual void apply_to(Matrix_real &parameters_mtx, Matrix &input, int parallel=0) override
Call to apply the gate on the input array/matrix Gates_block*input.
void set_min_fusion(int min_fusion)
void add_ccx(int target_qbit, const std::vector< int > &control_qbits)
Append a CCX gate (i.e.
void add_cu_to_front(int target_qbit, int control_qbit)
Add a CU gate (i.e.
void add_s(int target_qbit)
Append a S gate to the list of gates.
virtual void apply_to_inner(Matrix_real &parameters_mtx, const Matrix_real &precomputed_sincos, Matrix &input, int parallel=0) override
Internal apply entry that consumes already precomputed sin/cos values.
void determine_children(Gate *gate)
Call to obtain the child gates in the circuit.
void add_u1_to_front(int target_qbit)
Add a U1 gate to the front of the list of gates.
int extract_gates(Gates_block *op_block)
Call to extract the gates stored in the class.
void add_cry_to_front(int target_qbit, int control_qbit)
Add a CRY gate to the front of the list of gates.
bool contains_adaptive_gate()
Call to determine, whether the circuit contains daptive gate or not.
Double-precision complex matrix (float64).
Definition: matrix.h:38
void add_gates_to_front(std::vector< Gate *> gates_in)
Add an array of gates to the front of the list of gates.
void add_gate_to_front(Gate *gate)
Add an gate to the front of the list of gates.
void add_z(int target_qbit)
Append a Z gate to the list of gates.
void add_ryy_to_front(std::vector< int > target_qbits)
Add a RYY gate to the front of the list of gates.
std::vector< int > control_qbits
Vector of control qubit indices (for multi-qubit gates)
Definition: Gate.h:104
void add_cry(int target_qbit, int control_qbit)
Append a CRY gate to the list of gates.
Gates_block()
Default constructor of the class.
Definition: Gates_block.cpp:82
void add_rx_to_front(int target_qbit)
Add a RX gate to the front of the list of gates.
void add_tdg_to_front(int target_qbit)
Add a Tdg gate to the front of the list of gates.
A class responsible for grouping two-qubit (CNOT,CZ,CH) and one-qubit gates into layers.
Definition: Gates_block.h:44
void add_tdg(int target_qbit)
Append a Tdg gate to the list of gates.
void add_u3_to_front(int target_qbit)
Add a U3 gate to the front of the list of gates.
virtual std::vector< Matrix > apply_to_combined_inner(Matrix_real &parameters_mtx, const Matrix_real &precomputed_sincos, Matrix &input, int parallel) override
Internal combined forward+derivative entry with precomputed sin/cos.
Single-precision complex matrix (float32).
Definition: matrix_float.h:41
void add_cz(int target_qbit, int control_qbit)
Append a CZ gate gate to the list of gates.
Fixed point data related to a gate operation.
Definition: common_DFE.h:62
Base class for the representation of general gate operations.
Definition: Gate.h:86
bool is_qbit_present(std::vector< int > involved_qbits, int new_qbit, int num_of_qbits)
Call to check whether the given qubit is involved in the sub-circuit or not.
void add_rzz_to_front(std::vector< int > target_qbits)
Add a RZZ gate to the front of the list of gates.
void add_gate_nums(std::map< std::string, int > &gate_nums)
Call to add the number of the individual gate types in the circuit to the map given in the argument...
void add_ry_to_front(int target_qbit)
Add a RY gate to the front of the list of gates.
Header file for commonly used functions and wrappers to CBLAS functions.
int min_fusion
maximal number of qubits in partitions
Definition: Gates_block.h:55
void add_rx(int target_qbit)
Append a RX gate to the list of gates.
void insert_gate(Gate *gate, int idx)
Call to insert a gate at a given position.
void reset_parameter_start_indices()
Method to reset the parameter start indices of gate operations incorporated in the circuit...
Matrix_real inverse_reverse_parameters(const Matrix_real &v_in, std::vector< Gate *>::iterator gates_it, int num_of_gates)
Call to inverse-reverse the order of the parameters in an array.
void add_crz_to_front(int target_qbit, int control_qbit)
Add a CRY gate to the front of the list of gates.
void add_t_to_front(int target_qbit)
Add a T gate to the front of the list of gates.
void add_crot(int target_qbit, int control_qbit)
Append a CROT gate gate to the list of gates.
void add_crot_to_front(int target_qbit, int control_qbit)
Add a CROT gate gate to the front of the list of gates.
Header file for DFE support in unitary simulation.
virtual Matrix_real extract_parameters(Matrix_real &parameters) override
Call to extract parameters from the parameter array corresponding to the circuit, in which the gate i...
void add_crx(int target_qbit, int control_qbit)
Append a CRY gate to the list of gates.
Gate * get_gate(int idx)
Call to get the gates stored in the class.
void add_cr_to_front(int target_qbit, int control_qbit)
Add a CR gate to the front of the list of gates.
void list_gates(const Matrix_real &parameters, int start_index)
Call to print the list of gates stored in the block of gates for a specific set of parameters...
virtual std::vector< Matrix > apply_to_combined(Matrix_real &parameters_mtx, Matrix &input, int parallel) override
Combined forward + derivative application with shared precomputed trig cache.
Matrix get_reduced_density_matrix(Matrix_real &parameters_mtx, Matrix &input_state, matrix_base< int > &qbit_list_subset)
Call to evaluate the reduced densiy matrix.
void add_adaptive_to_front(int target_qbit, int control_qbit)
Add a Adaptive gate to the front of the list of gates.
std::vector< int > get_involved_qubits(bool only_target=false) override
Call to get the qubits involved in the gates stored in the block of gates.
int get_parameter_num() override
Call to get the number of free parameters.
void invalidate_structure_cache()
void add_gates(std::vector< Gate *> gates_in)
Append a list of gates to the list of gates.
void add_cp_to_front(int target_qbit, int control_qbit)
Add a CRY gate to the front of the list of gates.
void add_sxdg_to_front(int target_qbit)
Add a SXdg gate to the front of the list of gates.
void add_t(int target_qbit)
Append a T gate to the list of gates.
Class to store data of complex arrays and its properties.
Definition: matrix_real.h:41
SmartAtomicPtr< Gates_block > fusion_block
Definition: Gates_block.h:56
virtual void apply_from_right_inner(Matrix_real &parameters_mtx, const Matrix_real &precomputed_sincos, Matrix &input) override
Internal right-apply entry that consumes already precomputed sin/cos values.
virtual std::vector< Matrix > apply_derivate_to(Matrix_real &parameters_mtx, Matrix &input, int parallel) override
Call to evaluate the derivate of the circuit on an inout with respect to all of the free parameters...
void export_gate_list_to_binary(Matrix_real &parameters, Gates_block *gates_block, const std::string &filename, int verbosity=3)
?????????
void add_rzz(std::vector< int > target_qbits)
Append a RZZ gate to the list of gates.
void add_sx(int target_qbit)
Append a SX gate to the list of gates.
void add_swap(const std::vector< int > &target_qbits)
Append a SWAP gate to the list of gates.