Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
gate_operation.h
Go to the documentation of this file.
1 /*
2 Copyright 2025 SQUANDER Contributors
3 
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16 
17 #pragma once
18 
19 #include "Gate.h"
20 #include "density_operation.h"
21 #include "matrix_real.h"
22 
23 namespace squander {
24 namespace density {
25 
46 public:
52  GateOperation(Gate *gate, bool owns_gate = true);
53 
57  ~GateOperation() override;
58 
59  // Disable copy (use clone() instead)
60  GateOperation(const GateOperation &) = delete;
61  GateOperation &operator=(const GateOperation &) = delete;
62 
63  // Move semantics
64  GateOperation(GateOperation &&other) noexcept;
65  GateOperation &operator=(GateOperation &&other) noexcept;
66 
74  void apply_to_density(const double *params, int param_count,
75  DensityMatrix &rho) override;
76 
77  int get_parameter_num() const override;
78  std::string get_name() const override;
79  bool is_unitary() const override { return true; }
80 
81  std::unique_ptr<IDensityOperation> clone() const override;
82 
86  Gate *get_gate() const { return gate_; }
87 
91  int get_target_qbit() const;
92 
96  int get_control_qbit() const;
97 
98 private:
101 };
102 
103 } // namespace density
104 } // namespace squander
105 
int get_control_qbit() const
Get control qubit index (-1 if not a controlled gate)
Header file for a class for the representation of general gate operations.
std::unique_ptr< IDensityOperation > clone() const override
Create a deep copy of this operation.
int get_parameter_num() const override
Get number of free parameters this operation requires.
GateOperation & operator=(const GateOperation &)=delete
Gate * get_gate() const
Get the underlying gate (for inspection)
bool is_unitary() const override
Check if this is a unitary operation (gate) or non-unitary (noise)
Wraps an existing Gate for density matrix operations.
Quantum density matrix ρ for mixed-state representation.
int get_target_qbit() const
Get target qubit index.
void apply_to_density(const double *params, int param_count, DensityMatrix &rho) override
Apply gate to density matrix using optimized local kernel.
Base class for the representation of general gate operations.
Definition: Gate.h:86
std::string get_name() const override
Get operation name for debugging/display.
~GateOperation() override
Destructor - deletes gate if owns_gate was true.
Interface for any operation that can be applied to a density matrix.
GateOperation(Gate *gate, bool owns_gate=true)
Wrap an existing gate.