Browse Source

QuantumGate alias

master
watkinsr 2 years ago
parent
commit
6d4c8aaf19
  1. 27
      TODOS.txt
  2. 22
      include/QReg.h

27
TODOS.txt

@ -1,16 +1,15 @@
x Implement tensor function
x Fix dot product amplitudes
x Verify we can reproduce a entanglement
[x] Implement tensor function
[x] Fix dot product amplitudes
[x] Verify we can reproduce a entanglement
- support example1
- FORMGATE U HAD ID
- APPLY U R
- harder:
- SELECT S1 R2 0 1 (0-1 is a range, S1 is where it's saved and R2 is the register)
- MEASURE RES S1 (measure S1) (porbably hardest to support.)
- [x] FORMGATE U HAD ID
- [x] need to form hashmap for storing variables
- [ ] APPLY U R
- [ ] harder:
- [ ] SELECT S1 R2 0 1 (0-1 is a range, S1 is where it's saved and R2 is the register)
- [ ] MEASURE RES S1 (measure S1) (porbably hardest to support.)
- [ ] REPL stuff:
- [ ] introspection of registers/gates
- [ ] help command
Notes;
- we will drop ADD for now because too complex.
- REPL stuff:
- introspection of registers/gates
- help command

22
include/QReg.h

@ -1,3 +1,5 @@
#pragma once
#include <assert.h>
#include <stdlib.h>
#include <iostream>
@ -6,6 +8,8 @@
using namespace std;
using QuantumGate = vector<vector<complex<double>>>;
class QReg
{
public:
@ -15,22 +19,22 @@ public:
qubits = (int *)calloc(sizeof(int), numberOfQubits);
numberOfAmplitudes = (1 << numberOfQubits);
vector<vector<complex<double>>> matrix_(numberOfAmplitudes, vector<complex<double>>(1));
QuantumGate matrix_(numberOfAmplitudes, vector<complex<double>>(1));
amplitude_matrix = matrix_;
amplitude_matrix[init_bit][0] = 1;
}
void applyGateToSystem(vector<vector<complex<double>>> gate);
vector<vector<complex<double>>> dot_product_amplitudes(vector<vector<complex<double>>> gate);
void applyGateToSystem(QuantumGate gate);
QuantumGate dot_product_amplitudes(QuantumGate gate);
void printAmplitudes();
static vector<vector<complex<double>>> tensor(vector<vector<complex<double>>> A, vector<vector<complex<double>>> B);
const static vector<vector<complex<double>>> HAD_GATE;
const static vector<vector<complex<double>>> ID_GATE;
const static vector<vector<complex<double>>> CNOT_GATE;
static void printGate(vector<vector<complex<double>>> gate);
static QuantumGate tensor(QuantumGate A, QuantumGate B);
const static QuantumGate HAD_GATE;
const static QuantumGate ID_GATE;
const static QuantumGate CNOT_GATE;
static void printGate(QuantumGate gate);
static vector<vector<complex<double>>> getGateByString(const char* gate);
static QuantumGate getGateByString(const char* gate);
private:
int numberOfQubits;

Loading…
Cancel
Save