Qrack  9.0
General classical-emulating-quantum development framework
qbdt_node.hpp
Go to the documentation of this file.
1 //
3 // (C) Daniel Strano and the Qrack contributors 2017-2023. All rights reserved.
4 //
5 // QBinaryDecision tree is an alternative approach to quantum state representation, as
6 // opposed to state vector representation. This is a compressed form that can be
7 // operated directly on while compressed. Inspiration for the Qrack implementation was
8 // taken from JKQ DDSIM, maintained by the Institute for Integrated Circuits at the
9 // Johannes Kepler University Linz:
10 //
11 // https://github.com/iic-jku/ddsim
12 //
13 // Licensed under the GNU Lesser General Public License V3.
14 // See LICENSE.md in the project root or https://www.gnu.org/licenses/lgpl-3.0.en.html
15 // for details.
16 
17 #pragma once
18 
19 #include "qbdt_node_interface.hpp"
20 
21 namespace Qrack {
22 
23 class QBdtNode;
24 typedef std::shared_ptr<QBdtNode> QBdtNodePtr;
25 
26 class QBdtNode : public QBdtNodeInterface {
27 protected:
28 #if ENABLE_COMPLEX_X2
29  virtual void PushStateVector(const complex2& mtrxCol1, const complex2& mtrxCol2, const complex2& mtrxColShuff1,
30  const complex2& mtrxColShuff2, QBdtNodeInterfacePtr& b0, QBdtNodeInterfacePtr& b1, bitLenInt depth,
31  bitLenInt parDepth = 1U);
32 #else
33  virtual void PushStateVector(complex const* mtrx, QBdtNodeInterfacePtr& b0, QBdtNodeInterfacePtr& b1,
34  bitLenInt depth, bitLenInt parDepth = 1U);
35 #endif
36 
37 public:
40  {
41  // Intentionally left blank
42  }
43 
45  : QBdtNodeInterface(scl)
46  {
47  // Intentionally left blank
48  }
49 
51  : QBdtNodeInterface(scl, b)
52  {
53  // Intentionally left blank
54  }
55 
56  virtual ~QBdtNode()
57  {
58  // Virtual destructor for inheritance
59  }
60 
61  virtual QBdtNodeInterfacePtr ShallowClone() { return std::make_shared<QBdtNode>(scale, branches); }
62 
63  virtual void InsertAtDepth(QBdtNodeInterfacePtr b, bitLenInt depth, const bitLenInt& size, bitLenInt parDepth = 1U);
64 
65  virtual void PopStateVector(bitLenInt depth = 1U, bitLenInt parDepth = 1U);
66 
67  virtual void Branch(bitLenInt depth = 1U, bitLenInt parDeth = 1U);
68 
69  virtual void Prune(bitLenInt depth = 1U, bitLenInt parDepth = 1U);
70 
71  virtual void Normalize(bitLenInt depth = 1U);
72 
73 #if ENABLE_COMPLEX_X2
74  virtual void Apply2x2(const complex2& mtrxCol1, const complex2& mtrxCol2, const complex2& mtrxColShuff1,
75  const complex2& mtrxColShuff2, bitLenInt depth);
76 #else
77  virtual void Apply2x2(complex const* mtrx, bitLenInt depth);
78 #endif
79 };
80 
81 } // namespace Qrack
Definition: qbdt_node_interface.hpp:36
QBdtNodeInterfacePtr branches[2U]
Definition: qbdt_node_interface.hpp:56
complex scale
Definition: qbdt_node_interface.hpp:55
Definition: qbdt_node.hpp:26
virtual void Apply2x2(complex const *mtrx, bitLenInt depth)
Definition: node.cpp:638
virtual void Normalize(bitLenInt depth=1U)
Definition: node.cpp:245
virtual void Branch(bitLenInt depth=1U, bitLenInt parDeth=1U)
Definition: node.cpp:199
virtual void InsertAtDepth(QBdtNodeInterfacePtr b, bitLenInt depth, const bitLenInt &size, bitLenInt parDepth=1U)
Definition: node.cpp:365
virtual void PopStateVector(bitLenInt depth=1U, bitLenInt parDepth=1U)
Definition: node.cpp:286
virtual QBdtNodeInterfacePtr ShallowClone()
Definition: qbdt_node.hpp:61
virtual void Prune(bitLenInt depth=1U, bitLenInt parDepth=1U)
Definition: node.cpp:42
QBdtNode()
Definition: qbdt_node.hpp:38
QBdtNode(complex scl, QBdtNodeInterfacePtr *b)
Definition: qbdt_node.hpp:50
virtual void PushStateVector(complex const *mtrx, QBdtNodeInterfacePtr &b0, QBdtNodeInterfacePtr &b1, bitLenInt depth, bitLenInt parDepth=1U)
Definition: node.cpp:681
virtual ~QBdtNode()
Definition: qbdt_node.hpp:56
QBdtNode(complex scl)
Definition: qbdt_node.hpp:44
Definition: complex16x2simd.hpp:25
std::complex< half_float::half > complex
Definition: qrack_types.hpp:62
std::shared_ptr< QBdtNode > QBdtNodePtr
Definition: qbdt_node.hpp:23
std::shared_ptr< QBdtNodeInterface > QBdtNodeInterfacePtr
Definition: qbdt_node_interface.hpp:33
#define bitLenInt
Definition: qrack_types.hpp:44
SIMD implementation of the double precision complex vector type of 2 complex numbers,...
Definition: complex16x2simd.hpp:30