forked from marcusps/GraphSim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstabilizer.h
More file actions
67 lines (57 loc) · 2.08 KB
/
stabilizer.h
File metadata and controls
67 lines (57 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// stabilizer.h
/*!\file
defines the Stabilizer class */
#ifndef STABILIZER_H
#define STABILIZER_H
#include <iostream>
#include <vector>
#include <cassert>
#include "loccliff.h"
#include <ext/hash_set>
#ifndef SWIG
using __gnu_cxx::hash_set;
#endif
// See note at top of file graphsim.h in case of problems compiling
// the preceding lines.
#ifdef SWIG
struct QState;
#else
extern "C" {
// The following struct declaration is quoted in verbatim from Scott
// Aaronson's CHP program. (Scott, I hope, you don't mind.) It is used
// here to implement the functionality of comparing a stabilizer state
// in CHP with a state in graphsim. This is used to compare the action
// of the two programs to ensure correctness.
struct QState
{
long n; // # of qubits
unsigned long **x; // (2n+1)*n matrix for stabilizer/destabilizer x bits (there's one "scratch row" at
unsigned long **z; // (2n+1)*n matrix for z bits the bottom)
int *r; // Phase bits: 0 for +1, 1 for i, 2 for -1, 3 for -i. Normally either 0 or 2.
unsigned long pw[32]; // pw[i] = 2^i
long over32; // floor(n/8)+1
};
}
#endif //SWIG
//forward declarations, definition in graphsim.h:
typedef unsigned long VertexIndex;
struct QubitVertex;
class GraphRegister;
//! A stabilizer describing a quantum state.
/* This class is used at the moment only by GraphRegister::print_stabilizer and for
the compare method (when comparing with CHP). */
struct Stabilizer {
VertexIndex numQubits;
vector<vector<LocCliffOp> > paulis;
vector<RightPhase> rowsigns;
vector<VertexIndex> vtxidx;
Stabilizer (const VertexIndex numQubits_);
Stabilizer (const GraphRegister& gr, const hash_set<VertexIndex>& qubits);
Stabilizer (QState * qs);
void add_row (unsigned target, unsigned addend);
void conjugate (unsigned row, unsigned col, const LocCliffOp trans);
void conjugate_column (unsigned col, const LocCliffOp trans);
void print (ostream &os = cout) const;
bool compare (const Stabilizer &diag);
};
#endif //STABILIZER_H