Qrack  9.9
General classical-emulating-quantum development framework
qparity.hpp
Go to the documentation of this file.
1 //
3 // (C) Daniel Strano and the Qrack contributors 2017-2023. All rights reserved.
4 //
5 // This is a multithreaded, universal quantum register simulation, allowing
6 // (nonphysical) register cloning and direct measurement of probability and
7 // phase, to leverage what advantages classical emulation of qubits can have.
8 //
9 // Licensed under the GNU Lesser General Public License V3.
10 // See LICENSE.md in the project root or https://www.gnu.org/licenses/lgpl-3.0.en.html
11 // for details.
12 
13 #pragma once
14 
15 #include "common/qrack_types.hpp"
16 
17 namespace Qrack {
18 
19 class QParity;
20 typedef std::shared_ptr<QParity> QParityPtr;
21 
22 class QParity {
23 public:
27  virtual bool MParity(const bitCapInt& mask) { return ForceMParity(mask, false, false); }
28 
33  virtual void UniformParityRZ(const bitCapInt& mask, real1_f angle)
34  {
35  CUniformParityRZ(std::vector<bitLenInt>(), mask, angle);
36  }
37 
41  virtual real1_f ProbParity(const bitCapInt& mask) = 0;
42 
49  virtual bool ForceMParity(const bitCapInt& mask, bool result, bool doForce = true) = 0;
50 
56  virtual void CUniformParityRZ(const std::vector<bitLenInt>& controls, const bitCapInt& mask, real1_f angle) = 0;
57 };
58 } // namespace Qrack
Definition: qparity.hpp:22
virtual bool MParity(const bitCapInt &mask)
Measure (and collapse) parity of the masked set of qubits.
Definition: qparity.hpp:27
virtual void CUniformParityRZ(const std::vector< bitLenInt > &controls, const bitCapInt &mask, real1_f angle)=0
If the controls are set and the target qubit set parity is odd, this applies a phase factor of .
virtual void UniformParityRZ(const bitCapInt &mask, real1_f angle)
If the target qubit set parity is odd, this applies a phase factor of .
Definition: qparity.hpp:33
virtual bool ForceMParity(const bitCapInt &mask, bool result, bool doForce=true)=0
Act as if is a measurement of parity of the masked set of qubits was applied, except force the (usual...
virtual real1_f ProbParity(const bitCapInt &mask)=0
Overall probability of any odd permutation of the masked set of bits.
GLOSSARY: bitLenInt - "bit-length integer" - unsigned integer ID of qubit position in register bitCap...
Definition: complex16x2simd.hpp:25
std::shared_ptr< QParity > QParityPtr
Definition: qparity.hpp:19
float real1_f
Definition: qrack_types.hpp:91
#define bitCapInt
Definition: qrack_types.hpp:62