|
|
@ -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; |
|
|
|