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

Wraps an existing Gate for density matrix operations. More...

#include <gate_operation.h>

Inheritance diagram for squander::density::GateOperation:
Inheritance graph
[legend]

Public Member Functions

void apply_to_density (const double *params, int param_count, DensityMatrix &rho) override
 Apply gate to density matrix using optimized local kernel. More...
 
std::unique_ptr< IDensityOperationclone () const override
 Create a deep copy of this operation. More...
 
 GateOperation (Gate *gate, bool owns_gate=true)
 Wrap an existing gate. More...
 
 GateOperation (const GateOperation &)=delete
 
 GateOperation (GateOperation &&other) noexcept
 
int get_control_qbit () const
 Get control qubit index (-1 if not a controlled gate) More...
 
Gateget_gate () const
 Get the underlying gate (for inspection) More...
 
std::string get_name () const override
 Get operation name for debugging/display. More...
 
int get_parameter_num () const override
 Get number of free parameters this operation requires. More...
 
int get_target_qbit () const
 Get target qubit index. More...
 
bool is_unitary () const override
 Check if this is a unitary operation (gate) or non-unitary (noise) More...
 
GateOperationoperator= (const GateOperation &)=delete
 
GateOperationoperator= (GateOperation &&other) noexcept
 
 ~GateOperation () override
 Destructor - deletes gate if owns_gate was true. More...
 

Private Attributes

Gategate_
 
bool owns_gate_
 

Detailed Description

Wraps an existing Gate for density matrix operations.

This adapter allows existing SQUANDER gates (H, CNOT, RZ, etc.) to be used in noisy circuits operating on density matrices.

Uses optimized local kernel application:

Does NOT modify the original Gate class - clean separation of concerns.

Example:

Gate* h = new H(2, 0);
auto op = std::unique_ptr<GateOperation>(new GateOperation(h, true));
op->apply_to_density(nullptr, 0, rho); // H on qubit 0

Definition at line 45 of file gate_operation.h.

Constructor & Destructor Documentation

◆ GateOperation() [1/3]

squander::density::GateOperation::GateOperation ( Gate gate,
bool  owns_gate = true 
)

Wrap an existing gate.

Parameters
gateThe gate to wrap
owns_gateIf true, this wrapper will delete the gate on destruction

Definition at line 32 of file gate_operation.cpp.

Here is the caller graph for this function:

◆ ~GateOperation()

squander::density::GateOperation::~GateOperation ( )
override

Destructor - deletes gate if owns_gate was true.

Definition at line 39 of file gate_operation.cpp.

◆ GateOperation() [2/3]

squander::density::GateOperation::GateOperation ( const GateOperation )
delete

◆ GateOperation() [3/3]

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

Definition at line 50 of file gate_operation.cpp.

Member Function Documentation

◆ apply_to_density()

void squander::density::GateOperation::apply_to_density ( const double *  params,
int  param_count,
DensityMatrix rho 
)
overridevirtual

Apply gate to density matrix using optimized local kernel.

For single-qubit gates, applies the 2x2 kernel directly. For two-qubit gates, applies the 4x4 kernel directly. This is O(2^{2N+k}) instead of O(2^{3N}) for k-qubit gates.

Implements squander::density::IDensityOperation.

Definition at line 73 of file gate_operation.cpp.

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

◆ clone()

std::unique_ptr< IDensityOperation > squander::density::GateOperation::clone ( ) const
overridevirtual

Create a deep copy of this operation.

Returns
Unique pointer to the cloned operation

Implements squander::density::IDensityOperation.

Definition at line 175 of file gate_operation.cpp.

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

◆ get_control_qbit()

int squander::density::GateOperation::get_control_qbit ( ) const

Get control qubit index (-1 if not a controlled gate)

Definition at line 167 of file gate_operation.cpp.

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

◆ get_gate()

Gate* squander::density::GateOperation::get_gate ( ) const
inline

Get the underlying gate (for inspection)

Definition at line 86 of file gate_operation.h.

Here is the call graph for this function:

◆ get_name()

std::string squander::density::GateOperation::get_name ( ) const
overridevirtual

Get operation name for debugging/display.

Returns
Human-readable name (e.g., "H", "CNOT", "Depolarizing")

Implements squander::density::IDensityOperation.

Definition at line 159 of file gate_operation.cpp.

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

◆ get_parameter_num()

int squander::density::GateOperation::get_parameter_num ( ) const
overridevirtual

Get number of free parameters this operation requires.

Returns
Number of parameters (0 for constant gates/fixed noise)

Implements squander::density::IDensityOperation.

Definition at line 155 of file gate_operation.cpp.

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

◆ get_target_qbit()

int squander::density::GateOperation::get_target_qbit ( ) const

Get target qubit index.

Definition at line 163 of file gate_operation.cpp.

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

◆ is_unitary()

bool squander::density::GateOperation::is_unitary ( ) const
inlineoverridevirtual

Check if this is a unitary operation (gate) or non-unitary (noise)

Returns
true for unitary gates, false for noise channels

Implements squander::density::IDensityOperation.

Definition at line 79 of file gate_operation.h.

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

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

Definition at line 56 of file gate_operation.cpp.

Member Data Documentation

◆ gate_

Gate* squander::density::GateOperation::gate_
private

Definition at line 99 of file gate_operation.h.

◆ owns_gate_

bool squander::density::GateOperation::owns_gate_
private

Definition at line 100 of file gate_operation.h.


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