Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
squander::density::NoisyCircuit Class Reference

Quantum circuit with noise for density matrix simulation. More...

#include <noisy_circuit.h>

Classes

struct  OperationInfo
 Information about a circuit operation. More...
 

Public Member Functions

void add_amplitude_damping (int target)
 Add parametric amplitude damping noise (1 parameter) More...
 
void add_amplitude_damping (int target, double gamma)
 Add fixed amplitude damping noise (T1 relaxation, 0 parameters) More...
 
void add_CH (int target, int control)
 
void add_CNOT (int target, int control)
 
void add_CP (int target, int control)
 1 parameter More...
 
void add_CRX (int target, int control)
 1 parameter More...
 
void add_CRY (int target, int control)
 1 parameter More...
 
void add_CRZ (int target, int control)
 1 parameter More...
 
void add_CZ (int target, int control)
 
void add_depolarizing (int qbit_num)
 Add parametric depolarizing noise channel (1 parameter) More...
 
void add_depolarizing (int qbit_num, double error_rate)
 Add fixed depolarizing noise channel (0 parameters) More...
 
void add_H (int target)
 
void add_local_depolarizing (int target)
 Add parametric local single-qubit depolarizing noise (1 parameter) More...
 
void add_local_depolarizing (int target, double error_rate)
 Add fixed local single-qubit depolarizing noise (0 parameters) More...
 
void add_phase_damping (int target)
 Add parametric phase damping noise (1 parameter) More...
 
void add_phase_damping (int target, double lambda)
 Add fixed phase damping noise (T2 dephasing, 0 parameters) More...
 
void add_RX (int target)
 1 parameter More...
 
void add_RY (int target)
 1 parameter More...
 
void add_RZ (int target)
 1 parameter More...
 
void add_S (int target)
 
void add_Sdg (int target)
 
void add_SX (int target)
 
void add_T (int target)
 
void add_Tdg (int target)
 
void add_U1 (int target)
 1 parameter More...
 
void add_U2 (int target)
 2 parameters More...
 
void add_U3 (int target)
 3 parameters More...
 
void add_X (int target)
 
void add_Y (int target)
 
void add_Z (int target)
 
void apply_to (const double *params, int param_count, DensityMatrix &rho)
 Apply entire circuit to density matrix. More...
 
void apply_to (const matrix_base< double > &params, DensityMatrix &rho)
 Apply circuit using Matrix_real (backward compatibility) More...
 
size_t get_operation_count () const
 Get number of operations in the circuit. More...
 
std::vector< OperationInfoget_operation_info () const
 Get information about all operations. More...
 
int get_parameter_num () const
 Get total number of parameters needed. More...
 
int get_qbit_num () const
 Get number of qubits. More...
 
 NoisyCircuit (int qbit_num)
 Create empty circuit for n qubits. More...
 
 NoisyCircuit (const NoisyCircuit &)=delete
 
 NoisyCircuit (NoisyCircuit &&other) noexcept
 
NoisyCircuitoperator= (const NoisyCircuit &)=delete
 
NoisyCircuitoperator= (NoisyCircuit &&other) noexcept
 
 ~NoisyCircuit ()
 Destructor. More...
 

Private Member Functions

void add_gate_internal (Gate *gate)
 
void add_operation (std::unique_ptr< IDensityOperation > op)
 

Private Attributes

std::vector< std::unique_ptr< IDensityOperation > > operations_
 
std::vector< intparam_starts_
 
int qbit_num_
 
int total_params_ = 0
 

Detailed Description

Quantum circuit with noise for density matrix simulation.

NoisyCircuit manages a sequence of unitary gates and noise channels, providing a unified interface to build and execute noisy quantum circuits.

Key features:

Example:

NoisyCircuit circuit(2);
circuit.add_H(0);
circuit.add_CNOT(1, 0);
circuit.add_depolarizing(2, 0.01); // Fixed 1% noise
circuit.add_RZ(0); // Parametric gate
circuit.add_phase_damping(0); // Parametric noise
DensityMatrix rho(2);
std::vector<double> params = {0.5, 0.02}; // RZ angle, phase damping λ
circuit.apply_to(params.data(), params.size(), rho);

Definition at line 57 of file noisy_circuit.h.

Constructor & Destructor Documentation

◆ NoisyCircuit() [1/3]

squander::density::NoisyCircuit::NoisyCircuit ( int  qbit_num)
explicit

