00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _QGAME___H_
00026 #define _QGAME___H_
00027
00028 #include "qgtypes.h"
00029 #include "qgerror.h"
00030 #include "qggates.h"
00031 #include "qgprog.h"
00032
00033 #include <string>
00034 #include <vector>
00035
00036 namespace qgame {
00037
00045 struct Result {
00046 int misses;
00047 double maxError;
00048 double avgError;
00049 double maxExpOracles;
00050 double avgExpOracles;
00051 };
00052 std::ostream & operator<<(std::ostream &, const Result &);
00053
00058 struct Measurement {
00059 int qubit;
00060 int result;
00061 double prob;
00062 };
00063
00082 class QSys {
00083 QProgram *prg;
00084 int instrPnt;
00085 double prob;
00086
00087 int numQubits;
00088 Qureg reg;
00089 std::string oracleTT;
00090 int oracleCount;
00091 std::vector<Measurement> measureHistory;
00092 std::vector<bool> execInstr;
00093
00094 std::vector<QSys*> exec() throw(Error);
00095 void markBranch(bool branch);
00096 void appendMeasurement(QubitList q, int outcome, double prob);
00097
00098 friend std::ostream& operator<<(std::ostream &, const QSys &);
00099
00100 public:
00101 QSys();
00102 ~QSys();
00103 void init(int numQubits, QProgram *prg, const std::string &oracleTT);
00107 QSys *clone(double priorProb);
00110 static std::vector<QSys*> execute(int numQubits, QProgram *prg, const std::string &oracleTT) throw(Error);
00115 static Result testProgram(
00116 int numQubits,
00117 QProgram *prg,
00118 const std::vector<TestCase> &cases,
00119 const QubitList &finalMeasure,
00120 double threshold
00121 ) throw(Error);
00124 Qureg getReg();
00125 void setReg(const Qureg &);
00126 double getProb();
00127 void setProb(double prob);
00128 int getOracleCount();
00129 std::vector<Measurement> getMeasurementHistory();
00131 void apply(QGate *, const QubitList &) throw(Error);
00132 void apply(const QInstr &) throw(Error);
00135 };
00136
00137 std::ostream& operator<<(std::ostream &, const QSys &);
00139 };
00140
00141 #endif