Qrack  9.0
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(bitCapInt mask) { return ForceMParity(mask, false, false); }
28 
33  virtual void UniformParityRZ(bitCapInt mask, real1_f angle)
34  {
35  CUniformParityRZ(std::vector<bitLenInt>(), mask, angle);
36  }
37 
39  virtual real1_f ProbParity(bitCapInt mask) = 0;
40 
47  virtual bool ForceMParity(bitCapInt mask, bool result, bool doForce = true) = 0;
48 
54  virtual void CUniformParityRZ(const std::vector<bitLenInt>& controls, bitCapInt mask, real1_f angle) = 0;
55 };
56 } // namespace Qrack
Definition: qparity.hpp:22
virtual real1_f ProbParity(bitCapInt mask)=0
Overall probability of any odd permutation of the masked set of bits.
virtual void CUniformParityRZ(const std::vector< bitLenInt > &controls, 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 bool ForceMParity(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 bool MParity(bitCapInt mask)
Measure (and collapse) parity of the masked set of qubits.
Definition: qparity.hpp:27
virtual void UniformParityRZ(bitCapInt mask, real1_f angle)
If the target qubit set parity is odd, this applies a phase factor of .
Definition: qparity.hpp:33
Definition: complex16x2simd.hpp:25
std::shared_ptr< QParity > QParityPtr
Definition: qparity.hpp:19
float real1_f
Definition: qrack_types.hpp:64
#define bitCapInt
Definition: qrack_types.hpp:105