Create empty circuit for n qubits.

Parameters
qbit_numNumber of qubits (must be >= 1)

Definition at line 52 of file noisy_circuit.cpp.

Here is the call graph for this function:

◆ ~NoisyCircuit()

squander::density::NoisyCircuit::~NoisyCircuit ( )
default

Destructor.

Here is the caller graph for this function:

◆ NoisyCircuit() [2/3]

squander::density::NoisyCircuit::NoisyCircuit ( const NoisyCircuit )
delete

◆ NoisyCircuit() [3/3]

squander::density::NoisyCircuit::NoisyCircuit ( NoisyCircuit &&  other)
noexcept

Definition at line 64 of file noisy_circuit.cpp.

Member Function Documentation

◆ add_amplitude_damping() [1/2]

void squander::density::NoisyCircuit::add_amplitude_damping ( int  target)

Add parametric amplitude damping noise (1 parameter)

Parameters
targetTarget qubit index

Definition at line 225 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_amplitude_damping() [2/2]

void squander::density::NoisyCircuit::add_amplitude_damping ( int  target,
double  gamma 
)

Add fixed amplitude damping noise (T1 relaxation, 0 parameters)

Parameters
targetTarget qubit index
gammaFixed damping γ ∈ [0,1]

Definition at line 230 of file noisy_circuit.cpp.

Here is the call graph for this function:

◆ add_CH()

void squander::density::NoisyCircuit::add_CH ( int  target,
int  control 
)

Definition at line 178 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_CNOT()

void squander::density::NoisyCircuit::add_CNOT ( int  target,
int  control 
)

Definition at line 170 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_CP()

void squander::density::NoisyCircuit::add_CP ( int  target,
int  control 
)

1 parameter

Definition at line 198 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_CRX()

void squander::density::NoisyCircuit::add_CRX ( int  target,
int  control 
)

1 parameter

Definition at line 194 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_CRY()

void squander::density::NoisyCircuit::add_CRY ( int  target,
int  control 
)

1 parameter

Definition at line 186 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_CRZ()

void squander::density::NoisyCircuit::add_CRZ ( int  target,
int  control 
)

1 parameter

Definition at line 190 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_CZ()

void squander::density::NoisyCircuit::add_CZ ( int  target,
int  control 
)

Definition at line 174 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_depolarizing() [1/2]

void squander::density::NoisyCircuit::add_depolarizing ( int  qbit_num)

Add parametric depolarizing noise channel (1 parameter)

Parameters
qbit_numNumber of qubits the noise acts on

Definition at line 206 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_depolarizing() [2/2]

void squander::density::NoisyCircuit::add_depolarizing ( int  qbit_num,
double  error_rate 
)

Add fixed depolarizing noise channel (0 parameters)

Parameters
qbit_numNumber of qubits the noise acts on
error_rateFixed error rate p ∈ [0,1]

Definition at line 210 of file noisy_circuit.cpp.

Here is the call graph for this function:

◆ add_gate_internal()

void squander::density::NoisyCircuit::add_gate_internal ( Gate gate)
private

Definition at line 94 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_H()

void squander::density::NoisyCircuit::add_H ( int  target)

Definition at line 102 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_local_depolarizing() [1/2]

void squander::density::NoisyCircuit::add_local_depolarizing ( int  target)

Add parametric local single-qubit depolarizing noise (1 parameter)

Parameters
targetTarget qubit index

Definition at line 215 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_local_depolarizing() [2/2]

void squander::density::NoisyCircuit::add_local_depolarizing ( int  target,
double  error_rate 
)

Add fixed local single-qubit depolarizing noise (0 parameters)

Parameters
targetTarget qubit index
error_rateFixed depolarizing strength p in [0,1]

Definition at line 220 of file noisy_circuit.cpp.

Here is the call graph for this function:

◆ add_operation()

void squander::density::NoisyCircuit::add_operation ( std::unique_ptr< IDensityOperation op)
private

Definition at line 88 of file noisy_circuit.cpp.

Here is the caller graph for this function:

◆ add_phase_damping() [1/2]

void squander::density::NoisyCircuit::add_phase_damping ( int  target)

Add parametric phase damping noise (1 parameter)

Parameters
targetTarget qubit index

Definition at line 235 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_phase_damping() [2/2]

void squander::density::NoisyCircuit::add_phase_damping ( int  target,
double  lambda 
)

Add fixed phase damping noise (T2 dephasing, 0 parameters)

