Skip to content
Snippets Groups Projects
Qubits.hpp 847 B
Newer Older
#ifndef QUANTUM_GATE_QUBITS_HPP_
#define QUANTUM_GATE_QUBITS_HPP_

#include "Accelerator.hpp"
#include <complex>

/**
 *
 */
template<const int NumberOfQubits>
class Qubits: public AcceleratorBits<NumberOfQubits> {
	Qubits() :
			state((int) std::pow(2, NumberOfQubits)) {
		// Initialize to |000...000> state
		state.setZero();
		state(0) = 1.0;
	void applyUnitary(Eigen::MatrixXcd& U) {
		state = U * state;
	QubitState& getState() {
		return state;
	}

	void setState(QubitState& st) {
		state = st;
	}

		for (int i = 0; i < state.rows(); i++) {
			stream << std::bitset<NumberOfQubits>(i).to_string() << " -> " << state(i) << "\n";
		}