143 Gate(
int qbit_num_in);
152 Gate(
int qbit_num_in,
const std::vector<int>& target_qbits_in,
const std::vector<int>& control_qbits_in = std::vector<int>());
190 virtual void apply_to_list( std::vector<Matrix>& inputs,
int parallel );
206 virtual void apply_to_list( std::vector<Matrix_float>& inputs,
int parallel );
std::vector< Gate * > parents
list of parent gates to be applied in the circuit prior to this current gate
Matrix_real compute_precomputed_sincos(const Matrix_real ¶meters) const
Public wrapper to precompute gate-local sin/cos pairs.
Gate()
Default constructor of the class.
Header file of single-precision complex array storage with automatic and thread safe reference counti...
virtual Matrix inverse_gate_kernel(const Matrix_real &precomputed_sincos)
bool matrix_alloc_float_valid
void set_control_qbits(const std::vector< int > &control_qbits_in)
Call to set the control qubits for the gate operation.
Class to store single-precision real arrays and properties.
virtual void gate_kernel_to(const Matrix_real &precomputed_sincos, Matrix &output)
virtual Matrix derivative_aux_kernel(const Matrix_real &precomputed_sincos, int param_idx)
void add_child(Gate *child)
Call to add a child gate to the current gate.
virtual Matrix get_matrix()
Retrieve the gate matrix for zero-parameter gates (no parameters).
void clear_children()
Call to erase data on children.
std::vector< int > target_qbits
Vector of target qubit indices (for multi-qubit gates)
int control_qbit
The index of the qubit which acts as a control qubit (control_qbit >= 0) in controlled operations...
virtual std::vector< Matrix > apply_derivate_to(Matrix_real ¶meters_mtx_in, Matrix &input, int parallel)
Call to evaluate the derivate of the circuit on an inout with respect to all of the free parameters...
virtual Gate * clone()
Call to create a clone of the present class.
void set_children(std::vector< Gate *> &children_)
Call to set the children of the current gate.
void apply_kernel_from_right(Matrix &u3_1qbit, Matrix &input, const Matrix *alt_kernel=nullptr)
Call to apply the gate kernel on the input state or unitary from right (no AVX support) ...
virtual void set_qbit_num(int qbit_num_in)
Set the number of qubits spanning the matrix of the operation.
int target_qbit
The index of the qubit on which the operation acts (target_qbit >= 0)
virtual ~Gate()
Destructor of the class.
virtual std::vector< Matrix > apply_to_combined_inner(Matrix_real ¶meters_mtx_in, const Matrix_real &precomputed_sincos, Matrix &input, int parallel)
Internal combined forward+derivative entry with precomputed sin/cos.
Header file for a class containing basic methods for setting up the verbosity level.
int matrix_size
The size N of the NxN matrix associated with the operations.
static Matrix calc_one_qubit_u3(double ThetaOver2=0.0, double Phi=0.0, double Lambda=0.0)
Build a 2x2 U3 kernel from angles (theta/2, phi, lambda).
Non-owning carrier that references either Matrix (complex128) or Matrix_float (complex64) without dat...
int parameter_start_idx
the index in the parameter array (corrensponding to the encapsulated circuit) where the gate paramete...
Non-owning carrier that can reference either Matrix_real or Matrix_real_float.
virtual void apply_from_right_inner(Matrix_real ¶meter_mtx, const Matrix_real &precomputed_sincos, Matrix &input)
Internal right-apply entry that consumes already precomputed sin/cos values.
virtual void apply_to_inner(Matrix_real ¶meter_mtx, const Matrix_real &precomputed_sincos, Matrix &input, int parallel)
Internal apply entry that consumes already precomputed sin/cos values.
A class containing basic methods for setting up the verbosity level.
gate_type type
The type of the operation (see enumeration gate_type)
virtual void apply_from_right(Matrix &input)
Call to apply the gate on the input array/matrix by input*Gate.
std::vector< int > get_control_qbits() const
Call to get the vector of control qubits.
virtual void derivative_kernel_to(const Matrix_real &precomputed_sincos, int param_idx, Matrix &output)
gate_type get_type()
Call to get the type of the operation.
Header file of complex array storage array with automatic and thread safe reference counting...
virtual void inverse_gate_kernel_to(const Matrix_real &precomputed_sincos, Matrix &output)
void set_control_qbit(int control_qbit_in)
Call to set the control qubit for the gate operation.
void set_parameter_start_idx(int start_idx)
Call to set the starting index of the parameters in the parameter array corresponding to the circuit ...
std::vector< Gate * > get_parents()
Call to get the parents of the current gate.
int get_parameter_start_idx()
Call to get the starting index of the parameters in the parameter array corresponding to the circuit ...
void add_parent(Gate *parent)
Call to add a parent gate to the current gate.
void set_target_qbit(int target_qbit_in)
Call to set the target qubit for the gate operation.
virtual Matrix_real extract_parameters(Matrix_real ¶meters)
Call to extract parameters from the parameter array corresponding to the circuit, in which the gate i...
void clear_parents()
Call to erase data on parents.
Matrix_float matrix_alloc_float
Float32 matrix of the operation, when provided directly.
void set_matrix(Matrix input)
Call to set the stored matrix in the operation.
std::vector< Gate * > get_children()
Call to get the children of the current gate.
std::vector< int > get_target_qbits() const
Call to get the vector of target qubits.
Double-precision complex matrix (float64).
std::vector< int > control_qbits
Vector of control qubit indices (for multi-qubit gates)
virtual int get_parameter_num()
Call to get the number of free parameters.
virtual Matrix gate_kernel(const Matrix_real &precomputed_sincos)
Compute the gate kernel matrix from precomputed trigonometric values.
std::string name
A string labeling the gate operation.
Single-precision complex matrix (float32).
virtual std::vector< Matrix > apply_to_combined(Matrix_real ¶meters_mtx_in, Matrix &input, int parallel)
Combined forward + derivative application with shared precomputed trig cache.
std::vector< Gate * > children
list of child gates to be applied after this current gate
int get_target_qbit()
Call to get the index of the target qubit.
Base class for the representation of general gate operations.
void set_target_qbits(const std::vector< int > &target_qbits_in)
Call to set the target qubits for the gate operation.
std::string get_name()
Call to get the name label of the gate.
void apply_kernel_to(Matrix &u3_1qbit, Matrix &input, bool deriv=false, int parallel=0, const Matrix *alt_kernel=nullptr)
Call to apply the gate kernel on the input state or unitary with optional AVX support.
virtual Matrix derivative_kernel(const Matrix_real &precomputed_sincos, int param_idx)
std::vector< Matrix > apply_derivative_to_precomputed(const Matrix_real &precomputed_sincos, Matrix &input, int parallel)
Call to evaluate the derivate of the circuit on an inout with respect to all of the free parameters...
int parameter_num
the number of free parameters of the operation
Header file for commonly used functions and wrappers to CBLAS functions.
virtual void apply_to_list(std::vector< Matrix > &inputs, int parallel)
Call to apply the gate on a list of inputs.
void set_parents(std::vector< Gate *> &parents_)
Call to set the parents of the current gate.
virtual void derivative_aux_kernel_to(const Matrix_real &precomputed_sincos, int param_idx, Matrix &output)
int qbit_num
number of qubits spanning the matrix of the operation
Matrix_real precompute_sincos(const Matrix_real ¶meters) const
Precompute sin/cos pairs for each gate-local parameter.
int get_qbit_num()
Call to get the number of qubits composing the unitary.
gate_type
Type definition of operation types (also generalized for decomposition classes derived from the class...
virtual void apply_to(Matrix &input, int parallel)
Call to apply the gate on the input array/matrix.
virtual std::vector< double > get_parameter_multipliers() const
Returns the per-parameter multipliers relative to 2Ï used by extract_parameters. ...
virtual std::vector< int > get_involved_qubits(bool only_target=false)
Call to get the qubits involved in the gate operation.
virtual void reorder_qubits(std::vector< int > qbit_list)
Call to reorder the qubits in the matrix of the operation.
Matrix matrix_alloc
Matrix of the operation.
int get_control_qbit()
Call to get the index of the control qubit.
Class to store data of complex arrays and its properties.