28 #include <tbb/spin_mutex.h> 688 void add_gates( std::vector<Gate*> gates_in );
711 const Matrix& operation_mtx,
712 const std::vector<int>&
target_qbits = std::vector<int>(),
789 virtual void reorder_qubits( std::vector<int> qbit_list )
override;
908 DFEgate_kernel_type* convert_to_DFE_gates_with_derivates(
Matrix_real& parameters_mtx,
int& gatesNum,
int& gateSetNum,
int& redundantGateSets,
bool only_derivates=
false );
914 void adjust_parameters_for_derivation(
DFEgate_kernel_type* DFEgates,
const int gatesNum,
int& gate_idx,
int& gate_set_index );
920 DFEgate_kernel_type* convert_to_batched_DFE_gates( std::vector<Matrix_real>& parameters_mtx_vec,
int& gatesNum,
int& gateSetNum,
int& redundantGateSets );
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);
1003 bool is_qbit_present(std::vector<int> involved_qbits,
int new_qbit,
int num_of_qbits);
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).
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.
std::shared_ptr< tbb::spin_mutex > involved_qubits_cache_mutex
std::vector< int > target_qbits
Vector of target qubit indices (for multi-qubit gates)
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...
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)
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
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 ¶meters, 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 ¶meters, 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
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...
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.
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
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 ¶meters_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 ¶meters_mtx, Matrix &input) override
Call to apply the gate on the input array/matrix by input*CNOT.
bool involved_target_qubits_cache_valid
std::vector< int > involved_qubits_cache
virtual void apply_to(Matrix_real ¶meters_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 ¶meters_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).
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)
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.
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.
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 ¶meters_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).
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.
Base class for the representation of general gate operations.
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
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 ¶meters) 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 ¶meters, 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 ¶meters_mtx, Matrix &input, int parallel) override
Combined forward + derivative application with shared precomputed trig cache.
Matrix get_reduced_density_matrix(Matrix_real ¶meters_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.
SmartAtomicPtr< Gates_block > fusion_block
virtual void apply_from_right_inner(Matrix_real ¶meters_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 ¶meters_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 ¶meters, 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.