Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
noise_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 "density_operation.h"
20 
21 namespace squander {
22 namespace density {
23 
37 public:
38  bool is_unitary() const override { return false; }
39 };
40 
65 public:
71  DepolarizingOp(int qbit_num, double error_rate);
72 
77  explicit DepolarizingOp(int qbit_num);
78 
79  void apply_to_density(const double *params, int param_count,
80  DensityMatrix &rho) override;
81 
82  int get_parameter_num() const override { return is_parametric_ ? 1 : 0; }
83  std::string get_name() const override { return "Depolarizing"; }
84 
85  std::unique_ptr<IDensityOperation> clone() const override;
86 
87  // Accessors
88  int get_qbit_num() const { return qbit_num_; }
89  double get_error_rate() const { return fixed_error_rate_; }
90  bool is_parametric() const { return is_parametric_; }
91 
92 private:
93  int qbit_num_;
96 
97  void apply_depolarizing(DensityMatrix &rho, double error_rate);
98 };
99 
108 public:
109  LocalDepolarizingOp(int target_qbit, double error_rate);
110  explicit LocalDepolarizingOp(int target_qbit);
111 
112  void apply_to_density(const double *params, int param_count,
113  DensityMatrix &rho) override;
114 
115  int get_parameter_num() const override { return is_parametric_ ? 1 : 0; }
116  std::string get_name() const override { return "LocalDepolarizing"; }
117 
118  std::unique_ptr<IDensityOperation> clone() const override;
119 
120  int get_target_qbit() const { return target_qbit_; }
121  double get_error_rate() const { return fixed_error_rate_; }
122  bool is_parametric() const { return is_parametric_; }
123 
124 private:
128 
129  void apply_local_depolarizing(DensityMatrix &rho, double error_rate);
130 };
131 
152 public:
158  AmplitudeDampingOp(int target_qbit, double gamma);
159 
164  explicit AmplitudeDampingOp(int target_qbit);
165 
166  void apply_to_density(const double *params, int param_count,
167  DensityMatrix &rho) override;
168 
169  int get_parameter_num() const override { return is_parametric_ ? 1 : 0; }
170  std::string get_name() const override { return "AmplitudeDamping"; }
171 
172  std::unique_ptr<IDensityOperation> clone() const override;
173 
174  // Accessors
175  int get_target_qbit() const { return target_qbit_; }
176  double get_gamma() const { return fixed_gamma_; }
177  bool is_parametric() const { return is_parametric_; }
178 
179 private:
181  double fixed_gamma_;
183 
184  void apply_amplitude_damping(DensityMatrix &rho, double gamma);
185 };
186 
209 public:
215  PhaseDampingOp(int target_qbit, double lambda);
216 
221  explicit PhaseDampingOp(int target_qbit);
222 
223  void apply_to_density(const double *params, int param_count,
224  DensityMatrix &rho) override;
225 
226  int get_parameter_num() const override { return is_parametric_ ? 1 : 0; }
227  std::string get_name() const override { return "PhaseDamping"; }
228 
229  std::unique_ptr<IDensityOperation> clone() const override;
230 
231  // Accessors
232  int get_target_qbit() const { return target_qbit_; }
233  double get_lambda() const { return fixed_lambda_; }
234  bool is_parametric() const { return is_parametric_; }
235 
236 private:
240 
241  void apply_phase_damping(DensityMatrix &rho, double lambda);
242 };
243 
244 } // namespace density
245 } // namespace squander
246 
Base class for noise channel operations (CPTP maps).
std::string get_name() const override
Get operation name for debugging/display.
virtual std::unique_ptr< IDensityOperation > clone() const =0
Create a deep copy of this operation.
Amplitude damping channel (T1 relaxation): |1⟩ → |0⟩ decay.
std::string get_name() const override
Get operation name for debugging/display.
Quantum density matrix ρ for mixed-state representation.
Phase damping channel (T2 dephasing): loss of coherence.
std::string get_name() const override
Get operation name for debugging/display.
std::string get_name() const override
Get operation name for debugging/display.
int get_parameter_num() const override
Get number of free parameters this operation requires.
Depolarizing noise channel: ρ → (1-p)ρ + p·I/2^n.
virtual void apply_to_density(const double *params, int param_count, DensityMatrix &rho)=0
Apply this operation to the density matrix.
Local single-qubit depolarizing channel on one target qubit.
int get_parameter_num() const override
Get number of free parameters this operation requires.
Interface for any operation that can be applied to a density matrix.
bool is_unitary() const override
Check if this is a unitary operation (gate) or non-unitary (noise)
int get_parameter_num() const override
Get number of free parameters this operation requires.
int get_parameter_num() const override
Get number of free parameters this operation requires.