Parameters
targetTarget qubit index
lambdaFixed dephasing λ ∈ [0,1]

Definition at line 239 of file noisy_circuit.cpp.

Here is the call graph for this function:

◆ add_RX()

void squander::density::NoisyCircuit::add_RX ( int  target)

1 parameter

Definition at line 142 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_RY()

void squander::density::NoisyCircuit::add_RY ( int  target)

1 parameter

Definition at line 146 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_RZ()

void squander::density::NoisyCircuit::add_RZ ( int  target)

1 parameter

Definition at line 150 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_S()

void squander::density::NoisyCircuit::add_S ( int  target)

Definition at line 118 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_Sdg()

void squander::density::NoisyCircuit::add_Sdg ( int  target)

Definition at line 122 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_SX()

void squander::density::NoisyCircuit::add_SX ( int  target)

Definition at line 134 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_T()

void squander::density::NoisyCircuit::add_T ( int  target)

Definition at line 126 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_Tdg()

void squander::density::NoisyCircuit::add_Tdg ( int  target)

Definition at line 130 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_U1()

void squander::density::NoisyCircuit::add_U1 ( int  target)

1 parameter

Definition at line 154 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_U2()

void squander::density::NoisyCircuit::add_U2 ( int  target)

2 parameters

Definition at line 158 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_U3()

void squander::density::NoisyCircuit::add_U3 ( int  target)

3 parameters

Definition at line 162 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_X()

void squander::density::NoisyCircuit::add_X ( int  target)

Definition at line 106 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_Y()

void squander::density::NoisyCircuit::add_Y ( int  target)

Definition at line 110 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_Z()

void squander::density::NoisyCircuit::add_Z ( int  target)

Definition at line 114 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_to() [1/2]

void squander::density::NoisyCircuit::apply_to ( const double *  params,
int  param_count,
DensityMatrix rho 
)

Apply entire circuit to density matrix.

Parameters
paramsParameter array (gate params followed by noise params)
param_countTotal number of parameters
rhoDensity matrix to modify in-place

Parameters are consumed in the order operations were added. Each parametric operation extracts its parameters from the array.

Definition at line 248 of file noisy_circuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_to() [2/2]

void squander::density::NoisyCircuit::apply_to ( const matrix_base< double > &  params,
DensityMatrix rho 
)

Apply circuit using Matrix_real (backward compatibility)

Definition at line 271 of file noisy_circuit.cpp.

Here is the call graph for this function:

◆ get_operation_count()

size_t squander::density::NoisyCircuit::get_operation_count ( ) const
inline

Get number of operations in the circuit.

Definition at line 217 of file noisy_circuit.h.

Here is the caller graph for this function:

◆ get_operation_info()

std::vector< NoisyCircuit::OperationInfo > squander::density::NoisyCircuit::get_operation_info ( ) const

Get information about all operations.

Definition at line 281 of file noisy_circuit.cpp.

Here is the caller graph for this function:

◆ get_parameter_num()

int squander::density::NoisyCircuit::get_parameter_num ( ) const
inline

Get total number of parameters needed.

Definition at line 212 of file noisy_circuit.h.

Here is the caller graph for this function:

◆ get_qbit_num()

int squander::density::NoisyCircuit::get_qbit_num ( ) const
inline

Get number of qubits.

Definition at line 207 of file noisy_circuit.h.

Here is the caller graph for this function:

◆ operator=() [1/2]

NoisyCircuit& squander::density::NoisyCircuit::operator= ( const NoisyCircuit )
delete

◆ operator=() [2/2]

NoisyCircuit & squander::density::NoisyCircuit::operator= ( NoisyCircuit &&  other)
noexcept

Definition at line 72 of file noisy_circuit.cpp.

Member Data Documentation

◆ operations_

std::vector<std::unique_ptr<IDensityOperation> > squander::density::NoisyCircuit::operations_
private

Definition at line 240 of file noisy_circuit.h.

◆ param_starts_

std::vector<int> squander::density::NoisyCircuit::param_starts_
private

Definition at line 241 of file noisy_circuit.h.

◆ qbit_num_

int squander::density::NoisyCircuit::qbit_num_
private

Definition at line 239 of file noisy_circuit.h.

◆ total_params_

int squander::density::NoisyCircuit::total_params_ = 0
private

Definition at line 242 of file noisy_circuit.h.


The documentation for this class was generated from the following files: