diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..970d0a28 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "src/parser/libqasm"] + path = src/parser/libqasm + url = git@github.com:QE-Lab/libqasm.git + branch = develop diff --git a/CMakeLists.txt b/CMakeLists.txt index e5292edf..90774dab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,10 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.0) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) SET(PROJECT_NAME "qx-simulator") PROJECT(${PROJECT_NAME}) +enable_testing() + FIND_PACKAGE(OpenMP) IF(OPENMP_FOUND) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") @@ -16,6 +18,12 @@ IF(CMAKE_COMPILER_IS_GNUCXX) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wfatal-errors -O3 -DCG_BC -DQX_SPARSE_MV_MUL -D__BUILTIN_LINALG__ -msse4.2 -DUSE_OPENMP") ENDIF(CMAKE_COMPILER_IS_GNUCXX) +IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + SET(CXX "Clang-omp++") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++11 -Wall -Wfatal-errors -Wno-unused-local-typedef -O3 -DCG_BC -DQX_SPARSE_MV_MUL -D__BUILTIN_LINALG__ -msse4.2 -DUSE_OPENMP -Wno-reorder -Wno-unneeded-internal-declaration -Wno-unused-variable -Wno-unused-private-field -Wno-deprecated-register -Wno-unused-function") +ENDIF("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DXPU_TIMER") ADD_SUBDIRECTORY( diff --git a/Dockerfile.build b/Dockerfile.build index ebccf7b8..9e1b64be 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -1,4 +1,4 @@ FROM ubuntu:16.04 RUN apt-get update && \ - apt-get -y install g++ cmake make \ No newline at end of file + apt-get -y install g++ cmake make git python3 python3-dev bison flex swig diff --git a/Jenkinsfile b/Jenkinsfile index d90ff984..54d7626e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,23 +1,45 @@ pipeline { - agent { - dockerfile { - filename 'Dockerfile.build' + agent any + environment { + PERSIST_WORKSPACE = "" + } + stages { + stage('Checkout submodules') { + steps { + script { + PERSIST_WORKSPACE = WORKSPACE + } + sh 'pwd' + sh 'GIT_SSH_COMMAND="ssh -i /var/jenkins_home/.ssh/jenkins_libqasm_deploy_id_rsa" git submodule update --init -- src/parser/libqasm' + sh 'cd src/parser/libqasm/ && git submodule update --init -- qasm_flex_bison/test/doctest' + } } - } - stages { stage('Build') { + agent { + dockerfile { + filename 'Dockerfile.build' + } + } steps { - sh 'pwd' - sh 'mkdir build && cd build && cmake ../ && make' + dir(PERSIST_WORKSPACE) { + sh 'pwd' + sh 'mkdir build && cd build && cmake ../ && make' + } } } stage('Test') { + agent { + dockerfile { + filename 'Dockerfile.build' + } + } steps { - sh 'for file in src/circuits/*.qc; do build/bin/qx-simulator/qx-simulator "$file"; done' - + dir(PERSIST_WORKSPACE) { + sh 'for file in tests/circuits/*.qc; do build/bin/qx-simulator "$file"; done' + } } } } -} \ No newline at end of file +} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cf397d62..8d18cd97 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,12 +1,13 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} xpu-0.1.5 - parser + parser/libqasm/qasm_flex_bison/library/ qcode ) -ADD_LIBRARY(lexgram SHARED IMPORTED) -SET_TARGET_PROPERTIES(lexgram PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/parser/liblexgram.so) +ADD_SUBDIRECTORY( + ${CMAKE_CURRENT_SOURCE_DIR}/parser/libqasm/qasm_flex_bison/library +) ADD_EXECUTABLE(qx-server qx_server.cc) ADD_EXECUTABLE(qx-simulator-old simulator_old.cc) diff --git a/src/INFO/README b/src/INFO/README index eae6de96..a04d6730 100644 --- a/src/INFO/README +++ b/src/INFO/README @@ -6,7 +6,7 @@ / /___/ / _> < _\ \ _/ / / /|_/ / / /_/ / / /__ / __ | / / / /_/ / / , _/ \______/\__\ /_/|_| /___/ /___/ /_/ /_/ \____/ /____//_/ |_|/_/ \____/ /_/|_| - version 0.1 beta - QuTech - 2016 - report bugs and suggestions to: nader.khammassi@gmail.com + version 0.2 beta - QuTech - 2018 - report bugs and suggestions to: nader.khammassi@gmail.com =================================================================================================== diff --git a/src/core/circuit.h b/src/core/circuit.h index a39d83d4..9fe91147 100644 --- a/src/core/circuit.h +++ b/src/core/circuit.h @@ -31,178 +31,176 @@ namespace qx { class circuit { - private: - - uint32_t n_qubit; - std::vector gates; - std::string name; - uint32_t iteration; - double time; - - public: - - /** - * \brief circuit constructor - */ - circuit(uint32_t n_qubit, std::string name = "", uint32_t iteration=1) : n_qubit(n_qubit), name(name), iteration(iteration) - { - } - - /** - * \brief destructor - */ - ~circuit() - { - for (std::vector::iterator it= gates.begin(); it != gates.end(); it++) - delete (*it); - } - - /** - * \brief micro code generator - */ - std::string micro_code() - { - std::stringstream uc; - uc << "\n" << name << ": \n"; - for (std::vector::iterator it= gates.begin(); it != gates.end(); it++) - uc << (*it)->micro_code(); - return uc.str(); - } - - - - /** - * \brief destructor - */ - void clear() - { - for (std::vector::iterator it= gates.begin(); it != gates.end(); it++) - delete (*it); - gates.clear(); - } - - /** - * \brief add gate at the end of the circuit - */ - void add(gate * g) - { - // check gate validity before (target/ctrl qubits < n_qubit) - gates.push_back(g); - } - - /** - * \brief return gate - */ - qx::gate * operator [] (uint32_t i) - { - assert(i < gates.size()); - return gates[i]; - } - - /** - * \brief set iterations number - */ - void set_iterations(uint32_t n) - { - iteration = n; - } - - /** - * \brief set iterations number - */ - uint32_t get_iterations() - { - return iteration; - } - - /** - * \brief return gate - */ - qx::gate * get(uint32_t i) - { - assert(i < gates.size()); - return gates[i]; - } - - void execute(qu_register& reg, bool verbose=false, bool only_binary=false) - { - uint32_t it = iteration; - - #ifdef XPU_TIMER - println("[+] executing circuit '" << name << "' (" << it << " iter) ..."); - xpu::timer tmr; - tmr.start(); - #endif - - while (it--) - { - if (!verbose) - for (uint32_t i=0; iapply(reg); - else - { - for (uint32_t i=0; idump(); - gates[i]->apply(reg); - reg.dump(only_binary); - } - } - } - #ifdef XPU_TIMER - tmr.stop(); - println("[+] circuit execution time: " << tmr.elapsed() << " sec."); - #endif // XPU_TIMER - } - - /** - * \return gates count - */ - uint32_t size() - { - return gates.size(); - } - - /** - * insert a gate at the specified - * position - */ - void insert(uint32_t pos, qx::gate * g) - { - gates.insert(gates.begin()+pos,g); - } - - - /** - * \return the name of the circuit - */ - std::string id() - { - return name; - } - - void dump() - { - println("[+++] circuit '" << name << "' :"); - for (uint32_t i=0; idump(); - } - } - - uint32_t get_qubit_count() - { - return n_qubit; - } - - void set_qubit_count(uint32_t n) - { - n_qubit = n; - // check gate validity (target/ctrl qubits < n_qubit) - } - + private: + + uint64_t n_qubit; + std::vector gates; + std::string name; + uint64_t iteration; + double time; + + public: + + /** + * \brief circuit constructor + */ + circuit(uint64_t n_qubit, std::string name = "", uint32_t iteration=1) : n_qubit(n_qubit), name(name), iteration(iteration) + { + } + + /** + * \brief destructor + */ + ~circuit() + { + for (std::vector::iterator it= gates.begin(); it != gates.end(); it++) + delete (*it); + } + + /** + * \brief micro code generator + */ + std::string micro_code() + { + std::stringstream uc; + uc << "\n" << name << ": \n"; + for (std::vector::iterator it= gates.begin(); it != gates.end(); it++) + uc << (*it)->micro_code(); + return uc.str(); + } + + /** + * \brief destructor + */ + void clear() + { + for (std::vector::iterator it= gates.begin(); it != gates.end(); it++) + delete (*it); + gates.clear(); + } + + /** + * \brief add gate at the end of the circuit + */ + void add(gate * g) + { + // check gate validity before (target/ctrl qubits < n_qubit) + gates.push_back(g); + } + + /** + * \brief return gate + */ + qx::gate * operator [] (uint64_t i) + { + assert(i < gates.size()); + return gates[i]; + } + + /** + * \brief set iterations number + */ + void set_iterations(uint64_t n) + { + iteration = n; + } + + /** + * \brief set iterations number + */ + uint64_t get_iterations() + { + return iteration; + } + + /** + * \brief return gate + */ + qx::gate * get(uint64_t i) + { + assert(i < gates.size()); + return gates[i]; + } + + void execute(qu_register& reg, bool verbose=false, bool only_binary=false) + { + uint64_t it = iteration; + +#ifdef XPU_TIMER + println("[+] executing circuit '" << name << "' (" << it << " iter) ..."); + xpu::timer tmr; + tmr.start(); +#endif + + while (it--) + { + if (!verbose) + for (uint64_t i=0; iapply(reg); + else + { + for (uint64_t i=0; idump(); + gates[i]->apply(reg); + reg.dump(only_binary); + } + } + } +#ifdef XPU_TIMER + tmr.stop(); + println("[+] circuit execution time: " << tmr.elapsed() << " sec."); +#endif // XPU_TIMER + } + + /** + * \return gates count + */ + uint64_t size() + { + return gates.size(); + } + + /** + * insert a gate at the specified + * position + */ + void insert(uint64_t pos, qx::gate * g) + { + gates.insert(gates.begin()+pos,g); + } + + + /** + * \return the name of the circuit + */ + std::string id() + { + return name; + } + + void dump() + { + println("[+++] circuit '" << name << "' :"); + for (uint64_t i=0; idump(); + } + } + + uint64_t get_qubit_count() + { + return n_qubit; + } + + void set_qubit_count(uint64_t n) + { + n_qubit = n; + // check gate validity (target/ctrl qubits < n_qubit) + } + }; } // namespace qx diff --git a/src/core/gate.h b/src/core/gate.h index c8b058f6..f03e6b94 100644 --- a/src/core/gate.h +++ b/src/core/gate.h @@ -68,9 +68,15 @@ namespace qx __tdag_gate__ , __sdag_gate__ , __custom_gate__ , + __prepx_gate__ , + __prepy_gate__ , __prepz_gate__ , __measure_gate__ , __measure_reg_gate__, + __measure_x_gate__ , + __measure_x_reg_gate__, + __measure_y_gate__ , + __measure_y_reg_gate__, __ctrl_phase_shift_gate__, __parallel_gate__, __display__, @@ -80,7 +86,8 @@ namespace qx __lookup_table__, __classical_not_gate__, __qft_gate__, - __prepare_gate__ + __prepare_gate__, + __unitary_gate__ } gate_type_t; @@ -101,7 +108,6 @@ namespace qx #define __rc(r,c,s) (r*s+c) - /** * \brief common abstract gate interface for * all gates implementation. @@ -110,7 +116,7 @@ namespace qx { public: - virtual int32_t apply(qu_register& qureg) = 0; + virtual int64_t apply(qu_register& qureg) = 0; virtual std::vector qubits() = 0; virtual std::vector control_qubits() = 0; virtual std::vector target_qubits() = 0; @@ -159,11 +165,11 @@ namespace qx cmatrix_t noisy_hadamard(double epsilon1=0, double epsilon2=0) { #ifdef __BUILTIN_LINALG__ - return mxm(rotation(M_PI/4 + epsilon1), phase(M_PI + epsilon2)); + return mxm(rotation(M_PI/4 + epsilon1), phase(M_PI + epsilon2)); #else - cmatrix_t rz = rotation(M_PI/4 + epsilon1); - cmatrix_t p = phase(M_PI + epsilon2); - return mxm(rz,p); + cmatrix_t rz = rotation(M_PI/4 + epsilon1); + cmatrix_t p = phase(M_PI + epsilon2); + return mxm(rz,p); #endif } @@ -173,13 +179,13 @@ namespace qx */ cmatrix_t build_matrix(const complex_t * c, uint64_t n) { - // assert(n==2); - // TO DO : remove the n parameter - cmatrix_t m; // (n,n); - for (int i=0; iget(r,c1)) + pv[c2]*(m->get(r,c2)); + size_t bc = r; + size_t c1 = __bit_reset(bc,nk); + size_t c2 = __bit_set(bc,nk); + // complex_t s; // = 0; + pr[r] = pv[c1]*(m->get(r,c1)) + pv[c2]*(m->get(r,c2)); } return 0; @@ -291,22 +297,22 @@ namespace qx #pragma omp parallel for // shared(m00,m01,m10,m11) #endif for(size_t offset = start; offset < end; offset += (1L << (qubit + 1L))) - for(size_t i = offset; i < offset + (1L << qubit); i++) - { - size_t i0 = i + stride0; - size_t i1 = i + stride1; - - complex_t in0 = state[i0]; - complex_t in1 = state[i1]; - state[i0] = m00*in0+m01*in1; - state[i1] = m10*in0+m11*in1; + for(size_t i = offset; i < offset + (1L << qubit); i++) + { + size_t i0 = i + stride0; + size_t i1 = i + stride1; + + complex_t in0 = state[i0]; + complex_t in1 = state[i1]; + state[i0] = m00*in0+m01*in1; + state[i1] = m10*in0+m11*in1; #if 0 - __m128d in0 = state[i0].xmm; - __m128d in1 = state[i1].xmm; - state[i0].xmm = _mm_add_pd(xpu::_mm_mulc_pd(m00, in0), xpu::_mm_mulc_pd(m10, in1)); - state[i1].xmm = _mm_add_pd(xpu::_mm_mulc_pd(m10, in1), xpu::_mm_mulc_pd(m11, in1)); + __m128d in0 = state[i0].xmm; + __m128d in1 = state[i1].xmm; + state[i0].xmm = _mm_add_pd(xpu::_mm_mulc_pd(m00, in0), xpu::_mm_mulc_pd(m10, in1)); + state[i1].xmm = _mm_add_pd(xpu::_mm_mulc_pd(m10, in1), xpu::_mm_mulc_pd(m11, in1)); #endif - } + } } #ifdef __SSE__ @@ -317,17 +323,17 @@ namespace qx #pragma omp parallel for // private(m00,r00,neg) #endif for(size_t offset = start; offset < end; offset += (1L << (qubit + 1L))) - for(size_t i = offset; i < offset + (1L << qubit); i++) - { - size_t i0 = i + stride0; - size_t i1 = i + stride1; - - __m128d xin0 = state[i0].xmm; // _mm_load_pd((double*)&(state[i0].xmm)); - // __m128d xin1 = state[i1].xmm; // _mm_load_pd((double*)&(state[i1].xmm)); - - state[i0].xmm = state[i1].xmm; - state[i1].xmm = xin0; - } + for(size_t i = offset; i < offset + (1L << qubit); i++) + { + size_t i0 = i + stride0; + size_t i1 = i + stride1; + + __m128d xin0 = state[i0].xmm; // _mm_load_pd((double*)&(state[i0].xmm)); + // __m128d xin1 = state[i1].xmm; // _mm_load_pd((double*)&(state[i1].xmm)); + + state[i0].xmm = state[i1].xmm; + state[i1].xmm = xin0; + } } // #else // #error "FMA not available !" @@ -350,34 +356,34 @@ namespace qx #pragma omp parallel for // private(m00,r00,neg) #endif for(size_t offset = start; offset < end; offset += (1L << (qubit + 1L))) - for(size_t i = offset; i < offset + (1L << qubit); i++) - { - size_t i0 = i + stride0; - size_t i1 = i + stride1; + for(size_t i = offset; i < offset + (1L << qubit); i++) + { + size_t i0 = i + stride0; + size_t i1 = i + stride1; - __m128d xin0 = state[i0].xmm; // _mm_load_pd((double*)&(state[i0].xmm)); - __m128d xin1 = state[i1].xmm; // _mm_load_pd((double*)&(state[i1].xmm)); + __m128d xin0 = state[i0].xmm; // _mm_load_pd((double*)&(state[i0].xmm)); + __m128d xin1 = state[i1].xmm; // _mm_load_pd((double*)&(state[i1].xmm)); - __m128d t2; // = _mm_shuffle_pd(m01,m01,3); // 1 cyc - __m128d t1 = _mm_mul_pd(xin0,r00); // 5 cyc + __m128d t2; // = _mm_shuffle_pd(m01,m01,3); // 1 cyc + __m128d t1 = _mm_mul_pd(xin0,r00); // 5 cyc #ifdef __FMA__ - __m128d xi0 = _mm_fmadd_pd (xin1,r00, t1); // x2*t2+t1 // 5 cyc + __m128d xi0 = _mm_fmadd_pd (xin1,r00, t1); // x2*t2+t1 // 5 cyc #else - __m128d xi0 = _mm_mul_pd(xin1,r00); - xi0 = _mm_add_pd(xi0,t1); // x2*t2+t1 // 5 cyc + __m128d xi0 = _mm_mul_pd(xin1,r00); + xi0 = _mm_add_pd(xi0,t1); // x2*t2+t1 // 5 cyc #endif // __FMA__ - // t2 = _mm_shuffle_pd(m11,m11,3); // 1 cyc - t2 = _mm_xor_pd(r00,neg); // 1 cyc (m11=-m00) + // t2 = _mm_shuffle_pd(m11,m11,3); // 1 cyc + t2 = _mm_xor_pd(r00,neg); // 1 cyc (m11=-m00) #ifdef __FMA__ - __m128d xi1 = _mm_fmadd_pd (xin1, t2, t1); // x2*t2+t1 // 5 cyc + __m128d xi1 = _mm_fmadd_pd (xin1, t2, t1); // x2*t2+t1 // 5 cyc #else - __m128d xi1 = _mm_mul_pd(xin1,t2); - xi1 = _mm_add_pd(xi1,t1); // x2*t2+t1 // 5 cyc + __m128d xi1 = _mm_mul_pd(xin1,t2); + xi1 = _mm_add_pd(xi1,t1); // x2*t2+t1 // 5 cyc #endif - state[i0].xmm = xi0; // _mm_store_pd((double*)(&state[i0].xmm),xi0); - state[i1].xmm = xi1; // _mm_store_pd((double*)(&state[i1].xmm),xi1); - } + state[i0].xmm = xi0; // _mm_store_pd((double*)(&state[i0].xmm),xi0); + state[i1].xmm = xi1; // _mm_store_pd((double*)(&state[i1].xmm),xi1); + } } // #else // #error "FMA not available !" @@ -397,29 +403,29 @@ namespace qx for (uint64_t r=is; rget(r,c1)) + pv[c2]*(m->get(r,c2)); - // --- cc mul add --- - pr[r].xmm = _mm_add_pd((pv[c1]*(m.get(r,c1))).xmm, (pv[c2]*(m.get(r,c2))).xmm); - // --- cr mul add --- pr[r].xmm = _mm_add_pd(complex_t::mul_cr(pv[c1].xmm,m.get(r,c1).xmm), complex_t::mul_cr(pv[c2].xmm,m.get(r,c2).xmm)); - // --- f. mul add --- - // pr[r].xmm = complex_t::_mm_cr_mul_add_pd(pv[c1].xmm, m.get(r,c1).xmm, pv[c2].xmm, m.get(r,c2).xmm); + // complex_t s; // = 0; + //pr[r] = pv[c1]*(m->get(r,c1)) + pv[c2]*(m->get(r,c2)); + // --- cc mul add --- + pr[r].xmm = _mm_add_pd((pv[c1]*(m.get(r,c1))).xmm, (pv[c2]*(m.get(r,c2))).xmm); + // --- cr mul add --- pr[r].xmm = _mm_add_pd(complex_t::mul_cr(pv[c1].xmm,m.get(r,c1).xmm), complex_t::mul_cr(pv[c2].xmm,m.get(r,c2).xmm)); + // --- f. mul add --- + // pr[r].xmm = complex_t::_mm_cr_mul_add_pd(pv[c1].xmm, m.get(r,c1).xmm, pv[c2].xmm, m.get(r,c2).xmm); #else - pr[r] = (pv[c1]*(m.get(r,c1))) + (pv[c2]*(m.get(r,c2))); + pr[r] = (pv[c1]*(m.get(r,c1))) + (pv[c2]*(m.get(r,c2))); #endif } @@ -453,29 +459,29 @@ namespace qx for (uint64_t r=is; rget(r,c1)) + pv[c2]*(m->get(r,c2)); - // --- cc mul add --- - pr[r].xmm = _mm_add_pd((pv[c1]*(m.get(r,c1))).xmm, (pv[c2]*(m.get(r,c2))).xmm); - // --- cr mul add --- pr[r].xmm = _mm_add_pd(complex_t::mul_cr(pv[c1].xmm,m.get(r,c1).xmm), complex_t::mul_cr(pv[c2].xmm,m.get(r,c2).xmm)); - // --- f. mul add --- - // pr[r].xmm = complex_t::_mm_cr_mul_add_pd(pv[c1].xmm, m.get(r,c1).xmm, pv[c2].xmm, m.get(r,c2).xmm); + // complex_t s; // = 0; + // pr[r] = pv[c1]*(m->get(r,c1)) + pv[c2]*(m->get(r,c2)); + // --- cc mul add --- + pr[r].xmm = _mm_add_pd((pv[c1]*(m.get(r,c1))).xmm, (pv[c2]*(m.get(r,c2))).xmm); + // --- cr mul add --- pr[r].xmm = _mm_add_pd(complex_t::mul_cr(pv[c1].xmm,m.get(r,c1).xmm), complex_t::mul_cr(pv[c2].xmm,m.get(r,c2).xmm)); + // --- f. mul add --- + // pr[r].xmm = complex_t::_mm_cr_mul_add_pd(pv[c1].xmm, m.get(r,c1).xmm, pv[c2].xmm, m.get(r,c2).xmm); #else - pr[r] = (pv[c1]*(m.get(r,c1))) + (pv[c2]*(m.get(r,c2))); + pr[r] = (pv[c1]*(m.get(r,c1))) + (pv[c2]*(m.get(r,c2))); #endif } @@ -511,84 +517,84 @@ namespace qx for (uint64_t r=is; r { pulse 12,0,0 } - | wait 5 - | x180 q0 --> { pulse 9,0,0 } - */ - if (qubit > 2) return "# unsupported operation : qubit out of range"; - std::stringstream uc; - uc << pulse_lt[qubit][__y90__] << "\n"; - uc << " wait 4 \n"; - uc << pulse_lt[qubit][__x180__] << "\n"; - uc << " wait 4 \n"; - return uc.str(); - } + int64_t apply(qu_register& qureg) + { + size_t qs = qureg.states(); + complex_t * data = qureg.get_data().data(); + // sqg_apply(m,qubit,qureg); + __apply_h(0, qs, qubit, data, 0, (1 << qubit), hadamard_c); + // __apply_m(0, qs, qubit, data, 0, (1 << qubit), hadamard_c); + //__apply_h_old(0, qs, qubit, data, 0, (1 << qubit), hadamard_c); + + // qureg.set_binary(qubit,__state_unknown__); + qureg.set_measurement_prediction(qubit,__state_unknown__); + return 0; + } - std::vector qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } - - std::vector control_qubits() - { - std::vector r; - return r; - } - - std::vector target_qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } + std::string micro_code() + { + /** + | wait 5 + | y90 q0 --> { pulse 12,0,0 } + | wait 5 + | x180 q0 --> { pulse 9,0,0 } + */ + if (qubit > 2) return "# unsupported operation : qubit out of range"; + std::stringstream uc; + uc << pulse_lt[qubit][__y90__] << "\n"; + uc << " wait 4 \n"; + uc << pulse_lt[qubit][__x180__] << "\n"; + uc << " wait 4 \n"; + return uc.str(); + } - gate_type_t type() - { - return __hadamard_gate__; - } + std::vector qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } - void dump() - { - println(" [-] hadamard(q=" << qubit << ")"); - } + std::vector control_qubits() + { + std::vector r; + return r; + } + + std::vector target_qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + + gate_type_t type() + { + return __hadamard_gate__; + } + + void dump() + { + println(" [-] hadamard(q=" << qubit << ")"); + } }; - + void __swap(cvector_t& amp, size_t size, size_t bit, size_t trg, size_t ctrl, size_t offset=0) { // println("bit=" << bit); // println("ctrl=" << ctrl); complex_t * p = amp.data(); for (size_t i=__bit_set(0,bit); i<(1<first,it->second) = 1; - i(it->second,it->first) = 1; - i(it->first, it->first) = 0; - i(it->second,it->second) = 0; - } + cnot(uint64_t ctrl_q, uint64_t target_q) : control_qubit(ctrl_q), + target_qubit(target_q) + { + // m = build_matrix(cnot_c,4); // stack smaching + } + + // #define CG_HASH_SET + //#define CG_MATRIX +#ifndef CG_BC +#ifndef CG_MATRIX +#define CG_BC +#endif +#endif // CG_BC - // dump_matrix(i); + int64_t apply(qu_register& qreg) + { + // println("cnot " << control_qubit << "," << target_qubit); +#ifdef CG_MATRIX + uint64_t sn = qreg.states(); + uint64_t qn = qreg.size(); + uint64_t cq = control_qubit; + uint64_t tq = target_qubit; - qreg = mxv(i, qreg.get_data()); + cmatrix_t i = cidentity_t(sn); + perm_t p = perms(qn,cq,tq); - #elif defined(CG_BC) + // dump_matrix(i); - uint64_t sn = qreg.states(); - uint64_t qn = qreg.size(); - uint64_t cq = control_qubit; - uint64_t tq = target_qubit; + for (perm_t::iterator it = p.begin(); it != p.end(); it++) + { + i(it->first,it->second) = 1; + i(it->second,it->first) = 1; + i(it->first, it->first) = 0; + i(it->second,it->second) = 0; + } - cvector_t& amp = qreg.get_data(); + // dump_matrix(i); - // perms(qn,cq,tq,amp); -// #if 0 - size_t b1 = std::max(cq,tq); - size_t b2 = std::min(cq,tq); + qreg = mxv(i, qreg.get_data()); +#elif defined(CG_BC) - size_t steps = ((1 << qn)-(__bit_set(0,b1)))/(1 << (b1+1))+1; - /* - println("from=" << (__bit_set(0,b1))); - println("to=" << (1 << qn)); - println("s=" << (1 << (b1+1))); - println("steps=" << steps); - */ - if (qn<17) - fast_cx(amp, qn, b1, b2, tq, cq); - else - { + uint64_t sn = qreg.states(); + uint64_t qn = qreg.size(); + uint64_t cq = control_qubit; + uint64_t tq = target_qubit; + + cvector_t& amp = qreg.get_data(); + + // perms(qn,cq,tq,amp); + // #if 0 + size_t b1 = std::max(cq,tq); + size_t b2 = std::min(cq,tq); + + + size_t steps = ((1 << qn)-(__bit_set(0,b1)))/(1 << (b1+1))+1; + /* + println("from=" << (__bit_set(0,b1))); + println("to=" << (1 << qn)); + println("s=" << (1 << (b1+1))); + println("steps=" << steps); + */ + if (qn<17) + fast_cx(amp, qn, b1, b2, tq, cq); + else + { #ifdef USE_OPENMP - #pragma omp parallel for - for (size_t i=0; i swap_set; + uint64_t k2 = (1 << (k-1)); + uint64_t j2 = (1 << (j-1)); - // find swap pairs - for (uint64_t t = 0; t < r_size; t++) - { - if ((t & j2) <= 0) - continue; + uint64_t r_size = qreg.states(); - if (swap_set.find(t-k2) == swap_set.end()) - swap_set.insert(t); - } - - int32_t t2; - cvector_t& amp = qreg.get_data(); - complex_t c1, c2; + xpu::container::hash_set swap_set; - for (xpu::container::hash_set::iterator t = swap_set.begin(); t != swap_set.end(); ++t) - { - int32_t _t = *t; - t2 = (_t + k2 < r_size) ? _t + k2 : _t - k2; - c1 = amp(_t); - c2 = amp(t2); - std::swap(c1, c2); - amp(_t) = c1; - amp(t2) = c2; - } - //qreg=amp; - - #endif // CG_HASH_SET - - // if (qreg.get_binary(control_qubit) == __state_1__) - if (qreg.get_measurement_prediction(control_qubit) == __state_1__) - qreg.flip_binary(target_qubit); - //else if (qreg.get_binary(control_qubit) == __state_unknown__) - else if (qreg.get_measurement_prediction(control_qubit) == __state_unknown__) - qreg.set_measurement_prediction(target_qubit,__state_unknown__); - // qreg.set_binary(target_qubit,__state_unknown__); - - return 0; - } + // find swap pairs + for (uint64_t t = 0; t < r_size; t++) + { + if ((t & j2) <= 0) + continue; + if (swap_set.find(t-k2) == swap_set.end()) + swap_set.insert(t); + } - std::vector qubits() - { - std::vector r; - r.push_back(control_qubit); - r.push_back(target_qubit); - return r; - } - - std::vector control_qubits() - { - std::vector r; - r.push_back(control_qubit); - return r; - } - - std::vector target_qubits() - { - std::vector r; - r.push_back(target_qubit); - return r; - } + int64_t t2; + cvector_t& amp = qreg.get_data(); + complex_t c1, c2; + for (xpu::container::hash_set::iterator t = swap_set.begin(); t != swap_set.end(); ++t) + { + int64_t _t = *t; + t2 = (_t + k2 < r_size) ? _t + k2 : _t - k2; + c1 = amp(_t); + c2 = amp(t2); + std::swap(c1, c2); + amp(_t) = c1; + amp(t2) = c2; + } + //qreg=amp; - gate_type_t type() - { - return __cnot_gate__; - } - - void dump() - { - println(" [-] cnot(ctrl_qubit=" << control_qubit << ", target_qubit=" << target_qubit << ")"); - } +#endif // CG_HASH_SET + + // if (qreg.get_binary(control_qubit) == __state_1__) + if (qreg.get_measurement_prediction(control_qubit) == __state_1__) + qreg.flip_binary(target_qubit); + //else if (qreg.get_binary(control_qubit) == __state_unknown__) + else if (qreg.get_measurement_prediction(control_qubit) == __state_unknown__) + qreg.set_measurement_prediction(target_qubit,__state_unknown__); + // qreg.set_binary(target_qubit,__state_unknown__); + + return 0; + } + + + std::vector qubits() + { + std::vector r; + r.push_back(control_qubit); + r.push_back(target_qubit); + return r; + } + + std::vector control_qubits() + { + std::vector r; + r.push_back(control_qubit); + return r; + } + + std::vector target_qubits() + { + std::vector r; + r.push_back(target_qubit); + return r; + } + + + gate_type_t type() + { + return __cnot_gate__; + } + + void dump() + { + println(" [-] cnot(ctrl_qubit=" << control_qubit << ", target_qubit=" << target_qubit << ")"); + } private: #if 0 @@ -965,16 +971,16 @@ namespace qx #endif - void fast_cx(cvector_t& amp, size_t size, size_t bit1, size_t bit2, size_t trg, size_t ctrl) - { - /* - println("from=" << (__bit_set(0,bit1))); - println("to=" << (1 << size)); - println("s=" << (1 << (bit1+1))); - */ - for (size_t i=__bit_set(0,bit1); i<(1< done(sn, 0); - perm_t p = perms(qn,cq1,cq2,tq); - - uint64_t p1,p2; + std::vector done(sn, 0); + perm_t p = perms(qn,cq1,cq2,tq); - for (perm_t::iterator it = p.begin(); it != p.end(); it++) - { - p1 = it->first; - p2 = it->second; - if (!(done[p1] || done[p2])) - //if (!(done[p1])) - { - // std::swap(amp(p1),amp(p2)); // ublas - std::swap(amp[p1],amp[p2]); - //println("swap : " << p1 << "," << p2); - done[p1] = 1; - done[p2] = 1; - } - } -#endif + uint64_t p1,p2; - if ((qreg.get_measurement_prediction(control_qubit_1) == __state_1__) && - (qreg.get_measurement_prediction(control_qubit_2) == __state_1__) ) - { - qreg.flip_binary(target_qubit); - } - else if ((qreg.get_measurement_prediction(control_qubit_1) == __state_unknown__) || - (qreg.get_measurement_prediction(control_qubit_2) == __state_unknown__) ) - { - qreg.set_measurement_prediction(target_qubit,__state_unknown__); - // qreg.set_binary(target_qubit,__state_unknown__); - } - - return 0; - } + for (perm_t::iterator it = p.begin(); it != p.end(); it++) + { + p1 = it->first; + p2 = it->second; + if (!(done[p1] || done[p2])) + //if (!(done[p1])) + { + // std::swap(amp(p1),amp(p2)); // ublas + std::swap(amp[p1],amp[p2]); + //println("swap : " << p1 << "," << p2); + done[p1] = 1; + done[p2] = 1; + } + } +#endif + if ((qreg.get_measurement_prediction(control_qubit_1) == __state_1__) && + (qreg.get_measurement_prediction(control_qubit_2) == __state_1__) ) + { + qreg.flip_binary(target_qubit); + } + else if ((qreg.get_measurement_prediction(control_qubit_1) == __state_unknown__) || + (qreg.get_measurement_prediction(control_qubit_2) == __state_unknown__) ) + { + qreg.set_measurement_prediction(target_qubit,__state_unknown__); + // qreg.set_binary(target_qubit,__state_unknown__); + } - std::vector qubits() - { - std::vector r; - r.push_back(control_qubit_1); - r.push_back(control_qubit_2); - r.push_back(target_qubit); - return r; - } - - std::vector control_qubits() - { - std::vector r; - r.push_back(control_qubit_1); - r.push_back(control_qubit_2); - return r; - } - - std::vector target_qubits() - { - std::vector r; - r.push_back(target_qubit); - return r; - } + return 0; + } - gate_type_t type() - { - return __toffoli_gate__; - } + std::vector qubits() + { + std::vector r; + r.push_back(control_qubit_1); + r.push_back(control_qubit_2); + r.push_back(target_qubit); + return r; + } + + std::vector control_qubits() + { + std::vector r; + r.push_back(control_qubit_1); + r.push_back(control_qubit_2); + return r; + } + + std::vector target_qubits() + { + std::vector r; + r.push_back(target_qubit); + return r; + } - - void dump() - { - println(" [-] toffoli(ctrl_qubit_1=" << control_qubit_1 << ", ctrl_qubit_2=" << control_qubit_2 << ", target_qubit=" << target_qubit << ")"); - } + + gate_type_t type() + { + return __toffoli_gate__; + } + + + void dump() + { + println(" [-] toffoli(ctrl_qubit_1=" << control_qubit_1 << ", ctrl_qubit_2=" << control_qubit_2 << ", target_qubit=" << target_qubit << ")"); + } }; @@ -1135,8 +1141,8 @@ namespace qx cvector_t & = * p_amp; for (int i=cs; i 2) return "# unsupported operation : qubit out of range"; - std::stringstream uc; - // uc << pulse_lt[qubit][__x180__] << "\n"; - uc << " wait 4 \n"; - return uc.str(); - } + int64_t apply(qu_register& qreg) + { + return 0; + } + std::string micro_code() + { + if (qubit > 2) return "# unsupported operation : qubit out of range"; + std::stringstream uc; + // uc << pulse_lt[qubit][__x180__] << "\n"; + uc << " wait 4 \n"; + return uc.str(); + } - void dump() - { - println(" [-] identity(qubit=" << qubit << ")"); - } - - std::vector qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } - - std::vector control_qubits() - { - std::vector r; - return r; - } - - std::vector target_qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } - gate_type_t type() - { - return __identity_gate__; - } + void dump() + { + println(" [-] identity(qubit=" << qubit << ")"); + } + + std::vector qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + + std::vector control_qubits() + { + std::vector r; + return r; + } + + std::vector target_qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + + gate_type_t type() + { + return __identity_gate__; + } }; @@ -1263,88 +1269,87 @@ namespace qx */ class pauli_x : public gate { - private: + private: - uint64_t qubit; - cmatrix_t m; + uint64_t qubit; + cmatrix_t m; - public: + public: - pauli_x(uint64_t qubit) : qubit(qubit) - { - m = build_matrix(pauli_x_c,2); - } + pauli_x(uint64_t qubit) : qubit(qubit) + { + m = build_matrix(pauli_x_c,2); + } - int32_t apply(qu_register& qreg) - { -// #define FAST_FLIP + int64_t apply(qu_register& qreg) + { + // #define FAST_FLIP #ifdef FAST_FLIP + uint64_t qn = qreg.size(); + cvector_t& amp = qreg.get_data(); - uint64_t qn = qreg.size(); - cvector_t& amp = qreg.get_data(); - - // flip(qubit,qn,amp); - fast_flip(qubit,qn,amp); - /* - xpu::task flip_t(fliper,0,0,0,qubit,&); - xpu::parallel_for parallel_flip(0,(1 << qn),1,&flip_t); - parallel_flip.run(); - */ + // flip(qubit,qn,amp); + fast_flip(qubit,qn,amp); + /* + xpu::task flip_t(fliper,0,0,0,qubit,&); + xpu::parallel_for parallel_flip(0,(1 << qn),1,&flip_t); + parallel_flip.run(); + */ #else - uint64_t n = qreg.size(); - complex_t * s = qreg.get_data().data(); - // cm.dump(); - __apply_m(0, (1 << n), qubit, s, 0, (1 << qubit), m.m); - // sqg_apply(m,qubit,qreg); + uint64_t n = qreg.size(); + complex_t * s = qreg.get_data().data(); + // cm.dump(); + __apply_m(0, (1 << n), qubit, s, 0, (1 << qubit), m.m); + // sqg_apply(m,qubit,qreg); #endif // FAST_FLIP - qreg.flip_binary(qubit); - return 0; - } - - std::string micro_code() - { - /** - | wait 5 - | x180 q0 --> { pulse 9,0,0 } - */ - if (qubit > 2) return "# unsupported operation : qubit out of range"; - std::stringstream uc; - uc << pulse_lt[qubit][__x180__] << "\n"; - uc << " wait 4 \n"; - return uc.str(); - } + qreg.flip_binary(qubit); + return 0; + } + std::string micro_code() + { + /** + | wait 5 + | x180 q0 --> { pulse 9,0,0 } + */ + if (qubit > 2) return "# unsupported operation : qubit out of range"; + std::stringstream uc; + uc << pulse_lt[qubit][__x180__] << "\n"; + uc << " wait 4 \n"; + return uc.str(); + } - void dump() - { - println(" [-] pauli-x(qubit=" << qubit << ")"); - } - - std::vector qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } - - std::vector control_qubits() - { - std::vector r; - return r; - } - - std::vector target_qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } - gate_type_t type() - { - return __pauli_x_gate__; - } + void dump() + { + println(" [-] pauli-x(qubit=" << qubit << ")"); + } + + std::vector qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + + std::vector control_qubits() + { + std::vector r; + return r; + } + + std::vector target_qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + + gate_type_t type() + { + return __pauli_x_gate__; + } }; @@ -1357,71 +1362,68 @@ namespace qx */ class pauli_y : public gate { - private: + private: - uint64_t qubit; - cmatrix_t m; + uint64_t qubit; + cmatrix_t m; - public: + public: - pauli_y(uint64_t qubit) : qubit(qubit) - { - m = build_matrix(pauli_y_c,2); - } + pauli_y(uint64_t qubit) : qubit(qubit) + { + m = build_matrix(pauli_y_c,2); + } - int32_t apply(qu_register& qreg) - { - sqg_apply(m,qubit,qreg); - qreg.flip_binary(qubit); - return 0; - } - - std::string micro_code() - { - /** - | wait 5 - | x180 q0 --> { pulse 9,0,0 } - */ - if (qubit > 2) return "# unsupported operation : qubit out of range"; - std::stringstream uc; - uc << pulse_lt[qubit][__y180__] << "\n"; - uc << " wait 4 \n"; - return uc.str(); - } + int64_t apply(qu_register& qreg) + { + sqg_apply(m,qubit,qreg); + qreg.flip_binary(qubit); + return 0; + } + std::string micro_code() + { + /** + | wait 5 + | x180 q0 --> { pulse 9,0,0 } + */ + if (qubit > 2) return "# unsupported operation : qubit out of range"; + std::stringstream uc; + uc << pulse_lt[qubit][__y180__] << "\n"; + uc << " wait 4 \n"; + return uc.str(); + } - void dump() - { - println(" [-] pauli-y(qubit=" << qubit << ")"); - } - - std::vector qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } - - std::vector control_qubits() - { - std::vector r; - return r; - } - - std::vector target_qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } + void dump() + { + println(" [-] pauli-y(qubit=" << qubit << ")"); + } - gate_type_t type() - { - return __pauli_y_gate__; - } + std::vector qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + + std::vector control_qubits() + { + std::vector r; + return r; + } + std::vector target_qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + gate_type_t type() + { + return __pauli_y_gate__; + } }; @@ -1433,70 +1435,70 @@ namespace qx */ class pauli_z : public gate { - private: + private: - uint64_t qubit; - cmatrix_t m; + uint64_t qubit; + cmatrix_t m; - public: + public: - pauli_z(uint64_t qubit) : qubit(qubit) - { - m = build_matrix(pauli_z_c,2); - } + pauli_z(uint64_t qubit) : qubit(qubit) + { + m = build_matrix(pauli_z_c,2); + } - int32_t apply(qu_register& qreg) - { - sqg_apply(m,qubit,qreg); - return 0; - } - - std::string micro_code() - { - /** - | wait 5 - | x180 q0 --> { pulse 9,0,0 } - */ - if (qubit > 2) return "# unsupported operation : qubit out of range"; - std::stringstream uc; - uc << pulse_lt[qubit][__y180__] << "\n"; - uc << " wait 4 \n"; - uc << pulse_lt[qubit][__x180__] << "\n"; - uc << " wait 4 \n"; - return uc.str(); - } + int64_t apply(qu_register& qreg) + { + sqg_apply(m,qubit,qreg); + return 0; + } + std::string micro_code() + { + /** + | wait 5 + | x180 q0 --> { pulse 9,0,0 } + */ + if (qubit > 2) return "# unsupported operation : qubit out of range"; + std::stringstream uc; + uc << pulse_lt[qubit][__y180__] << "\n"; + uc << " wait 4 \n"; + uc << pulse_lt[qubit][__x180__] << "\n"; + uc << " wait 4 \n"; + return uc.str(); + } - void dump() - { - println(" [-] pauli-z(qubit=" << qubit << ")"); - } - - std::vector qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } - - std::vector control_qubits() - { - std::vector r; - return r; - } - - std::vector target_qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } - gate_type_t type() - { - return __pauli_z_gate__; - } + void dump() + { + println(" [-] pauli-z(qubit=" << qubit << ")"); + } + + std::vector qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + + std::vector control_qubits() + { + std::vector r; + return r; + } + + std::vector target_qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + + gate_type_t type() + { + return __pauli_z_gate__; + } }; /** @@ -1507,66 +1509,66 @@ namespace qx */ class phase_shift : public gate { - private: + private: - uint64_t qubit; - cmatrix_t m; + uint64_t qubit; + cmatrix_t m; - public: + public: - phase_shift(uint64_t qubit) : qubit(qubit) - { - m = build_matrix(phase_c,2); - } + phase_shift(uint64_t qubit) : qubit(qubit) + { + m = build_matrix(phase_c,2); + } - int32_t apply(qu_register& qreg) - { - sqg_apply(m,qubit,qreg); - return 0; - } - - std::string micro_code() - { - if (qubit > 2) return "# unsupported operation : qubit out of range"; - std::stringstream uc; - uc << pulse_lt[qubit][__y90__] << "\n"; - uc << " wait 4 \n"; - uc << pulse_lt[qubit][__x90__] << "\n"; - uc << " wait 4 \n"; - uc << pulse_lt[qubit][__ym90__] << "\n"; - uc << " wait 4 \n"; - return uc.str(); - } + int64_t apply(qu_register& qreg) + { + sqg_apply(m,qubit,qreg); + return 0; + } - void dump() - { - println(" [-] phase(qubit=" << qubit << ")"); - } - - std::vector qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } - - std::vector control_qubits() - { - std::vector r; - return r; - } - - std::vector target_qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } + std::string micro_code() + { + if (qubit > 2) return "# unsupported operation : qubit out of range"; + std::stringstream uc; + uc << pulse_lt[qubit][__y90__] << "\n"; + uc << " wait 4 \n"; + uc << pulse_lt[qubit][__x90__] << "\n"; + uc << " wait 4 \n"; + uc << pulse_lt[qubit][__ym90__] << "\n"; + uc << " wait 4 \n"; + return uc.str(); + } - gate_type_t type() - { - return __phase_gate__; - } + void dump() + { + println(" [-] phase(qubit=" << qubit << ")"); + } + + std::vector qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + + std::vector control_qubits() + { + std::vector r; + return r; + } + + std::vector target_qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + + gate_type_t type() + { + return __phase_gate__; + } }; @@ -1575,53 +1577,53 @@ namespace qx */ class s_dag_gate : public gate { - private: - - uint64_t qubit; - cmatrix_t m; - - public: - - s_dag_gate(uint64_t qubit) : qubit(qubit) - { - m = build_matrix(sdag_gate_c,2); - } - - int32_t apply(qu_register& qreg) - { - sqg_apply(m,qubit,qreg); - return 0; - } - - void dump() - { - println(" [-] s_dag_gate(qubit=" << qubit << ")"); - } - - std::vector qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } - - std::vector control_qubits() - { - std::vector r; - return r; - } - - std::vector target_qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } - - gate_type_t type() - { - return __sdag_gate__; - } + private: + + uint64_t qubit; + cmatrix_t m; + + public: + + s_dag_gate(uint64_t qubit) : qubit(qubit) + { + m = build_matrix(sdag_gate_c,2); + } + + int64_t apply(qu_register& qreg) + { + sqg_apply(m,qubit,qreg); + return 0; + } + + void dump() + { + println(" [-] s_dag_gate(qubit=" << qubit << ")"); + } + + std::vector qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + + std::vector control_qubits() + { + std::vector r; + return r; + } + + std::vector target_qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + + gate_type_t type() + { + return __sdag_gate__; + } }; @@ -1643,7 +1645,7 @@ namespace qx m = build_matrix(t_gate_c,2); } - int32_t apply(qu_register& qreg) + int64_t apply(qu_register& qreg) { sqg_apply(m,qubit,qreg); return 0; @@ -1688,118 +1690,213 @@ namespace qx */ class t_dag_gate : public gate { - private: + private: - uint64_t qubit; - cmatrix_t m; + uint64_t qubit; + cmatrix_t m; - public: + public: - t_dag_gate(uint64_t qubit) : qubit(qubit) - { - m = build_matrix(tdag_gate_c,2); - } + t_dag_gate(uint64_t qubit) : qubit(qubit) + { + m = build_matrix(tdag_gate_c,2); + } - int32_t apply(qu_register& qreg) - { - sqg_apply(m,qubit,qreg); - return 0; - } + int64_t apply(qu_register& qreg) + { + sqg_apply(m,qubit,qreg); + return 0; + } - void dump() - { - println(" [-] t_dag_gate(qubit=" << qubit << ")"); - } - - std::vector qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } - - std::vector control_qubits() - { - std::vector r; - return r; - } - - std::vector target_qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } + void dump() + { + println(" [-] t_dag_gate(qubit=" << qubit << ")"); + } - gate_type_t type() - { - return __tdag_gate__; - } + std::vector qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } - }; + std::vector control_qubits() + { + std::vector r; + return r; + } + std::vector target_qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + gate_type_t type() + { + return __tdag_gate__; + } + }; + /** + * phase factoring + */ + void reset_gphase(cmatrix_t& m) + { + double n = m(0,0).norm(); + if (n > 10e-9) + { + complex_t p(m(0,0).re/n,m(0,0).im/n); + m(0,0) /= p; + m(0,1) /= p; + m(1,0) /= p; + m(1,1) /= p; + } + else + { + n = m(0,1).norm(); + complex_t p(m(0,1).re/n,m(0,1).im/n); + m(0,0) /= p; + m(0,1) /= p; + m(1,0) /= p; + m(1,1) /= p; + } + double n1 = std::sqrt(m(0,0).norm()+m(1,0).norm()); + double n2 = std::sqrt(m(0,1).norm()+m(1,1).norm()); + m(0,0) /= n1; + m(0,1) /= n2; + m(1,0) /= n1; + m(1,1) /= n2; + } /** - * \brief rotation-x : - */ - class rx : public gate + * | (cos(?/2) -e(i?)sin(?/2)) | + * general gate u = | | + * | (e(i?)sin(?/2) e(i?+i?)cos(?/2)) | + */ + class unitary : public gate { - private: + private: - uint64_t qubit; - double angle; - cmatrix_t m; + uint64_t qubit; + double angle[3]; + cmatrix_t m; - public: + public: - rx(uint64_t qubit, double angle) : qubit(qubit), angle(angle) - { - // m.resize(2,2); - m(0,0) = cos(angle/2); m(0,1) = complex_t(0,-sin(angle/2)); - m(1,0) = complex_t(0,-sin(angle/2)); m(1,1) = cos(angle/2); - } + unitary(uint64_t qubit, double angle[3]) : qubit(qubit) + { + // m.resize(2,2); + m(0,0) = cos(angle[1]/2); m(0,1) = complex_t(-cos(angle[2]/2),-sin(angle[2]/2))*sin(angle[1]/2); + m(1,0) = complex_t(cos(angle[3]/2),sin(angle[3]/2))*sin(angle[1]/2) ; m(1,1) = complex_t(cos((angle[3]/2)+(angle[2]/2)),sin((angle[3]/2)+(angle[2]/2)))*cos(angle[1]/2); + } - int32_t apply(qu_register& qreg) - { - sqg_apply(m,qubit,qreg); - qreg.set_measurement_prediction(qubit,__state_unknown__); - // qreg.set_binary(qubit,__state_unknown__); - return 0; - } + int64_t apply(qu_register& qreg) + { + sqg_apply(m,qubit,qreg); + qreg.set_measurement_prediction(qubit,__state_unknown__); + // qreg.set_binary(qubit,__state_unknown__); + return 0; + } - void dump() - { - println(" [-] rx(qubit=" << qubit << ", angle=" << angle << ")"); - } - - std::vector qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } - - std::vector control_qubits() - { - std::vector r; - return r; - } - - std::vector target_qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } + double get_angle() + { + return *angle; + } - gate_type_t type() - { - return __rx_gate__; - } + void dump() + { + println(" [-] unitary(qubit=" << qubit << ", angle=" << angle << ")"); + } + + std::vector qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + + std::vector control_qubits() + { + std::vector r; + return r; + } + + std::vector target_qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + + gate_type_t type() + { + return __unitary_gate__; + } + + }; + + /** + * \brief rotation-x : + */ + class rx : public gate + { + private: + + uint64_t qubit; + double angle; + cmatrix_t m; + + public: + + rx(uint64_t qubit, double angle) : qubit(qubit), angle(angle) + { + // m.resize(2,2); + m(0,0) = cos(angle/2); m(0,1) = complex_t(0,-sin(angle/2)); + m(1,0) = complex_t(0,-sin(angle/2)); m(1,1) = cos(angle/2); + reset_gphase(m); + } + + int64_t apply(qu_register& qreg) + { + sqg_apply(m,qubit,qreg); + qreg.set_measurement_prediction(qubit,__state_unknown__); + // qreg.set_binary(qubit,__state_unknown__); + return 0; + } + + void dump() + { + println(" [-] rx(qubit=" << qubit << ", angle=" << angle << ")"); + } + + std::vector qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + + std::vector control_qubits() + { + std::vector r; + return r; + } + + std::vector target_qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + + gate_type_t type() + { + return __rx_gate__; + } }; @@ -1809,59 +1906,60 @@ namespace qx */ class ry : public gate { - private: + private: - uint64_t qubit; - double angle; - cmatrix_t m; + uint64_t qubit; + double angle; + cmatrix_t m; - public: + public: - ry(uint64_t qubit, double angle) : qubit(qubit), angle(angle) - { - // m.resize(2,2); - m(0,0) = cos(angle/2); m(0,1) = -sin(angle/2); - m(1,0) = sin(angle/2); m(1,1) = cos(angle/2); - } + ry(uint64_t qubit, double angle) : qubit(qubit), angle(angle) + { + // m.resize(2,2); + m(0,0) = cos(angle/2); m(0,1) = -sin(angle/2); + m(1,0) = sin(angle/2); m(1,1) = cos(angle/2); + // reset_gphase(m); + } - int32_t apply(qu_register& qreg) - { - sqg_apply(m,qubit,qreg); - qreg.set_measurement_prediction(qubit,__state_unknown__); - //qreg.set_binary(qubit,__state_unknown__); - return 0; - } + int64_t apply(qu_register& qreg) + { + sqg_apply(m,qubit,qreg); + qreg.set_measurement_prediction(qubit,__state_unknown__); + //qreg.set_binary(qubit,__state_unknown__); + return 0; + } - void dump() - { - println(" [-] ry(qubit=" << qubit << ", angle=" << angle << ")"); - } - - std::vector qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } - - std::vector control_qubits() - { - std::vector r; - return r; - } - - std::vector target_qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } + void dump() + { + println(" [-] ry(qubit=" << qubit << ", angle=" << angle << ")"); + } + std::vector qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } - gate_type_t type() - { - return __ry_gate__; - } + std::vector control_qubits() + { + std::vector r; + return r; + } + + std::vector target_qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + + + gate_type_t type() + { + return __ry_gate__; + } }; @@ -1870,58 +1968,59 @@ namespace qx */ class rz : public gate { - private: + private: - uint64_t qubit; - double angle; - cmatrix_t m; + uint64_t qubit; + double angle; + cmatrix_t m; - public: + public: - rz(uint64_t qubit, double angle) : qubit(qubit), angle(angle) - { - // m.resize(2,2); - m(0,0) = complex_t(cos(-angle/2), sin(-angle/2)); m(0,1) = 0; - m(1,0) = 0; m(1,1) = complex_t(cos(angle/2), sin(angle/2)); - } + rz(uint64_t qubit, double angle) : qubit(qubit), angle(angle) + { + // m.resize(2,2); + m(0,0) = complex_t(cos(-angle/2), sin(-angle/2)); m(0,1) = 0; + m(1,0) = 0; m(1,1) = complex_t(cos(angle/2), sin(angle/2)); + reset_gphase(m); + } - int32_t apply(qu_register& qreg) - { - sqg_apply(m,qubit,qreg); - qreg.set_measurement_prediction(qubit,__state_unknown__); - //qreg.set_binary(qubit,__state_unknown__); - return 0; - } + int64_t apply(qu_register& qreg) + { + sqg_apply(m,qubit,qreg); + qreg.set_measurement_prediction(qubit,__state_unknown__); + //qreg.set_binary(qubit,__state_unknown__); + return 0; + } - void dump() - { - println(" [-] rz(qubit=" << qubit << ", angle=" << angle << ")"); - } - - std::vector qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } - - std::vector control_qubits() - { - std::vector r; - return r; - } - - std::vector target_qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } + void dump() + { + println(" [-] rz(qubit=" << qubit << ", angle=" << angle << ")"); + } - gate_type_t type() - { - return __rz_gate__; - } + std::vector qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + + std::vector control_qubits() + { + std::vector r; + return r; + } + + std::vector target_qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + + gate_type_t type() + { + return __rz_gate__; + } }; void __shift(cvector_t& amp, size_t size, size_t bit, complex_t p, size_t offset=0) @@ -1931,15 +2030,15 @@ namespace qx complex_t * x = amp.data(); // println(">>>> " << p); for (size_t i=__bit_set(0,bit); i<(1<(v) << "," << std::bitset<16>(__bit_reset(v,trg)) << ")"); - } + for (size_t j=0; j<(1<(v) << "," << std::bitset<16>(__bit_reset(v,trg)) << ")"); + } } void __shift(complex_t * x, size_t size, size_t bit, complex_t p, size_t offset=0) @@ -1947,13 +2046,13 @@ namespace qx // println("bit=" << bit); // println("ctrl=" << ctrl); for (size_t i=__bit_set(0,bit); i<(1<(v) << "," << std::bitset<16>(__bit_reset(v,trg)) << ")"); - } + for (size_t j=0; j<(1<(v) << "," << std::bitset<16>(__bit_reset(v,trg)) << ")"); + } } @@ -1970,9 +2069,9 @@ namespace qx size_t offset = __bit_set(0,bit1); //for (size_t i=__bit_set(0,bit1); i<(1<get(r,c1)) + pv[c2]*(m->get(r,c2)); - pr[r].xmm = _mm_add_pd((pv[c1]*(m.get(r,c1))).xmm, (pv[c2]*(m.get(r,c2))).xmm); + // complex_t s; // = 0; + //pr[r] = pv[c1]*(m->get(r,c1)) + pv[c2]*(m->get(r,c2)); + pr[r].xmm = _mm_add_pd((pv[c1]*(m.get(r,c1))).xmm, (pv[c2]*(m.get(r,c2))).xmm); #endif } size_t bit2 = qubit; for (size_t j=qubit+1; j qubits() - { - return qubit; - } - - std::vector control_qubits() - { - return qubit; - } - - std::vector target_qubits() - { - return qubit; - } + void dump() + { + print(" [-] qft("); + for (size_t i=0; i<(qubit.size()-1); ++i) + print("q" << qubit[i] << ","); + println("q" << qubit[qubit.size()-1] << ")"); + } - gate_type_t type() - { - return __qft_gate__; - } + std::vector qubits() + { + return qubit; + } + + std::vector control_qubits() + { + return qubit; + } + + std::vector target_qubits() + { + return qubit; + } + + gate_type_t type() + { + return __qft_gate__; + } }; + /** + * phase shifter + */ + void __apply_cm(complex_t * state, + complex_t m[2][2], + std::size_t i11, std::size_t i12, std::size_t i13, + std::size_t i21, std::size_t i22, std::size_t i23, + std::size_t i31, std::size_t i32, std::size_t ish ) + { + complex_t m00 = m[0][0], + m01 = m[0][1], + m10 = m[1][0], + m11 = m[1][1]; + + for(std::size_t r1 = i11; r1 < i12; r1 += i13) + { + #ifdef USE_OPENMP + // #pragma omp parallel for + #endif + for(std::size_t r2 = r1 + i21; r2 < r1 + i22; r2 += i23) + { + for(std::size_t ind0 = r2 + i31; ind0 < r2 + i32; ind0++) + { + std::size_t ind1 = ind0 + ish; + complex_t in0 = state[ind0], in1 = state[ind1]; + + state[ind0] = m00 * in0 + m01 * in1; + state[ind1] = m10 * in0 + m11 * in1; + } + } + } + } + /** - * \brief controlled phase shift by (2*pi/(2^(ctrl-target))) - * + * \brief controlled phase shift by arbitrary phase angle or (2*pi/(2^(k=ctrl-target))) */ class ctrl_phase_shift : public gate { @@ -2240,54 +2371,94 @@ namespace qx uint64_t ctrl_qubit; uint64_t target_qubit; complex_t z; + complex_t m[2][2]; + double phase; + + protected: + + void build_operator() + { + m[0][0] = complex_t(cos(-phase/2), sin(-phase/2)); m[0][1] = 0; + m[1][0] = 0; m[1][1] = complex_t(cos(phase/2), sin(phase/2)); + + double n = m[0][0].norm(); + if (n > 10e-9) + { + complex_t p(m[0][0].re/n,m[0][0].im/n); + m[0][0] /= p; + m[0][1] /= p; + m[1][0] /= p; + m[1][1] /= p; + } + else + { + n = m[0][1].norm(); + complex_t p(m[0][0].re/n,m[0][0].im/n); + m[0][0] /= p; + m[0][1] /= p; + m[1][0] /= p; + m[1][1] /= p; + } + } + + public: - ctrl_phase_shift(uint64_t ctrl_qubit, uint64_t target_qubit) : ctrl_qubit(ctrl_qubit), - target_qubit(target_qubit), - z(cos(2*M_PI/(1 << (ctrl_qubit - target_qubit))), - sin(2*M_PI/(1 << (ctrl_qubit - target_qubit)))) - { - } + /** + * ctor (q) + */ + ctrl_phase_shift(uint64_t ctrl_qubit, uint64_t target_qubit) : ctrl_qubit(ctrl_qubit), + target_qubit(target_qubit) + { + phase = 2*M_PI/(1 << (ctrl_qubit - target_qubit)); + build_operator(); + } - ctrl_phase_shift(uint64_t ctrl_qubit, uint64_t target_qubit, uint64_t k) : ctrl_qubit(ctrl_qubit), - target_qubit(target_qubit), - z(cos(2*M_PI/(1 << (k))), - sin(2*M_PI/(1 << (k)))) - { - } + /** + * ctor (k) + */ + ctrl_phase_shift(uint64_t ctrl_qubit, uint64_t target_qubit, size_t k) : ctrl_qubit(ctrl_qubit), + target_qubit(target_qubit) + { + phase = 2*M_PI/(1 << k); + build_operator(); + } - ctrl_phase_shift(uint64_t ctrl_qubit, uint64_t target_qubit, complex_t angle) : ctrl_qubit(ctrl_qubit), - target_qubit(target_qubit), - z(angle) - { - } + /** + * ctor (p) + */ + ctrl_phase_shift(uint64_t ctrl_qubit, uint64_t target_qubit, double angle) : ctrl_qubit(ctrl_qubit), + target_qubit(target_qubit) + { + phase = angle; + build_operator(); + } - int32_t apply(qu_register& qreg) + + int64_t apply(qu_register& qreg) { + uint64_t n = qreg.size(); + complex_t * s = qreg.get_data().data(); + size_t c = ctrl_qubit; + size_t t = target_qubit; + + if (c > t) + __apply_cm(qreg.get_data().data(), + m, + 0, (1 << n), 1l << (c+1l), + 1l << c, 1l << (c+1l), 1l << (t+1l), + 0l, 1l << t, 1l << t); + else + __apply_cm(qreg.get_data().data(), + m, + 0, (1 << n), 1l << (t+1l), + 0l, 1l << t, 1l << (c+1l), + 1l << c, 1l<< (c+1l), 1l << t); - size_t b1 = std::max(ctrl_qubit,target_qubit); - size_t b2 = std::min(ctrl_qubit,target_qubit); - size_t qn = qreg.size(); - size_t steps = ((1 << qn)-(__bit_set(0,b1)))/(1 << (b1+1))+1; - cvector_t& amp = qreg.get_data(); -#ifdef USE_OPENMP -#pragma omp parallel for - for (size_t i=0; i qubits() - { - std::vector r; - r.push_back(qubit1); - r.push_back(qubit2); - return r; - } - - std::vector control_qubits() - { - std::vector r; - return r; - } - - std::vector target_qubits() - { - std::vector r; - r.push_back(qubit1); - r.push_back(qubit2); - return r; - } - gate_type_t type() - { - return __swap_gate__; - } + void dump() + { + println(" [-] swap(q1=" << qubit1 << ", q2=" << qubit2 << ")"); + } + + std::vector qubits() + { + std::vector r; + r.push_back(qubit1); + r.push_back(qubit2); + return r; + } + + std::vector control_qubits() + { + std::vector r; + return r; + } + + std::vector target_qubits() + { + std::vector r; + r.push_back(qubit1); + r.push_back(qubit2); + return r; + } + + gate_type_t type() + { + return __swap_gate__; + } }; @@ -2400,56 +2571,56 @@ namespace qx */ class cphase : public gate { - private: - - uint64_t ctrl_qubit; - uint64_t target_qubit; - - public: + private: - cphase(uint64_t ctrl_qubit, uint64_t target_qubit) : ctrl_qubit(ctrl_qubit), target_qubit(target_qubit) - { - } + uint64_t ctrl_qubit; + uint64_t target_qubit; - int32_t apply(qu_register& qreg) - { - hadamard(target_qubit).apply(qreg); - cnot(ctrl_qubit,target_qubit).apply(qreg); - hadamard(target_qubit).apply(qreg); - return 0; - } + public: - void dump() - { - println(" [-] cphase(ctrl_qubit=" << ctrl_qubit << ", target_qubit=" << target_qubit << ")"); - } + cphase(uint64_t ctrl_qubit, uint64_t target_qubit) : ctrl_qubit(ctrl_qubit), target_qubit(target_qubit) + { + } - std::vector qubits() - { - std::vector r; - r.push_back(ctrl_qubit); - r.push_back(target_qubit); - return r; - } - - std::vector control_qubits() - { - std::vector r; - r.push_back(ctrl_qubit); - return r; - } - - std::vector target_qubits() - { - std::vector r; - r.push_back(target_qubit); - return r; - } + int64_t apply(qu_register& qreg) + { + hadamard(target_qubit).apply(qreg); + cnot(ctrl_qubit,target_qubit).apply(qreg); + hadamard(target_qubit).apply(qreg); + return 0; + } - gate_type_t type() - { - return __cphase_gate__; - } + void dump() + { + println(" [-] cphase(ctrl_qubit=" << ctrl_qubit << ", target_qubit=" << target_qubit << ")"); + } + + std::vector qubits() + { + std::vector r; + r.push_back(ctrl_qubit); + r.push_back(target_qubit); + return r; + } + + std::vector control_qubits() + { + std::vector r; + r.push_back(ctrl_qubit); + return r; + } + + std::vector target_qubits() + { + std::vector r; + r.push_back(target_qubit); + return r; + } + + gate_type_t type() + { + return __cphase_gate__; + } }; @@ -2465,81 +2636,81 @@ namespace qx uint64_t qubit; cmatrix_t m; - public: - -// #ifdef __BUILTIN_LINALG__ -// custom(std::vector qubits, qx::linalg::matrix m) : qubits(qubits), m(m) -// #else - custom(uint64_t qubit, cmatrix_t m) : qubit(qubit), m(m) -// #endif - { -// uint64_t size = 1 << qubits.size(); -// if (size != m.size1() || size != m.size2()) -// println("[x] error: cutom gate : the matrix size do not match the number of qubits !"); - // verify also that the matrix is unitary -// #ifdef __BUILTIN_LINALG__ - // cmatrix_t ctr(m.size2(),m.size1()); - // qx::linalg::matrix ctr(m.size2(),m.size1()); - // for (uint64_t i=0; i mxctr = mxm(m,ctr); - // qx::linalg::identity_matrix id(m.size1()); -// #else -// cmatrix_t mxctr = mxm(m,ublas::trans(conj(m))); -// ublas::identity_matrix id(m.size1()); -// #endif + public: -// #ifdef __BUILTIN_LINALG__ -// if (qx::linalg::equals(mxctr,id)) -// #else -// if (equals(mxctr,id)) -// #endif -// println("[x] error: custom gate : the specified matrix is not unitary !"); - } + // #ifdef __BUILTIN_LINALG__ + // custom(std::vector qubits, qx::linalg::matrix m) : qubits(qubits), m(m) + // #else + custom(uint64_t qubit, cmatrix_t m) : qubit(qubit), m(m) + // #endif + { + // uint64_t size = 1 << qubits.size(); + // if (size != m.size1() || size != m.size2()) + // println("[x] error: cutom gate : the matrix size do not match the number of qubits !"); + // verify also that the matrix is unitary + // #ifdef __BUILTIN_LINALG__ + // cmatrix_t ctr(m.size2(),m.size1()); + // qx::linalg::matrix ctr(m.size2(),m.size1()); + // for (uint64_t i=0; i mxctr = mxm(m,ctr); + // qx::linalg::identity_matrix id(m.size1()); + // #else + // cmatrix_t mxctr = mxm(m,ublas::trans(conj(m))); + // ublas::identity_matrix id(m.size1()); + // #endif + + // #ifdef __BUILTIN_LINALG__ + // if (qx::linalg::equals(mxctr,id)) + // #else + // if (equals(mxctr,id)) + // #endif + // println("[x] error: custom gate : the specified matrix is not unitary !"); + } - /** - * apply - */ - int32_t apply(qu_register& qreg) - { - sqg_apply(m,qubit,qreg); - qreg.set_measurement_prediction(qubit,__state_unknown__); - return 0; - } + /** + * apply + */ + int64_t apply(qu_register& qreg) + { + sqg_apply(m,qubit,qreg); + qreg.set_measurement_prediction(qubit,__state_unknown__); + return 0; + } - /** - * dump - */ - void dump() - { - println(" [-] custom matrix on qubit " << qubit); - // println(" [-] custom(qubits=" << qubits << ", matrix=" << m << ")"); - } + /** + * dump + */ + void dump() + { + println(" [-] custom matrix on qubit " << qubit); + // println(" [-] custom(qubits=" << qubits << ", matrix=" << m << ")"); + } - /** - * type - */ - gate_type_t type() - { - return __custom_gate__; - } + /** + * type + */ + gate_type_t type() + { + return __custom_gate__; + } }; - int p1_worker(int cs, int ce, int s, double * p1, uint64_t qubit, xpu::lockable * l, cvector_t * p_data) + int p1_worker(uint64_t cs, uint64_t ce, uint64_t s, double * p1, uint64_t qubit, xpu::lockable * l, cvector_t * p_data) { cvector_t &data = * p_data; double local_p1 = 0; for (uint64_t i=cs; ilock(); @@ -2550,28 +2721,28 @@ namespace qx } - int zero_worker(int cs, int ce, int s, int m, double * length, uint64_t qubit, xpu::lockable * l, cvector_t * p_data) + int zero_worker(uint64_t cs, uint64_t ce, uint64_t s, int64_t m, double * length, uint64_t qubit, xpu::lockable * l, cvector_t * p_data) { cvector_t &data = * p_data; double local_length = 0; uint64_t size = data.size(); if (m) { - for (uint64_t i=cs; ilock(); *length += local_length; @@ -2579,7 +2750,7 @@ namespace qx return 0; } - int renorm_worker(int cs, int ce, int s, double * length, cvector_t * p_data) + int renorm_worker(uint64_t cs, uint64_t ce, uint64_t s, double * length, cvector_t * p_data) { cvector_t &data = * p_data; double l = *length; @@ -2589,10 +2760,10 @@ namespace qx __m256d vl = _mm256_set1_pd(l); for (uint64_t i=cs; i 12) - { - // #define PARALLEL_MEASUREMENT - // #ifdef PARALLEL_MEASUREMENT + public: - xpu::lockable * l = new xpu::core::os::mutex(); - xpu::task p1_worker_t(p1_worker, 0, n, 1, &p, qubit, l, &data); - xpu::parallel_for parallel_p1( 0, n, 1, &p1_worker_t); - parallel_p1.run(); + measure(uint64_t qubit, bool disable_averaging=false) : qubit(qubit), measure_all(false), disable_averaging(disable_averaging) + { + } - if (f 17) + { + // #define PARALLEL_MEASUREMENT + // #ifdef PARALLEL_MEASUREMENT - xpu::task renorm_worker_t(renorm_worker, 0, n, 1, &length, &data); - xpu::parallel_for parallel_renorm( 0, n, 1, &renorm_worker_t); - parallel_renorm.run(); - } - else - { - //#else - - int32_t k, l, m; - int32_t j = qubit; - double fvalue; - - std::bitset b; - b.reset(); - b.set(qubit); - uint64_t bc = b.to_ulong(); - - while (bc < n) - { - bc = b.to_ulong(); - // p += std::norm(data[bc]); - p += data[bc].norm(); - b = inc(b); - b.set(qubit); - bc = b.to_ulong(); - } + xpu::lockable * l = new xpu::core::os::mutex(); + xpu::task p1_worker_t(p1_worker, (uint64_t)0, n, (uint64_t)1, &p, qubit, l, &data); + xpu::parallel_for parallel_p1( (uint64_t)0, n, (uint64_t)1, &p1_worker_t); + parallel_p1.run(); - if (f b; + b.reset(); + b.set(qubit); + uint64_t bc = b.to_ulong(); + + while (bc < n) + { + bc = b.to_ulong(); + // p += std::norm(data[bc]); + p += data[bc].norm(); + b = inc(b); + b.set(qubit); + bc = b.to_ulong(); + } + + if (f] measured value : " << value); - // #endif // PARALLEL_MEASUREMENT - } + qreg.set_measurement_prediction(qubit,(value == 1 ? __state_1__ : __state_0__)); + qreg.set_measurement(qubit,(value == 1 ? true : false)); + //qreg.set_binary(qubit,(value == 1 ? __state_1__ : __state_0__)); - // println(" [>] measured value : " << value); + if (!disable_averaging) + { + if (qreg.measurement_averaging_enabled) + { + if (value == 1) + { + // println("> exited_states++"); + qreg.measurement_averaging[qubit].exited_states++; + } + else + { + // println("> ground_states++"); + qreg.measurement_averaging[qubit].ground_states++; + } + } + } - qreg.set_measurement_prediction(qubit,(value == 1 ? __state_1__ : __state_0__)); - qreg.set_measurement(qubit,(value == 1 ? true : false)); - //qreg.set_binary(qubit,(value == 1 ? __state_1__ : __state_0__)); + return value; + } - if (!disable_averaging) - { - if (qreg.measurement_averaging_enabled) - { - if (value == 1) - { - // println("> exited_states++"); - qreg.measurement_averaging[qubit].exited_states++; - } - else - { - // println("> ground_states++"); - qreg.measurement_averaging[qubit].ground_states++; - } - } - } + void dump() + { + if (measure_all) + println(" [-] measure(register)"); + else + println(" [-] measure(qubit=" << qubit << ")"); + } - return value; - } + std::vector qubits() + { + std::vector r; + if (!measure_all) + r.push_back(qubit); + else // this is a dirty hack, itshould be fixed later (unknown qubit number !) + { + for (int64_t i=0; i qubits() - { - std::vector r; - if (!measure_all) - r.push_back(qubit); - else // this is a dirty hack, itshould be fixed later (unknown qubit number !) - { - for (int32_t i=0; i control_qubits() + { + std::vector r; + return r; + } - std::vector control_qubits() - { - std::vector r; - return r; - } - - std::vector target_qubits() - { - return qubits(); - } + std::vector target_qubits() + { + return qubits(); + } - gate_type_t type() - { - if (measure_all) - return __measure_reg_gate__; - else - return __measure_gate__; - } + gate_type_t type() + { + if (measure_all) + return __measure_reg_gate__; + else + return __measure_gate__; + } }; - /** - * \brief generic binary controlled gate + * measure_x */ - class bin_ctrl : public gate + class measure_x : public gate { - private: + private: - uint64_t bit; - gate * g; + uint64_t qubit; + bool measure_all; + bool disable_averaging; - public: + qx::hadamard hg; + qx::measure mg; - bin_ctrl(uint64_t bit, gate * g) : bit(bit), g(g) - { - } + public: - int32_t apply(qu_register& qreg) - { - if (qreg.test(bit)) - g->apply(qreg); - return 0; - } + measure_x(uint64_t qubit, bool disable_averaging=false) : qubit(qubit), measure_all(false), hg(qubit), mg(qubit), disable_averaging(disable_averaging) + { + } - gate * get_gate() - { - return g; - } + measure_x() : qubit(0), hg(qubit), mg(qubit), measure_all(true) + { + } - uint64_t get_bit() - { - return bit; - } + int64_t apply(qu_register& qreg) + { + int64_t r = 0; - void dump() - { - print(" [-] bin_ctrl: \n bit=" << bit << " -> "); - g->dump(); - } - - std::vector qubits() - { - return g->qubits(); - } + if (measure_all) + { + for (size_t i=0; i control_qubits() - { - return g->control_qubits(); - } - - std::vector target_qubits() - { - return g->target_qubits(); - } + hg.apply(qreg); + r = mg.apply(qreg); + hg.apply(qreg); - gate_type_t type() - { - return __bin_ctrl_gate__; - } + return r; + } + void dump() + { + if (measure_all) + println(" [-] measure_x(register)"); + else + println(" [-] measure_x(qubit=" << qubit << ")"); + } - }; + std::vector qubits() + { + std::vector r; + if (!measure_all) + r.push_back(qubit); + else // this is a dirty hack, itshould be fixed later (unknown qubit number !) + { + for (int64_t i=0; i control_qubits() + { + std::vector r; + return r; + } + std::vector target_qubits() + { + return qubits(); + } + gate_type_t type() + { + if (measure_all) + return __measure_x_reg_gate__; + else + return __measure_x_gate__; + } + }; /** - * \brief classical binary not gate + * measure_y */ - class classical_not : public gate + class measure_y : public gate { - private: - - uint64_t bit; - - public: - - classical_not(uint64_t bit) : bit(bit) - { - } - - int32_t apply(qu_register& qreg) - { - qreg.flip_measurement(bit); - return 0; - } - - uint64_t get_bit() - { - return bit; - } - - void dump() - { - // println(" [-] classical not gate: \n bit=" << bit); - println(" not " << bit); - } - - std::vector qubits() - { - return std::vector(); - } + private: - std::vector control_qubits() - { - return std::vector(); - } - - std::vector target_qubits() - { - return std::vector(); - } + uint64_t qubit; + bool measure_all; + bool disable_averaging; - gate_type_t type() - { - return __classical_not_gate__; - } - }; + qx::phase_shift sg; + qx::pauli_z zg; + qx::measure_x mg; + /* + S(qubit); + Z(qubit); + bool b = MeasX(qubit, randint); + S(qubit); + */ + public: + measure_y(uint64_t qubit, bool disable_averaging=false) : qubit(qubit), measure_all(false), sg(qubit), zg(qubit), mg(qubit), disable_averaging(disable_averaging) + { + } + measure_y() : qubit(0), sg(qubit), zg(qubit), mg(), measure_all(true) + { + } + int64_t apply(qu_register& qreg) + { + int64_t r = 0; - /** - * prepz - */ - class prepz : public gate - { - private: + if (measure_all) + { + for (size_t i=0; i qubits() - { - std::vector r; - r.push_back(qubit); - return r; - } + std::vector qubits() + { + std::vector r; + if (!measure_all) + r.push_back(qubit); + else // this is a dirty hack, itshould be fixed later (unknown qubit number !) + { + for (int64_t i=0; i control_qubits() - { - std::vector r; - return r; - } - - std::vector target_qubits() - { - return qubits(); - } + std::vector control_qubits() + { + std::vector r; + return r; + } - gate_type_t type() - { - return __prepz_gate__; - } + std::vector target_qubits() + { + return qubits(); + } + gate_type_t type() + { + if (measure_all) + return __measure_y_reg_gate__; + else + return __measure_y_gate__; + } }; - class lookup_gate_table : public gate + + /** + * \brief generic binary controlled gate + */ + class bin_ctrl : public gate { private: - std::vector ctrl_bits; - std::map gates; + // uint64_t bit; + std::vector bits; + gate * g; public: - lookup_gate_table(uint64_t b0) - { - ctrl_bits.push_back(b0); - } - - - lookup_gate_table(uint64_t b0, uint64_t b1) - { - ctrl_bits.push_back(b0); - ctrl_bits.push_back(b1); - } - - - lookup_gate_table(uint64_t b0, uint64_t b1, uint64_t b2) - { - ctrl_bits.push_back(b0); - ctrl_bits.push_back(b1); - ctrl_bits.push_back(b2); - } - - - lookup_gate_table(std::vector ctrl_bits) : ctrl_bits(ctrl_bits) - { - } + bin_ctrl(size_t bit, gate * g) : g(g) + { + bits.push_back(bit); + } - - void add_gate(uint64_t cond, gate * g) - { - assert(cond < (1<< ctrl_bits.size())); - gates[cond] = g; - } + bin_ctrl(std::vector bit, gate * g) : g(g) + { + for (auto b : bit) + bits.push_back(b); + } - - int32_t apply(qu_register& qreg) - { - uint64_t k = 0; + int64_t apply(qu_register& qreg) + { + bool m = true; + for (auto b : bits) + if (!qreg.test(b)) + m = false; + if (m) + g->apply(qreg); + return 0; + } - for (uint64_t i=0; i "); + g->dump(); + } - if (it != gates.end()) - (*it).second->apply(qreg); + std::vector qubits() + { + return g->qubits(); + } - return 0; - } + std::vector control_qubits() + { + return g->control_qubits(); + } - std::vector qubits() - { - std::vector r; - // to do - std::map::iterator ig; - for (ig=gates.begin(); ig!=gates.end(); ++ig) - { - std::vector ri = ig->second->qubits(); - r.insert(r.begin(), ri.begin(), ri.end()); - } - return r; - } + std::vector target_qubits() + { + return g->target_qubits(); + } + gate_type_t type() + { + return __bin_ctrl_gate__; + } - std::vector control_qubits() - { - std::vector r; - // to do - std::map::iterator ig; - for (ig=gates.begin(); ig!=gates.end(); ++ig) - { - std::vector ri = ig->second->control_qubits(); - if (ri.size()) - r.insert(r.begin(), ri.begin(), ri.end()); - } - return r; - } - - std::vector target_qubits() - { - std::vector r; - // to do - std::map::iterator ig; - for (ig=gates.begin(); ig!=gates.end(); ++ig) - { - std::vector ri = ig->second->target_qubits(); - if (ri.size()) - r.insert(r.begin(), ri.begin(), ri.end()); - } - return r; - } + }; - void dump() - { - println(" [-] lookup gate table : "); - } + #define bin_ctrl_pauli_x(b,q) bin_ctrl(b,new pauli_x(q)) + #define bin_ctrl_pauli_y(b,q) bin_ctrl(b,new pauli_y(q)) + #define bin_ctrl_pauli_z(b,q) bin_ctrl(b,new pauli_z(q)) - gate_type_t type() - { - return __lookup_table__; - } - - }; /** - * \brief display : debug utility - * display intermediate quantum states of a - * quantum register whithin a circuit. + * \brief classical binary not gate */ - class display : public gate + class classical_not : public gate { - private: - - bool only_binary; + private: - public: + uint64_t bit; - display(bool only_binary=false) : only_binary(only_binary) - { - } + public: - int32_t apply(qu_register& qreg) - { - qreg.dump(only_binary); - return 0; - } + classical_not(uint64_t bit) : bit(bit) + { + } - void dump() - { - println(" [-] display(only_binary=" << only_binary << ")"); - } - - std::vector qubits() - { - std::vector r; - return r; - } + int64_t apply(qu_register& qreg) + { + qreg.flip_measurement(bit); + return 0; + } - std::vector control_qubits() - { - std::vector r; - return r; - } - - std::vector target_qubits() - { - std::vector r; - return r; - } + uint64_t get_bit() + { + return bit; + } - gate_type_t type() - { - if (only_binary) - return __display_binary__; - else - return __display__; - } + void dump() + { + // println(" [-] classical not gate: \n bit=" << bit); + println(" [-] not " << bit); + } + + std::vector qubits() + { + return std::vector(); + } + std::vector control_qubits() + { + return std::vector(); + } - }; + std::vector target_qubits() + { + return std::vector(); + } + gate_type_t type() + { + return __classical_not_gate__; + } + }; /** - * parallel gates + * prepz */ - class parallel_gates : public gate + class prepz : public gate { - public: - - parallel_gates() - { - } + private: - int32_t apply(qu_register& qreg) - { - for (uint64_t i=0; iapply(qreg); - return 0; - } + uint64_t qubit; - uint64_t add(gate * g) - { - gates.push_back(g); - return gates.size(); - } + public: - std::vector get_gates() - { - return gates; - } - - std::vector qubits() - { - std::vector r; - for (uint64_t i=0; i q = gates[i]->qubits(); - r.insert(r.end(),q.begin(),q.end()); - } - return r; - } - - - std::vector control_qubits() - { - std::vector r; - for (uint64_t i=0; i q = gates[i]->control_qubits(); - r.insert(r.end(),q.begin(),q.end()); - } - return r; - } - - std::vector target_qubits() - { - std::vector r; - for (uint64_t i=0; i q = gates[i]->target_qubits(); - r.insert(r.end(),q.begin(),q.end()); - } - return r; - } + prepz(uint64_t qubit) : qubit(qubit) + { + } + int64_t apply(qu_register& qreg) + { + measure(qubit,true).apply(qreg); + bin_ctrl_pauli_x(qubit,qubit).apply(qreg); + // bin_ctrl_pauli_z(qubit,qubit).apply(qreg); + qreg.set_measurement(qubit,false); + return 0; + } - void dump() - { - println(" [-] parallel_gates (" << gates.size() << " gates) : "); - for (uint64_t i=0; idump(); - } + void dump() + { + println(" [-] prepz(qubit=" << qubit << ")"); + } + std::vector qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } - gate_type_t type() - { - return __parallel_gate__; - } - + std::vector control_qubits() + { + std::vector r; + return r; + } - private: + std::vector target_qubits() + { + return qubits(); + } - std::vector gates; // list of the parallel gates + gate_type_t type() + { + return __prepz_gate__; + } }; - /** - * prepare the qubits into an arbitrary quantum state + * prepx */ - class prepare : public gate + class prepx : public gate { - private: + private: - quantum_state_t * state; + uint64_t qubit; + hadamard h; - public: + public: - prepare(quantum_state_t * state) : state(state) - { - } - + prepx(uint64_t qubit) : qubit(qubit), h(qubit) + { + } - int32_t apply(qu_register& qreg) - { - qreg.reset(); - cvector_t& q = qreg.get_data(); - double norm = 0; + int64_t apply(qu_register& qreg) + { + h.apply(qreg); + measure(qubit,true).apply(qreg); + h.apply(qreg); + bin_ctrl_pauli_z(qubit,qubit).apply(qreg); + qreg.set_measurement(qubit,false); + return 0; + } - for (quantum_state_t::iterator i=state->begin(); i != state->end(); ++i) - { - basis_state_t bs = (*i).first; - complex_t c = (*i).second; - // println("bs=" << bs << ", a=" << c); - q[bs] = c; - norm += c.norm(); //std::norm(c); - } - - if (std::fabs(norm-1) > QUBIT_ERROR_THRESHOLD) - { - println("[!] warning : the loaded quantum state is not normalized (norm = " << norm << ") !"); - println("[!] renormalizing the quantum state..."); - qreg.normalize(); - println("[!] quantum state renormalized successfully."); - } + void dump() + { + println(" [-] prepx(qubit=" << qubit << ")"); + } - for (size_t qi=0; qi qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } - void dump() - { - println(" [-] prepare (quantum_state=" << state << ")"); - } - - std::vector qubits() - { - std::vector r; - // this is a dirty hack, itshould be fixed later (unknown qubit number !) - for (int32_t i=0; i control_qubits() + { + std::vector r; + return r; + } - std::vector control_qubits() - { - std::vector r; - return r; - } - - std::vector target_qubits() - { - return qubits(); - } + std::vector target_qubits() + { + return qubits(); + } + + gate_type_t type() + { + return __prepx_gate__; + } - gate_type_t type() - { - return __prepare_gate__; - } }; + /** - * \brief print : debug utility - * print arbitrary string + * prepy */ - class print_str : public gate + class prepy : public gate { - private: - - std::string str; + private: - public: + uint64_t qubit; + prepx px; + phase_shift s; - print_str(std::string& s) : str(s) - { - } + public: - int32_t apply(qu_register& qreg) - { - println(str); - return 0; - } + prepy(uint64_t qubit) : qubit(qubit), px(qubit), s(qubit) + { + } - void dump() - { - println(" print " << str << "\""); - } - - std::vector qubits() - { - std::vector r; - return r; - } + int64_t apply(qu_register& qreg) + { + px.apply(qreg); + s.apply(qreg); + qreg.set_measurement(qubit,false); + return 0; + } - std::vector control_qubits() - { - std::vector r; - return r; - } - - std::vector target_qubits() - { - std::vector r; - return r; - } + void dump() + { + println(" [-] prepy(qubit=" << qubit << ")"); + } - gate_type_t type() - { - return __print_str__; - } + std::vector qubits() + { + std::vector r; + r.push_back(qubit); + return r; + } + + std::vector control_qubits() + { + std::vector r; + return r; + } + + std::vector target_qubits() + { + return qubits(); + } + + gate_type_t type() + { + return __prepy_gate__; + } + + }; + + + + + + + + + class lookup_gate_table : public gate + { + private: + + std::vector ctrl_bits; + std::map gates; + + public: + + lookup_gate_table(uint64_t b0) + { + ctrl_bits.push_back(b0); + } + + + lookup_gate_table(uint64_t b0, uint64_t b1) + { + ctrl_bits.push_back(b0); + ctrl_bits.push_back(b1); + } + + + lookup_gate_table(uint64_t b0, uint64_t b1, uint64_t b2) + { + ctrl_bits.push_back(b0); + ctrl_bits.push_back(b1); + ctrl_bits.push_back(b2); + } + + + lookup_gate_table(std::vector ctrl_bits) : ctrl_bits(ctrl_bits) + { + } + + + void add_gate(uint64_t cond, gate * g) + { + assert(cond < (1<< ctrl_bits.size())); + gates[cond] = g; + } + + + int64_t apply(qu_register& qreg) + { + uint64_t k = 0; + + for (uint64_t i=0; i qubits() + { + std::vector r; + return r; + } + + std::vector control_qubits() + { + std::vector r; + return r; + } + + std::vector target_qubits() + { + std::vector r; + return r; + } + + gate_type_t type() + { + if (only_binary) + return __display_binary__; + else + return __display__; + } + + }; + + + + /** + * parallel gates + */ + class parallel_gates : public gate + { + public: + + parallel_gates() + { + } + + int64_t apply(qu_register& qreg) + { + for (uint64_t i=0; iapply(qreg); + return 0; + } + + uint64_t add(gate * g) + { + gates.push_back(g); + return gates.size(); + } + + std::vector get_gates() + { + return gates; + } + + std::vector qubits() + { + std::vector r; + for (uint64_t i=0; i q = gates[i]->qubits(); + r.insert(r.end(),q.begin(),q.end()); + } + return r; + } + + + std::vector control_qubits() + { + std::vector r; + for (uint64_t i=0; i q = gates[i]->control_qubits(); + r.insert(r.end(),q.begin(),q.end()); + } + return r; + } + + std::vector target_qubits() + { + std::vector r; + for (uint64_t i=0; i q = gates[i]->target_qubits(); + r.insert(r.end(),q.begin(),q.end()); + } + return r; + } + + + void dump() + { + println(" [-] parallel_gates (" << gates.size() << " gates) : "); + for (uint64_t i=0; idump(); + } + + + gate_type_t type() + { + return __parallel_gate__; + } + + + private: + + std::vector gates; // list of the parallel gates + + }; + + + /** + * prepare the qubits into an arbitrary quantum state + */ + class prepare : public gate + { + private: + + quantum_state_t * state; + + public: + prepare(quantum_state_t * state) : state(state) + { + } + + + int64_t apply(qu_register& qreg) + { + qreg.reset(); + cvector_t& q = qreg.get_data(); + double norm = 0; + + for (quantum_state_t::iterator i=state->begin(); i != state->end(); ++i) + { + basis_state_t bs = (*i).first; + complex_t c = (*i).second; + // println("bs=" << bs << ", a=" << c); + q[bs] = c; + norm += c.norm(); //std::norm(c); + } + + if (std::fabs(norm-1) > QUBIT_ERROR_THRESHOLD) + { + println("[!] warning : the loaded quantum state is not normalized (norm = " << norm << ") !"); + println("[!] renormalizing the quantum state..."); + qreg.normalize(); + println("[!] quantum state renormalized successfully."); + } + + for (size_t qi=0; qi qubits() + { + std::vector r; + // this is a dirty hack, itshould be fixed later (unknown qubit number !) + for (int64_t i=0; i control_qubits() + { + std::vector r; + return r; + } + + std::vector target_qubits() + { + return qubits(); + } + + gate_type_t type() + { + return __prepare_gate__; + } }; + /** + * \brief print : debug utility + * print arbitrary string + */ + class print_str : public gate + { + private: + std::string str; + public: + + print_str(std::string& s) : str(s) + { + } + + int64_t apply(qu_register& qreg) + { + println(str); + return 0; + } + + void dump() + { + println(" print " << str << "\""); + } + + std::vector qubits() + { + std::vector r; + return r; + } + + std::vector control_qubits() + { + std::vector r; + return r; + } + + std::vector target_qubits() + { + std::vector r; + return r; + } + + gate_type_t type() + { + return __print_str__; + } + + }; } diff --git a/src/core/linalg.h b/src/core/linalg.h index 64c244d5..4c41dac3 100644 --- a/src/core/linalg.h +++ b/src/core/linalg.h @@ -50,7 +50,7 @@ namespace qx // typedef ublas::matrix cmatrix_t; // typedef ublas::identity_matrix cidentity_t; // #else - typedef std::vector > cvector_t; + typedef std::vector > cvector_t; // typedef xpu::vector cvector_t; // typedef qx::linalg::matrix cmatrix_t; typedef qx::linalg::tiny_matrix cmatrix_t; diff --git a/src/core/register.cc b/src/core/register.cc index 02650d35..ecb849a1 100644 --- a/src/core/register.cc +++ b/src/core/register.cc @@ -1,11 +1,13 @@ +#include + /** * set_binary */ -// void qx::qu_register::set_binary(uint32_t state, uint32_t nq) -void qx::qu_register::set_measurement_prediction(uint32_t state, uint32_t nq) +// void qx::qu_register::set_binary(uint64_t state, uint64_t nq) +void qx::qu_register::set_measurement_prediction(uint64_t state, uint64_t nq) { - //uint32_t k=0; - uint32_t k=nq-1; + //uint64_t k=0; + uint64_t k=nq-1; while (nq--) { // binary[k--] = (((state >> nq) & 1) ? __state_1__ : __state_0__); @@ -17,10 +19,10 @@ void qx::qu_register::set_measurement_prediction(uint32_t state, uint32_t nq) /** * \brief set measurement outcome */ -void qx::qu_register::set_measurement(uint32_t state, uint32_t nq) +void qx::qu_register::set_measurement(uint64_t state, uint64_t nq) { - //uint32_t k=0; - uint32_t k=nq-1; + //uint64_t k=0; + uint64_t k=nq-1; while (nq--) { // binary[k--] = (((state >> nq) & 1) ? __state_1__ : __state_0__); @@ -31,9 +33,9 @@ void qx::qu_register::set_measurement(uint32_t state, uint32_t nq) /** * collapse state */ -uint32_t qx::qu_register::collapse(uint32_t entry) +uint64_t qx::qu_register::collapse(uint64_t entry) { - for (uint32_t i=0; i> nq) & 1) ? "1" : "0"); } @@ -58,10 +60,10 @@ void qx::qu_register::to_binary(uint32_t state, uint32_t nq) /** * to binary string */ -std::string qx::qu_register::to_binary_string(uint32_t state, uint32_t nq) +std::string qx::qu_register::to_binary_string(uint64_t state, uint64_t nq) { std::string s(nq,'0'); - uint32_t k=0; + uint64_t k=0; while (nq--) { s[k] = (((state >> nq) & 1) ? '1' : '0'); @@ -74,19 +76,25 @@ std::string qx::qu_register::to_binary_string(uint32_t state, uint32_t nq) /** * \brief quantum register of n_qubit */ -// qx::qu_register::qu_register(uint32_t n_qubits) : data(1 << n_qubits), binary(n_qubits), n_qubits(n_qubits), rgenerator(xpu::timer().current()*10e5), udistribution(.0,1) -//qx::qu_register::qu_register(uint32_t n_qubits) : data(1 << n_qubits), measurement_prediction(n_qubits), measurement_register(n_qubits), n_qubits(n_qubits), rgenerator(xpu::timer().current()*10e5), udistribution(.0,1) -qx::qu_register::qu_register(uint32_t n_qubits) : data(1 << n_qubits), aux(1 << n_qubits), measurement_prediction(n_qubits), measurement_register(n_qubits), n_qubits(n_qubits), rgenerator(xpu::timer().current()*10e5), udistribution(.0,1), measurement_averaging_enabled(true), measurement_averaging(n_qubits) +// qx::qu_register::qu_register(uint64_t n_qubits) : data(1 << n_qubits), binary(n_qubits), n_qubits(n_qubits), rgenerator(xpu::timer().current()*10e5), udistribution(.0,1) +//qx::qu_register::qu_register(uint64_t n_qubits) : data(1 << n_qubits), measurement_prediction(n_qubits), measurement_register(n_qubits), n_qubits(n_qubits), rgenerator(xpu::timer().current()*10e5), udistribution(.0,1) +qx::qu_register::qu_register(uint64_t n_qubits) : data(1ULL << n_qubits), aux(1ULL << n_qubits), measurement_prediction(n_qubits), measurement_register(n_qubits), n_qubits(n_qubits), rgenerator(xpu::timer().current()*10e5), udistribution(.0,1), measurement_averaging_enabled(true), measurement_averaging(n_qubits) { + if(n_qubits>63) { + throw std::invalid_argument("hard limit of 63 qubits exceeded"); + } + data[0] = complex_t(1,0); - for (uint32_t i=1; i<(1 << n_qubits); ++i) + for (uint64_t i=1; i<(1ULL << n_qubits); ++i) { data[i] = 0; - for (uint32_t i=0; i> nq) & 1) ? __state_1__ : __state_0__); @@ -310,7 +318,7 @@ void qx::qu_register::set_measurement_prediction(uint32_t state) * \brief setter * set bit to the state */ -void qx::qu_register::set_measurement_prediction(uint32_t q, state_t s) +void qx::qu_register::set_measurement_prediction(uint64_t q, state_t s) { assert(q to the state */ -void qx::qu_register::set_measurement(uint32_t q, bool m) +void qx::qu_register::set_measurement(uint64_t q, bool m) { assert(q */ -state_t qx::qu_register::get_measurement_prediction(uint32_t q) +state_t qx::qu_register::get_measurement_prediction(uint64_t q) { assert(q of the binary register * \return true if bit is 1 */ -bool qx::qu_register::test(uint32_t q) // throw (qubit_not_measured_exception) // trow exception if qubit value is unknown (never measured) !!!! +bool qx::qu_register::test(uint64_t q) // throw (qubit_not_measured_exception) // trow exception if qubit value is unknown (never measured) !!!! { assert(q udistribution; + uint64_t n_qubits; - /** - * \brief collapse - */ - uint32_t collapse(uint32_t entry); + std::default_random_engine rgenerator; + std::uniform_real_distribution udistribution; + + /** + * \brief collapse + */ + uint64_t collapse(uint64_t entry); - /** - * \brief convert to binary - */ - void to_binary(uint32_t state, uint32_t nq); + /** + * \brief convert to binary + */ + void to_binary(uint64_t state, uint64_t nq); - /** - * \brief set from binary - */ - //void set_binary(uint32_t state, uint32_t nq); - void set_measurement_prediction(uint32_t state, uint32_t nq); + /** + * \brief set from binary + */ + //void set_binary(uint64_t state, uint64_t nq); + void set_measurement_prediction(uint64_t state, uint64_t nq); public: - /** - * \brief quantum register of n_qubit - */ - qu_register(uint32_t n_qubits); - - - /** - * measurement averaging - */ - measurement_averaging_t measurement_averaging; - bool measurement_averaging_enabled; - - void enable_measurement_averaging() - { - measurement_averaging_enabled = true; - for (size_t i=0; i + */ + void set_measurement_prediction(uint64_t state); + + /** + * \brief setter + * set bit to the state + */ + // void set_binary(uint64_t q, state_t s); + void set_measurement_prediction(uint64_t q, state_t s); + + /** + * \brief set measurement outcome + */ + void set_measurement(uint64_t state, uint64_t nq); + /** + * \brief set measurement outcome + */ + void set_measurement(uint64_t q, bool m); + + /** + * \brief getter + * \return the measurement prediction of qubit + */ + state_t get_measurement_prediction(uint64_t q); + + /** + * \brief getter + * \return the measurement outcome of qubit + */ + bool get_measurement(uint64_t q); + + /** + * \brief test bit of the binary register + * \return true if bit is 1 + */ + bool test(uint64_t q); // throw (qubit_not_measured_exception) // trow exception if qubit value is unknown (never measured) !!!! + + /** + * \brief flip binary + */ + void flip_binary(uint64_t q); + + /** + * \brief flip measurement + */ + void flip_measurement(uint64_t q); + + /** + * \brief return a string describing the quantum state + */ + std::string quantum_state() + { + std::stringstream ss; + ss << std::fixed; + ss << "START\n"; + for (int i=0; i> nq) & 1) ? "1" : "0"); + ss << "> +\n"; + } + } + ss << "END\n"; + return ss.str(); + } + + /** + * \brief renormalize the quantum state + */ + void normalize() + { + double length = 0; + for (size_t k = 0; k < data.size(); k++) + length += data[k].norm(); // std::norm(data[k]); + length = std::sqrt(length); + for (size_t k = 0; k < data.size(); k++) + data[k] /= length; + } /** - * uniform rndom number generator - */ - double rand() - { - return udistribution(rgenerator); - } - - /** - * \brief measure the entire quantum register - */ - int32_t measure(); - - /** - * \brief dump - */ - void dump(bool only_binary); - - /** - * \brief return the quantum state as a string - */ - std::string get_state(bool only_binary); - - - std::string to_binary_string(uint32_t state, uint32_t nq); - - /** - * \brief set the regiter to - */ - void set_measurement_prediction(uint32_t state); - - /** - * \brief setter - * set bit to the state - */ - // void set_binary(uint32_t q, state_t s); - void set_measurement_prediction(uint32_t q, state_t s); - - /** - * \brief set measurement outcome - */ - void set_measurement(uint32_t state, uint32_t nq); - - /** - * \brief set measurement outcome - */ - void set_measurement(uint32_t q, bool m); - - - - - - /** - * \brief getter - * \return the measurement prediction of qubit - */ - state_t get_measurement_prediction(uint32_t q); - - /** - * \brief getter - * \return the measurement outcome of qubit - */ - bool get_measurement(uint32_t q); - - - /** - * \brief test bit of the binary register - * \return true if bit is 1 - */ - bool test(uint32_t q); // throw (qubit_not_measured_exception) // trow exception if qubit value is unknown (never measured) !!!! - - /** - * \brief flip binary - */ - void flip_binary(uint32_t q); - - /** - * \brief flip measurement - */ - void flip_measurement(uint32_t q); - - /** - * \brief return a string describing the quantum state - */ - std::string quantum_state() - { - std::stringstream ss; - ss << std::fixed; - ss << "START\n"; - for (int i=0; i> nq) & 1) ? "1" : "0"); - ss << "> +\n"; - } - } - ss << "END\n"; - return ss.str(); - } - - /** - * \brief renormalize the quantum state - */ - void normalize() - { - double length = 0; - for (size_t k = 0; k < data.size(); k++) - length += data[k].norm(); // std::norm(data[k]); - length = std::sqrt(length); - for (size_t k = 0; k < data.size(); k++) - data[k] /= length; - } - - /** - * \brief returns a string describing the binary register - */ - std::string binary_register() - { - std::stringstream ss; - ss << "START\n"; - //for (int i=binary.size()-1; i>=0; --i) - //ss << " | " << __format_bin(binary[i]); - for (int i=measurement_prediction.size()-1; i>=0; --i) - ss << " | " << __format_bin(measurement_register[i]); - // ss << " | " << __format_bin(measurement_prediction[i]); - ss << " | \n"; - ss << "END\n"; - return ss.str(); - } + * \brief returns a string describing the binary register + */ + std::string binary_register() + { + std::stringstream ss; + ss << "START\n"; + //for (int i=binary.size()-1; i>=0; --i) + //ss << " | " << __format_bin(binary[i]); + for (int i=measurement_prediction.size()-1; i>=0; --i) + ss << " | " << __format_bin(measurement_register[i]); + // ss << " | " << __format_bin(measurement_prediction[i]); + ss << " | \n"; + ss << "END\n"; + return ss.str(); + } }; diff --git a/src/libqasm_interface.h b/src/libqasm_interface.h index 3fe50a09..0a5a6113 100644 --- a/src/libqasm_interface.h +++ b/src/libqasm_interface.h @@ -2,10 +2,81 @@ #define LIBQASM_INTERFACE_H #include -#include +#include #define ITER_FOR_IN(e, l) for (auto e = l.begin(); e != l.end(); e++) +#define __ret_gate_1(__g) \ +{\ + if (!pg)\ + if (!bc)\ + return new __g(sqid(operation));\ + else\ + return new qx::bin_ctrl(bv, new __g(sqid(operation)));\ + else\ + {\ + if (!bc)\ + {\ + for (auto q : qv)\ + pg->add(new __g(q));\ + }\ + else\ + {\ + for (auto q : qv)\ + pg->add(new qx::bin_ctrl(bv, new __g(q)));\ + }\ + return pg;\ + }\ +}\ + + +#define __ret_bin_gate(__g) \ +{\ + if (!pg)\ + return new __g(bid(operation));\ + else\ + {\ + for (auto b : bv)\ + pg->add(new __g(b));\ + return pg;\ + }\ +}\ + + + +#define __ret_gate_2(__g) \ +{\ + const std::vector & qv0 = operation.getQubitsInvolved(1).getSelectedQubits().getIndices();\ + const std::vector & qv1 = operation.getQubitsInvolved(2).getSelectedQubits().getIndices();\ + \ + if (qv0.size() != qv1.size())\ + throw ("[x] error : parallel "+type+" args have different sizes !"); \ + \ + if (qv0.size() == 1)\ + {\ + if (!bc)\ + return new __g(qv0[0], qv1[0]);\ + else\ + return new qx::bin_ctrl(bv, new __g(qv0[0], qv1[0]));\ + }\ + else\ + {\ + pg = new qx::parallel_gates();\ + if (!bc)\ + {\ + for (size_t i=0; iadd(new __g(qv0[i],qv1[i]));\ + }\ + else\ + {\ + for (size_t i=0; iadd(new qx::bin_ctrl(bv, new __g(qv0[i],qv1[i])));\ + }\ + return pg;\ + }\ +}\ + + int sqid(compiler::Operation &operation) { return operation @@ -32,94 +103,341 @@ int bid(compiler::Operation &operation) qx::gate *gateLookup(compiler::Operation &operation) { - std::string type = operation.getType(); - if (type == "h") - return new qx::hadamard(sqid(operation)); - if (type == "cnot") - return new qx::cnot( - qid(operation, 1), - qid(operation, 2)); - if (type == "toffoli") - return new qx::toffoli( - qid(operation, 1), - qid(operation, 2), - qid(operation, 3)); - if (type == "x") - return new qx::pauli_x(sqid(operation)); - if (type == "y") - return new qx::pauli_y(sqid(operation)); - if (type == "z") - return new qx::pauli_z(sqid(operation)); - if (type == "s") - return new qx::phase_shift(sqid(operation)); - if (type == "sdag") - return new qx::s_dag_gate(sqid(operation)); - if (type == "t") - return new qx::t_gate(sqid(operation)); - if (type == "tdag") - return new qx::t_dag_gate(sqid(operation)); - if (type == "rx") - return new qx::rx( - sqid(operation), - operation.getRotationAngle()); - if (type == "ry") - return new qx::ry( - sqid(operation), - operation.getRotationAngle()); - if (type == "rz") - return new qx::rz( - sqid(operation), - operation.getRotationAngle()); - if (type == "swap") - return new qx::swap( - qid(operation, 1), - qid(operation, 2)); - if (type == "cz") - return new qx::cphase( - qid(operation, 1), - qid(operation, 2)); - if (type == "prep_z") - return new qx::prepz(sqid(operation)); - if (type == "measure" || type == "measure_z") - return new qx::measure(sqid(operation)); - if (type == "measure_all") - return new qx::measure(); - if (type == "display") - return new qx::display(); - if (type == "x90") - return new qx::rx(sqid(operation), M_PI/2); - if (type == "mx90") - return new qx::rx(sqid(operation), -M_PI/2); - if (type == "y90") - return new qx::ry(sqid(operation), M_PI/2); - if (type == "my90") - return new qx::ry(sqid(operation), -M_PI/2); - if (type == "c-x") - return new qx::bin_ctrl( - bid(operation), - new qx::pauli_x(sqid(operation))); - if (type == "c-z") - return new qx::bin_ctrl( - bid(operation), - new qx::pauli_z(sqid(operation))); - if (type == "prep_y") - return NULL; - if (type == "prep_x") - return NULL; - if (type == "measure_x") - return NULL; - if (type == "measure_y") - return NULL; - if (type == "cr") - return NULL; - if (type == "crk") - return NULL; - return NULL; + // operation.printOperation(); + bool bc = false; + const std::vector & qv = operation.getQubitsInvolved().getSelectedQubits().getIndices(); + const std::vector & bv = operation.getControlBits().getSelectedBits().getIndices(); + qx::parallel_gates * pg = NULL; + + if (bv.size()) + bc = true; + if (qv.size() > 1) + pg = new qx::parallel_gates(); + + //if (bc) { std::cout << operation.getControlBits().printMembers(); } + + std::string type = operation.getType(); + + if (type == "toffoli") + { + const std::vector & qv0 = operation.getQubitsInvolved(1).getSelectedQubits().getIndices(); + const std::vector & qv1 = operation.getQubitsInvolved(2).getSelectedQubits().getIndices(); + const std::vector & qv2 = operation.getQubitsInvolved(3).getSelectedQubits().getIndices(); + + if ((qv0.size() != qv1.size()) || (qv0.size() != qv2.size())) + throw ("[x] error : parallel toffoli args have different sizes !"); + + if (qv0.size() == 1) + { + if (!bc) + return new qx::toffoli(qv0[0], qv1[0], qv2[0]); + else + return new qx::bin_ctrl(bv, new qx::toffoli(qv0[0], qv1[0], qv2[0])); + } + else + { + pg = new qx::parallel_gates(); + if (!bc) + for (size_t i=0; iadd(new qx::toffoli(qv0[i],qv1[i],qv2[i])); + else + for (size_t i=0; iadd(new qx::bin_ctrl(bv, new qx::toffoli(qv0[i],qv1[i],qv2[i]))); + return pg; + } + } + + ///////// common sq gates ////// + if (type == "x") + __ret_gate_1(qx::pauli_x) + if (type == "y") + __ret_gate_1(qx::pauli_y) + if (type == "z") + __ret_gate_1(qx::pauli_z) + if (type == "h") + __ret_gate_1(qx::hadamard) + if (type == "s") + __ret_gate_1(qx::phase_shift) + if (type == "sdag") + __ret_gate_1(qx::s_dag_gate) + if (type == "t") + __ret_gate_1(qx::t_gate) + if (type == "tdag") + __ret_gate_1(qx::t_dag_gate) + + /////////// classical ///////// + + if (type == "not") + __ret_bin_gate(qx::classical_not) + + /////////// rotations ///////// + if (type == "rx") + { + double angle = operation.getRotationAngle(); + if (!pg) + if (!bc) + return new qx::rx(sqid(operation), angle); + else + return new qx::bin_ctrl(bv, new qx::rx(sqid(operation), angle)); + else + { + if (!bc) + for (auto q : qv) + pg->add(new qx::rx(q,angle)); + else + for (auto q : qv) + pg->add(new qx::bin_ctrl(bv, new qx::rx(q,angle))); + return pg; + } + } + if (type == "ry") + { + double angle = operation.getRotationAngle(); + if (!pg) + if (!bc) + return new qx::ry(sqid(operation), angle); + else + return new qx::bin_ctrl(bv, new qx::ry(sqid(operation), angle)); + else + { + if (!bc) + for (auto q : qv) + pg->add(new qx::ry(q,angle)); + else + for (auto q : qv) + pg->add(new qx::bin_ctrl(bv, new qx::ry(q,angle))); + return pg; + } + } + if (type == "rz") + { + double angle = operation.getRotationAngle(); + if (!pg) + if (!bc) + return new qx::rz(sqid(operation), angle); + else + return new qx::bin_ctrl(bv, new qx::rz(sqid(operation), angle)); + else + { + if (!bc) + for (auto q : qv) + pg->add(new qx::rz(q,angle)); + else + for (auto q : qv) + pg->add(new qx::bin_ctrl(bv, new qx::rz(q,angle))); + return pg; + } + } + + //////////// two qubits gates ////////////// + if (type == "cnot") + __ret_gate_2(qx::cnot) + if (type == "cz") + __ret_gate_2(qx::cphase) + if (type == "swap") + __ret_gate_2(qx::swap) + + ///////////// prep gates ////////////////// + if (type == "prep_z") + __ret_gate_1(qx::prepz) + if (type == "prep_y") + __ret_gate_1(qx::prepy) + if (type == "prep_x") + __ret_gate_1(qx::prepx) + + ////////// measurements ////////////////// + if (type == "measure" || type == "measure_z") + { + if (!pg) + return new qx::measure(sqid(operation)); + else + { + for (auto q : qv) + pg->add(new qx::measure(q)); + return pg; + } + } + if (type == "measure_all") + return new qx::measure(); + + if (type == "measure_x") + { + if (!pg) + return new qx::measure_x(sqid(operation)); + else + { + for (auto q : qv) + pg->add(new qx::measure_x(q)); + return pg; + } + } + if (type == "measure_y") + { + if (!pg) + return new qx::measure_y(sqid(operation)); + else + { + for (auto q : qv) + pg->add(new qx::measure_y(q)); + return pg; + } + } + + ////////////// display ///////////////// + if (type == "display") + return new qx::display(); + if (type == "display_binary") + return new qx::display(true); + + /////////////// x90 ////////////////// + if (type == "x90") + { + double angle = M_PI/2; + if (!pg) + if (!bc) + return new qx::rx(sqid(operation), angle); + else + return new qx::bin_ctrl(bv, new qx::rx(sqid(operation), angle)); + else + { + if (!bc) + for (auto q : qv) + pg->add(new qx::rx(q,angle)); + else + for (auto q : qv) + pg->add(new qx::bin_ctrl(bv, new qx::rx(q,angle))); + return pg; + } + } + if (type == "mx90") + { + double angle = -M_PI/2; + if (!pg) + if (!bc) + return new qx::rx(sqid(operation), angle); + else + return new qx::bin_ctrl(bv, new qx::rx(sqid(operation), angle)); + else + { + if (!bc) + for (auto q : qv) + pg->add(new qx::rx(q,angle)); + else + for (auto q : qv) + pg->add(new qx::bin_ctrl(bv, new qx::rx(q,angle))); + return pg; + } + } + if (type == "y90") + { + double angle = M_PI/2; + if (!pg) + if (!bc) + return new qx::ry(sqid(operation), angle); + else + return new qx::bin_ctrl(bv, new qx::ry(sqid(operation), angle)); + else + { + if (!bc) + for (auto q : qv) + pg->add(new qx::ry(q,angle)); + else + for (auto q : qv) + pg->add(new qx::bin_ctrl(bv, new qx::ry(q,angle))); + return pg; + } + } + if (type == "my90") + { + double angle = -M_PI/2; + if (!pg) + if (!bc) + return new qx::ry(sqid(operation), angle); + else + return new qx::bin_ctrl(bv, new qx::ry(sqid(operation), angle)); + else + { + if (!bc) + for (auto q : qv) + pg->add(new qx::ry(q,angle)); + else + for (auto q : qv) + pg->add(new qx::bin_ctrl(bv, new qx::ry(q,angle))); + return pg; + } + } + if (type == "c-x") + return new qx::bin_ctrl( + bid(operation), + new qx::pauli_x(sqid(operation))); + if (type == "c-z") + return new qx::bin_ctrl( + bid(operation), + new qx::pauli_z(sqid(operation))); + + if (type == "cr") + { + double angle = operation.getRotationAngle(); + const std::vector & qv0 = operation.getQubitsInvolved(1).getSelectedQubits().getIndices(); + const std::vector & qv1 = operation.getQubitsInvolved(2).getSelectedQubits().getIndices(); + + if (qv0.size() != qv1.size()) + throw ("[x] error : parallel 'cr' args have different sizes !"); + + if (qv0.size() == 1) + { + if (!bc) + return new qx::ctrl_phase_shift(qv0[0], qv1[0],angle); + else + return new qx::bin_ctrl(bv, new qx::ctrl_phase_shift(qv0[0], qv1[0],angle)); + } + else + { + pg = new qx::parallel_gates(); + if (!bc) + for (size_t i=0; iadd(new qx::ctrl_phase_shift(qv0[i],qv1[i],angle)); + else + for (size_t i=0; iadd(new qx::bin_ctrl(bv, new qx::ctrl_phase_shift(qv0[i],qv1[i],angle))); + return pg; + } + } + if (type == "crk") + { + size_t angle = operation.getRotationAngle(); + const std::vector & qv0 = operation.getQubitsInvolved(1).getSelectedQubits().getIndices(); + const std::vector & qv1 = operation.getQubitsInvolved(2).getSelectedQubits().getIndices(); + + if (qv0.size() != qv1.size()) + throw ("[x] error : parallel 'crk' args have different sizes !"); + + if (qv0.size() == 1) + { + if (!bc) + return new qx::ctrl_phase_shift(qv0[0], qv1[0],angle); + else + return new qx::bin_ctrl(bv, new qx::ctrl_phase_shift(qv0[0], qv1[0],angle)); + } + else + { + pg = new qx::parallel_gates(); + if (!bc) + for (size_t i=0; iadd(new qx::ctrl_phase_shift(qv0[i],qv1[i],angle)); + else + for (size_t i=0; iadd(new qx::bin_ctrl(bv, new qx::ctrl_phase_shift(qv0[i],qv1[i],angle))); + return pg; + } + } + + return NULL; } -qx::circuit *qxCircuitFromCQasm(uint32_t qubits_count, compiler::SubCircuit &subcircuit) +qx::circuit *qxCircuitFromCQasm(uint64_t qubits_count, compiler::SubCircuit &subcircuit) { - uint32_t iterations = subcircuit.numberIterations(); + uint64_t iterations = subcircuit.numberIterations(); std::string name = subcircuit.nameSubCircuit(); qx::circuit *circuit = new qx::circuit(qubits_count, name, iterations); @@ -134,18 +452,27 @@ qx::circuit *qxCircuitFromCQasm(uint32_t qubits_count, compiler::SubCircuit &sub = (*p_cluster)->getOperations(); ITER_FOR_IN(p_operation, operations) { - qx::gate *g = gateLookup(**p_operation); - if (!g) - { - throw (*p_operation)->getType(); - } - else - { - circuit->add(g); - } + qx::gate * g; + try + { + g = gateLookup(**p_operation); + } + catch (const char * error) + { + std::cerr << error << std::endl; + exit(-1); + } + if (!g) + { + throw (*p_operation)->getType(); + } + else + { + circuit->add(g); + } } } - + // circuit->dump(); return circuit; } diff --git a/src/parser/liblexgram.so b/src/parser/liblexgram.so deleted file mode 100755 index ba659d0f..00000000 Binary files a/src/parser/liblexgram.so and /dev/null differ diff --git a/src/parser/libqasm b/src/parser/libqasm new file mode 160000 index 00000000..c7470a5f --- /dev/null +++ b/src/parser/libqasm @@ -0,0 +1 @@ +Subproject commit c7470a5f1dbb478156af9e34891e6196bc8eff0b diff --git a/src/parser/qasm_ast.hpp b/src/parser/qasm_ast.hpp deleted file mode 100644 index 5299eaad..00000000 --- a/src/parser/qasm_ast.hpp +++ /dev/null @@ -1,601 +0,0 @@ -#pragma once -#ifndef QASM_AST_REP -#define QASM_AST_REP - - -#include -#include -#include -#include -#include -#include -#include - -namespace compiler -{ - - class NumericalIdentifiers - // This class takes a list of identifiers used by both bits and qubits to internal int vectors - { - public: - NumericalIdentifiers() = default; - - void addToVector (const int index) - // This is used when a single integer is encountered - { - indices_.push_back( static_cast (index) ); - } - - void addToVector (const int index_min, const int index_max) - // This is used for when a range of qubits is being defined - { - for (int index = index_min; index <= index_max; ++index) - indices_.push_back( static_cast (index) ); - } - - const std::vector & getIndices() const - { - return indices_; - } - - void removeDuplicates() - { - std::sort( indices_.begin(), indices_.end() ); - indices_.erase( std::unique( indices_.begin(), indices_.end() ), indices_.end() ); - } - - void clear() - { - indices_.clear(); - } - - void printMembers() const - { - std::cout << "Indices: "; - for (size_t elems : getIndices()) - { - std::cout << elems << " "; - } - std::cout << std::endl; - } - - protected: - std::vector indices_; - }; // class NumericalIdentifiers - - class Qubits - // This class encapsulates the participating qubits in the specified operation - { - public: - - Qubits() = default; - Qubits(NumericalIdentifiers indices) : selected_qubits_ (indices) {} - - void setSelectedQubits(NumericalIdentifiers indices) - { - selected_qubits_ = indices; - } - - const NumericalIdentifiers& getSelectedQubits() const - { - return selected_qubits_; - } - - void printMembers() const - { - std::cout << "Selected Qubits - "; - getSelectedQubits().printMembers(); - } - - protected: - NumericalIdentifiers selected_qubits_; - }; - - class Bits - // This class encapsulates the participating bit in the specified operation - { - public: - - Bits() = default; - Bits(NumericalIdentifiers indices) : selected_bits_ (indices) {} - - void setSelectedBits(NumericalIdentifiers indices) - { - selected_bits_ = indices; - } - - const NumericalIdentifiers& getSelectedBits() const - { - return selected_bits_; - } - - void printMembers() const - { - std::cout << "Selected Bits - "; - getSelectedBits().printMembers(); - } - - protected: - NumericalIdentifiers selected_bits_; - }; - - class Operation - { - public: - Operation(const std::string type, Qubits qubits_involved) - : qubits_ (qubits_involved), - rotation_angle_ (std::numeric_limits::max()), bit_controlled_(false) - // This is the most common operation, the single qubit operation, or reset_averaging - { - type_ = toLowerCase(type); - } - - Operation(const std::string type, Qubits qubits_involved, const double rotation_angle) - : qubits_ (qubits_involved), - rotation_angle_ (rotation_angle), bit_controlled_(false) - // Single qubit rotations - { - type_ = toLowerCase(type); - } - - Operation(const std::string type, Qubits qubit_pair1, std::string axis1, Qubits qubit_pair2, std::string axis2) - : rotation_angle_ (std::numeric_limits::max()), bit_controlled_(false) - // Measure parity operation - { - type_ = toLowerCase(type); - measure_parity_qubits_ = std::pair (qubit_pair1,qubit_pair2); - measure_parity_axis_ = std::pair (toLowerCase(axis1),toLowerCase(axis2)); - } - - Operation(const std::string type) - : rotation_angle_ (std::numeric_limits::max()), bit_controlled_(false) - // Measure all operation - { - type_ = toLowerCase(type); - all_qubits_bits_ = true; - } - - Operation(const std::string type, const int waitInt) - : rotation_angle_ (std::numeric_limits::max()), bit_controlled_(false) - // Wait command - { - type_ = toLowerCase(type); - wait_time_ = waitInt; - } - - Operation(const std::string type, const Bits display_bits) - : rotation_angle_ (std::numeric_limits::max()), bit_controlled_(false) - // Display command - { - type_ = toLowerCase(type); - bits_ = display_bits; - } - - Operation(const std::string type, Qubits qubit_pair1, Qubits qubit_pair2) - : rotation_angle_ (std::numeric_limits::max()), bit_controlled_(false) - // Two qubit gate operations - { - type_ = toLowerCase(type); - two_qubit_pairs_ = std::pair (qubit_pair1,qubit_pair2); - } - - Operation(const std::string type, Qubits qubit_pair1, Qubits qubit_pair2, double rotations) - : rotation_angle_ (rotations), bit_controlled_(false) - // Two qubit gate operations - { - type_ = toLowerCase(type); - two_qubit_pairs_ = std::pair (qubit_pair1,qubit_pair2); - } - - Operation(const std::string type, Qubits qubit_pair1, Qubits qubit_pair2, Qubits qubit_pair3) - : rotation_angle_ (std::numeric_limits::max()), bit_controlled_(false) - // Toffoli operations - { - type_ = toLowerCase(type); - toffoli_qubit_pairs_ = std::pair> ( - qubit_pair1, - std::pair (qubit_pair2,qubit_pair3) - ); - } - - std::string getType() const - { - return type_; - } - - const Qubits& getQubitsInvolved() const - { - return qubits_; - } - - const Qubits& getQubitsInvolved(const int qubit_pair_index) const - { - if (type_ == "toffoli") - { - switch(qubit_pair_index){ - case 1: return toffoli_qubit_pairs_.first; break; - case 2: return toffoli_qubit_pairs_.second.first; break; - case 3: return toffoli_qubit_pairs_.second.second; break; - default: throw std::runtime_error( std::string("Accessing qubit pair ") - + std::to_string(qubit_pair_index) - + std::string(" on operation ") + type_ ); return qubits_; - } - } - else if (type_ == "cnot" || type_ == "cz" || type_ == "swap" || type_ == "cr") - { - switch(qubit_pair_index){ - case 1: return two_qubit_pairs_.first; break; - case 2: return two_qubit_pairs_.second; break; - default: throw std::runtime_error( std::string("Accessing qubit pair ") - + std::to_string(qubit_pair_index) - + std::string(" on operation ") + type_ ); return qubits_; - } - } - else - { - throw std::runtime_error( std::string("Accessing qubit pair ") - + std::to_string(qubit_pair_index) - + std::string(" on operation ") + type_ ); - return qubits_; - } - } - - double getRotationAngle() const - { - return rotation_angle_; - } - - const std::pair< std::pair, std::pair > getMeasureParityQubitsAndAxis() const - { - std::pair< std::pair, std::pair > pair_result (measure_parity_qubits_, measure_parity_axis_); - return pair_result; - } - - const std::pair & getTwoQubitPairs() const - { - return two_qubit_pairs_; - } - - const std::pair< Qubits, std::pair >& getToffoliQubitPairs() const - { - - return toffoli_qubit_pairs_; - } - - bool isBitControlled() const - { - return bit_controlled_; - } - - bool allQubitsBits() const - { - return all_qubits_bits_; - } - - void setControlBits(Bits control_bits) - { - bits_ = control_bits; - bit_controlled_ = true; - } - - const Bits& getControlBits() const - { - return bits_; - } - - const Bits& getDisplayBits() const - { - return bits_; - } - - int getWaitTime() const - { - return wait_time_; - } - - void printOperation() const - { - std::cout << "Operation " << type_ << ": "; - if ( type_ == "rx" || type_ == "ry" || type_ == "rz" ) - { - getQubitsInvolved().printMembers(); - std::cout << "Rotations = " << getRotationAngle() << std::endl; - } - else if (type_ == "measure_parity") - { - std::cout << std::endl; - auto measureParityProperties = getMeasureParityQubitsAndAxis(); - measureParityProperties.first.first.printMembers(); - std::cout << "With axis " << measureParityProperties.second.first << std::endl; - measureParityProperties.first.second.printMembers(); - std::cout << "With axis " << measureParityProperties.second.second << std::endl; - } - else if (type_ == "cnot" || type_ == "cz" || type_ == "swap") - { - std::cout << std::endl; - std::cout << "Qubit Pair 1: "; - getTwoQubitPairs().first.printMembers(); - std::cout << "Qubit Pair 2: "; - getTwoQubitPairs().second.printMembers(); - } - else if (type_ == "cr") - { - std::cout << std::endl; - std::cout << "Qubit Pair 1: "; - getTwoQubitPairs().first.printMembers(); - std::cout << "Qubit Pair 2: "; - getTwoQubitPairs().second.printMembers(); - std::cout << "Rotation = " << getRotationAngle() << std::endl; - } - else if (type_ == "toffoli") - { - std::cout << std::endl; - std::cout << "Qubit Pair 1: "; - getToffoliQubitPairs().first.printMembers(); - std::cout << "Qubit Pair 2: "; - getToffoliQubitPairs().second.first.printMembers(); - std::cout << "Qubit Pair 3: "; - getToffoliQubitPairs().second.second.printMembers(); - } - else if (type_ == "wait") - { - std::cout << std::endl; - std::cout << "Wait time (integer) = " << getWaitTime() << std::endl; - } - else if (type_ == "display") - { - std::cout << "Display bits: "; - getDisplayBits().printMembers(); - } - else getQubitsInvolved().printMembers(); - - if (isBitControlled()){ - std::cout << "Bit controlled with bits: "; - getControlBits().printMembers(); - } - } - - protected: - - std::string toLowerCase(const std::string& string_input) - { - std::string lower_case_input = string_input; - std::transform(lower_case_input.begin(), lower_case_input.end(), lower_case_input.begin(), ::tolower); - return lower_case_input; - } - - std::string type_; - Qubits qubits_; - Bits bits_; - double rotation_angle_; - bool bit_controlled_; - bool all_qubits_bits_ = false; - int wait_time_; - std::pair measure_parity_qubits_; - std::pair measure_parity_axis_; - std::pair two_qubit_pairs_; - std::pair > toffoli_qubit_pairs_; - }; // class Operation - - class OperationsCluster - // This class enables parallel operation support - { - public: - OperationsCluster() - { - isParallel_ = false; - } - - OperationsCluster(Operation* valid_op) - { - operations_.push_back(valid_op); - isParallel_ = false; - } - - Operation* lastOperation() - { - return operations_.back(); - } - - void addOperation( Operation* valid_op ) - { - operations_.push_back(valid_op); - } - - void addParallelOperation( Operation* valid_op ) - { - operations_.push_back(valid_op); - isParallel_ = true; - } - - bool isParallel() const - { - return isParallel_; - } - - const std::vector< Operation* >& getOperations() const - { - return operations_; - } - - void printOperations() - { - if (isParallel()) - { - std::cout << "Parallel operations cluster: " << std::endl; - for (auto elem : getOperations()) - elem -> printOperation(); - std::cout << "End Parallel operations \n" << std::endl; - } - else - { - std::cout << "Serial operation: " << std::endl; - for (auto elem : getOperations()) - elem -> printOperation(); - std::cout << "End Serial operation \n" << std::endl; - } - } - - protected: - std::vector< Operation* > operations_; - bool isParallel_; - }; // class Operations - - class SubCircuit - // This class encapsulates the subcircuit with the number of iterations and also the statements contained in it. - { - public: - SubCircuit(const char *name, const int subcircuit_number): - name_ ( std::string(name) ), - number_iterations_ ( 1 ), // By default, we run the subcircuit at least once - subcircuit_number_ ( subcircuit_number ) - { - } - - int numberIterations() const - { - return number_iterations_; - } - - void numberIterations(int iterations) - { - number_iterations_ = iterations; - } - - size_t rankSubCircuit() const - { - return subcircuit_number_; - } - - const std::string& nameSubCircuit() const - { - return name_; - } - - void addOperationsCluster(OperationsCluster *opclus) - { - operations_cluster_.push_back(opclus); - } - - OperationsCluster* lastOperationsCluster() - { - return operations_cluster_.back(); - } - - const std::vector< OperationsCluster* >& getOperationsCluster() const - { - return operations_cluster_; - } - - void printMembers() const - { - std::cout << "Subcircuit Name = " << nameSubCircuit() << " , Rank = " << rankSubCircuit() << std::endl; - std::cout << nameSubCircuit() << " has " << numberIterations() << " iterations." << std::endl; - std::cout << "Contains these operations clusters:" << std::endl; - for (auto elem : getOperationsCluster()) - elem->printOperations(); - std::cout << "End of subcircuit " << nameSubCircuit() << std::endl << std::endl; - } - - protected: - std::string name_; // This member is the name of the subcircuit - int number_iterations_; // This member is the number of iterations the subcircuit is supposed to run - size_t subcircuit_number_; // This member provides the order of the subcircuits when it is found in the qasm file - std::vector< OperationsCluster* > operations_cluster_; - }; //class SubCircuit - - class SubCircuits - // This class groups all the subcircuits found in the cqasm file - { - public: - SubCircuits() - { - SubCircuit default_circuit("default", 0); - subcircuits_.push_back ( default_circuit ); - } - - void addSubCircuit(SubCircuit subcircuit) - { - subcircuits_.push_back(subcircuit); - } - - size_t numberOfSubCircuits() const - { - return subcircuits_.size(); - } - - SubCircuit& lastSubCircuit() - { - return subcircuits_.back(); - } - - const std::vector& getAllSubCircuits() const - { - return subcircuits_; - } - - protected: - std::vector subcircuits_; - }; //class SubCircuits - - class QasmRepresentation - // This class is supposed to provide an encapsulation of all the objects within the qasm file - { - public: - QasmRepresentation() = default; - - void qubitRegister(int participating_number) - { - qubit_register_ = participating_number; - } - - int numQubits() - { - return qubit_register_; - } - - SubCircuits& getSubCircuits() - { - return subcircuits_; - } - - void addMappings(std::string name_key, NumericalIdentifiers indices, bool isQubit) - { - // Make sure they are all lowercase - std::transform(name_key.begin(), name_key.end(), name_key.begin(), ::tolower); - // Make pair between the indices and whether or not it is a qubit - std::pair map_value (indices, isQubit); - mappings_[name_key] = map_value; - } - - const NumericalIdentifiers& getMappedIndices(std::string name_key, bool isQubit) const - { - // Make sure they are all lowercase - std::transform(name_key.begin(), name_key.end(), name_key.begin(), ::tolower); - - if( mappings_.find(name_key)->second.second == isQubit && - mappings_.find(name_key) != mappings_.end() ) - return mappings_.find(name_key)->second.first; - else - throw std::runtime_error(std::string("Could not get wanted mapping ") + name_key); - } - - void printMappings() const - // This is just for debugging purposes - { - for (auto elem : mappings_) - { - std::cout << elem.first << ": "; - elem.second.first.printMembers(); std::cout << elem.second.second << std::endl; - } - } - - protected: - SubCircuits subcircuits_; - int qubit_register_; - std::map > mappings_; - }; // class QasmRepresentation -} //namespace compiler - - -#endif \ No newline at end of file diff --git a/src/parser/qasm_semantic.hpp b/src/parser/qasm_semantic.hpp deleted file mode 100644 index 656abade..00000000 --- a/src/parser/qasm_semantic.hpp +++ /dev/null @@ -1,186 +0,0 @@ -#pragma once -#ifndef AST_SEMANTIC_HPP - -#include "qasm_ast.hpp" -#include -#include - -extern int yyparse(); -extern int yylex(); -extern FILE* yyin; -extern compiler::QasmRepresentation qasm_representation; - -namespace compiler -{ - class QasmSemanticChecker - { - public: - QasmSemanticChecker(FILE *qasm_file) - { - // set lex to read from it instead of defaulting to STDIN: - yyin = qasm_file; - - // parse through the input until there is no more: - int result = 0; - - do { - result += yyparse(); - } while (!feof(yyin)); - if (result) - throw std::runtime_error(std::string("Could not parse qasm file!\n")); - - maxNumQubit_ = qasm_representation.numQubits(); - qasm_ = qasm_representation; - result = doChecks(); - parse_result_ = result; - } - - int parseResult() const - { - return parse_result_; - } - - const compiler::QasmRepresentation& getQasmRepresentation() const - { - return qasm_; - } - - protected: - compiler::QasmRepresentation qasm_; - size_t maxNumQubit_; - int parse_result_; - - - int doChecks() - { - int checkResult = 0; - for (auto subcircuit : qasm_.getSubCircuits().getAllSubCircuits()) - { - for (auto ops_cluster : subcircuit.getOperationsCluster()) - { - for (auto ops : ops_cluster->getOperations()) - { - checkQubits(*ops, checkResult); - } - } - } - - if (!checkResult) - std::cout << "Semantic check complete. Qasm file is valid." << std::endl; - else - throw std::runtime_error(std::string("Qasm file invalid\n")); - return checkResult; - } - - void checkQubits(compiler::Operation& op, int & result) - { - std::string type_ = op.getType(); - if (type_ == "measure_parity") - { - result = checkMeasureParity(op); - } - else if (type_ == "cnot" || type_ == "cz" || type_ == "swap" || type_ == "cr") - { - result = checkTwoQubits(op); - } - else if (type_ == "toffoli") - { - result = checkToffoli(op); - } - else if (type_ == "measure_all") - { - result = checkMeasureAll(op); - } - else if (type_ == "reset-averaging") - { - result = checkResetAveraging(op); - } - else if (type_ == "wait" || type_ == "display" || type_ == "not") - { - result = checkWaitDisplayNot(op); - } - else - // No other special operations. Left with single qubits - { - result = checkSingleQubit(op); - } - if (result > 0) - throw std::runtime_error(std::string("Operation invalid\n")); - - } - - int checkQubitList(const compiler::Qubits& qubits) const - { - auto indices = qubits.getSelectedQubits().getIndices(); - if (indices.back() < maxNumQubit_) - return 0; - else - throw std::runtime_error(std::string("Qubit indices exceed the number in qubit register\n")); - } - - int checkQubitListLength(const compiler::Operation& op __attribute__((unused))) const - // This function ensures that the lengths of the qubit lists are the same for the different pairs involved in the operation - { - return 0; - } - - int checkSingleQubit(const compiler::Operation& op) const - { - return checkQubitList(op.getQubitsInvolved()); - } - - int checkWaitDisplayNot(const compiler::Operation& op __attribute__((unused))) const - { - return 0; - } - - int checkResetAveraging(const compiler::Operation& op) const - { - int result = 1; - if (op.allQubitsBits()) - result = 0; - else - result = checkQubitList(op.getQubitsInvolved()); - return result; - } - - int checkMeasureAll(const compiler::Operation& op __attribute__((unused))) const - { - return 0; - } - - int checkToffoli(const compiler::Operation& op) const - { - int result = 1; - int resultlist = checkQubitList(op.getToffoliQubitPairs().first); - resultlist += checkQubitList(op.getToffoliQubitPairs().second.first); - resultlist += checkQubitList(op.getToffoliQubitPairs().second.second); - result *= resultlist; - return result; - } - - int checkTwoQubits(const compiler::Operation& op) const - { - int result = 1; - int resultlist = checkQubitList(op.getTwoQubitPairs().first); - resultlist += checkQubitList(op.getTwoQubitPairs().second); - result *= resultlist; - return result; - } - - int checkMeasureParity(const compiler::Operation& op) const - { - int result = 1; - auto measureParityProperties = op.getMeasureParityQubitsAndAxis(); - int resultlist = checkQubitList(measureParityProperties.first.first); - resultlist += checkQubitList(measureParityProperties.first.second); - result *= resultlist; - return result; - } - - - }; // class QasmSemanticChecker - -} // namespace compiler - -#endif \ No newline at end of file diff --git a/src/qx_server.cc b/src/qx_server.cc index 41f6825b..cc0bd19b 100644 --- a/src/qx_server.cc +++ b/src/qx_server.cc @@ -7,6 +7,7 @@ #include #include #include +#include "qx_version.h" int main(int argc, char **argv) @@ -19,7 +20,7 @@ int main(int argc, char **argv) println(" / /___/ / _> < _\\ \\ _/ / / /|_/ / / /_/ / / /__ / __ | / / / /_/ / / , _/ "); println(" \\______/\\__\\ /_/|_| /___/ /___/ /_/ /_/ \\____/ /____//_/ |_|/_/ \\____/ /_/|_| "); println(" "); - println(" version 0.1 beta - QuTech - 2016 - report bugs and suggestions to: nader.khammassi@gmail.com "); + println(" version " << QX_VERSION << " - QuTech - " << QX_RELEASE_YEAR << " - report bugs and suggestions to: nader.khammassi@gmail.com"); println(" =================================================================================================== "); println(""); diff --git a/src/qx_version.h b/src/qx_version.h new file mode 100644 index 00000000..4f209d15 --- /dev/null +++ b/src/qx_version.h @@ -0,0 +1,4 @@ +#ifndef QX_VERSION +#define QX_VERSION "0.2 beta" +#define QX_RELEASE_YEAR "2018" +#endif diff --git a/src/simulator.cc b/src/simulator.cc index ee10ca69..c04e043b 100644 --- a/src/simulator.cc +++ b/src/simulator.cc @@ -10,11 +10,12 @@ #include #include #include -#include +#include #include +#include "qx_version.h" void print_banner() { println(""); @@ -25,7 +26,7 @@ void print_banner() { println(" / /___/ / _> < _\\ \\ _/ / / /|_/ / / /_/ / / /__ / __ | / / / /_/ / / , _/ "); println(" \\______/\\__\\ /_/|_| /___/ /___/ /_/ /_/ \\____/ /____//_/ |_|/_/ \\____/ /_/|_| "); println(" "); - println(" version 0.1 beta - QuTech - 2016 - report bugs and suggestions to: nader.khammassi@gmail.com "); + println(" version " << QX_VERSION << " - QuTech - " << QX_RELEASE_YEAR << " - report bugs and suggestions to: nader.khammassi@gmail.com"); println(" =================================================================================================== "); println(""); } @@ -46,22 +47,23 @@ int main(int argc, char **argv) return -1; } - // Parse arguments and initialise xpu cores + // parse arguments and initialise xpu cores file_path = argv[1]; if (argc == 3) ncpu = (atoi(argv[2])); if (ncpu && ncpu < 128) xpu::init(ncpu); else xpu::init(); - // Parse file and create abstract syntax tree + // parse file and create abstract syntax tree println("[+] loading circuit from '" << file_path << "' ..."); FILE *qasm_file = fopen(file_path.c_str(), "r"); if (!qasm_file) { - std::cerr << "[x] Error: Could not open " << file_path << std::endl; + std::cerr << "[x] error: could not open " << file_path << std::endl; + xpu::clean(); return -1; } - // Construct libqasm parser and safely parse input file + // construct libqasm parser and safely parse input file compiler::QasmSemanticChecker *parser; compiler::QasmRepresentation ast; try @@ -71,8 +73,9 @@ int main(int argc, char **argv) } catch (std::exception &e) { - std::cerr << "Error while parsing file " << file_path << ": " << std::endl; + std::cerr << "error while parsing file " << file_path << ": " << std::endl; std::cerr << e.what() << std::endl; + xpu::clean(); return -1; } @@ -81,8 +84,19 @@ int main(int argc, char **argv) std::vector circuits; uint32_t qubits = ast.numQubits(); println("[+] creating quantum register of " << qubits << " qubits... "); - qx::qu_register reg(qubits); - + qx::qu_register *reg = NULL; + + try { + reg = new qx::qu_register(qubits); + } catch(std::bad_alloc& exception) { + std::cerr << "[x] not enough memory, aborting" << std::endl; + xpu::clean(); + return -1; + } catch(std::exception& exception) { + std::cerr << "[x] unexpected exception (" << exception.what() << "), aborting" << std::endl; + xpu::clean(); + return -1; + } // Convert libqasm ast to qx internal representation qx::QxRepresentation qxr = qx::QxRepresentation(qubits); @@ -97,6 +111,7 @@ int main(int argc, char **argv) catch (std::string type) { std::cerr << "[x] Encountered unsuported gate: " << type << std::endl; + xpu::clean(); return -1; } } @@ -138,7 +153,7 @@ int main(int argc, char **argv) } for (uint32_t i=0; iexecute(reg); + circuits[i]->execute(*reg); xpu::clean(); diff --git a/src/simulator_old.cc b/src/simulator_old.cc index 62d42269..950312f9 100644 --- a/src/simulator_old.cc +++ b/src/simulator_old.cc @@ -13,6 +13,7 @@ #include #include #include +#include "qx_version.h" /** * simulator @@ -27,7 +28,7 @@ int main(int argc, char **argv) println(" / /___/ / _> < _\\ \\ _/ / / /|_/ / / /_/ / / /__ / __ | / / / /_/ / / , _/ "); println(" \\______/\\__\\ /_/|_| /___/ /___/ /_/ /_/ \\____/ /____//_/ |_|/_/ \\____/ /_/|_| "); println(" "); - println(" version 0.1 beta - QuTech - 2016 - report bugs and suggestions to: nader.khammassi@gmail.com "); + println(" version " << QX_VERSION << " - QuTech - " << QX_RELEASE_YEAR << " - report bugs and suggestions to: nader.khammassi@gmail.com"); println(" =================================================================================================== "); println(""); @@ -59,10 +60,20 @@ int main(int argc, char **argv) qcp.parse(); //qcp.dump(); + qx::qu_register *reg = NULL; println("[+] creating quantum register of " << qcp.qubits() << " qubits... "); - qx::qu_register reg(qcp.qubits()); - + try { + reg = new qx::qu_register(qcp.qubits()); + } catch(std::bad_alloc& exception) { + println("[!] not enough memory, aborting"); + xpu::clean(); + return -1; + } catch(std::exception& exception) { + println("[!] unexpected exception (" << exception.what() << "), aborting"); + xpu::clean(); + return -1; + } qx::circuits_t circuits; @@ -106,8 +117,10 @@ int main(int argc, char **argv) // qcp.execute(reg); for (uint32_t i=0; iexecute(reg); + circuits[i]->execute(*reg); + xpu::clean(); + return 0; } diff --git a/src/xpu-0.1.5/xpu/aligned_memory_allocator.h b/src/xpu-0.1.5/xpu/aligned_memory_allocator.h index e91cc99d..f3b56a79 100644 --- a/src/xpu-0.1.5/xpu/aligned_memory_allocator.h +++ b/src/xpu-0.1.5/xpu/aligned_memory_allocator.h @@ -3,6 +3,7 @@ #include #include +#include namespace xpu { @@ -37,8 +38,11 @@ namespace xpu } inline pointer allocate (size_type n) { - // return (pointer)_aligned_malloc(n*sizeof(value_type), N); - return (pointer)_mm_malloc(n*sizeof(value_type), N); + pointer rv = (pointer)_mm_malloc(n*sizeof(value_type), N); + if(NULL==rv) { + throw std::bad_alloc(); + } + return rv; } inline void deallocate (pointer p, size_type) { diff --git a/src/xpu-0.1.5/xpu/complex.h b/src/xpu-0.1.5/xpu/complex.h index 281e6704..a3d0a209 100644 --- a/src/xpu-0.1.5/xpu/complex.h +++ b/src/xpu-0.1.5/xpu/complex.h @@ -351,6 +351,19 @@ namespace xpu #endif } + void operator/= (const complex_d &v) + { + // #ifdef __SSE__ + // __m128d d = _mm_set1_pd(v); + // xmm = _mm_div_pd(xmm, d); + // #else + double a = re, b = im, c = v.re, d = v.im; + re = (a*c+b*d)/(c*c+d*d); + im = (b*c-a*d)/(c*c+d*d); + // #endif + } + + void operator>> (double *v) { #ifdef __SSE__ diff --git a/tests/circuits/bell_pair.qc b/tests/circuits/bell_pair.qc index dda8edbb..08284e62 100644 --- a/tests/circuits/bell_pair.qc +++ b/tests/circuits/bell_pair.qc @@ -1,9 +1,27 @@ +version 1.0 +# file : bell_pair.qc +# author : Nader Khammassi +# brief : EPR pair circuit - +# define 2 qubits qubits 2 -.epr - h q1 - cnot q0,q1 - display \ No newline at end of file + +.init + prep_z q[0] + prep_z q[1] + display + +.entangle + h q[0] + cnot q[0],q[1] + display # display the quantum state + +.measurement + measure q[0] + measure q[1] + display + +# to activate error injection, uncomment the following line (error rate = 1%) +# error_model depolarizing_channel,0.01 diff --git a/tests/circuits/benchmark.qc b/tests/circuits/benchmark.qc deleted file mode 100644 index c89068b1..00000000 --- a/tests/circuits/benchmark.qc +++ /dev/null @@ -1,29 +0,0 @@ -qubits 24 - -h q0 -cnot q0,q1 -cnot q0,q2 -cnot q0,q2 -cnot q0,q3 -cnot q0,q4 -cnot q0,q5 -cnot q0,q6 -cnot q0,q7 -cnot q0,q8 -cnot q0,q9 -cnot q0,q10 -cnot q0,q11 -cnot q0,q12 -cnot q0,q13 -cnot q0,q14 -cnot q0,q15 -cnot q0,q16 -cnot q0,q17 -cnot q0,q18 -cnot q0,q19 -cnot q0,q20 -cnot q0,q21 -cnot q0,q22 -cnot q0,q23 -measure - diff --git a/tests/circuits/bin_ctrl.qc b/tests/circuits/bin_ctrl.qc new file mode 100644 index 00000000..cc3561f9 --- /dev/null +++ b/tests/circuits/bin_ctrl.qc @@ -0,0 +1,31 @@ +version 1.0 + +# file : bin_ctrl.qc +# author : Nader Khammassi +# brief : binary-controlled gates test + + +qubits 4 + +.init + x q[0:1] + measure q[0:1] + display + +.bin_ctrl_x_b0_q0_x_b1_q1 + c-x b[0],q[0] + c-x b[1],q[1] + display + +.bin_ctrl_cnot_b0b1_q0_q2 + c-cnot b[0:1],q[0],q[2] + display + +.bin_ctrl_toffoli_b0b1_q0q1q2 + measure q[2] + c-toffoli b[0:1],q[0],q[1],q[2] + display + +.bin_ctrl_rx_b0_q0_pi + c-rx b[0],q[0],3.141592653589793 + display diff --git a/tests/circuits/entangle.qc b/tests/circuits/entangle.qc index ad274c73..85eeb144 100644 --- a/tests/circuits/entangle.qc +++ b/tests/circuits/entangle.qc @@ -1,42 +1,28 @@ +version 1.0 +# file : entangle.qc +# author : Nader Khammassi +# brief : basic 8 qubits entanglement circuit +qubits 8 -qubits 16 - - -.entangle(10) - h q0 - cnot q0,q1 - cnot q0,q2 - cnot q0,q3 - cnot q0,q4 - cnot q0,q5 - cnot q0,q6 - cnot q0,q7 - cnot q0,q8 - cnot q0,q9 - cnot q0,q10 - cnot q0,q11 - cnot q0,q12 - cnot q0,q13 - cnot q0,q14 - cnot q0,q15 - -# .measure - measure q0 - measure q1 - measure q2 - measure q3 - measure q4 - measure q5 - measure q6 - measure q7 - measure q8 - measure q9 - measure q10 - measure q11 - measure q12 - measure q13 - measure q14 - measure q15 - display_binary +.init + + prep_z q[0:7] + +.entangle + + h q[0] + cnot q[0],q[1] + cnot q[0],q[2] + cnot q[0],q[3] + cnot q[0],q[4] + cnot q[0],q[5] + cnot q[0],q[6] + cnot q[0],q[7] + display + +.measurement + + measure q[0:7] + display diff --git a/tests/circuits/epr.qc b/tests/circuits/epr.qc deleted file mode 100644 index d2ce1076..00000000 --- a/tests/circuits/epr.qc +++ /dev/null @@ -1,25 +0,0 @@ -# file : epr.qc -# author : Nader Khammassi -# brief : EPR pair circuit - -# define 2 qubits -qubits 2 - -display - -.init - prepz q0 - prepz q1 - -.entangle - h q0 - cnot q0,q1 - display # display the quantum state - -.measurement - measure q0 - measure q1 - display - -# to activate error injection, uncomment the following line -# error_model depolarizing_channel,0.1 diff --git a/tests/circuits/epr_test.qc b/tests/circuits/epr_test.qc deleted file mode 100644 index e8fc98ed..00000000 --- a/tests/circuits/epr_test.qc +++ /dev/null @@ -1,14 +0,0 @@ - - -qubits 2 - - -.bell - h q0 - cnot q0,q1 - display - -.measurement - measure q0 - measure q1 - display \ No newline at end of file diff --git a/tests/circuits/full_adder.qc b/tests/circuits/full_adder.qc index eddd7785..93904897 100644 --- a/tests/circuits/full_adder.qc +++ b/tests/circuits/full_adder.qc @@ -1,3 +1,5 @@ +version 1.0 + # file : full_adder.qc # author : Nader Khammassi # brief : quantum full adder (carry-save addition) @@ -6,16 +8,16 @@ qubits 4 # rename qubits -map q0,A -map q1,B -map q2,C -map q3,D +map q[0],b0 +map q[1],b1 +map q[2],b2 +map q[3],b3 # init inputs to some values .init - x A - x C + x b0 + x b2 display_binary # initial input value @@ -23,19 +25,19 @@ map q3,D # perform addition .add - toffoli B,C,D - cnot B,C - toffoli A,C,D - cnot A,C + toffoli b1,b2,b3 + cnot b1,b2 + toffoli b0,b2,b3 + cnot b0,b2 display_binary # result .reverse_add - cnot A,C - toffoli A,C,D - cnot B,C - toffoli B,C,D + cnot b0,b2 + toffoli b0,b2,b3 + cnot b1,b2 + toffoli b1,b2,b3 display_binary # result diff --git a/tests/circuits/grover_1_5q.qc b/tests/circuits/grover_1_5q.qc deleted file mode 100644 index ec8a76e1..00000000 --- a/tests/circuits/grover_1_5q.qc +++ /dev/null @@ -1,41 +0,0 @@ -qubits 5 - -.init - x q2 - h q0 - h q1 - h q2 - -# iterating 1 times -.grover(1) - - # oracle_1 - - x q1 - toffoli q0,q1,q3 - toffoli q1,q3,q4 - cnot q4,q2 - toffoli q1,q3,q4 - toffoli q0,q1,q3 - x q1 - h q0 - h q1 - - # inversion - - x q0 - x q1 - h q1 - toffoli q0,q1,q3 - cnot q3,q1 - toffoli q0,q1,q3 - h q1 - x q0 - x q1 - h q0 - h q1 - -.measure - h q2 - measure q2 - display diff --git a/tests/circuits/grover_3_11q.qc b/tests/circuits/grover_3_11q.qc deleted file mode 100644 index d487d5a1..00000000 --- a/tests/circuits/grover_3_11q.qc +++ /dev/null @@ -1,56 +0,0 @@ -# -# grover algorithm -# search number : 3 -# data : q2,q1,q0 - -qubits 7 - -.init - x q3 - h q0 - h q1 - h q2 - h q3 - -# iterating 2 times -.grover(2) - - # oracle_3 - - x q2 - toffoli q0,q1,q4 - toffoli q1,q4,q5 - toffoli q2,q5,q6 - cnot q6,q3 - toffoli q2,q5,q6 - toffoli q1,q4,q5 - toffoli q0,q1,q4 - x q2 - h q0 - h q1 - h q2 - - # inversion - - x q0 - x q1 - x q2 - h q2 - toffoli q0,q1,q2 - h q2 - x q0 - x q1 - x q2 - h q0 - h q1 - h q2 - display - -.measure - h q3 - measure q3 - display - measure - display - -# error_model depolarizing_channel, 0.01 \ No newline at end of file diff --git a/tests/circuits/grover_search.qc b/tests/circuits/grover_search.qc new file mode 100644 index 00000000..81cf4775 --- /dev/null +++ b/tests/circuits/grover_search.qc @@ -0,0 +1,51 @@ +version 1.0 + + +# file : grover_search.qc +# author : Nader Khammassi +# brief : search number |3> in 3 qubits search space. + +qubits 7 + +.init + + x q[3] + h q[0:3] + +# iterating 2 times +.grover(2) + + # oracle |x> ?= |3> + x q[2] + toffoli q[0],q[1],q[4] + toffoli q[1],q[4],q[5] + toffoli q[2],q[5],q[6] + cnot q[6],q[3] + toffoli q[2],q[5],q[6] + toffoli q[1],q[4],q[5] + toffoli q[0],q[1],q[4] + + x q[2] + h q[0:2] + + # inversion + x q[0:2] + h q[2] + toffoli q[0],q[1],q[2] + h q[2] + x q[0:2] + h q[0:2] + display + +.final_state + + h q[3] + x q[3] + display + +.mesurement + + measure q[0:2] # measure the solution + display + +# error_model depolarizing_channel, 0.01 diff --git a/tests/circuits/measure.qc b/tests/circuits/measure.qc new file mode 100644 index 00000000..6b72c6dd --- /dev/null +++ b/tests/circuits/measure.qc @@ -0,0 +1,39 @@ +version 1.0 + +# file : measure.qc +# author : Nader Khammassi +# brief : test measurement in different cases + + +qubits 2 + + +.ground + prep_z q[0,1] + measure q[0] + display + + +.exited_state + prep_z q[0,1] + x q[0] + measure q[0] + display_binary + + +.superposition_loop(1000) + prep_z q[0,1] + h q[1] + measure q[1] + + +.entangle_loop(100) + prep_z q[0,1] + h q[0] + cnot q[0],q[1] + measure q[0] + measure q[1] + +.entangle_result + display_binary + diff --git a/tests/circuits/measure_all.qc b/tests/circuits/measure_all.qc new file mode 100644 index 00000000..8d2a317d --- /dev/null +++ b/tests/circuits/measure_all.qc @@ -0,0 +1,18 @@ +version 1.0 + +# file : measure_all.qc +# author : Nader Khammassi +# brief : measure_all test + +qubits 4 + + .measurement(1000) + prep_z q[0,1,2,3] + x90 q[0] + h q[1] + x q[2] + measure_all + +.result + display + diff --git a/tests/circuits/measure_test.qc b/tests/circuits/measure_test.qc deleted file mode 100644 index bf572728..00000000 --- a/tests/circuits/measure_test.qc +++ /dev/null @@ -1,16 +0,0 @@ -qubits 17 - - -h q0 -h q1 -h q2 -h q3 -h q4 -h q5 -h q6 -h q7 -h q8 - -measure - -display_binary diff --git a/tests/circuits/prep_x.qc b/tests/circuits/prep_x.qc new file mode 100644 index 00000000..85428d06 --- /dev/null +++ b/tests/circuits/prep_x.qc @@ -0,0 +1,17 @@ +version 1.0 + +# file : prep_x.qc +# author : Nader Khammassi +# brief : 'prep_x' test + +# define 1 qubit +qubits 1 + +.prepare + prep_x q[0] + display + +.measurement + measure q[0] + display + diff --git a/tests/circuits/prep_y.qc b/tests/circuits/prep_y.qc new file mode 100644 index 00000000..bd9b2ba3 --- /dev/null +++ b/tests/circuits/prep_y.qc @@ -0,0 +1,18 @@ +version 1.0 + +# file : prep_y.qc +# author : Nader Khammassi +# brief : 'prep_y' test + +# define 1 qubit +qubits 1 + + +.prepare + prep_y q[0] + display + +.measurement + measure q[0] + display + diff --git a/tests/circuits/prep_z.qc b/tests/circuits/prep_z.qc new file mode 100644 index 00000000..a8f72e61 --- /dev/null +++ b/tests/circuits/prep_z.qc @@ -0,0 +1,18 @@ +version 1.0 + +# file : prep_z.qc +# author : Nader Khammassi +# brief : 'prep_z' test + +# define 1 qubit +qubits 1 + + +.prepare + prep_z q[0] + display + +.measurement + measure q[0] + display + diff --git a/tests/circuits/qasm/test1.qasm b/tests/circuits/qasm/test1.qasm deleted file mode 100644 index 0f8dc1d4..00000000 --- a/tests/circuits/qasm/test1.qasm +++ /dev/null @@ -1,12 +0,0 @@ -# -# File: test1.qasm -# Date: 22-Mar-04 -# Author: I. Chuang -# -# Sample qasm input file - EPR creation -# - qubit q0 - qubit q1 - - h q0 # create EPR pair - cnot q0,q1 diff --git a/tests/circuits/qasm/test10.qasm b/tests/circuits/qasm/test10.qasm deleted file mode 100644 index 4f788eb3..00000000 --- a/tests/circuits/qasm/test10.qasm +++ /dev/null @@ -1,16 +0,0 @@ -# -# File: test10.qasm -# Date: 22-Mar-04 -# Author: I. Chuang -# -# Sample qasm input file - multi-qubit gates -# also demonstrates use of classical bits - - qubit q0 - cbit c1 - qubit q2 - - h q0 - Utwo q0,c1 - S q2 - Utwo c1,q2 diff --git a/tests/circuits/qasm/test11.qasm b/tests/circuits/qasm/test11.qasm deleted file mode 100644 index e668be71..00000000 --- a/tests/circuits/qasm/test11.qasm +++ /dev/null @@ -1,20 +0,0 @@ -# -# File: test11.qasm -# Date: 22-Mar-04 -# Author: I. Chuang -# -# Sample qasm input file - user-defined -# multi-qubit ops - - defbox fx,2,0,'U_{f(x)}' - defbox fxy,3,0,'U_{f(x,y)}' - - qubit q0 - qubit q1 - qubit q2 - - h q0 - fx q0,q1 - h q1 - fxy q0,q1,q2 - diff --git a/tests/circuits/qasm/test12.qasm b/tests/circuits/qasm/test12.qasm deleted file mode 100644 index d9a6a7ca..00000000 --- a/tests/circuits/qasm/test12.qasm +++ /dev/null @@ -1,20 +0,0 @@ -# -# File: test12.qasm -# Date: 22-Mar-04 -# Author: I. Chuang -# -# Sample qasm input file - multi-qubit controlled -# multi-qubit operations - - defbox CU2,3,1,'U' - defbox CV2,3,1,'V' - - qubit q0 - qubit q1 - qubit q2 - - h q0 - CU2 q0,q1,q2 - h q0 - CV2 q2,q0,q1 - \ No newline at end of file diff --git a/tests/circuits/qasm/test13.qasm b/tests/circuits/qasm/test13.qasm deleted file mode 100644 index a8def423..00000000 --- a/tests/circuits/qasm/test13.qasm +++ /dev/null @@ -1,42 +0,0 @@ -# -# File: test13.qasm -# Date: 22-Mar-04 -# Author: I. Chuang -# -# Sample qasm input file - three-qubit phase -# estimation circuit with QFT and controlled-U - - defbox CU,3,1,'U' - defbox CU2,3,1,'U^2' - defbox CU4,3,1,'U^4' - def c-S,1,'S' - def c-T,1,'T' - - qubit j0,0 # QFT qubits - qubit j1,0 - qubit j2,0 - qubit s0 # U qubits - qubit s1 - - h j0 # equal superposition - h j1 - h j2 - - CU4 j0,s0,s1 # controlled-U - CU2 j1,s0,s1 - CU j2,s0,s1 - - h j0 # QFT - c-S j0,j1 - h j1 - nop j0 - c-T j0,j2 - c-S j1,j2 - h j2 - nop j0 - nop j0 - nop j1 - - measure j0 # final measurement - measure j1 - measure j2 diff --git a/tests/circuits/qasm/test14.qasm b/tests/circuits/qasm/test14.qasm deleted file mode 100644 index 889910c2..00000000 --- a/tests/circuits/qasm/test14.qasm +++ /dev/null @@ -1,49 +0,0 @@ -# -# File: test14.qasm -# Date: 22-Mar-04 -# Author: I. Chuang -# -# Sample qasm input file - three-qubit FT QEC -# circuit with syndrome measurement - - defbox synd,4,0,'\txt{Process\\Syndrome}' - defbox rop,7,4,'{\cal R}' - - qubit q0 # code data qubits - qubit q1 - qubit q2 - qubit s0,0 # syndrome measurement qubits - qubit s1,0 - cbit c0,0 # classical bits to store syndromes - cbit c1,0 - - h s0 # create EPR pair for FT meas - cnot s0,s1 - cnot q0,s0 # measure parity of q0,q1 - nop s1 # prevent cnot's from colliding - cnot q1,s1 - cnot s0,s1 # uncreate EPR - h s0 - measure s0 # measure syndrome qubits - nop s1 - measure s1 - cnot s0,c0 # copy to classical bits - nop s1 - cnot s1,c1 - space s0 - - zero s0 - zero s1 - h s0 # create EPR pair for FT meas - cnot s0,s1 - cnot q1,s0 # measure parity of q1,q2 - nop s1 # prevent cnot's from colliding - cnot q2,s1 - cnot s0,s1 # uncreate EPR - h s0 - measure s0 # measure syndrome qubits - nop s1 - measure s1 - - synd s0,s1,c0,c1 - rop s0,s1,c0,c1,q0,q1,q2 diff --git a/tests/circuits/qasm/test15.qasm b/tests/circuits/qasm/test15.qasm deleted file mode 100644 index 0d7ed35e..00000000 --- a/tests/circuits/qasm/test15.qasm +++ /dev/null @@ -1,17 +0,0 @@ -# -# File: test15.qasm -# Date: 24-Mar-04 -# Author: I. Chuang -# -# Sample qasm input file - "D-type" measurement -# requested by Nielsen - - def MeasZ,0,'\dmeterwide{HZ_\theta}{18pt}' - - qubit q0,\psi - qubit q1,+ - - nop q0 - ZZ q0,q1 - nop q0 - MeasZ q0 diff --git a/tests/circuits/qasm/test16.qasm b/tests/circuits/qasm/test16.qasm deleted file mode 100644 index 1aa78ddf..00000000 --- a/tests/circuits/qasm/test16.qasm +++ /dev/null @@ -1,22 +0,0 @@ -# -# File: test16.qasm -# Date: 24-Mar-04 -# Author: I. Chuang -# -# Sample qasm input file - example from Nielsen -# paper on cluster states - - qubit q0,\psi - qubit q1,\psi - qubit q2,\phi - qubit q3,0 - - nop q0 - nop q0 - slash q0 - nop q1 - ZZ q1,q2 - cnot q2,q3 - nop q2 - discard q2 - dmeter q3 diff --git a/tests/circuits/qasm/test17.qasm b/tests/circuits/qasm/test17.qasm deleted file mode 100644 index e1eefac7..00000000 --- a/tests/circuits/qasm/test17.qasm +++ /dev/null @@ -1,22 +0,0 @@ -# -# File: test17.qasm -# Date: 24-Mar-04 -# Author: I. Chuang -# -# Sample qasm input file - example from Nielsen -# paper on cluster states - - def MeasH,0,'\dmeter{H}' - - qubit q0,\psi - qubit q1,+ - qubit q2,+ - qubit q3,\phi - - nop q0 - nop q2 - ZZ q0,q1 - ZZ q2,q3 - ZZ q1,q2 - MeasH q1 - MeasH q2 diff --git a/tests/circuits/qasm/test18.qasm b/tests/circuits/qasm/test18.qasm deleted file mode 100644 index 04576ece..00000000 --- a/tests/circuits/qasm/test18.qasm +++ /dev/null @@ -1,20 +0,0 @@ -# -# File: test18.qasm -# Date: 25-Mar-04 -# Author: I. Chuang -# -# Sample qasm input file - multiple-control bullet op - - def MeasH,0,'\dmeter{H}' - def Z4,3,'bullet' # handled specially - - qubit q0,\psi - qubit q1,+ - qubit q2,+ - qubit q3,\phi - - nop q0 - nop q2 - Z4 q0,q1,q2,q3 - MeasH q1 - MeasH q2 diff --git a/tests/circuits/qasm/test2.qasm b/tests/circuits/qasm/test2.qasm deleted file mode 100644 index e50e380a..00000000 --- a/tests/circuits/qasm/test2.qasm +++ /dev/null @@ -1,20 +0,0 @@ -# -# File: test2.qasm -# Date: 22-Mar-04 -# Author: I. Chuang -# -# Sample qasm input file - simple teleportation circuit -# - qubit q0 - qubit q1 - qubit q2 - - h q1 # create EPR pair - cnot q1,q2 - cnot q0,q1 # Bell basis measurement - h q0 - nop q1 - measure q0 - measure q1 - c-z q1,q2 # correction step - c-x q0,q2 diff --git a/tests/circuits/qasm/test3.qasm b/tests/circuits/qasm/test3.qasm deleted file mode 100644 index 01c82477..00000000 --- a/tests/circuits/qasm/test3.qasm +++ /dev/null @@ -1,13 +0,0 @@ -# -# File: test3.qasm -# Date: 22-Mar-04 -# Author: I. Chuang -# -# Sample qasm input file - swap circuit -# - qubit q0 - qubit q1 - - cnot q0,q1 - cnot q1,q0 - cnot q0,q1 diff --git a/tests/circuits/qasm/test4.qasm b/tests/circuits/qasm/test4.qasm deleted file mode 100644 index c4dc61ef..00000000 --- a/tests/circuits/qasm/test4.qasm +++ /dev/null @@ -1,23 +0,0 @@ -# -# File: test4.qasm -# Date: 22-Mar-04 -# Author: I. Chuang -# -# Sample qasm input file - quantum -# fourier transform on three qubits - - def c-S,1,'S' - def c-T,1,'T' - - qubit j0 - qubit j1 - qubit j2 - - h j0 - c-S j1,j0 - c-T j2,j0 - nop j1 - h j1 - c-S j2,j1 - h j2 - swap j0,j2 diff --git a/tests/circuits/qasm/test5.qasm b/tests/circuits/qasm/test5.qasm deleted file mode 100644 index 0a1a7e51..00000000 --- a/tests/circuits/qasm/test5.qasm +++ /dev/null @@ -1,15 +0,0 @@ -# -# File: test5.qasm -# Date: 22-Mar-04 -# Author: I. Chuang -# -# Sample qasm input file - demonstrate arbitray qubit matrix ops - - def c-P,1,'\m{e^{i\alpha} & 0 \cr 0 & e^{-i\alpha}}' - def Ryt,0,'\m{\cos{\theta}&-\sin{\theta}\cr\sin{\theta}&\cos{\theta}}' - - qubit j0 - qubit j1 - - c-P j0,j1 - Ryt j0 \ No newline at end of file diff --git a/tests/circuits/qasm/test6.qasm b/tests/circuits/qasm/test6.qasm deleted file mode 100644 index 88d48c87..00000000 --- a/tests/circuits/qasm/test6.qasm +++ /dev/null @@ -1,20 +0,0 @@ -# -# File: test6.qasm -# Date: 22-Mar-04 -# Author: I. Chuang -# -# Sample qasm input file - demonstrate -# multiple-qubit controlled single-q-gates - - def c-U,3,'U' - - qubit j0 - qubit j1 - qubit j2 - qubit j3 - - toffoli j0,j1,j2 - X j0 - c-U j2,j3,j0,j1 - H j2 - measure j3 diff --git a/tests/circuits/qasm/test7.qasm b/tests/circuits/qasm/test7.qasm deleted file mode 100644 index ffc7227b..00000000 --- a/tests/circuits/qasm/test7.qasm +++ /dev/null @@ -1,21 +0,0 @@ -# -# File: test7.qasm -# Date: 22-Mar-04 -# Author: I. Chuang -# -# Sample qasm input file - measurement -# of operator with correction - - def c-U,1,'U' - def c-V,1,'V' - - qubit q0 - qubit q1 - - H q0 - c-U q0,q1 - H q0 - measure q0 - c-V q0,q1 - nop q0 - nop q1 diff --git a/tests/circuits/qasm/test8.qasm b/tests/circuits/qasm/test8.qasm deleted file mode 100644 index ba88ef68..00000000 --- a/tests/circuits/qasm/test8.qasm +++ /dev/null @@ -1,23 +0,0 @@ -# -# File: test8.qasm -# Date: 22-Mar-04 -# Author: I. Chuang -# -# Sample qasm input file - stage in -# simplification of quantum teleportation - - def c-Z,1,'Z' - - qubit q0,\psi - qubit q1,0 - qubit q2,0 - - H q1 - cnot q0,q1 - cnot q1,q2 - cnot q0,q1 - cnot q1,q2 - H q0 - c-Z q2,q0 - H q0 - H q0 diff --git a/tests/circuits/qasm/test9.qasm b/tests/circuits/qasm/test9.qasm deleted file mode 100644 index fc1486be..00000000 --- a/tests/circuits/qasm/test9.qasm +++ /dev/null @@ -1,20 +0,0 @@ -# -# File: test9.qasm -# Date: 22-Mar-04 -# Author: I. Chuang -# -# Sample qasm input file - two-qubit gate circuit -# implementation of Toffoli - - def c-X,1,'\sqrt{X}' - def c-Xd,1,'{\sqrt{X}}^\dagger' - - qubit q0 - qubit q1 - qubit q2 - - c-X q1,q2 - cnot q0,q1 - c-Xd q1,q2 - cnot q0,q1 - c-X q0,q2 diff --git a/tests/circuits/qec_3q_bit_flip_code.qc b/tests/circuits/qec_3q_bit_flip_code.qc index 9b9e3f2d..5ccb31d5 100644 --- a/tests/circuits/qec_3q_bit_flip_code.qc +++ b/tests/circuits/qec_3q_bit_flip_code.qc @@ -1,3 +1,4 @@ +version 1.0 # file : qec_3q_bit_flip_code.qc # author : Nader Khammassi @@ -9,48 +10,52 @@ qubits 5 # initialize logical qubit .init - x q0 + x q[0] display # encoding .encoding - cnot q0,q1 - cnot q0,q2 + cnot q[0],q[1] + cnot q[0],q[2] display_binary # error injection .error_injection - x q2 + x q[1] display # parity check .parity_check - cnot q0,q3 - cnot q1,q3 - cnot q0,q4 - cnot q2,q4 - measure q3 - measure q4 + cnot q[0],q[3] + cnot q[1],q[3] + cnot q[0],q[4] + cnot q[2],q[4] + measure q[3] + measure q[4] display_binary # error correction circuit can be described here .error_correction - # x q4 - # toffoli q3,q4,q1 - # x q4 - # not q4 - # c-x b3,b4,q1 - + # syn : 11 -> q[0] + c-x b[4,3],q[0] + # syn : 01 -> flip q[1] + not b[4] + c-x b[4,3],q[1] + not b[4] + # syn : 10 -> q[2] + not b[3] + c-x b[4,3],q[2] + not b[3] display # decoding .decoding - cnot q0,q2 - cnot q0,q1 + cnot q[0],q[2] + cnot q[0],q[1] # display display_binary -# error_model depolarizing_channel,0.1 \ No newline at end of file +# error_model depolarizing_channel,0.1 diff --git a/tests/circuits/qft_3q.qc b/tests/circuits/qft_3q.qc new file mode 100644 index 00000000..e1c39fab --- /dev/null +++ b/tests/circuits/qft_3q.qc @@ -0,0 +1,34 @@ +version 1.0 + +# file : qft_3q.qc +# author : Nader Khammassi +# brief : 3 qubits quantum fourrier transform (QFT) +# input state is |q2.q1.q0> = |100> + +qubits 3 + +# input = |100> +.input + x q[2] + display + +# qft circuit +.qft + + h q[0] + cr q[1],q[0],1.5707963 # cr2 + cr q[2],q[0],0.7853982 # cr4 + + h q[1] + cr q[2],q[1],1.5707963 # cr2 + + h q[2] + +# reverse qubit order +.reverse + swap q[0],q[2] + display + + + + diff --git a/tests/circuits/qft_3q_crk.qc b/tests/circuits/qft_3q_crk.qc new file mode 100644 index 00000000..51507f49 --- /dev/null +++ b/tests/circuits/qft_3q_crk.qc @@ -0,0 +1,32 @@ +version 1.0 + +# file : qft_3q_crk.qc +# author : Nader Khammassi +# brief : 3 qubits quantum fourrier transform (QFT) using +# the CRK notation +# input state is |q2.q1.q0> = |100> + +qubits 4 + +# input = |100> +.input + x q[2] + display + +# qft circuit +.qft + + h q[0] + crk q[1],q[0],2 + crk q[2],q[0],3 + + h q[1] + crk q[2],q[1],2 + + h q[2] + +# reverse qubit order +.reverse + swap q[0],q[2] + display + diff --git a/tests/circuits/qft_8q.qc b/tests/circuits/qft_8q.qc deleted file mode 100644 index 533bbf11..00000000 --- a/tests/circuits/qft_8q.qc +++ /dev/null @@ -1,67 +0,0 @@ - -# file : qft_8q.qc -# author : Nader Khammassi -# brief : 8 qubits quantum fourrier transform (QFT) - -# define 8 qubits -qubits 8 - -# init qubits to |0...01> (set your own input state here) -.init - x q0 - x q2 - x q4 - x q6 - display_binary # display the input binary state - -# main qft circuit -.qft - h q0 - cr q1,q0 - cr q2,q0 - cr q3,q0 - cr q4,q0 - cr q5,q0 - cr q6,q0 - cr q7,q0 - h q1 - cr q2,q1 - cr q3,q1 - cr q4,q1 - cr q5,q1 - cr q6,q1 - cr q7,q1 - h q2 - cr q3,q2 - cr q4,q2 - cr q5,q2 - cr q6,q2 - cr q7,q2 - h q3 - cr q4,q3 - cr q5,q3 - cr q6,q3 - cr q7,q3 - h q4 - cr q5,q4 - cr q6,q4 - cr q7,q4 - h q5 - cr q6,q5 - cr q7,q5 - h q6 - cr q7,q6 - h q7 - -# reverse qubit order -.reverse - swap q0,q7 - swap q1,q6 - swap q2,q5 - swap q3,q4 - -# display - - -# to activate error injection, uncomment the next line -# error_model depolarizing_channel,0.001 diff --git a/tests/circuits/rb.qc b/tests/circuits/rb.qc deleted file mode 100644 index fa00602d..00000000 --- a/tests/circuits/rb.qc +++ /dev/null @@ -1,40 +0,0 @@ - - -qubits 1 - - -# prepz q0 - -.rb(100) - prepz q0 - x q0 - h q0 - y q0 - x q0 - x q0 - y q0 - h q0 - x q0 - x q0 - h q0 - y q0 - x q0 - x q0 - y q0 - h q0 - x q0 - x q0 - h q0 - y q0 - x q0 - x q0 - y q0 - h q0 - x q0 - measure q0 - -.result - - display - -error_model depolarizing_channel,0.001 \ No newline at end of file diff --git a/tests/circuits/result_of_the_execution_of_transversal_cnot_on_00_logical_state.txt b/tests/circuits/result_of_the_execution_of_transversal_cnot_on_00_logical_state.txt deleted file mode 100644 index a0d17a4e..00000000 --- a/tests/circuits/result_of_the_execution_of_transversal_cnot_on_00_logical_state.txt +++ /dev/null @@ -1,573 +0,0 @@ - - =================================================================================================== - _______ - / ___ \ _ __ ____ ____ __ ___ __ __ __ ___ ______ ____ ___ - / / / | | |/_/ / __/ / _/ / |/ / / / / / / / / _ |/_ __/ / __ \ / _ \ - / /___/ / _> < _\ \ _/ / / /|_/ / / /_/ / / /__ / __ | / / / /_/ / / , _/ - \______/\__\ /_/|_| /___/ /___/ /_/ /_/ \____/ /____//_/ |_|/_/ \____/ /_/|_| - - version 0.1 beta - QuTech - 2016 - report bugs and suggestions to: nader.khammassi@gmail.com - =================================================================================================== - -[+] loading circuit from 'transversal_cnot_on_17q_ninja_star.qc' ... -[-] loading quantum_code file 'transversal_cnot_on_17q_ninja_star.qc'... -[+] code loaded successfully. -[+] initializing xpu... -[+] initialized. -[+] creating quantum register of 26 qubits... -[+] executing circuit 'initializing_first_qubit_to_logical_0_state' ... -[+] circuit execution time: 66.194 sec. -[+] executing circuit 'start_surface_code_cycle' ... -[+] circuit execution time: 40.7373 sec. -[+] executing circuit 'round_1' ... -[+] circuit execution time: 1.18398 sec. -[+] executing circuit 'round_2' ... -[+] circuit execution time: 1.23667 sec. -[+] executing circuit 'round_3' ... -[+] circuit execution time: 1.16636 sec. -[+] executing circuit 'round_4' ... -[+] circuit execution time: 1.12539 sec. -[+] executing circuit 'syndromes_measurements' ... -[>>] binary register: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | X | X | X | X | X | X | X | X | X | -------------------------------------------- -[+] circuit execution time: 27.7549 sec. -[+] executing circuit 'initialize_second_qubit_to_logical_0_state' ... -[+] circuit execution time: 66.8046 sec. -[+] executing circuit 'start_surface_code_cycle' ... -[+] circuit execution time: 39.9722 sec. -[+] executing circuit 'round_1' ... -[+] circuit execution time: 1.05816 sec. -[+] executing circuit 'round_2' ... -[+] circuit execution time: 1.01459 sec. -[+] executing circuit 'round_3' ... -[+] circuit execution time: 1.04055 sec. -[+] executing circuit 'round_4' ... -[+] circuit execution time: 1.01965 sec. -[+] executing circuit 'measurements' ... -[>>] binary register: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | -------------------------------------------- -[+] circuit execution time: 24.4562 sec. -[+] executing circuit 'state_before_the_transversal_cnot' ... ---------------[quantum state]-------------- - (0.062500,0.000000) |00000000000000000000000000> + - (0.062500,0.000000) |00000000000000000000000110> + - (0.062500,0.000000) |00000000000000000000011011> + - (0.062500,0.000000) |00000000000000000000011101> + - (0.062500,0.000000) |00000000000000000011000000> + - (0.062500,0.000000) |00000000000000000011000110> + - (0.062500,0.000000) |00000000000000000011011011> + - (0.062500,0.000000) |00000000000000000011011101> + - (0.062500,0.000000) |00000000000000000101101011> + - (0.062500,0.000000) |00000000000000000101101101> + - (0.062500,0.000000) |00000000000000000101110000> + - (0.062500,0.000000) |00000000000000000101110110> + - (0.062500,0.000000) |00000000000000000110101011> + - (0.062500,0.000000) |00000000000000000110101101> + - (0.062500,0.000000) |00000000000000000110110000> + - (0.062500,0.000000) |00000000000000000110110110> + - (0.062500,0.000000) |00000000000000110000000000> + - (0.062500,0.000000) |00000000000000110000000110> + - (0.062500,0.000000) |00000000000000110000011011> + - (0.062500,0.000000) |00000000000000110000011101> + - (0.062500,0.000000) |00000000000000110011000000> + - (0.062500,0.000000) |00000000000000110011000110> + - (0.062500,0.000000) |00000000000000110011011011> + - (0.062500,0.000000) |00000000000000110011011101> + - (0.062500,0.000000) |00000000000000110101101011> + - (0.062500,0.000000) |00000000000000110101101101> + - (0.062500,0.000000) |00000000000000110101110000> + - (0.062500,0.000000) |00000000000000110101110110> + - (0.062500,0.000000) |00000000000000110110101011> + - (0.062500,0.000000) |00000000000000110110101101> + - (0.062500,0.000000) |00000000000000110110110000> + - (0.062500,0.000000) |00000000000000110110110110> + - (0.062500,0.000000) |00000000000011011000000000> + - (0.062500,0.000000) |00000000000011011000000110> + - (0.062500,0.000000) |00000000000011011000011011> + - (0.062500,0.000000) |00000000000011011000011101> + - (0.062500,0.000000) |00000000000011011011000000> + - (0.062500,0.000000) |00000000000011011011000110> + - (0.062500,0.000000) |00000000000011011011011011> + - (0.062500,0.000000) |00000000000011011011011101> + - (0.062500,0.000000) |00000000000011011101101011> + - (0.062500,0.000000) |00000000000011011101101101> + - (0.062500,0.000000) |00000000000011011101110000> + - (0.062500,0.000000) |00000000000011011101110110> + - (0.062500,0.000000) |00000000000011011110101011> + - (0.062500,0.000000) |00000000000011011110101101> + - (0.062500,0.000000) |00000000000011011110110000> + - (0.062500,0.000000) |00000000000011011110110110> + - (0.062500,0.000000) |00000000000011101000000000> + - (0.062500,0.000000) |00000000000011101000000110> + - (0.062500,0.000000) |00000000000011101000011011> + - (0.062500,0.000000) |00000000000011101000011101> + - (0.062500,0.000000) |00000000000011101011000000> + - (0.062500,0.000000) |00000000000011101011000110> + - (0.062500,0.000000) |00000000000011101011011011> + - (0.062500,0.000000) |00000000000011101011011101> + - (0.062500,0.000000) |00000000000011101101101011> + - (0.062500,0.000000) |00000000000011101101101101> + - (0.062500,0.000000) |00000000000011101101110000> + - (0.062500,0.000000) |00000000000011101101110110> + - (0.062500,0.000000) |00000000000011101110101011> + - (0.062500,0.000000) |00000000000011101110101101> + - (0.062500,0.000000) |00000000000011101110110000> + - (0.062500,0.000000) |00000000000011101110110110> + - (0.062500,0.000000) |00000000011000000000000000> + - (0.062500,0.000000) |00000000011000000000000110> + - (0.062500,0.000000) |00000000011000000000011011> + - (0.062500,0.000000) |00000000011000000000011101> + - (0.062500,0.000000) |00000000011000000011000000> + - (0.062500,0.000000) |00000000011000000011000110> + - (0.062500,0.000000) |00000000011000000011011011> + - (0.062500,0.000000) |00000000011000000011011101> + - (0.062500,0.000000) |00000000011000000101101011> + - (0.062500,0.000000) |00000000011000000101101101> + - (0.062500,0.000000) |00000000011000000101110000> + - (0.062500,0.000000) |00000000011000000101110110> + - (0.062500,0.000000) |00000000011000000110101011> + - (0.062500,0.000000) |00000000011000000110101101> + - (0.062500,0.000000) |00000000011000000110110000> + - (0.062500,0.000000) |00000000011000000110110110> + - (0.062500,0.000000) |00000000011000110000000000> + - (0.062500,0.000000) |00000000011000110000000110> + - (0.062500,0.000000) |00000000011000110000011011> + - (0.062500,0.000000) |00000000011000110000011101> + - (0.062500,0.000000) |00000000011000110011000000> + - (0.062500,0.000000) |00000000011000110011000110> + - (0.062500,0.000000) |00000000011000110011011011> + - (0.062500,0.000000) |00000000011000110011011101> + - (0.062500,0.000000) |00000000011000110101101011> + - (0.062500,0.000000) |00000000011000110101101101> + - (0.062500,0.000000) |00000000011000110101110000> + - (0.062500,0.000000) |00000000011000110101110110> + - (0.062500,0.000000) |00000000011000110110101011> + - (0.062500,0.000000) |00000000011000110110101101> + - (0.062500,0.000000) |00000000011000110110110000> + - (0.062500,0.000000) |00000000011000110110110110> + - (0.062500,0.000000) |00000000011011011000000000> + - (0.062500,0.000000) |00000000011011011000000110> + - (0.062500,0.000000) |00000000011011011000011011> + - (0.062500,0.000000) |00000000011011011000011101> + - (0.062500,0.000000) |00000000011011011011000000> + - (0.062500,0.000000) |00000000011011011011000110> + - (0.062500,0.000000) |00000000011011011011011011> + - (0.062500,0.000000) |00000000011011011011011101> + - (0.062500,0.000000) |00000000011011011101101011> + - (0.062500,0.000000) |00000000011011011101101101> + - (0.062500,0.000000) |00000000011011011101110000> + - (0.062500,0.000000) |00000000011011011101110110> + - (0.062500,0.000000) |00000000011011011110101011> + - (0.062500,0.000000) |00000000011011011110101101> + - (0.062500,0.000000) |00000000011011011110110000> + - (0.062500,0.000000) |00000000011011011110110110> + - (0.062500,0.000000) |00000000011011101000000000> + - (0.062500,0.000000) |00000000011011101000000110> + - (0.062500,0.000000) |00000000011011101000011011> + - (0.062500,0.000000) |00000000011011101000011101> + - (0.062500,0.000000) |00000000011011101011000000> + - (0.062500,0.000000) |00000000011011101011000110> + - (0.062500,0.000000) |00000000011011101011011011> + - (0.062500,0.000000) |00000000011011101011011101> + - (0.062500,0.000000) |00000000011011101101101011> + - (0.062500,0.000000) |00000000011011101101101101> + - (0.062500,0.000000) |00000000011011101101110000> + - (0.062500,0.000000) |00000000011011101101110110> + - (0.062500,0.000000) |00000000011011101110101011> + - (0.062500,0.000000) |00000000011011101110101101> + - (0.062500,0.000000) |00000000011011101110110000> + - (0.062500,0.000000) |00000000011011101110110110> + - (0.062500,0.000000) |00000000101101011000000000> + - (0.062500,0.000000) |00000000101101011000000110> + - (0.062500,0.000000) |00000000101101011000011011> + - (0.062500,0.000000) |00000000101101011000011101> + - (0.062500,0.000000) |00000000101101011011000000> + - (0.062500,0.000000) |00000000101101011011000110> + - (0.062500,0.000000) |00000000101101011011011011> + - (0.062500,0.000000) |00000000101101011011011101> + - (0.062500,0.000000) |00000000101101011101101011> + - (0.062500,0.000000) |00000000101101011101101101> + - (0.062500,0.000000) |00000000101101011101110000> + - (0.062500,0.000000) |00000000101101011101110110> + - (0.062500,0.000000) |00000000101101011110101011> + - (0.062500,0.000000) |00000000101101011110101101> + - (0.062500,0.000000) |00000000101101011110110000> + - (0.062500,0.000000) |00000000101101011110110110> + - (0.062500,0.000000) |00000000101101101000000000> + - (0.062500,0.000000) |00000000101101101000000110> + - (0.062500,0.000000) |00000000101101101000011011> + - (0.062500,0.000000) |00000000101101101000011101> + - (0.062500,0.000000) |00000000101101101011000000> + - (0.062500,0.000000) |00000000101101101011000110> + - (0.062500,0.000000) |00000000101101101011011011> + - (0.062500,0.000000) |00000000101101101011011101> + - (0.062500,0.000000) |00000000101101101101101011> + - (0.062500,0.000000) |00000000101101101101101101> + - (0.062500,0.000000) |00000000101101101101110000> + - (0.062500,0.000000) |00000000101101101101110110> + - (0.062500,0.000000) |00000000101101101110101011> + - (0.062500,0.000000) |00000000101101101110101101> + - (0.062500,0.000000) |00000000101101101110110000> + - (0.062500,0.000000) |00000000101101101110110110> + - (0.062500,0.000000) |00000000101110000000000000> + - (0.062500,0.000000) |00000000101110000000000110> + - (0.062500,0.000000) |00000000101110000000011011> + - (0.062500,0.000000) |00000000101110000000011101> + - (0.062500,0.000000) |00000000101110000011000000> + - (0.062500,0.000000) |00000000101110000011000110> + - (0.062500,0.000000) |00000000101110000011011011> + - (0.062500,0.000000) |00000000101110000011011101> + - (0.062500,0.000000) |00000000101110000101101011> + - (0.062500,0.000000) |00000000101110000101101101> + - (0.062500,0.000000) |00000000101110000101110000> + - (0.062500,0.000000) |00000000101110000101110110> + - (0.062500,0.000000) |00000000101110000110101011> + - (0.062500,0.000000) |00000000101110000110101101> + - (0.062500,0.000000) |00000000101110000110110000> + - (0.062500,0.000000) |00000000101110000110110110> + - (0.062500,0.000000) |00000000101110110000000000> + - (0.062500,0.000000) |00000000101110110000000110> + - (0.062500,0.000000) |00000000101110110000011011> + - (0.062500,0.000000) |00000000101110110000011101> + - (0.062500,0.000000) |00000000101110110011000000> + - (0.062500,0.000000) |00000000101110110011000110> + - (0.062500,0.000000) |00000000101110110011011011> + - (0.062500,0.000000) |00000000101110110011011101> + - (0.062500,0.000000) |00000000101110110101101011> + - (0.062500,0.000000) |00000000101110110101101101> + - (0.062500,0.000000) |00000000101110110101110000> + - (0.062500,0.000000) |00000000101110110101110110> + - (0.062500,0.000000) |00000000101110110110101011> + - (0.062500,0.000000) |00000000101110110110101101> + - (0.062500,0.000000) |00000000101110110110110000> + - (0.062500,0.000000) |00000000101110110110110110> + - (0.062500,0.000000) |00000000110101011000000000> + - (0.062500,0.000000) |00000000110101011000000110> + - (0.062500,0.000000) |00000000110101011000011011> + - (0.062500,0.000000) |00000000110101011000011101> + - (0.062500,0.000000) |00000000110101011011000000> + - (0.062500,0.000000) |00000000110101011011000110> + - (0.062500,0.000000) |00000000110101011011011011> + - (0.062500,0.000000) |00000000110101011011011101> + - (0.062500,0.000000) |00000000110101011101101011> + - (0.062500,0.000000) |00000000110101011101101101> + - (0.062500,0.000000) |00000000110101011101110000> + - (0.062500,0.000000) |00000000110101011101110110> + - (0.062500,0.000000) |00000000110101011110101011> + - (0.062500,0.000000) |00000000110101011110101101> + - (0.062500,0.000000) |00000000110101011110110000> + - (0.062500,0.000000) |00000000110101011110110110> + - (0.062500,0.000000) |00000000110101101000000000> + - (0.062500,0.000000) |00000000110101101000000110> + - (0.062500,0.000000) |00000000110101101000011011> + - (0.062500,0.000000) |00000000110101101000011101> + - (0.062500,0.000000) |00000000110101101011000000> + - (0.062500,0.000000) |00000000110101101011000110> + - (0.062500,0.000000) |00000000110101101011011011> + - (0.062500,0.000000) |00000000110101101011011101> + - (0.062500,0.000000) |00000000110101101101101011> + - (0.062500,0.000000) |00000000110101101101101101> + - (0.062500,0.000000) |00000000110101101101110000> + - (0.062500,0.000000) |00000000110101101101110110> + - (0.062500,0.000000) |00000000110101101110101011> + - (0.062500,0.000000) |00000000110101101110101101> + - (0.062500,0.000000) |00000000110101101110110000> + - (0.062500,0.000000) |00000000110101101110110110> + - (0.062500,0.000000) |00000000110110000000000000> + - (0.062500,0.000000) |00000000110110000000000110> + - (0.062500,0.000000) |00000000110110000000011011> + - (0.062500,0.000000) |00000000110110000000011101> + - (0.062500,0.000000) |00000000110110000011000000> + - (0.062500,0.000000) |00000000110110000011000110> + - (0.062500,0.000000) |00000000110110000011011011> + - (0.062500,0.000000) |00000000110110000011011101> + - (0.062500,0.000000) |00000000110110000101101011> + - (0.062500,0.000000) |00000000110110000101101101> + - (0.062500,0.000000) |00000000110110000101110000> + - (0.062500,0.000000) |00000000110110000101110110> + - (0.062500,0.000000) |00000000110110000110101011> + - (0.062500,0.000000) |00000000110110000110101101> + - (0.062500,0.000000) |00000000110110000110110000> + - (0.062500,0.000000) |00000000110110000110110110> + - (0.062500,0.000000) |00000000110110110000000000> + - (0.062500,0.000000) |00000000110110110000000110> + - (0.062500,0.000000) |00000000110110110000011011> + - (0.062500,0.000000) |00000000110110110000011101> + - (0.062500,0.000000) |00000000110110110011000000> + - (0.062500,0.000000) |00000000110110110011000110> + - (0.062500,0.000000) |00000000110110110011011011> + - (0.062500,0.000000) |00000000110110110011011101> + - (0.062500,0.000000) |00000000110110110101101011> + - (0.062500,0.000000) |00000000110110110101101101> + - (0.062500,0.000000) |00000000110110110101110000> + - (0.062500,0.000000) |00000000110110110101110110> + - (0.062500,0.000000) |00000000110110110110101011> + - (0.062500,0.000000) |00000000110110110110101101> + - (0.062500,0.000000) |00000000110110110110110000> + - (0.062500,0.000000) |00000000110110110110110110> + -[>>] binary register: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | -------------------------------------------- -[+] circuit execution time: 0.123051 sec. -[+] executing circuit 'transversal_cnot' ... -[+] circuit execution time: 1.987782 sec. -[+] executing circuit 'state_after_the_transversal_cnot' ... ---------------[quantum state]-------------- - (0.062500,0.000000) |00000000000000000000000000> + - (0.062500,0.000000) |00000000000000000000000110> + - (0.062500,0.000000) |00000000000000000000011011> + - (0.062500,0.000000) |00000000000000000000011101> + - (0.062500,0.000000) |00000000000000000011000000> + - (0.062500,0.000000) |00000000000000000011000110> + - (0.062500,0.000000) |00000000000000000011011011> + - (0.062500,0.000000) |00000000000000000011011101> + - (0.062500,0.000000) |00000000000000000101101011> + - (0.062500,0.000000) |00000000000000000101101101> + - (0.062500,0.000000) |00000000000000000101110000> + - (0.062500,0.000000) |00000000000000000101110110> + - (0.062500,0.000000) |00000000000000000110101011> + - (0.062500,0.000000) |00000000000000000110101101> + - (0.062500,0.000000) |00000000000000000110110000> + - (0.062500,0.000000) |00000000000000000110110110> + - (0.062500,0.000000) |00000000000000110000000000> + - (0.062500,0.000000) |00000000000000110000000110> + - (0.062500,0.000000) |00000000000000110000011011> + - (0.062500,0.000000) |00000000000000110000011101> + - (0.062500,0.000000) |00000000000000110011000000> + - (0.062500,0.000000) |00000000000000110011000110> + - (0.062500,0.000000) |00000000000000110011011011> + - (0.062500,0.000000) |00000000000000110011011101> + - (0.062500,0.000000) |00000000000000110101101011> + - (0.062500,0.000000) |00000000000000110101101101> + - (0.062500,0.000000) |00000000000000110101110000> + - (0.062500,0.000000) |00000000000000110101110110> + - (0.062500,0.000000) |00000000000000110110101011> + - (0.062500,0.000000) |00000000000000110110101101> + - (0.062500,0.000000) |00000000000000110110110000> + - (0.062500,0.000000) |00000000000000110110110110> + - (0.062500,0.000000) |00000000000011011000000000> + - (0.062500,0.000000) |00000000000011011000000110> + - (0.062500,0.000000) |00000000000011011000011011> + - (0.062500,0.000000) |00000000000011011000011101> + - (0.062500,0.000000) |00000000000011011011000000> + - (0.062500,0.000000) |00000000000011011011000110> + - (0.062500,0.000000) |00000000000011011011011011> + - (0.062500,0.000000) |00000000000011011011011101> + - (0.062500,0.000000) |00000000000011011101101011> + - (0.062500,0.000000) |00000000000011011101101101> + - (0.062500,0.000000) |00000000000011011101110000> + - (0.062500,0.000000) |00000000000011011101110110> + - (0.062500,0.000000) |00000000000011011110101011> + - (0.062500,0.000000) |00000000000011011110101101> + - (0.062500,0.000000) |00000000000011011110110000> + - (0.062500,0.000000) |00000000000011011110110110> + - (0.062500,0.000000) |00000000000011101000000000> + - (0.062500,0.000000) |00000000000011101000000110> + - (0.062500,0.000000) |00000000000011101000011011> + - (0.062500,0.000000) |00000000000011101000011101> + - (0.062500,0.000000) |00000000000011101011000000> + - (0.062500,0.000000) |00000000000011101011000110> + - (0.062500,0.000000) |00000000000011101011011011> + - (0.062500,0.000000) |00000000000011101011011101> + - (0.062500,0.000000) |00000000000011101101101011> + - (0.062500,0.000000) |00000000000011101101101101> + - (0.062500,0.000000) |00000000000011101101110000> + - (0.062500,0.000000) |00000000000011101101110110> + - (0.062500,0.000000) |00000000000011101110101011> + - (0.062500,0.000000) |00000000000011101110101101> + - (0.062500,0.000000) |00000000000011101110110000> + - (0.062500,0.000000) |00000000000011101110110110> + - (0.062500,0.000000) |00000000011000000000000000> + - (0.062500,0.000000) |00000000011000000000000110> + - (0.062500,0.000000) |00000000011000000000011011> + - (0.062500,0.000000) |00000000011000000000011101> + - (0.062500,0.000000) |00000000011000000011000000> + - (0.062500,0.000000) |00000000011000000011000110> + - (0.062500,0.000000) |00000000011000000011011011> + - (0.062500,0.000000) |00000000011000000011011101> + - (0.062500,0.000000) |00000000011000000101101011> + - (0.062500,0.000000) |00000000011000000101101101> + - (0.062500,0.000000) |00000000011000000101110000> + - (0.062500,0.000000) |00000000011000000101110110> + - (0.062500,0.000000) |00000000011000000110101011> + - (0.062500,0.000000) |00000000011000000110101101> + - (0.062500,0.000000) |00000000011000000110110000> + - (0.062500,0.000000) |00000000011000000110110110> + - (0.062500,0.000000) |00000000011000110000000000> + - (0.062500,0.000000) |00000000011000110000000110> + - (0.062500,0.000000) |00000000011000110000011011> + - (0.062500,0.000000) |00000000011000110000011101> + - (0.062500,0.000000) |00000000011000110011000000> + - (0.062500,0.000000) |00000000011000110011000110> + - (0.062500,0.000000) |00000000011000110011011011> + - (0.062500,0.000000) |00000000011000110011011101> + - (0.062500,0.000000) |00000000011000110101101011> + - (0.062500,0.000000) |00000000011000110101101101> + - (0.062500,0.000000) |00000000011000110101110000> + - (0.062500,0.000000) |00000000011000110101110110> + - (0.062500,0.000000) |00000000011000110110101011> + - (0.062500,0.000000) |00000000011000110110101101> + - (0.062500,0.000000) |00000000011000110110110000> + - (0.062500,0.000000) |00000000011000110110110110> + - (0.062500,0.000000) |00000000011011011000000000> + - (0.062500,0.000000) |00000000011011011000000110> + - (0.062500,0.000000) |00000000011011011000011011> + - (0.062500,0.000000) |00000000011011011000011101> + - (0.062500,0.000000) |00000000011011011011000000> + - (0.062500,0.000000) |00000000011011011011000110> + - (0.062500,0.000000) |00000000011011011011011011> + - (0.062500,0.000000) |00000000011011011011011101> + - (0.062500,0.000000) |00000000011011011101101011> + - (0.062500,0.000000) |00000000011011011101101101> + - (0.062500,0.000000) |00000000011011011101110000> + - (0.062500,0.000000) |00000000011011011101110110> + - (0.062500,0.000000) |00000000011011011110101011> + - (0.062500,0.000000) |00000000011011011110101101> + - (0.062500,0.000000) |00000000011011011110110000> + - (0.062500,0.000000) |00000000011011011110110110> + - (0.062500,0.000000) |00000000011011101000000000> + - (0.062500,0.000000) |00000000011011101000000110> + - (0.062500,0.000000) |00000000011011101000011011> + - (0.062500,0.000000) |00000000011011101000011101> + - (0.062500,0.000000) |00000000011011101011000000> + - (0.062500,0.000000) |00000000011011101011000110> + - (0.062500,0.000000) |00000000011011101011011011> + - (0.062500,0.000000) |00000000011011101011011101> + - (0.062500,0.000000) |00000000011011101101101011> + - (0.062500,0.000000) |00000000011011101101101101> + - (0.062500,0.000000) |00000000011011101101110000> + - (0.062500,0.000000) |00000000011011101101110110> + - (0.062500,0.000000) |00000000011011101110101011> + - (0.062500,0.000000) |00000000011011101110101101> + - (0.062500,0.000000) |00000000011011101110110000> + - (0.062500,0.000000) |00000000011011101110110110> + - (0.062500,0.000000) |00000000101101011000000000> + - (0.062500,0.000000) |00000000101101011000000110> + - (0.062500,0.000000) |00000000101101011000011011> + - (0.062500,0.000000) |00000000101101011000011101> + - (0.062500,0.000000) |00000000101101011011000000> + - (0.062500,0.000000) |00000000101101011011000110> + - (0.062500,0.000000) |00000000101101011011011011> + - (0.062500,0.000000) |00000000101101011011011101> + - (0.062500,0.000000) |00000000101101011101101011> + - (0.062500,0.000000) |00000000101101011101101101> + - (0.062500,0.000000) |00000000101101011101110000> + - (0.062500,0.000000) |00000000101101011101110110> + - (0.062500,0.000000) |00000000101101011110101011> + - (0.062500,0.000000) |00000000101101011110101101> + - (0.062500,0.000000) |00000000101101011110110000> + - (0.062500,0.000000) |00000000101101011110110110> + - (0.062500,0.000000) |00000000101101101000000000> + - (0.062500,0.000000) |00000000101101101000000110> + - (0.062500,0.000000) |00000000101101101000011011> + - (0.062500,0.000000) |00000000101101101000011101> + - (0.062500,0.000000) |00000000101101101011000000> + - (0.062500,0.000000) |00000000101101101011000110> + - (0.062500,0.000000) |00000000101101101011011011> + - (0.062500,0.000000) |00000000101101101011011101> + - (0.062500,0.000000) |00000000101101101101101011> + - (0.062500,0.000000) |00000000101101101101101101> + - (0.062500,0.000000) |00000000101101101101110000> + - (0.062500,0.000000) |00000000101101101101110110> + - (0.062500,0.000000) |00000000101101101110101011> + - (0.062500,0.000000) |00000000101101101110101101> + - (0.062500,0.000000) |00000000101101101110110000> + - (0.062500,0.000000) |00000000101101101110110110> + - (0.062500,0.000000) |00000000101110000000000000> + - (0.062500,0.000000) |00000000101110000000000110> + - (0.062500,0.000000) |00000000101110000000011011> + - (0.062500,0.000000) |00000000101110000000011101> + - (0.062500,0.000000) |00000000101110000011000000> + - (0.062500,0.000000) |00000000101110000011000110> + - (0.062500,0.000000) |00000000101110000011011011> + - (0.062500,0.000000) |00000000101110000011011101> + - (0.062500,0.000000) |00000000101110000101101011> + - (0.062500,0.000000) |00000000101110000101101101> + - (0.062500,0.000000) |00000000101110000101110000> + - (0.062500,0.000000) |00000000101110000101110110> + - (0.062500,0.000000) |00000000101110000110101011> + - (0.062500,0.000000) |00000000101110000110101101> + - (0.062500,0.000000) |00000000101110000110110000> + - (0.062500,0.000000) |00000000101110000110110110> + - (0.062500,0.000000) |00000000101110110000000000> + - (0.062500,0.000000) |00000000101110110000000110> + - (0.062500,0.000000) |00000000101110110000011011> + - (0.062500,0.000000) |00000000101110110000011101> + - (0.062500,0.000000) |00000000101110110011000000> + - (0.062500,0.000000) |00000000101110110011000110> + - (0.062500,0.000000) |00000000101110110011011011> + - (0.062500,0.000000) |00000000101110110011011101> + - (0.062500,0.000000) |00000000101110110101101011> + - (0.062500,0.000000) |00000000101110110101101101> + - (0.062500,0.000000) |00000000101110110101110000> + - (0.062500,0.000000) |00000000101110110101110110> + - (0.062500,0.000000) |00000000101110110110101011> + - (0.062500,0.000000) |00000000101110110110101101> + - (0.062500,0.000000) |00000000101110110110110000> + - (0.062500,0.000000) |00000000101110110110110110> + - (0.062500,0.000000) |00000000110101011000000000> + - (0.062500,0.000000) |00000000110101011000000110> + - (0.062500,0.000000) |00000000110101011000011011> + - (0.062500,0.000000) |00000000110101011000011101> + - (0.062500,0.000000) |00000000110101011011000000> + - (0.062500,0.000000) |00000000110101011011000110> + - (0.062500,0.000000) |00000000110101011011011011> + - (0.062500,0.000000) |00000000110101011011011101> + - (0.062500,0.000000) |00000000110101011101101011> + - (0.062500,0.000000) |00000000110101011101101101> + - (0.062500,0.000000) |00000000110101011101110000> + - (0.062500,0.000000) |00000000110101011101110110> + - (0.062500,0.000000) |00000000110101011110101011> + - (0.062500,0.000000) |00000000110101011110101101> + - (0.062500,0.000000) |00000000110101011110110000> + - (0.062500,0.000000) |00000000110101011110110110> + - (0.062500,0.000000) |00000000110101101000000000> + - (0.062500,0.000000) |00000000110101101000000110> + - (0.062500,0.000000) |00000000110101101000011011> + - (0.062500,0.000000) |00000000110101101000011101> + - (0.062500,0.000000) |00000000110101101011000000> + - (0.062500,0.000000) |00000000110101101011000110> + - (0.062500,0.000000) |00000000110101101011011011> + - (0.062500,0.000000) |00000000110101101011011101> + - (0.062500,0.000000) |00000000110101101101101011> + - (0.062500,0.000000) |00000000110101101101101101> + - (0.062500,0.000000) |00000000110101101101110000> + - (0.062500,0.000000) |00000000110101101101110110> + - (0.062500,0.000000) |00000000110101101110101011> + - (0.062500,0.000000) |00000000110101101110101101> + - (0.062500,0.000000) |00000000110101101110110000> + - (0.062500,0.000000) |00000000110101101110110110> + - (0.062500,0.000000) |00000000110110000000000000> + - (0.062500,0.000000) |00000000110110000000000110> + - (0.062500,0.000000) |00000000110110000000011011> + - (0.062500,0.000000) |00000000110110000000011101> + - (0.062500,0.000000) |00000000110110000011000000> + - (0.062500,0.000000) |00000000110110000011000110> + - (0.062500,0.000000) |00000000110110000011011011> + - (0.062500,0.000000) |00000000110110000011011101> + - (0.062500,0.000000) |00000000110110000101101011> + - (0.062500,0.000000) |00000000110110000101101101> + - (0.062500,0.000000) |00000000110110000101110000> + - (0.062500,0.000000) |00000000110110000101110110> + - (0.062500,0.000000) |00000000110110000110101011> + - (0.062500,0.000000) |00000000110110000110101101> + - (0.062500,0.000000) |00000000110110000110110000> + - (0.062500,0.000000) |00000000110110000110110110> + - (0.062500,0.000000) |00000000110110110000000000> + - (0.062500,0.000000) |00000000110110110000000110> + - (0.062500,0.000000) |00000000110110110000011011> + - (0.062500,0.000000) |00000000110110110000011101> + - (0.062500,0.000000) |00000000110110110011000000> + - (0.062500,0.000000) |00000000110110110011000110> + - (0.062500,0.000000) |00000000110110110011011011> + - (0.062500,0.000000) |00000000110110110011011101> + - (0.062500,0.000000) |00000000110110110101101011> + - (0.062500,0.000000) |00000000110110110101101101> + - (0.062500,0.000000) |00000000110110110101110000> + - (0.062500,0.000000) |00000000110110110101110110> + - (0.062500,0.000000) |00000000110110110110101011> + - (0.062500,0.000000) |00000000110110110110101101> + - (0.062500,0.000000) |00000000110110110110110000> + - (0.062500,0.000000) |00000000110110110110110110> + -[>>] binary register: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | -------------------------------------------- -[+] circuit execution time: 0.115250 sec. diff --git a/tests/circuits/result_of_the_execution_of_transversal_cnot_on_01_logical_state.txt b/tests/circuits/result_of_the_execution_of_transversal_cnot_on_01_logical_state.txt deleted file mode 100644 index aa054897..00000000 --- a/tests/circuits/result_of_the_execution_of_transversal_cnot_on_01_logical_state.txt +++ /dev/null @@ -1,594 +0,0 @@ - - =================================================================================================== - _______ - / ___ \ _ __ ____ ____ __ ___ __ __ __ ___ ______ ____ ___ - / / / | | |/_/ / __/ / _/ / |/ / / / / / / / / _ |/_ __/ / __ \ / _ \ - / /___/ / _> < _\ \ _/ / / /|_/ / / /_/ / / /__ / __ | / / / /_/ / / , _/ - \______/\__\ /_/|_| /___/ /___/ /_/ /_/ \____/ /____//_/ |_|/_/ \____/ /_/|_| - - version 0.1 beta - QuTech - 2016 - report bugs and suggestions to: nader.khammassi@gmail.com - =================================================================================================== - -[+] loading circuit from 'transversal_cnot_on_17q_ninja_star.qc' ... -[-] loading quantum_code file 'transversal_cnot_on_17q_ninja_star.qc'... -[+] code loaded successfully. -[+] initializing xpu... -[+] initialized. -[+] creating quantum register of 26 qubits... -[+] executing circuit 'initializing_first_qubit_to_logical_0_state' ... -[+] circuit execution time: 59.1026 sec. -[+] executing circuit 'start_surface_code_cycle' ... -[+] circuit execution time: 39.1931 sec. -[+] executing circuit 'round_1' ... -[+] circuit execution time: 1.2046 sec. -[+] executing circuit 'round_2' ... -[+] circuit execution time: 1.35554 sec. -[+] executing circuit 'round_3' ... -[+] circuit execution time: 1.3109 sec. -[+] executing circuit 'round_4' ... -[+] circuit execution time: 1.22193 sec. -[+] executing circuit 'syndromes_measurements' ... -[>>] binary register: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | X | X | X | X | X | X | X | X | X | -------------------------------------------- -[+] circuit execution time: 23.1463 sec. -[+] executing circuit 'set_first_qubit_to_logical_1_state' ... ---------------[quantum state]-------------- - (0.250000,0.000000) |00000000000000000001001001> + - (0.250000,0.000000) |00000000000000000001001111> + - (0.250000,0.000000) |00000000000000000001010010> + - (0.250000,0.000000) |00000000000000000001010100> + - (0.250000,0.000000) |00000000000000000010001001> + - (0.250000,0.000000) |00000000000000000010001111> + - (0.250000,0.000000) |00000000000000000010010010> + - (0.250000,0.000000) |00000000000000000010010100> + - (0.250000,0.000000) |00000000000000000100100010> + - (0.250000,0.000000) |00000000000000000100100100> + - (0.250000,0.000000) |00000000000000000100111001> + - (0.250000,0.000000) |00000000000000000100111111> + - (0.250000,0.000000) |00000000000000000111100010> + - (0.250000,0.000000) |00000000000000000111100100> + - (0.250000,0.000000) |00000000000000000111111001> + - (0.250000,0.000000) |00000000000000000111111111> + -[>>] binary register: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | X | X | X | X | X | X | X | X | X | -------------------------------------------- -[+] circuit execution time: 17.981343 sec. -[+] executing circuit 'initialize_second_qubit_to_logical_0_state' ... -[+] circuit execution time: 63.449385 sec. -[+] executing circuit 'start_surface_code_cycle' ... -[+] circuit execution time: 32.969146 sec. -[+] executing circuit 'round_1' ... -[+] circuit execution time: 1.169122 sec. -[+] executing circuit 'round_2' ... -[+] circuit execution time: 1.075034 sec. -[+] executing circuit 'round_3' ... -[+] circuit execution time: 1.105469 sec. -[+] executing circuit 'round_4' ... -[+] circuit execution time: 1.158388 sec. -[+] executing circuit 'measurements' ... -[>>] binary register: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | -------------------------------------------- -[+] circuit execution time: 26.355828 sec. -[+] executing circuit 'state_before_the_transversal_cnot' ... ---------------[quantum state]-------------- - (0.062500,0.000000) |00000000000000000001001001> + - (0.062500,0.000000) |00000000000000000001001111> + - (0.062500,0.000000) |00000000000000000001010010> + - (0.062500,0.000000) |00000000000000000001010100> + - (0.062500,0.000000) |00000000000000000010001001> + - (0.062500,0.000000) |00000000000000000010001111> + - (0.062500,0.000000) |00000000000000000010010010> + - (0.062500,0.000000) |00000000000000000010010100> + - (0.062500,0.000000) |00000000000000000100100010> + - (0.062500,0.000000) |00000000000000000100100100> + - (0.062500,0.000000) |00000000000000000100111001> + - (0.062500,0.000000) |00000000000000000100111111> + - (0.062500,0.000000) |00000000000000000111100010> + - (0.062500,0.000000) |00000000000000000111100100> + - (0.062500,0.000000) |00000000000000000111111001> + - (0.062500,0.000000) |00000000000000000111111111> + - (0.062500,0.000000) |00000000000000110001001001> + - (0.062500,0.000000) |00000000000000110001001111> + - (0.062500,0.000000) |00000000000000110001010010> + - (0.062500,0.000000) |00000000000000110001010100> + - (0.062500,0.000000) |00000000000000110010001001> + - (0.062500,0.000000) |00000000000000110010001111> + - (0.062500,0.000000) |00000000000000110010010010> + - (0.062500,0.000000) |00000000000000110010010100> + - (0.062500,0.000000) |00000000000000110100100010> + - (0.062500,0.000000) |00000000000000110100100100> + - (0.062500,0.000000) |00000000000000110100111001> + - (0.062500,0.000000) |00000000000000110100111111> + - (0.062500,0.000000) |00000000000000110111100010> + - (0.062500,0.000000) |00000000000000110111100100> + - (0.062500,0.000000) |00000000000000110111111001> + - (0.062500,0.000000) |00000000000000110111111111> + - (0.062500,0.000000) |00000000000011011001001001> + - (0.062500,0.000000) |00000000000011011001001111> + - (0.062500,0.000000) |00000000000011011001010010> + - (0.062500,0.000000) |00000000000011011001010100> + - (0.062500,0.000000) |00000000000011011010001001> + - (0.062500,0.000000) |00000000000011011010001111> + - (0.062500,0.000000) |00000000000011011010010010> + - (0.062500,0.000000) |00000000000011011010010100> + - (0.062500,0.000000) |00000000000011011100100010> + - (0.062500,0.000000) |00000000000011011100100100> + - (0.062500,0.000000) |00000000000011011100111001> + - (0.062500,0.000000) |00000000000011011100111111> + - (0.062500,0.000000) |00000000000011011111100010> + - (0.062500,0.000000) |00000000000011011111100100> + - (0.062500,0.000000) |00000000000011011111111001> + - (0.062500,0.000000) |00000000000011011111111111> + - (0.062500,0.000000) |00000000000011101001001001> + - (0.062500,0.000000) |00000000000011101001001111> + - (0.062500,0.000000) |00000000000011101001010010> + - (0.062500,0.000000) |00000000000011101001010100> + - (0.062500,0.000000) |00000000000011101010001001> + - (0.062500,0.000000) |00000000000011101010001111> + - (0.062500,0.000000) |00000000000011101010010010> + - (0.062500,0.000000) |00000000000011101010010100> + - (0.062500,0.000000) |00000000000011101100100010> + - (0.062500,0.000000) |00000000000011101100100100> + - (0.062500,0.000000) |00000000000011101100111001> + - (0.062500,0.000000) |00000000000011101100111111> + - (0.062500,0.000000) |00000000000011101111100010> + - (0.062500,0.000000) |00000000000011101111100100> + - (0.062500,0.000000) |00000000000011101111111001> + - (0.062500,0.000000) |00000000000011101111111111> + - (0.062500,0.000000) |00000000011000000001001001> + - (0.062500,0.000000) |00000000011000000001001111> + - (0.062500,0.000000) |00000000011000000001010010> + - (0.062500,0.000000) |00000000011000000001010100> + - (0.062500,0.000000) |00000000011000000010001001> + - (0.062500,0.000000) |00000000011000000010001111> + - (0.062500,0.000000) |00000000011000000010010010> + - (0.062500,0.000000) |00000000011000000010010100> + - (0.062500,0.000000) |00000000011000000100100010> + - (0.062500,0.000000) |00000000011000000100100100> + - (0.062500,0.000000) |00000000011000000100111001> + - (0.062500,0.000000) |00000000011000000100111111> + - (0.062500,0.000000) |00000000011000000111100010> + - (0.062500,0.000000) |00000000011000000111100100> + - (0.062500,0.000000) |00000000011000000111111001> + - (0.062500,0.000000) |00000000011000000111111111> + - (0.062500,0.000000) |00000000011000110001001001> + - (0.062500,0.000000) |00000000011000110001001111> + - (0.062500,0.000000) |00000000011000110001010010> + - (0.062500,0.000000) |00000000011000110001010100> + - (0.062500,0.000000) |00000000011000110010001001> + - (0.062500,0.000000) |00000000011000110010001111> + - (0.062500,0.000000) |00000000011000110010010010> + - (0.062500,0.000000) |00000000011000110010010100> + - (0.062500,0.000000) |00000000011000110100100010> + - (0.062500,0.000000) |00000000011000110100100100> + - (0.062500,0.000000) |00000000011000110100111001> + - (0.062500,0.000000) |00000000011000110100111111> + - (0.062500,0.000000) |00000000011000110111100010> + - (0.062500,0.000000) |00000000011000110111100100> + - (0.062500,0.000000) |00000000011000110111111001> + - (0.062500,0.000000) |00000000011000110111111111> + - (0.062500,0.000000) |00000000011011011001001001> + - (0.062500,0.000000) |00000000011011011001001111> + - (0.062500,0.000000) |00000000011011011001010010> + - (0.062500,0.000000) |00000000011011011001010100> + - (0.062500,0.000000) |00000000011011011010001001> + - (0.062500,0.000000) |00000000011011011010001111> + - (0.062500,0.000000) |00000000011011011010010010> + - (0.062500,0.000000) |00000000011011011010010100> + - (0.062500,0.000000) |00000000011011011100100010> + - (0.062500,0.000000) |00000000011011011100100100> + - (0.062500,0.000000) |00000000011011011100111001> + - (0.062500,0.000000) |00000000011011011100111111> + - (0.062500,0.000000) |00000000011011011111100010> + - (0.062500,0.000000) |00000000011011011111100100> + - (0.062500,0.000000) |00000000011011011111111001> + - (0.062500,0.000000) |00000000011011011111111111> + - (0.062500,0.000000) |00000000011011101001001001> + - (0.062500,0.000000) |00000000011011101001001111> + - (0.062500,0.000000) |00000000011011101001010010> + - (0.062500,0.000000) |00000000011011101001010100> + - (0.062500,0.000000) |00000000011011101010001001> + - (0.062500,0.000000) |00000000011011101010001111> + - (0.062500,0.000000) |00000000011011101010010010> + - (0.062500,0.000000) |00000000011011101010010100> + - (0.062500,0.000000) |00000000011011101100100010> + - (0.062500,0.000000) |00000000011011101100100100> + - (0.062500,0.000000) |00000000011011101100111001> + - (0.062500,0.000000) |00000000011011101100111111> + - (0.062500,0.000000) |00000000011011101111100010> + - (0.062500,0.000000) |00000000011011101111100100> + - (0.062500,0.000000) |00000000011011101111111001> + - (0.062500,0.000000) |00000000011011101111111111> + - (0.062500,0.000000) |00000000101101011001001001> + - (0.062500,0.000000) |00000000101101011001001111> + - (0.062500,0.000000) |00000000101101011001010010> + - (0.062500,0.000000) |00000000101101011001010100> + - (0.062500,0.000000) |00000000101101011010001001> + - (0.062500,0.000000) |00000000101101011010001111> + - (0.062500,0.000000) |00000000101101011010010010> + - (0.062500,0.000000) |00000000101101011010010100> + - (0.062500,0.000000) |00000000101101011100100010> + - (0.062500,0.000000) |00000000101101011100100100> + - (0.062500,0.000000) |00000000101101011100111001> + - (0.062500,0.000000) |00000000101101011100111111> + - (0.062500,0.000000) |00000000101101011111100010> + - (0.062500,0.000000) |00000000101101011111100100> + - (0.062500,0.000000) |00000000101101011111111001> + - (0.062500,0.000000) |00000000101101011111111111> + - (0.062500,0.000000) |00000000101101101001001001> + - (0.062500,0.000000) |00000000101101101001001111> + - (0.062500,0.000000) |00000000101101101001010010> + - (0.062500,0.000000) |00000000101101101001010100> + - (0.062500,0.000000) |00000000101101101010001001> + - (0.062500,0.000000) |00000000101101101010001111> + - (0.062500,0.000000) |00000000101101101010010010> + - (0.062500,0.000000) |00000000101101101010010100> + - (0.062500,0.000000) |00000000101101101100100010> + - (0.062500,0.000000) |00000000101101101100100100> + - (0.062500,0.000000) |00000000101101101100111001> + - (0.062500,0.000000) |00000000101101101100111111> + - (0.062500,0.000000) |00000000101101101111100010> + - (0.062500,0.000000) |00000000101101101111100100> + - (0.062500,0.000000) |00000000101101101111111001> + - (0.062500,0.000000) |00000000101101101111111111> + - (0.062500,0.000000) |00000000101110000001001001> + - (0.062500,0.000000) |00000000101110000001001111> + - (0.062500,0.000000) |00000000101110000001010010> + - (0.062500,0.000000) |00000000101110000001010100> + - (0.062500,0.000000) |00000000101110000010001001> + - (0.062500,0.000000) |00000000101110000010001111> + - (0.062500,0.000000) |00000000101110000010010010> + - (0.062500,0.000000) |00000000101110000010010100> + - (0.062500,0.000000) |00000000101110000100100010> + - (0.062500,0.000000) |00000000101110000100100100> + - (0.062500,0.000000) |00000000101110000100111001> + - (0.062500,0.000000) |00000000101110000100111111> + - (0.062500,0.000000) |00000000101110000111100010> + - (0.062500,0.000000) |00000000101110000111100100> + - (0.062500,0.000000) |00000000101110000111111001> + - (0.062500,0.000000) |00000000101110000111111111> + - (0.062500,0.000000) |00000000101110110001001001> + - (0.062500,0.000000) |00000000101110110001001111> + - (0.062500,0.000000) |00000000101110110001010010> + - (0.062500,0.000000) |00000000101110110001010100> + - (0.062500,0.000000) |00000000101110110010001001> + - (0.062500,0.000000) |00000000101110110010001111> + - (0.062500,0.000000) |00000000101110110010010010> + - (0.062500,0.000000) |00000000101110110010010100> + - (0.062500,0.000000) |00000000101110110100100010> + - (0.062500,0.000000) |00000000101110110100100100> + - (0.062500,0.000000) |00000000101110110100111001> + - (0.062500,0.000000) |00000000101110110100111111> + - (0.062500,0.000000) |00000000101110110111100010> + - (0.062500,0.000000) |00000000101110110111100100> + - (0.062500,0.000000) |00000000101110110111111001> + - (0.062500,0.000000) |00000000101110110111111111> + - (0.062500,0.000000) |00000000110101011001001001> + - (0.062500,0.000000) |00000000110101011001001111> + - (0.062500,0.000000) |00000000110101011001010010> + - (0.062500,0.000000) |00000000110101011001010100> + - (0.062500,0.000000) |00000000110101011010001001> + - (0.062500,0.000000) |00000000110101011010001111> + - (0.062500,0.000000) |00000000110101011010010010> + - (0.062500,0.000000) |00000000110101011010010100> + - (0.062500,0.000000) |00000000110101011100100010> + - (0.062500,0.000000) |00000000110101011100100100> + - (0.062500,0.000000) |00000000110101011100111001> + - (0.062500,0.000000) |00000000110101011100111111> + - (0.062500,0.000000) |00000000110101011111100010> + - (0.062500,0.000000) |00000000110101011111100100> + - (0.062500,0.000000) |00000000110101011111111001> + - (0.062500,0.000000) |00000000110101011111111111> + - (0.062500,0.000000) |00000000110101101001001001> + - (0.062500,0.000000) |00000000110101101001001111> + - (0.062500,0.000000) |00000000110101101001010010> + - (0.062500,0.000000) |00000000110101101001010100> + - (0.062500,0.000000) |00000000110101101010001001> + - (0.062500,0.000000) |00000000110101101010001111> + - (0.062500,0.000000) |00000000110101101010010010> + - (0.062500,0.000000) |00000000110101101010010100> + - (0.062500,0.000000) |00000000110101101100100010> + - (0.062500,0.000000) |00000000110101101100100100> + - (0.062500,0.000000) |00000000110101101100111001> + - (0.062500,0.000000) |00000000110101101100111111> + - (0.062500,0.000000) |00000000110101101111100010> + - (0.062500,0.000000) |00000000110101101111100100> + - (0.062500,0.000000) |00000000110101101111111001> + - (0.062500,0.000000) |00000000110101101111111111> + - (0.062500,0.000000) |00000000110110000001001001> + - (0.062500,0.000000) |00000000110110000001001111> + - (0.062500,0.000000) |00000000110110000001010010> + - (0.062500,0.000000) |00000000110110000001010100> + - (0.062500,0.000000) |00000000110110000010001001> + - (0.062500,0.000000) |00000000110110000010001111> + - (0.062500,0.000000) |00000000110110000010010010> + - (0.062500,0.000000) |00000000110110000010010100> + - (0.062500,0.000000) |00000000110110000100100010> + - (0.062500,0.000000) |00000000110110000100100100> + - (0.062500,0.000000) |00000000110110000100111001> + - (0.062500,0.000000) |00000000110110000100111111> + - (0.062500,0.000000) |00000000110110000111100010> + - (0.062500,0.000000) |00000000110110000111100100> + - (0.062500,0.000000) |00000000110110000111111001> + - (0.062500,0.000000) |00000000110110000111111111> + - (0.062500,0.000000) |00000000110110110001001001> + - (0.062500,0.000000) |00000000110110110001001111> + - (0.062500,0.000000) |00000000110110110001010010> + - (0.062500,0.000000) |00000000110110110001010100> + - (0.062500,0.000000) |00000000110110110010001001> + - (0.062500,0.000000) |00000000110110110010001111> + - (0.062500,0.000000) |00000000110110110010010010> + - (0.062500,0.000000) |00000000110110110010010100> + - (0.062500,0.000000) |00000000110110110100100010> + - (0.062500,0.000000) |00000000110110110100100100> + - (0.062500,0.000000) |00000000110110110100111001> + - (0.062500,0.000000) |00000000110110110100111111> + - (0.062500,0.000000) |00000000110110110111100010> + - (0.062500,0.000000) |00000000110110110111100100> + - (0.062500,0.000000) |00000000110110110111111001> + - (0.062500,0.000000) |00000000110110110111111111> + -[>>] binary register: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | -------------------------------------------- -[+] circuit execution time: 0.142440 sec. -[+] executing circuit 'transversal_cnot' ... -[+] circuit execution time: 1.241058 sec. -[+] executing circuit 'state_after_the_transversal_cnot' ... ---------------[quantum state]-------------- - (0.062500,0.000000) |00000000001001001001001001> + - (0.062500,0.000000) |00000000001001001001001111> + - (0.062500,0.000000) |00000000001001001001010010> + - (0.062500,0.000000) |00000000001001001001010100> + - (0.062500,0.000000) |00000000001001001010001001> + - (0.062500,0.000000) |00000000001001001010001111> + - (0.062500,0.000000) |00000000001001001010010010> + - (0.062500,0.000000) |00000000001001001010010100> + - (0.062500,0.000000) |00000000001001001100100010> + - (0.062500,0.000000) |00000000001001001100100100> + - (0.062500,0.000000) |00000000001001001100111001> + - (0.062500,0.000000) |00000000001001001100111111> + - (0.062500,0.000000) |00000000001001001111100010> + - (0.062500,0.000000) |00000000001001001111100100> + - (0.062500,0.000000) |00000000001001001111111001> + - (0.062500,0.000000) |00000000001001001111111111> + - (0.062500,0.000000) |00000000001001111001001001> + - (0.062500,0.000000) |00000000001001111001001111> + - (0.062500,0.000000) |00000000001001111001010010> + - (0.062500,0.000000) |00000000001001111001010100> + - (0.062500,0.000000) |00000000001001111010001001> + - (0.062500,0.000000) |00000000001001111010001111> + - (0.062500,0.000000) |00000000001001111010010010> + - (0.062500,0.000000) |00000000001001111010010100> + - (0.062500,0.000000) |00000000001001111100100010> + - (0.062500,0.000000) |00000000001001111100100100> + - (0.062500,0.000000) |00000000001001111100111001> + - (0.062500,0.000000) |00000000001001111100111111> + - (0.062500,0.000000) |00000000001001111111100010> + - (0.062500,0.000000) |00000000001001111111100100> + - (0.062500,0.000000) |00000000001001111111111001> + - (0.062500,0.000000) |00000000001001111111111111> + - (0.062500,0.000000) |00000000001010010001001001> + - (0.062500,0.000000) |00000000001010010001001111> + - (0.062500,0.000000) |00000000001010010001010010> + - (0.062500,0.000000) |00000000001010010001010100> + - (0.062500,0.000000) |00000000001010010010001001> + - (0.062500,0.000000) |00000000001010010010001111> + - (0.062500,0.000000) |00000000001010010010010010> + - (0.062500,0.000000) |00000000001010010010010100> + - (0.062500,0.000000) |00000000001010010100100010> + - (0.062500,0.000000) |00000000001010010100100100> + - (0.062500,0.000000) |00000000001010010100111001> + - (0.062500,0.000000) |00000000001010010100111111> + - (0.062500,0.000000) |00000000001010010111100010> + - (0.062500,0.000000) |00000000001010010111100100> + - (0.062500,0.000000) |00000000001010010111111001> + - (0.062500,0.000000) |00000000001010010111111111> + - (0.062500,0.000000) |00000000001010100001001001> + - (0.062500,0.000000) |00000000001010100001001111> + - (0.062500,0.000000) |00000000001010100001010010> + - (0.062500,0.000000) |00000000001010100001010100> + - (0.062500,0.000000) |00000000001010100010001001> + - (0.062500,0.000000) |00000000001010100010001111> + - (0.062500,0.000000) |00000000001010100010010010> + - (0.062500,0.000000) |00000000001010100010010100> + - (0.062500,0.000000) |00000000001010100100100010> + - (0.062500,0.000000) |00000000001010100100100100> + - (0.062500,0.000000) |00000000001010100100111001> + - (0.062500,0.000000) |00000000001010100100111111> + - (0.062500,0.000000) |00000000001010100111100010> + - (0.062500,0.000000) |00000000001010100111100100> + - (0.062500,0.000000) |00000000001010100111111001> + - (0.062500,0.000000) |00000000001010100111111111> + - (0.062500,0.000000) |00000000010001001001001001> + - (0.062500,0.000000) |00000000010001001001001111> + - (0.062500,0.000000) |00000000010001001001010010> + - (0.062500,0.000000) |00000000010001001001010100> + - (0.062500,0.000000) |00000000010001001010001001> + - (0.062500,0.000000) |00000000010001001010001111> + - (0.062500,0.000000) |00000000010001001010010010> + - (0.062500,0.000000) |00000000010001001010010100> + - (0.062500,0.000000) |00000000010001001100100010> + - (0.062500,0.000000) |00000000010001001100100100> + - (0.062500,0.000000) |00000000010001001100111001> + - (0.062500,0.000000) |00000000010001001100111111> + - (0.062500,0.000000) |00000000010001001111100010> + - (0.062500,0.000000) |00000000010001001111100100> + - (0.062500,0.000000) |00000000010001001111111001> + - (0.062500,0.000000) |00000000010001001111111111> + - (0.062500,0.000000) |00000000010001111001001001> + - (0.062500,0.000000) |00000000010001111001001111> + - (0.062500,0.000000) |00000000010001111001010010> + - (0.062500,0.000000) |00000000010001111001010100> + - (0.062500,0.000000) |00000000010001111010001001> + - (0.062500,0.000000) |00000000010001111010001111> + - (0.062500,0.000000) |00000000010001111010010010> + - (0.062500,0.000000) |00000000010001111010010100> + - (0.062500,0.000000) |00000000010001111100100010> + - (0.062500,0.000000) |00000000010001111100100100> + - (0.062500,0.000000) |00000000010001111100111001> + - (0.062500,0.000000) |00000000010001111100111111> + - (0.062500,0.000000) |00000000010001111111100010> + - (0.062500,0.000000) |00000000010001111111100100> + - (0.062500,0.000000) |00000000010001111111111001> + - (0.062500,0.000000) |00000000010001111111111111> + - (0.062500,0.000000) |00000000010010010001001001> + - (0.062500,0.000000) |00000000010010010001001111> + - (0.062500,0.000000) |00000000010010010001010010> + - (0.062500,0.000000) |00000000010010010001010100> + - (0.062500,0.000000) |00000000010010010010001001> + - (0.062500,0.000000) |00000000010010010010001111> + - (0.062500,0.000000) |00000000010010010010010010> + - (0.062500,0.000000) |00000000010010010010010100> + - (0.062500,0.000000) |00000000010010010100100010> + - (0.062500,0.000000) |00000000010010010100100100> + - (0.062500,0.000000) |00000000010010010100111001> + - (0.062500,0.000000) |00000000010010010100111111> + - (0.062500,0.000000) |00000000010010010111100010> + - (0.062500,0.000000) |00000000010010010111100100> + - (0.062500,0.000000) |00000000010010010111111001> + - (0.062500,0.000000) |00000000010010010111111111> + - (0.062500,0.000000) |00000000010010100001001001> + - (0.062500,0.000000) |00000000010010100001001111> + - (0.062500,0.000000) |00000000010010100001010010> + - (0.062500,0.000000) |00000000010010100001010100> + - (0.062500,0.000000) |00000000010010100010001001> + - (0.062500,0.000000) |00000000010010100010001111> + - (0.062500,0.000000) |00000000010010100010010010> + - (0.062500,0.000000) |00000000010010100010010100> + - (0.062500,0.000000) |00000000010010100100100010> + - (0.062500,0.000000) |00000000010010100100100100> + - (0.062500,0.000000) |00000000010010100100111001> + - (0.062500,0.000000) |00000000010010100100111111> + - (0.062500,0.000000) |00000000010010100111100010> + - (0.062500,0.000000) |00000000010010100111100100> + - (0.062500,0.000000) |00000000010010100111111001> + - (0.062500,0.000000) |00000000010010100111111111> + - (0.062500,0.000000) |00000000100100010001001001> + - (0.062500,0.000000) |00000000100100010001001111> + - (0.062500,0.000000) |00000000100100010001010010> + - (0.062500,0.000000) |00000000100100010001010100> + - (0.062500,0.000000) |00000000100100010010001001> + - (0.062500,0.000000) |00000000100100010010001111> + - (0.062500,0.000000) |00000000100100010010010010> + - (0.062500,0.000000) |00000000100100010010010100> + - (0.062500,0.000000) |00000000100100010100100010> + - (0.062500,0.000000) |00000000100100010100100100> + - (0.062500,0.000000) |00000000100100010100111001> + - (0.062500,0.000000) |00000000100100010100111111> + - (0.062500,0.000000) |00000000100100010111100010> + - (0.062500,0.000000) |00000000100100010111100100> + - (0.062500,0.000000) |00000000100100010111111001> + - (0.062500,0.000000) |00000000100100010111111111> + - (0.062500,0.000000) |00000000100100100001001001> + - (0.062500,0.000000) |00000000100100100001001111> + - (0.062500,0.000000) |00000000100100100001010010> + - (0.062500,0.000000) |00000000100100100001010100> + - (0.062500,0.000000) |00000000100100100010001001> + - (0.062500,0.000000) |00000000100100100010001111> + - (0.062500,0.000000) |00000000100100100010010010> + - (0.062500,0.000000) |00000000100100100010010100> + - (0.062500,0.000000) |00000000100100100100100010> + - (0.062500,0.000000) |00000000100100100100100100> + - (0.062500,0.000000) |00000000100100100100111001> + - (0.062500,0.000000) |00000000100100100100111111> + - (0.062500,0.000000) |00000000100100100111100010> + - (0.062500,0.000000) |00000000100100100111100100> + - (0.062500,0.000000) |00000000100100100111111001> + - (0.062500,0.000000) |00000000100100100111111111> + - (0.062500,0.000000) |00000000100111001001001001> + - (0.062500,0.000000) |00000000100111001001001111> + - (0.062500,0.000000) |00000000100111001001010010> + - (0.062500,0.000000) |00000000100111001001010100> + - (0.062500,0.000000) |00000000100111001010001001> + - (0.062500,0.000000) |00000000100111001010001111> + - (0.062500,0.000000) |00000000100111001010010010> + - (0.062500,0.000000) |00000000100111001010010100> + - (0.062500,0.000000) |00000000100111001100100010> + - (0.062500,0.000000) |00000000100111001100100100> + - (0.062500,0.000000) |00000000100111001100111001> + - (0.062500,0.000000) |00000000100111001100111111> + - (0.062500,0.000000) |00000000100111001111100010> + - (0.062500,0.000000) |00000000100111001111100100> + - (0.062500,0.000000) |00000000100111001111111001> + - (0.062500,0.000000) |00000000100111001111111111> + - (0.062500,0.000000) |00000000100111111001001001> + - (0.062500,0.000000) |00000000100111111001001111> + - (0.062500,0.000000) |00000000100111111001010010> + - (0.062500,0.000000) |00000000100111111001010100> + - (0.062500,0.000000) |00000000100111111010001001> + - (0.062500,0.000000) |00000000100111111010001111> + - (0.062500,0.000000) |00000000100111111010010010> + - (0.062500,0.000000) |00000000100111111010010100> + - (0.062500,0.000000) |00000000100111111100100010> + - (0.062500,0.000000) |00000000100111111100100100> + - (0.062500,0.000000) |00000000100111111100111001> + - (0.062500,0.000000) |00000000100111111100111111> + - (0.062500,0.000000) |00000000100111111111100010> + - (0.062500,0.000000) |00000000100111111111100100> + - (0.062500,0.000000) |00000000100111111111111001> + - (0.062500,0.000000) |00000000100111111111111111> + - (0.062500,0.000000) |00000000111100010001001001> + - (0.062500,0.000000) |00000000111100010001001111> + - (0.062500,0.000000) |00000000111100010001010010> + - (0.062500,0.000000) |00000000111100010001010100> + - (0.062500,0.000000) |00000000111100010010001001> + - (0.062500,0.000000) |00000000111100010010001111> + - (0.062500,0.000000) |00000000111100010010010010> + - (0.062500,0.000000) |00000000111100010010010100> + - (0.062500,0.000000) |00000000111100010100100010> + - (0.062500,0.000000) |00000000111100010100100100> + - (0.062500,0.000000) |00000000111100010100111001> + - (0.062500,0.000000) |00000000111100010100111111> + - (0.062500,0.000000) |00000000111100010111100010> + - (0.062500,0.000000) |00000000111100010111100100> + - (0.062500,0.000000) |00000000111100010111111001> + - (0.062500,0.000000) |00000000111100010111111111> + - (0.062500,0.000000) |00000000111100100001001001> + - (0.062500,0.000000) |00000000111100100001001111> + - (0.062500,0.000000) |00000000111100100001010010> + - (0.062500,0.000000) |00000000111100100001010100> + - (0.062500,0.000000) |00000000111100100010001001> + - (0.062500,0.000000) |00000000111100100010001111> + - (0.062500,0.000000) |00000000111100100010010010> + - (0.062500,0.000000) |00000000111100100010010100> + - (0.062500,0.000000) |00000000111100100100100010> + - (0.062500,0.000000) |00000000111100100100100100> + - (0.062500,0.000000) |00000000111100100100111001> + - (0.062500,0.000000) |00000000111100100100111111> + - (0.062500,0.000000) |00000000111100100111100010> + - (0.062500,0.000000) |00000000111100100111100100> + - (0.062500,0.000000) |00000000111100100111111001> + - (0.062500,0.000000) |00000000111100100111111111> + - (0.062500,0.000000) |00000000111111001001001001> + - (0.062500,0.000000) |00000000111111001001001111> + - (0.062500,0.000000) |00000000111111001001010010> + - (0.062500,0.000000) |00000000111111001001010100> + - (0.062500,0.000000) |00000000111111001010001001> + - (0.062500,0.000000) |00000000111111001010001111> + - (0.062500,0.000000) |00000000111111001010010010> + - (0.062500,0.000000) |00000000111111001010010100> + - (0.062500,0.000000) |00000000111111001100100010> + - (0.062500,0.000000) |00000000111111001100100100> + - (0.062500,0.000000) |00000000111111001100111001> + - (0.062500,0.000000) |00000000111111001100111111> + - (0.062500,0.000000) |00000000111111001111100010> + - (0.062500,0.000000) |00000000111111001111100100> + - (0.062500,0.000000) |00000000111111001111111001> + - (0.062500,0.000000) |00000000111111001111111111> + - (0.062500,0.000000) |00000000111111111001001001> + - (0.062500,0.000000) |00000000111111111001001111> + - (0.062500,0.000000) |00000000111111111001010010> + - (0.062500,0.000000) |00000000111111111001010100> + - (0.062500,0.000000) |00000000111111111010001001> + - (0.062500,0.000000) |00000000111111111010001111> + - (0.062500,0.000000) |00000000111111111010010010> + - (0.062500,0.000000) |00000000111111111010010100> + - (0.062500,0.000000) |00000000111111111100100010> + - (0.062500,0.000000) |00000000111111111100100100> + - (0.062500,0.000000) |00000000111111111100111001> + - (0.062500,0.000000) |00000000111111111100111111> + - (0.062500,0.000000) |00000000111111111111100010> + - (0.062500,0.000000) |00000000111111111111100100> + - (0.062500,0.000000) |00000000111111111111111001> + - (0.062500,0.000000) |00000000111111111111111111> + -[>>] binary register: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | -------------------------------------------- -[+] circuit execution time: 0.114458 sec. diff --git a/tests/circuits/result_of_the_execution_of_transversal_cnot_on_10_logical_state.txt b/tests/circuits/result_of_the_execution_of_transversal_cnot_on_10_logical_state.txt deleted file mode 100644 index 52b4c1bf..00000000 --- a/tests/circuits/result_of_the_execution_of_transversal_cnot_on_10_logical_state.txt +++ /dev/null @@ -1,575 +0,0 @@ - - =================================================================================================== - _______ - / ___ \ _ __ ____ ____ __ ___ __ __ __ ___ ______ ____ ___ - / / / | | |/_/ / __/ / _/ / |/ / / / / / / / / _ |/_ __/ / __ \ / _ \ - / /___/ / _> < _\ \ _/ / / /|_/ / / /_/ / / /__ / __ | / / / /_/ / / , _/ - \______/\__\ /_/|_| /___/ /___/ /_/ /_/ \____/ /____//_/ |_|/_/ \____/ /_/|_| - - version 0.1 beta - QuTech - 2016 - report bugs and suggestions to: nader.khammassi@gmail.com - =================================================================================================== - -[+] loading circuit from 'transversal_cnot_on_17q_ninja_star.qc' ... -[-] loading quantum_code file 'transversal_cnot_on_17q_ninja_star.qc'... -[+] code loaded successfully. -[+] initializing xpu... -[+] initialized. -[+] creating quantum register of 26 qubits... -[+] executing circuit 'initializing_first_qubit_to_logical_0_state' ... -[+] circuit execution time: 65.9622 sec. -[+] executing circuit 'start_surface_code_cycle' ... -[+] circuit execution time: 35.3582 sec. -[+] executing circuit 'round_1' ... -[+] circuit execution time: 1.22443 sec. -[+] executing circuit 'round_2' ... -[+] circuit execution time: 1.21067 sec. -[+] executing circuit 'round_3' ... -[+] circuit execution time: 1.19311 sec. -[+] executing circuit 'round_4' ... -[+] circuit execution time: 1.1092 sec. -[+] executing circuit 'syndromes_measurements' ... -[>>] binary register: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | X | X | X | X | X | X | X | X | X | -------------------------------------------- -[+] circuit execution time: 24.8191 sec. -[+] executing circuit 'initialize_second_qubit_to_logical_0_state' ... -[+] circuit execution time: 63.75 sec. -[+] executing circuit 'start_surface_code_cycle' ... -[+] circuit execution time: 41.0536 sec. -[+] executing circuit 'round_1' ... -[+] circuit execution time: 1.12445 sec. -[+] executing circuit 'round_2' ... -[+] circuit execution time: 1.07635 sec. -[+] executing circuit 'round_3' ... -[+] circuit execution time: 1.05858 sec. -[+] executing circuit 'round_4' ... -[+] circuit execution time: 1.05479 sec. -[+] executing circuit 'measurements' ... -[>>] binary register: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | -------------------------------------------- -[+] circuit execution time: 25.0169 sec. -[+] executing circuit 'set_second_logical_qubit_to_logical_1_state' ... -[+] circuit execution time: 16.3568 sec. -[+] executing circuit 'state_before_the_transversal_cnot' ... ---------------[quantum state]-------------- - (0.062500,0.000000) |00000000001001001000000000> + - (0.062500,0.000000) |00000000001001001000000110> + - (0.062500,0.000000) |00000000001001001000011011> + - (0.062500,0.000000) |00000000001001001000011101> + - (0.062500,0.000000) |00000000001001001011000000> + - (0.062500,0.000000) |00000000001001001011000110> + - (0.062500,0.000000) |00000000001001001011011011> + - (0.062500,0.000000) |00000000001001001011011101> + - (0.062500,0.000000) |00000000001001001101101011> + - (0.062500,0.000000) |00000000001001001101101101> + - (0.062500,0.000000) |00000000001001001101110000> + - (0.062500,0.000000) |00000000001001001101110110> + - (0.062500,0.000000) |00000000001001001110101011> + - (0.062500,0.000000) |00000000001001001110101101> + - (0.062500,0.000000) |00000000001001001110110000> + - (0.062500,0.000000) |00000000001001001110110110> + - (0.062500,0.000000) |00000000001001111000000000> + - (0.062500,0.000000) |00000000001001111000000110> + - (0.062500,0.000000) |00000000001001111000011011> + - (0.062500,0.000000) |00000000001001111000011101> + - (0.062500,0.000000) |00000000001001111011000000> + - (0.062500,0.000000) |00000000001001111011000110> + - (0.062500,0.000000) |00000000001001111011011011> + - (0.062500,0.000000) |00000000001001111011011101> + - (0.062500,0.000000) |00000000001001111101101011> + - (0.062500,0.000000) |00000000001001111101101101> + - (0.062500,0.000000) |00000000001001111101110000> + - (0.062500,0.000000) |00000000001001111101110110> + - (0.062500,0.000000) |00000000001001111110101011> + - (0.062500,0.000000) |00000000001001111110101101> + - (0.062500,0.000000) |00000000001001111110110000> + - (0.062500,0.000000) |00000000001001111110110110> + - (0.062500,0.000000) |00000000001010010000000000> + - (0.062500,0.000000) |00000000001010010000000110> + - (0.062500,0.000000) |00000000001010010000011011> + - (0.062500,0.000000) |00000000001010010000011101> + - (0.062500,0.000000) |00000000001010010011000000> + - (0.062500,0.000000) |00000000001010010011000110> + - (0.062500,0.000000) |00000000001010010011011011> + - (0.062500,0.000000) |00000000001010010011011101> + - (0.062500,0.000000) |00000000001010010101101011> + - (0.062500,0.000000) |00000000001010010101101101> + - (0.062500,0.000000) |00000000001010010101110000> + - (0.062500,0.000000) |00000000001010010101110110> + - (0.062500,0.000000) |00000000001010010110101011> + - (0.062500,0.000000) |00000000001010010110101101> + - (0.062500,0.000000) |00000000001010010110110000> + - (0.062500,0.000000) |00000000001010010110110110> + - (0.062500,0.000000) |00000000001010100000000000> + - (0.062500,0.000000) |00000000001010100000000110> + - (0.062500,0.000000) |00000000001010100000011011> + - (0.062500,0.000000) |00000000001010100000011101> + - (0.062500,0.000000) |00000000001010100011000000> + - (0.062500,0.000000) |00000000001010100011000110> + - (0.062500,0.000000) |00000000001010100011011011> + - (0.062500,0.000000) |00000000001010100011011101> + - (0.062500,0.000000) |00000000001010100101101011> + - (0.062500,0.000000) |00000000001010100101101101> + - (0.062500,0.000000) |00000000001010100101110000> + - (0.062500,0.000000) |00000000001010100101110110> + - (0.062500,0.000000) |00000000001010100110101011> + - (0.062500,0.000000) |00000000001010100110101101> + - (0.062500,0.000000) |00000000001010100110110000> + - (0.062500,0.000000) |00000000001010100110110110> + - (0.062500,0.000000) |00000000010001001000000000> + - (0.062500,0.000000) |00000000010001001000000110> + - (0.062500,0.000000) |00000000010001001000011011> + - (0.062500,0.000000) |00000000010001001000011101> + - (0.062500,0.000000) |00000000010001001011000000> + - (0.062500,0.000000) |00000000010001001011000110> + - (0.062500,0.000000) |00000000010001001011011011> + - (0.062500,0.000000) |00000000010001001011011101> + - (0.062500,0.000000) |00000000010001001101101011> + - (0.062500,0.000000) |00000000010001001101101101> + - (0.062500,0.000000) |00000000010001001101110000> + - (0.062500,0.000000) |00000000010001001101110110> + - (0.062500,0.000000) |00000000010001001110101011> + - (0.062500,0.000000) |00000000010001001110101101> + - (0.062500,0.000000) |00000000010001001110110000> + - (0.062500,0.000000) |00000000010001001110110110> + - (0.062500,0.000000) |00000000010001111000000000> + - (0.062500,0.000000) |00000000010001111000000110> + - (0.062500,0.000000) |00000000010001111000011011> + - (0.062500,0.000000) |00000000010001111000011101> + - (0.062500,0.000000) |00000000010001111011000000> + - (0.062500,0.000000) |00000000010001111011000110> + - (0.062500,0.000000) |00000000010001111011011011> + - (0.062500,0.000000) |00000000010001111011011101> + - (0.062500,0.000000) |00000000010001111101101011> + - (0.062500,0.000000) |00000000010001111101101101> + - (0.062500,0.000000) |00000000010001111101110000> + - (0.062500,0.000000) |00000000010001111101110110> + - (0.062500,0.000000) |00000000010001111110101011> + - (0.062500,0.000000) |00000000010001111110101101> + - (0.062500,0.000000) |00000000010001111110110000> + - (0.062500,0.000000) |00000000010001111110110110> + - (0.062500,0.000000) |00000000010010010000000000> + - (0.062500,0.000000) |00000000010010010000000110> + - (0.062500,0.000000) |00000000010010010000011011> + - (0.062500,0.000000) |00000000010010010000011101> + - (0.062500,0.000000) |00000000010010010011000000> + - (0.062500,0.000000) |00000000010010010011000110> + - (0.062500,0.000000) |00000000010010010011011011> + - (0.062500,0.000000) |00000000010010010011011101> + - (0.062500,0.000000) |00000000010010010101101011> + - (0.062500,0.000000) |00000000010010010101101101> + - (0.062500,0.000000) |00000000010010010101110000> + - (0.062500,0.000000) |00000000010010010101110110> + - (0.062500,0.000000) |00000000010010010110101011> + - (0.062500,0.000000) |00000000010010010110101101> + - (0.062500,0.000000) |00000000010010010110110000> + - (0.062500,0.000000) |00000000010010010110110110> + - (0.062500,0.000000) |00000000010010100000000000> + - (0.062500,0.000000) |00000000010010100000000110> + - (0.062500,0.000000) |00000000010010100000011011> + - (0.062500,0.000000) |00000000010010100000011101> + - (0.062500,0.000000) |00000000010010100011000000> + - (0.062500,0.000000) |00000000010010100011000110> + - (0.062500,0.000000) |00000000010010100011011011> + - (0.062500,0.000000) |00000000010010100011011101> + - (0.062500,0.000000) |00000000010010100101101011> + - (0.062500,0.000000) |00000000010010100101101101> + - (0.062500,0.000000) |00000000010010100101110000> + - (0.062500,0.000000) |00000000010010100101110110> + - (0.062500,0.000000) |00000000010010100110101011> + - (0.062500,0.000000) |00000000010010100110101101> + - (0.062500,0.000000) |00000000010010100110110000> + - (0.062500,0.000000) |00000000010010100110110110> + - (0.062500,0.000000) |00000000100100010000000000> + - (0.062500,0.000000) |00000000100100010000000110> + - (0.062500,0.000000) |00000000100100010000011011> + - (0.062500,0.000000) |00000000100100010000011101> + - (0.062500,0.000000) |00000000100100010011000000> + - (0.062500,0.000000) |00000000100100010011000110> + - (0.062500,0.000000) |00000000100100010011011011> + - (0.062500,0.000000) |00000000100100010011011101> + - (0.062500,0.000000) |00000000100100010101101011> + - (0.062500,0.000000) |00000000100100010101101101> + - (0.062500,0.000000) |00000000100100010101110000> + - (0.062500,0.000000) |00000000100100010101110110> + - (0.062500,0.000000) |00000000100100010110101011> + - (0.062500,0.000000) |00000000100100010110101101> + - (0.062500,0.000000) |00000000100100010110110000> + - (0.062500,0.000000) |00000000100100010110110110> + - (0.062500,0.000000) |00000000100100100000000000> + - (0.062500,0.000000) |00000000100100100000000110> + - (0.062500,0.000000) |00000000100100100000011011> + - (0.062500,0.000000) |00000000100100100000011101> + - (0.062500,0.000000) |00000000100100100011000000> + - (0.062500,0.000000) |00000000100100100011000110> + - (0.062500,0.000000) |00000000100100100011011011> + - (0.062500,0.000000) |00000000100100100011011101> + - (0.062500,0.000000) |00000000100100100101101011> + - (0.062500,0.000000) |00000000100100100101101101> + - (0.062500,0.000000) |00000000100100100101110000> + - (0.062500,0.000000) |00000000100100100101110110> + - (0.062500,0.000000) |00000000100100100110101011> + - (0.062500,0.000000) |00000000100100100110101101> + - (0.062500,0.000000) |00000000100100100110110000> + - (0.062500,0.000000) |00000000100100100110110110> + - (0.062500,0.000000) |00000000100111001000000000> + - (0.062500,0.000000) |00000000100111001000000110> + - (0.062500,0.000000) |00000000100111001000011011> + - (0.062500,0.000000) |00000000100111001000011101> + - (0.062500,0.000000) |00000000100111001011000000> + - (0.062500,0.000000) |00000000100111001011000110> + - (0.062500,0.000000) |00000000100111001011011011> + - (0.062500,0.000000) |00000000100111001011011101> + - (0.062500,0.000000) |00000000100111001101101011> + - (0.062500,0.000000) |00000000100111001101101101> + - (0.062500,0.000000) |00000000100111001101110000> + - (0.062500,0.000000) |00000000100111001101110110> + - (0.062500,0.000000) |00000000100111001110101011> + - (0.062500,0.000000) |00000000100111001110101101> + - (0.062500,0.000000) |00000000100111001110110000> + - (0.062500,0.000000) |00000000100111001110110110> + - (0.062500,0.000000) |00000000100111111000000000> + - (0.062500,0.000000) |00000000100111111000000110> + - (0.062500,0.000000) |00000000100111111000011011> + - (0.062500,0.000000) |00000000100111111000011101> + - (0.062500,0.000000) |00000000100111111011000000> + - (0.062500,0.000000) |00000000100111111011000110> + - (0.062500,0.000000) |00000000100111111011011011> + - (0.062500,0.000000) |00000000100111111011011101> + - (0.062500,0.000000) |00000000100111111101101011> + - (0.062500,0.000000) |00000000100111111101101101> + - (0.062500,0.000000) |00000000100111111101110000> + - (0.062500,0.000000) |00000000100111111101110110> + - (0.062500,0.000000) |00000000100111111110101011> + - (0.062500,0.000000) |00000000100111111110101101> + - (0.062500,0.000000) |00000000100111111110110000> + - (0.062500,0.000000) |00000000100111111110110110> + - (0.062500,0.000000) |00000000111100010000000000> + - (0.062500,0.000000) |00000000111100010000000110> + - (0.062500,0.000000) |00000000111100010000011011> + - (0.062500,0.000000) |00000000111100010000011101> + - (0.062500,0.000000) |00000000111100010011000000> + - (0.062500,0.000000) |00000000111100010011000110> + - (0.062500,0.000000) |00000000111100010011011011> + - (0.062500,0.000000) |00000000111100010011011101> + - (0.062500,0.000000) |00000000111100010101101011> + - (0.062500,0.000000) |00000000111100010101101101> + - (0.062500,0.000000) |00000000111100010101110000> + - (0.062500,0.000000) |00000000111100010101110110> + - (0.062500,0.000000) |00000000111100010110101011> + - (0.062500,0.000000) |00000000111100010110101101> + - (0.062500,0.000000) |00000000111100010110110000> + - (0.062500,0.000000) |00000000111100010110110110> + - (0.062500,0.000000) |00000000111100100000000000> + - (0.062500,0.000000) |00000000111100100000000110> + - (0.062500,0.000000) |00000000111100100000011011> + - (0.062500,0.000000) |00000000111100100000011101> + - (0.062500,0.000000) |00000000111100100011000000> + - (0.062500,0.000000) |00000000111100100011000110> + - (0.062500,0.000000) |00000000111100100011011011> + - (0.062500,0.000000) |00000000111100100011011101> + - (0.062500,0.000000) |00000000111100100101101011> + - (0.062500,0.000000) |00000000111100100101101101> + - (0.062500,0.000000) |00000000111100100101110000> + - (0.062500,0.000000) |00000000111100100101110110> + - (0.062500,0.000000) |00000000111100100110101011> + - (0.062500,0.000000) |00000000111100100110101101> + - (0.062500,0.000000) |00000000111100100110110000> + - (0.062500,0.000000) |00000000111100100110110110> + - (0.062500,0.000000) |00000000111111001000000000> + - (0.062500,0.000000) |00000000111111001000000110> + - (0.062500,0.000000) |00000000111111001000011011> + - (0.062500,0.000000) |00000000111111001000011101> + - (0.062500,0.000000) |00000000111111001011000000> + - (0.062500,0.000000) |00000000111111001011000110> + - (0.062500,0.000000) |00000000111111001011011011> + - (0.062500,0.000000) |00000000111111001011011101> + - (0.062500,0.000000) |00000000111111001101101011> + - (0.062500,0.000000) |00000000111111001101101101> + - (0.062500,0.000000) |00000000111111001101110000> + - (0.062500,0.000000) |00000000111111001101110110> + - (0.062500,0.000000) |00000000111111001110101011> + - (0.062500,0.000000) |00000000111111001110101101> + - (0.062500,0.000000) |00000000111111001110110000> + - (0.062500,0.000000) |00000000111111001110110110> + - (0.062500,0.000000) |00000000111111111000000000> + - (0.062500,0.000000) |00000000111111111000000110> + - (0.062500,0.000000) |00000000111111111000011011> + - (0.062500,0.000000) |00000000111111111000011101> + - (0.062500,0.000000) |00000000111111111011000000> + - (0.062500,0.000000) |00000000111111111011000110> + - (0.062500,0.000000) |00000000111111111011011011> + - (0.062500,0.000000) |00000000111111111011011101> + - (0.062500,0.000000) |00000000111111111101101011> + - (0.062500,0.000000) |00000000111111111101101101> + - (0.062500,0.000000) |00000000111111111101110000> + - (0.062500,0.000000) |00000000111111111101110110> + - (0.062500,0.000000) |00000000111111111110101011> + - (0.062500,0.000000) |00000000111111111110101101> + - (0.062500,0.000000) |00000000111111111110110000> + - (0.062500,0.000000) |00000000111111111110110110> + -[>>] binary register: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | -------------------------------------------- -[+] circuit execution time: 0.130143 sec. -[+] executing circuit 'transversal_cnot' ... -[+] circuit execution time: 2.000961 sec. -[+] executing circuit 'state_after_the_transversal_cnot' ... ---------------[quantum state]-------------- - (0.062500,0.000000) |00000000001001001000000000> + - (0.062500,0.000000) |00000000001001001000000110> + - (0.062500,0.000000) |00000000001001001000011011> + - (0.062500,0.000000) |00000000001001001000011101> + - (0.062500,0.000000) |00000000001001001011000000> + - (0.062500,0.000000) |00000000001001001011000110> + - (0.062500,0.000000) |00000000001001001011011011> + - (0.062500,0.000000) |00000000001001001011011101> + - (0.062500,0.000000) |00000000001001001101101011> + - (0.062500,0.000000) |00000000001001001101101101> + - (0.062500,0.000000) |00000000001001001101110000> + - (0.062500,0.000000) |00000000001001001101110110> + - (0.062500,0.000000) |00000000001001001110101011> + - (0.062500,0.000000) |00000000001001001110101101> + - (0.062500,0.000000) |00000000001001001110110000> + - (0.062500,0.000000) |00000000001001001110110110> + - (0.062500,0.000000) |00000000001001111000000000> + - (0.062500,0.000000) |00000000001001111000000110> + - (0.062500,0.000000) |00000000001001111000011011> + - (0.062500,0.000000) |00000000001001111000011101> + - (0.062500,0.000000) |00000000001001111011000000> + - (0.062500,0.000000) |00000000001001111011000110> + - (0.062500,0.000000) |00000000001001111011011011> + - (0.062500,0.000000) |00000000001001111011011101> + - (0.062500,0.000000) |00000000001001111101101011> + - (0.062500,0.000000) |00000000001001111101101101> + - (0.062500,0.000000) |00000000001001111101110000> + - (0.062500,0.000000) |00000000001001111101110110> + - (0.062500,0.000000) |00000000001001111110101011> + - (0.062500,0.000000) |00000000001001111110101101> + - (0.062500,0.000000) |00000000001001111110110000> + - (0.062500,0.000000) |00000000001001111110110110> + - (0.062500,0.000000) |00000000001010010000000000> + - (0.062500,0.000000) |00000000001010010000000110> + - (0.062500,0.000000) |00000000001010010000011011> + - (0.062500,0.000000) |00000000001010010000011101> + - (0.062500,0.000000) |00000000001010010011000000> + - (0.062500,0.000000) |00000000001010010011000110> + - (0.062500,0.000000) |00000000001010010011011011> + - (0.062500,0.000000) |00000000001010010011011101> + - (0.062500,0.000000) |00000000001010010101101011> + - (0.062500,0.000000) |00000000001010010101101101> + - (0.062500,0.000000) |00000000001010010101110000> + - (0.062500,0.000000) |00000000001010010101110110> + - (0.062500,0.000000) |00000000001010010110101011> + - (0.062500,0.000000) |00000000001010010110101101> + - (0.062500,0.000000) |00000000001010010110110000> + - (0.062500,0.000000) |00000000001010010110110110> + - (0.062500,0.000000) |00000000001010100000000000> + - (0.062500,0.000000) |00000000001010100000000110> + - (0.062500,0.000000) |00000000001010100000011011> + - (0.062500,0.000000) |00000000001010100000011101> + - (0.062500,0.000000) |00000000001010100011000000> + - (0.062500,0.000000) |00000000001010100011000110> + - (0.062500,0.000000) |00000000001010100011011011> + - (0.062500,0.000000) |00000000001010100011011101> + - (0.062500,0.000000) |00000000001010100101101011> + - (0.062500,0.000000) |00000000001010100101101101> + - (0.062500,0.000000) |00000000001010100101110000> + - (0.062500,0.000000) |00000000001010100101110110> + - (0.062500,0.000000) |00000000001010100110101011> + - (0.062500,0.000000) |00000000001010100110101101> + - (0.062500,0.000000) |00000000001010100110110000> + - (0.062500,0.000000) |00000000001010100110110110> + - (0.062500,0.000000) |00000000010001001000000000> + - (0.062500,0.000000) |00000000010001001000000110> + - (0.062500,0.000000) |00000000010001001000011011> + - (0.062500,0.000000) |00000000010001001000011101> + - (0.062500,0.000000) |00000000010001001011000000> + - (0.062500,0.000000) |00000000010001001011000110> + - (0.062500,0.000000) |00000000010001001011011011> + - (0.062500,0.000000) |00000000010001001011011101> + - (0.062500,0.000000) |00000000010001001101101011> + - (0.062500,0.000000) |00000000010001001101101101> + - (0.062500,0.000000) |00000000010001001101110000> + - (0.062500,0.000000) |00000000010001001101110110> + - (0.062500,0.000000) |00000000010001001110101011> + - (0.062500,0.000000) |00000000010001001110101101> + - (0.062500,0.000000) |00000000010001001110110000> + - (0.062500,0.000000) |00000000010001001110110110> + - (0.062500,0.000000) |00000000010001111000000000> + - (0.062500,0.000000) |00000000010001111000000110> + - (0.062500,0.000000) |00000000010001111000011011> + - (0.062500,0.000000) |00000000010001111000011101> + - (0.062500,0.000000) |00000000010001111011000000> + - (0.062500,0.000000) |00000000010001111011000110> + - (0.062500,0.000000) |00000000010001111011011011> + - (0.062500,0.000000) |00000000010001111011011101> + - (0.062500,0.000000) |00000000010001111101101011> + - (0.062500,0.000000) |00000000010001111101101101> + - (0.062500,0.000000) |00000000010001111101110000> + - (0.062500,0.000000) |00000000010001111101110110> + - (0.062500,0.000000) |00000000010001111110101011> + - (0.062500,0.000000) |00000000010001111110101101> + - (0.062500,0.000000) |00000000010001111110110000> + - (0.062500,0.000000) |00000000010001111110110110> + - (0.062500,0.000000) |00000000010010010000000000> + - (0.062500,0.000000) |00000000010010010000000110> + - (0.062500,0.000000) |00000000010010010000011011> + - (0.062500,0.000000) |00000000010010010000011101> + - (0.062500,0.000000) |00000000010010010011000000> + - (0.062500,0.000000) |00000000010010010011000110> + - (0.062500,0.000000) |00000000010010010011011011> + - (0.062500,0.000000) |00000000010010010011011101> + - (0.062500,0.000000) |00000000010010010101101011> + - (0.062500,0.000000) |00000000010010010101101101> + - (0.062500,0.000000) |00000000010010010101110000> + - (0.062500,0.000000) |00000000010010010101110110> + - (0.062500,0.000000) |00000000010010010110101011> + - (0.062500,0.000000) |00000000010010010110101101> + - (0.062500,0.000000) |00000000010010010110110000> + - (0.062500,0.000000) |00000000010010010110110110> + - (0.062500,0.000000) |00000000010010100000000000> + - (0.062500,0.000000) |00000000010010100000000110> + - (0.062500,0.000000) |00000000010010100000011011> + - (0.062500,0.000000) |00000000010010100000011101> + - (0.062500,0.000000) |00000000010010100011000000> + - (0.062500,0.000000) |00000000010010100011000110> + - (0.062500,0.000000) |00000000010010100011011011> + - (0.062500,0.000000) |00000000010010100011011101> + - (0.062500,0.000000) |00000000010010100101101011> + - (0.062500,0.000000) |00000000010010100101101101> + - (0.062500,0.000000) |00000000010010100101110000> + - (0.062500,0.000000) |00000000010010100101110110> + - (0.062500,0.000000) |00000000010010100110101011> + - (0.062500,0.000000) |00000000010010100110101101> + - (0.062500,0.000000) |00000000010010100110110000> + - (0.062500,0.000000) |00000000010010100110110110> + - (0.062500,0.000000) |00000000100100010000000000> + - (0.062500,0.000000) |00000000100100010000000110> + - (0.062500,0.000000) |00000000100100010000011011> + - (0.062500,0.000000) |00000000100100010000011101> + - (0.062500,0.000000) |00000000100100010011000000> + - (0.062500,0.000000) |00000000100100010011000110> + - (0.062500,0.000000) |00000000100100010011011011> + - (0.062500,0.000000) |00000000100100010011011101> + - (0.062500,0.000000) |00000000100100010101101011> + - (0.062500,0.000000) |00000000100100010101101101> + - (0.062500,0.000000) |00000000100100010101110000> + - (0.062500,0.000000) |00000000100100010101110110> + - (0.062500,0.000000) |00000000100100010110101011> + - (0.062500,0.000000) |00000000100100010110101101> + - (0.062500,0.000000) |00000000100100010110110000> + - (0.062500,0.000000) |00000000100100010110110110> + - (0.062500,0.000000) |00000000100100100000000000> + - (0.062500,0.000000) |00000000100100100000000110> + - (0.062500,0.000000) |00000000100100100000011011> + - (0.062500,0.000000) |00000000100100100000011101> + - (0.062500,0.000000) |00000000100100100011000000> + - (0.062500,0.000000) |00000000100100100011000110> + - (0.062500,0.000000) |00000000100100100011011011> + - (0.062500,0.000000) |00000000100100100011011101> + - (0.062500,0.000000) |00000000100100100101101011> + - (0.062500,0.000000) |00000000100100100101101101> + - (0.062500,0.000000) |00000000100100100101110000> + - (0.062500,0.000000) |00000000100100100101110110> + - (0.062500,0.000000) |00000000100100100110101011> + - (0.062500,0.000000) |00000000100100100110101101> + - (0.062500,0.000000) |00000000100100100110110000> + - (0.062500,0.000000) |00000000100100100110110110> + - (0.062500,0.000000) |00000000100111001000000000> + - (0.062500,0.000000) |00000000100111001000000110> + - (0.062500,0.000000) |00000000100111001000011011> + - (0.062500,0.000000) |00000000100111001000011101> + - (0.062500,0.000000) |00000000100111001011000000> + - (0.062500,0.000000) |00000000100111001011000110> + - (0.062500,0.000000) |00000000100111001011011011> + - (0.062500,0.000000) |00000000100111001011011101> + - (0.062500,0.000000) |00000000100111001101101011> + - (0.062500,0.000000) |00000000100111001101101101> + - (0.062500,0.000000) |00000000100111001101110000> + - (0.062500,0.000000) |00000000100111001101110110> + - (0.062500,0.000000) |00000000100111001110101011> + - (0.062500,0.000000) |00000000100111001110101101> + - (0.062500,0.000000) |00000000100111001110110000> + - (0.062500,0.000000) |00000000100111001110110110> + - (0.062500,0.000000) |00000000100111111000000000> + - (0.062500,0.000000) |00000000100111111000000110> + - (0.062500,0.000000) |00000000100111111000011011> + - (0.062500,0.000000) |00000000100111111000011101> + - (0.062500,0.000000) |00000000100111111011000000> + - (0.062500,0.000000) |00000000100111111011000110> + - (0.062500,0.000000) |00000000100111111011011011> + - (0.062500,0.000000) |00000000100111111011011101> + - (0.062500,0.000000) |00000000100111111101101011> + - (0.062500,0.000000) |00000000100111111101101101> + - (0.062500,0.000000) |00000000100111111101110000> + - (0.062500,0.000000) |00000000100111111101110110> + - (0.062500,0.000000) |00000000100111111110101011> + - (0.062500,0.000000) |00000000100111111110101101> + - (0.062500,0.000000) |00000000100111111110110000> + - (0.062500,0.000000) |00000000100111111110110110> + - (0.062500,0.000000) |00000000111100010000000000> + - (0.062500,0.000000) |00000000111100010000000110> + - (0.062500,0.000000) |00000000111100010000011011> + - (0.062500,0.000000) |00000000111100010000011101> + - (0.062500,0.000000) |00000000111100010011000000> + - (0.062500,0.000000) |00000000111100010011000110> + - (0.062500,0.000000) |00000000111100010011011011> + - (0.062500,0.000000) |00000000111100010011011101> + - (0.062500,0.000000) |00000000111100010101101011> + - (0.062500,0.000000) |00000000111100010101101101> + - (0.062500,0.000000) |00000000111100010101110000> + - (0.062500,0.000000) |00000000111100010101110110> + - (0.062500,0.000000) |00000000111100010110101011> + - (0.062500,0.000000) |00000000111100010110101101> + - (0.062500,0.000000) |00000000111100010110110000> + - (0.062500,0.000000) |00000000111100010110110110> + - (0.062500,0.000000) |00000000111100100000000000> + - (0.062500,0.000000) |00000000111100100000000110> + - (0.062500,0.000000) |00000000111100100000011011> + - (0.062500,0.000000) |00000000111100100000011101> + - (0.062500,0.000000) |00000000111100100011000000> + - (0.062500,0.000000) |00000000111100100011000110> + - (0.062500,0.000000) |00000000111100100011011011> + - (0.062500,0.000000) |00000000111100100011011101> + - (0.062500,0.000000) |00000000111100100101101011> + - (0.062500,0.000000) |00000000111100100101101101> + - (0.062500,0.000000) |00000000111100100101110000> + - (0.062500,0.000000) |00000000111100100101110110> + - (0.062500,0.000000) |00000000111100100110101011> + - (0.062500,0.000000) |00000000111100100110101101> + - (0.062500,0.000000) |00000000111100100110110000> + - (0.062500,0.000000) |00000000111100100110110110> + - (0.062500,0.000000) |00000000111111001000000000> + - (0.062500,0.000000) |00000000111111001000000110> + - (0.062500,0.000000) |00000000111111001000011011> + - (0.062500,0.000000) |00000000111111001000011101> + - (0.062500,0.000000) |00000000111111001011000000> + - (0.062500,0.000000) |00000000111111001011000110> + - (0.062500,0.000000) |00000000111111001011011011> + - (0.062500,0.000000) |00000000111111001011011101> + - (0.062500,0.000000) |00000000111111001101101011> + - (0.062500,0.000000) |00000000111111001101101101> + - (0.062500,0.000000) |00000000111111001101110000> + - (0.062500,0.000000) |00000000111111001101110110> + - (0.062500,0.000000) |00000000111111001110101011> + - (0.062500,0.000000) |00000000111111001110101101> + - (0.062500,0.000000) |00000000111111001110110000> + - (0.062500,0.000000) |00000000111111001110110110> + - (0.062500,0.000000) |00000000111111111000000000> + - (0.062500,0.000000) |00000000111111111000000110> + - (0.062500,0.000000) |00000000111111111000011011> + - (0.062500,0.000000) |00000000111111111000011101> + - (0.062500,0.000000) |00000000111111111011000000> + - (0.062500,0.000000) |00000000111111111011000110> + - (0.062500,0.000000) |00000000111111111011011011> + - (0.062500,0.000000) |00000000111111111011011101> + - (0.062500,0.000000) |00000000111111111101101011> + - (0.062500,0.000000) |00000000111111111101101101> + - (0.062500,0.000000) |00000000111111111101110000> + - (0.062500,0.000000) |00000000111111111101110110> + - (0.062500,0.000000) |00000000111111111110101011> + - (0.062500,0.000000) |00000000111111111110101101> + - (0.062500,0.000000) |00000000111111111110110000> + - (0.062500,0.000000) |00000000111111111110110110> + -[>>] binary register: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | -------------------------------------------- -[+] circuit execution time: 0.119171 sec. diff --git a/tests/circuits/result_of_the_execution_of_transversal_cnot_on_11_logical_state.txt b/tests/circuits/result_of_the_execution_of_transversal_cnot_on_11_logical_state.txt deleted file mode 100644 index f8342569..00000000 --- a/tests/circuits/result_of_the_execution_of_transversal_cnot_on_11_logical_state.txt +++ /dev/null @@ -1,596 +0,0 @@ - - =================================================================================================== - _______ - / ___ \ _ __ ____ ____ __ ___ __ __ __ ___ ______ ____ ___ - / / / | | |/_/ / __/ / _/ / |/ / / / / / / / / _ |/_ __/ / __ \ / _ \ - / /___/ / _> < _\ \ _/ / / /|_/ / / /_/ / / /__ / __ | / / / /_/ / / , _/ - \______/\__\ /_/|_| /___/ /___/ /_/ /_/ \____/ /____//_/ |_|/_/ \____/ /_/|_| - - version 0.1 beta - QuTech - 2016 - report bugs and suggestions to: nader.khammassi@gmail.com - =================================================================================================== - -[+] loading circuit from 'transversal_cnot_on_17q_ninja_star.qc' ... -[-] loading quantum_code file 'transversal_cnot_on_17q_ninja_star.qc'... -[+] code loaded successfully. -[+] initializing xpu... -[+] initialized. -[+] creating quantum register of 26 qubits... -[+] executing circuit 'initializing_first_qubit_to_logical_0_state' ... -[+] circuit execution time: 60.0021 sec. -[+] executing circuit 'start_surface_code_cycle' ... -[+] circuit execution time: 35.2956 sec. -[+] executing circuit 'round_1' ... -[+] circuit execution time: 1.15371 sec. -[+] executing circuit 'round_2' ... -[+] circuit execution time: 1.18526 sec. -[+] executing circuit 'round_3' ... -[+] circuit execution time: 1.19037 sec. -[+] executing circuit 'round_4' ... -[+] circuit execution time: 1.07547 sec. -[+] executing circuit 'syndromes_measurements' ... -[>>] binary register: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | X | X | X | X | X | X | X | X | X | -------------------------------------------- -[+] circuit execution time: 24.0269 sec. -[+] executing circuit 'set_first_qubit_to_logical_1_state' ... ---------------[quantum state]-------------- - (0.250000,0.000000) |00000000000000000001001001> + - (0.250000,0.000000) |00000000000000000001001111> + - (0.250000,0.000000) |00000000000000000001010010> + - (0.250000,0.000000) |00000000000000000001010100> + - (0.250000,0.000000) |00000000000000000010001001> + - (0.250000,0.000000) |00000000000000000010001111> + - (0.250000,0.000000) |00000000000000000010010010> + - (0.250000,0.000000) |00000000000000000010010100> + - (0.250000,0.000000) |00000000000000000100100010> + - (0.250000,0.000000) |00000000000000000100100100> + - (0.250000,0.000000) |00000000000000000100111001> + - (0.250000,0.000000) |00000000000000000100111111> + - (0.250000,0.000000) |00000000000000000111100010> + - (0.250000,0.000000) |00000000000000000111100100> + - (0.250000,0.000000) |00000000000000000111111001> + - (0.250000,0.000000) |00000000000000000111111111> + -[>>] binary register: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | X | X | X | X | X | X | X | X | X | -------------------------------------------- -[+] circuit execution time: 16.089044 sec. -[+] executing circuit 'initialize_second_qubit_to_logical_0_state' ... -[+] circuit execution time: 63.546451 sec. -[+] executing circuit 'start_surface_code_cycle' ... -[+] circuit execution time: 33.318410 sec. -[+] executing circuit 'round_1' ... -[+] circuit execution time: 1.005124 sec. -[+] executing circuit 'round_2' ... -[+] circuit execution time: 0.991059 sec. -[+] executing circuit 'round_3' ... -[+] circuit execution time: 1.017883 sec. -[+] executing circuit 'round_4' ... -[+] circuit execution time: 0.995314 sec. -[+] executing circuit 'measurements' ... -[>>] binary register: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | -------------------------------------------- -[+] circuit execution time: 24.304411 sec. -[+] executing circuit 'set_second_logical_qubit_to_logical_1_state' ... -[+] circuit execution time: 17.148509 sec. -[+] executing circuit 'state_before_the_transversal_cnot' ... ---------------[quantum state]-------------- - (0.062500,0.000000) |00000000001001001001001001> + - (0.062500,0.000000) |00000000001001001001001111> + - (0.062500,0.000000) |00000000001001001001010010> + - (0.062500,0.000000) |00000000001001001001010100> + - (0.062500,0.000000) |00000000001001001010001001> + - (0.062500,0.000000) |00000000001001001010001111> + - (0.062500,0.000000) |00000000001001001010010010> + - (0.062500,0.000000) |00000000001001001010010100> + - (0.062500,0.000000) |00000000001001001100100010> + - (0.062500,0.000000) |00000000001001001100100100> + - (0.062500,0.000000) |00000000001001001100111001> + - (0.062500,0.000000) |00000000001001001100111111> + - (0.062500,0.000000) |00000000001001001111100010> + - (0.062500,0.000000) |00000000001001001111100100> + - (0.062500,0.000000) |00000000001001001111111001> + - (0.062500,0.000000) |00000000001001001111111111> + - (0.062500,0.000000) |00000000001001111001001001> + - (0.062500,0.000000) |00000000001001111001001111> + - (0.062500,0.000000) |00000000001001111001010010> + - (0.062500,0.000000) |00000000001001111001010100> + - (0.062500,0.000000) |00000000001001111010001001> + - (0.062500,0.000000) |00000000001001111010001111> + - (0.062500,0.000000) |00000000001001111010010010> + - (0.062500,0.000000) |00000000001001111010010100> + - (0.062500,0.000000) |00000000001001111100100010> + - (0.062500,0.000000) |00000000001001111100100100> + - (0.062500,0.000000) |00000000001001111100111001> + - (0.062500,0.000000) |00000000001001111100111111> + - (0.062500,0.000000) |00000000001001111111100010> + - (0.062500,0.000000) |00000000001001111111100100> + - (0.062500,0.000000) |00000000001001111111111001> + - (0.062500,0.000000) |00000000001001111111111111> + - (0.062500,0.000000) |00000000001010010001001001> + - (0.062500,0.000000) |00000000001010010001001111> + - (0.062500,0.000000) |00000000001010010001010010> + - (0.062500,0.000000) |00000000001010010001010100> + - (0.062500,0.000000) |00000000001010010010001001> + - (0.062500,0.000000) |00000000001010010010001111> + - (0.062500,0.000000) |00000000001010010010010010> + - (0.062500,0.000000) |00000000001010010010010100> + - (0.062500,0.000000) |00000000001010010100100010> + - (0.062500,0.000000) |00000000001010010100100100> + - (0.062500,0.000000) |00000000001010010100111001> + - (0.062500,0.000000) |00000000001010010100111111> + - (0.062500,0.000000) |00000000001010010111100010> + - (0.062500,0.000000) |00000000001010010111100100> + - (0.062500,0.000000) |00000000001010010111111001> + - (0.062500,0.000000) |00000000001010010111111111> + - (0.062500,0.000000) |00000000001010100001001001> + - (0.062500,0.000000) |00000000001010100001001111> + - (0.062500,0.000000) |00000000001010100001010010> + - (0.062500,0.000000) |00000000001010100001010100> + - (0.062500,0.000000) |00000000001010100010001001> + - (0.062500,0.000000) |00000000001010100010001111> + - (0.062500,0.000000) |00000000001010100010010010> + - (0.062500,0.000000) |00000000001010100010010100> + - (0.062500,0.000000) |00000000001010100100100010> + - (0.062500,0.000000) |00000000001010100100100100> + - (0.062500,0.000000) |00000000001010100100111001> + - (0.062500,0.000000) |00000000001010100100111111> + - (0.062500,0.000000) |00000000001010100111100010> + - (0.062500,0.000000) |00000000001010100111100100> + - (0.062500,0.000000) |00000000001010100111111001> + - (0.062500,0.000000) |00000000001010100111111111> + - (0.062500,0.000000) |00000000010001001001001001> + - (0.062500,0.000000) |00000000010001001001001111> + - (0.062500,0.000000) |00000000010001001001010010> + - (0.062500,0.000000) |00000000010001001001010100> + - (0.062500,0.000000) |00000000010001001010001001> + - (0.062500,0.000000) |00000000010001001010001111> + - (0.062500,0.000000) |00000000010001001010010010> + - (0.062500,0.000000) |00000000010001001010010100> + - (0.062500,0.000000) |00000000010001001100100010> + - (0.062500,0.000000) |00000000010001001100100100> + - (0.062500,0.000000) |00000000010001001100111001> + - (0.062500,0.000000) |00000000010001001100111111> + - (0.062500,0.000000) |00000000010001001111100010> + - (0.062500,0.000000) |00000000010001001111100100> + - (0.062500,0.000000) |00000000010001001111111001> + - (0.062500,0.000000) |00000000010001001111111111> + - (0.062500,0.000000) |00000000010001111001001001> + - (0.062500,0.000000) |00000000010001111001001111> + - (0.062500,0.000000) |00000000010001111001010010> + - (0.062500,0.000000) |00000000010001111001010100> + - (0.062500,0.000000) |00000000010001111010001001> + - (0.062500,0.000000) |00000000010001111010001111> + - (0.062500,0.000000) |00000000010001111010010010> + - (0.062500,0.000000) |00000000010001111010010100> + - (0.062500,0.000000) |00000000010001111100100010> + - (0.062500,0.000000) |00000000010001111100100100> + - (0.062500,0.000000) |00000000010001111100111001> + - (0.062500,0.000000) |00000000010001111100111111> + - (0.062500,0.000000) |00000000010001111111100010> + - (0.062500,0.000000) |00000000010001111111100100> + - (0.062500,0.000000) |00000000010001111111111001> + - (0.062500,0.000000) |00000000010001111111111111> + - (0.062500,0.000000) |00000000010010010001001001> + - (0.062500,0.000000) |00000000010010010001001111> + - (0.062500,0.000000) |00000000010010010001010010> + - (0.062500,0.000000) |00000000010010010001010100> + - (0.062500,0.000000) |00000000010010010010001001> + - (0.062500,0.000000) |00000000010010010010001111> + - (0.062500,0.000000) |00000000010010010010010010> + - (0.062500,0.000000) |00000000010010010010010100> + - (0.062500,0.000000) |00000000010010010100100010> + - (0.062500,0.000000) |00000000010010010100100100> + - (0.062500,0.000000) |00000000010010010100111001> + - (0.062500,0.000000) |00000000010010010100111111> + - (0.062500,0.000000) |00000000010010010111100010> + - (0.062500,0.000000) |00000000010010010111100100> + - (0.062500,0.000000) |00000000010010010111111001> + - (0.062500,0.000000) |00000000010010010111111111> + - (0.062500,0.000000) |00000000010010100001001001> + - (0.062500,0.000000) |00000000010010100001001111> + - (0.062500,0.000000) |00000000010010100001010010> + - (0.062500,0.000000) |00000000010010100001010100> + - (0.062500,0.000000) |00000000010010100010001001> + - (0.062500,0.000000) |00000000010010100010001111> + - (0.062500,0.000000) |00000000010010100010010010> + - (0.062500,0.000000) |00000000010010100010010100> + - (0.062500,0.000000) |00000000010010100100100010> + - (0.062500,0.000000) |00000000010010100100100100> + - (0.062500,0.000000) |00000000010010100100111001> + - (0.062500,0.000000) |00000000010010100100111111> + - (0.062500,0.000000) |00000000010010100111100010> + - (0.062500,0.000000) |00000000010010100111100100> + - (0.062500,0.000000) |00000000010010100111111001> + - (0.062500,0.000000) |00000000010010100111111111> + - (0.062500,0.000000) |00000000100100010001001001> + - (0.062500,0.000000) |00000000100100010001001111> + - (0.062500,0.000000) |00000000100100010001010010> + - (0.062500,0.000000) |00000000100100010001010100> + - (0.062500,0.000000) |00000000100100010010001001> + - (0.062500,0.000000) |00000000100100010010001111> + - (0.062500,0.000000) |00000000100100010010010010> + - (0.062500,0.000000) |00000000100100010010010100> + - (0.062500,0.000000) |00000000100100010100100010> + - (0.062500,0.000000) |00000000100100010100100100> + - (0.062500,0.000000) |00000000100100010100111001> + - (0.062500,0.000000) |00000000100100010100111111> + - (0.062500,0.000000) |00000000100100010111100010> + - (0.062500,0.000000) |00000000100100010111100100> + - (0.062500,0.000000) |00000000100100010111111001> + - (0.062500,0.000000) |00000000100100010111111111> + - (0.062500,0.000000) |00000000100100100001001001> + - (0.062500,0.000000) |00000000100100100001001111> + - (0.062500,0.000000) |00000000100100100001010010> + - (0.062500,0.000000) |00000000100100100001010100> + - (0.062500,0.000000) |00000000100100100010001001> + - (0.062500,0.000000) |00000000100100100010001111> + - (0.062500,0.000000) |00000000100100100010010010> + - (0.062500,0.000000) |00000000100100100010010100> + - (0.062500,0.000000) |00000000100100100100100010> + - (0.062500,0.000000) |00000000100100100100100100> + - (0.062500,0.000000) |00000000100100100100111001> + - (0.062500,0.000000) |00000000100100100100111111> + - (0.062500,0.000000) |00000000100100100111100010> + - (0.062500,0.000000) |00000000100100100111100100> + - (0.062500,0.000000) |00000000100100100111111001> + - (0.062500,0.000000) |00000000100100100111111111> + - (0.062500,0.000000) |00000000100111001001001001> + - (0.062500,0.000000) |00000000100111001001001111> + - (0.062500,0.000000) |00000000100111001001010010> + - (0.062500,0.000000) |00000000100111001001010100> + - (0.062500,0.000000) |00000000100111001010001001> + - (0.062500,0.000000) |00000000100111001010001111> + - (0.062500,0.000000) |00000000100111001010010010> + - (0.062500,0.000000) |00000000100111001010010100> + - (0.062500,0.000000) |00000000100111001100100010> + - (0.062500,0.000000) |00000000100111001100100100> + - (0.062500,0.000000) |00000000100111001100111001> + - (0.062500,0.000000) |00000000100111001100111111> + - (0.062500,0.000000) |00000000100111001111100010> + - (0.062500,0.000000) |00000000100111001111100100> + - (0.062500,0.000000) |00000000100111001111111001> + - (0.062500,0.000000) |00000000100111001111111111> + - (0.062500,0.000000) |00000000100111111001001001> + - (0.062500,0.000000) |00000000100111111001001111> + - (0.062500,0.000000) |00000000100111111001010010> + - (0.062500,0.000000) |00000000100111111001010100> + - (0.062500,0.000000) |00000000100111111010001001> + - (0.062500,0.000000) |00000000100111111010001111> + - (0.062500,0.000000) |00000000100111111010010010> + - (0.062500,0.000000) |00000000100111111010010100> + - (0.062500,0.000000) |00000000100111111100100010> + - (0.062500,0.000000) |00000000100111111100100100> + - (0.062500,0.000000) |00000000100111111100111001> + - (0.062500,0.000000) |00000000100111111100111111> + - (0.062500,0.000000) |00000000100111111111100010> + - (0.062500,0.000000) |00000000100111111111100100> + - (0.062500,0.000000) |00000000100111111111111001> + - (0.062500,0.000000) |00000000100111111111111111> + - (0.062500,0.000000) |00000000111100010001001001> + - (0.062500,0.000000) |00000000111100010001001111> + - (0.062500,0.000000) |00000000111100010001010010> + - (0.062500,0.000000) |00000000111100010001010100> + - (0.062500,0.000000) |00000000111100010010001001> + - (0.062500,0.000000) |00000000111100010010001111> + - (0.062500,0.000000) |00000000111100010010010010> + - (0.062500,0.000000) |00000000111100010010010100> + - (0.062500,0.000000) |00000000111100010100100010> + - (0.062500,0.000000) |00000000111100010100100100> + - (0.062500,0.000000) |00000000111100010100111001> + - (0.062500,0.000000) |00000000111100010100111111> + - (0.062500,0.000000) |00000000111100010111100010> + - (0.062500,0.000000) |00000000111100010111100100> + - (0.062500,0.000000) |00000000111100010111111001> + - (0.062500,0.000000) |00000000111100010111111111> + - (0.062500,0.000000) |00000000111100100001001001> + - (0.062500,0.000000) |00000000111100100001001111> + - (0.062500,0.000000) |00000000111100100001010010> + - (0.062500,0.000000) |00000000111100100001010100> + - (0.062500,0.000000) |00000000111100100010001001> + - (0.062500,0.000000) |00000000111100100010001111> + - (0.062500,0.000000) |00000000111100100010010010> + - (0.062500,0.000000) |00000000111100100010010100> + - (0.062500,0.000000) |00000000111100100100100010> + - (0.062500,0.000000) |00000000111100100100100100> + - (0.062500,0.000000) |00000000111100100100111001> + - (0.062500,0.000000) |00000000111100100100111111> + - (0.062500,0.000000) |00000000111100100111100010> + - (0.062500,0.000000) |00000000111100100111100100> + - (0.062500,0.000000) |00000000111100100111111001> + - (0.062500,0.000000) |00000000111100100111111111> + - (0.062500,0.000000) |00000000111111001001001001> + - (0.062500,0.000000) |00000000111111001001001111> + - (0.062500,0.000000) |00000000111111001001010010> + - (0.062500,0.000000) |00000000111111001001010100> + - (0.062500,0.000000) |00000000111111001010001001> + - (0.062500,0.000000) |00000000111111001010001111> + - (0.062500,0.000000) |00000000111111001010010010> + - (0.062500,0.000000) |00000000111111001010010100> + - (0.062500,0.000000) |00000000111111001100100010> + - (0.062500,0.000000) |00000000111111001100100100> + - (0.062500,0.000000) |00000000111111001100111001> + - (0.062500,0.000000) |00000000111111001100111111> + - (0.062500,0.000000) |00000000111111001111100010> + - (0.062500,0.000000) |00000000111111001111100100> + - (0.062500,0.000000) |00000000111111001111111001> + - (0.062500,0.000000) |00000000111111001111111111> + - (0.062500,0.000000) |00000000111111111001001001> + - (0.062500,0.000000) |00000000111111111001001111> + - (0.062500,0.000000) |00000000111111111001010010> + - (0.062500,0.000000) |00000000111111111001010100> + - (0.062500,0.000000) |00000000111111111010001001> + - (0.062500,0.000000) |00000000111111111010001111> + - (0.062500,0.000000) |00000000111111111010010010> + - (0.062500,0.000000) |00000000111111111010010100> + - (0.062500,0.000000) |00000000111111111100100010> + - (0.062500,0.000000) |00000000111111111100100100> + - (0.062500,0.000000) |00000000111111111100111001> + - (0.062500,0.000000) |00000000111111111100111111> + - (0.062500,0.000000) |00000000111111111111100010> + - (0.062500,0.000000) |00000000111111111111100100> + - (0.062500,0.000000) |00000000111111111111111001> + - (0.062500,0.000000) |00000000111111111111111111> + -[>>] binary register: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | -------------------------------------------- -[+] circuit execution time: 0.123438 sec. -[+] executing circuit 'transversal_cnot' ... -[+] circuit execution time: 1.903713 sec. -[+] executing circuit 'state_after_the_transversal_cnot' ... ---------------[quantum state]-------------- - (0.062500,0.000000) |00000000000000000001001001> + - (0.062500,0.000000) |00000000000000000001001111> + - (0.062500,0.000000) |00000000000000000001010010> + - (0.062500,0.000000) |00000000000000000001010100> + - (0.062500,0.000000) |00000000000000000010001001> + - (0.062500,0.000000) |00000000000000000010001111> + - (0.062500,0.000000) |00000000000000000010010010> + - (0.062500,0.000000) |00000000000000000010010100> + - (0.062500,0.000000) |00000000000000000100100010> + - (0.062500,0.000000) |00000000000000000100100100> + - (0.062500,0.000000) |00000000000000000100111001> + - (0.062500,0.000000) |00000000000000000100111111> + - (0.062500,0.000000) |00000000000000000111100010> + - (0.062500,0.000000) |00000000000000000111100100> + - (0.062500,0.000000) |00000000000000000111111001> + - (0.062500,0.000000) |00000000000000000111111111> + - (0.062500,0.000000) |00000000000000110001001001> + - (0.062500,0.000000) |00000000000000110001001111> + - (0.062500,0.000000) |00000000000000110001010010> + - (0.062500,0.000000) |00000000000000110001010100> + - (0.062500,0.000000) |00000000000000110010001001> + - (0.062500,0.000000) |00000000000000110010001111> + - (0.062500,0.000000) |00000000000000110010010010> + - (0.062500,0.000000) |00000000000000110010010100> + - (0.062500,0.000000) |00000000000000110100100010> + - (0.062500,0.000000) |00000000000000110100100100> + - (0.062500,0.000000) |00000000000000110100111001> + - (0.062500,0.000000) |00000000000000110100111111> + - (0.062500,0.000000) |00000000000000110111100010> + - (0.062500,0.000000) |00000000000000110111100100> + - (0.062500,0.000000) |00000000000000110111111001> + - (0.062500,0.000000) |00000000000000110111111111> + - (0.062500,0.000000) |00000000000011011001001001> + - (0.062500,0.000000) |00000000000011011001001111> + - (0.062500,0.000000) |00000000000011011001010010> + - (0.062500,0.000000) |00000000000011011001010100> + - (0.062500,0.000000) |00000000000011011010001001> + - (0.062500,0.000000) |00000000000011011010001111> + - (0.062500,0.000000) |00000000000011011010010010> + - (0.062500,0.000000) |00000000000011011010010100> + - (0.062500,0.000000) |00000000000011011100100010> + - (0.062500,0.000000) |00000000000011011100100100> + - (0.062500,0.000000) |00000000000011011100111001> + - (0.062500,0.000000) |00000000000011011100111111> + - (0.062500,0.000000) |00000000000011011111100010> + - (0.062500,0.000000) |00000000000011011111100100> + - (0.062500,0.000000) |00000000000011011111111001> + - (0.062500,0.000000) |00000000000011011111111111> + - (0.062500,0.000000) |00000000000011101001001001> + - (0.062500,0.000000) |00000000000011101001001111> + - (0.062500,0.000000) |00000000000011101001010010> + - (0.062500,0.000000) |00000000000011101001010100> + - (0.062500,0.000000) |00000000000011101010001001> + - (0.062500,0.000000) |00000000000011101010001111> + - (0.062500,0.000000) |00000000000011101010010010> + - (0.062500,0.000000) |00000000000011101010010100> + - (0.062500,0.000000) |00000000000011101100100010> + - (0.062500,0.000000) |00000000000011101100100100> + - (0.062500,0.000000) |00000000000011101100111001> + - (0.062500,0.000000) |00000000000011101100111111> + - (0.062500,0.000000) |00000000000011101111100010> + - (0.062500,0.000000) |00000000000011101111100100> + - (0.062500,0.000000) |00000000000011101111111001> + - (0.062500,0.000000) |00000000000011101111111111> + - (0.062500,0.000000) |00000000011000000001001001> + - (0.062500,0.000000) |00000000011000000001001111> + - (0.062500,0.000000) |00000000011000000001010010> + - (0.062500,0.000000) |00000000011000000001010100> + - (0.062500,0.000000) |00000000011000000010001001> + - (0.062500,0.000000) |00000000011000000010001111> + - (0.062500,0.000000) |00000000011000000010010010> + - (0.062500,0.000000) |00000000011000000010010100> + - (0.062500,0.000000) |00000000011000000100100010> + - (0.062500,0.000000) |00000000011000000100100100> + - (0.062500,0.000000) |00000000011000000100111001> + - (0.062500,0.000000) |00000000011000000100111111> + - (0.062500,0.000000) |00000000011000000111100010> + - (0.062500,0.000000) |00000000011000000111100100> + - (0.062500,0.000000) |00000000011000000111111001> + - (0.062500,0.000000) |00000000011000000111111111> + - (0.062500,0.000000) |00000000011000110001001001> + - (0.062500,0.000000) |00000000011000110001001111> + - (0.062500,0.000000) |00000000011000110001010010> + - (0.062500,0.000000) |00000000011000110001010100> + - (0.062500,0.000000) |00000000011000110010001001> + - (0.062500,0.000000) |00000000011000110010001111> + - (0.062500,0.000000) |00000000011000110010010010> + - (0.062500,0.000000) |00000000011000110010010100> + - (0.062500,0.000000) |00000000011000110100100010> + - (0.062500,0.000000) |00000000011000110100100100> + - (0.062500,0.000000) |00000000011000110100111001> + - (0.062500,0.000000) |00000000011000110100111111> + - (0.062500,0.000000) |00000000011000110111100010> + - (0.062500,0.000000) |00000000011000110111100100> + - (0.062500,0.000000) |00000000011000110111111001> + - (0.062500,0.000000) |00000000011000110111111111> + - (0.062500,0.000000) |00000000011011011001001001> + - (0.062500,0.000000) |00000000011011011001001111> + - (0.062500,0.000000) |00000000011011011001010010> + - (0.062500,0.000000) |00000000011011011001010100> + - (0.062500,0.000000) |00000000011011011010001001> + - (0.062500,0.000000) |00000000011011011010001111> + - (0.062500,0.000000) |00000000011011011010010010> + - (0.062500,0.000000) |00000000011011011010010100> + - (0.062500,0.000000) |00000000011011011100100010> + - (0.062500,0.000000) |00000000011011011100100100> + - (0.062500,0.000000) |00000000011011011100111001> + - (0.062500,0.000000) |00000000011011011100111111> + - (0.062500,0.000000) |00000000011011011111100010> + - (0.062500,0.000000) |00000000011011011111100100> + - (0.062500,0.000000) |00000000011011011111111001> + - (0.062500,0.000000) |00000000011011011111111111> + - (0.062500,0.000000) |00000000011011101001001001> + - (0.062500,0.000000) |00000000011011101001001111> + - (0.062500,0.000000) |00000000011011101001010010> + - (0.062500,0.000000) |00000000011011101001010100> + - (0.062500,0.000000) |00000000011011101010001001> + - (0.062500,0.000000) |00000000011011101010001111> + - (0.062500,0.000000) |00000000011011101010010010> + - (0.062500,0.000000) |00000000011011101010010100> + - (0.062500,0.000000) |00000000011011101100100010> + - (0.062500,0.000000) |00000000011011101100100100> + - (0.062500,0.000000) |00000000011011101100111001> + - (0.062500,0.000000) |00000000011011101100111111> + - (0.062500,0.000000) |00000000011011101111100010> + - (0.062500,0.000000) |00000000011011101111100100> + - (0.062500,0.000000) |00000000011011101111111001> + - (0.062500,0.000000) |00000000011011101111111111> + - (0.062500,0.000000) |00000000101101011001001001> + - (0.062500,0.000000) |00000000101101011001001111> + - (0.062500,0.000000) |00000000101101011001010010> + - (0.062500,0.000000) |00000000101101011001010100> + - (0.062500,0.000000) |00000000101101011010001001> + - (0.062500,0.000000) |00000000101101011010001111> + - (0.062500,0.000000) |00000000101101011010010010> + - (0.062500,0.000000) |00000000101101011010010100> + - (0.062500,0.000000) |00000000101101011100100010> + - (0.062500,0.000000) |00000000101101011100100100> + - (0.062500,0.000000) |00000000101101011100111001> + - (0.062500,0.000000) |00000000101101011100111111> + - (0.062500,0.000000) |00000000101101011111100010> + - (0.062500,0.000000) |00000000101101011111100100> + - (0.062500,0.000000) |00000000101101011111111001> + - (0.062500,0.000000) |00000000101101011111111111> + - (0.062500,0.000000) |00000000101101101001001001> + - (0.062500,0.000000) |00000000101101101001001111> + - (0.062500,0.000000) |00000000101101101001010010> + - (0.062500,0.000000) |00000000101101101001010100> + - (0.062500,0.000000) |00000000101101101010001001> + - (0.062500,0.000000) |00000000101101101010001111> + - (0.062500,0.000000) |00000000101101101010010010> + - (0.062500,0.000000) |00000000101101101010010100> + - (0.062500,0.000000) |00000000101101101100100010> + - (0.062500,0.000000) |00000000101101101100100100> + - (0.062500,0.000000) |00000000101101101100111001> + - (0.062500,0.000000) |00000000101101101100111111> + - (0.062500,0.000000) |00000000101101101111100010> + - (0.062500,0.000000) |00000000101101101111100100> + - (0.062500,0.000000) |00000000101101101111111001> + - (0.062500,0.000000) |00000000101101101111111111> + - (0.062500,0.000000) |00000000101110000001001001> + - (0.062500,0.000000) |00000000101110000001001111> + - (0.062500,0.000000) |00000000101110000001010010> + - (0.062500,0.000000) |00000000101110000001010100> + - (0.062500,0.000000) |00000000101110000010001001> + - (0.062500,0.000000) |00000000101110000010001111> + - (0.062500,0.000000) |00000000101110000010010010> + - (0.062500,0.000000) |00000000101110000010010100> + - (0.062500,0.000000) |00000000101110000100100010> + - (0.062500,0.000000) |00000000101110000100100100> + - (0.062500,0.000000) |00000000101110000100111001> + - (0.062500,0.000000) |00000000101110000100111111> + - (0.062500,0.000000) |00000000101110000111100010> + - (0.062500,0.000000) |00000000101110000111100100> + - (0.062500,0.000000) |00000000101110000111111001> + - (0.062500,0.000000) |00000000101110000111111111> + - (0.062500,0.000000) |00000000101110110001001001> + - (0.062500,0.000000) |00000000101110110001001111> + - (0.062500,0.000000) |00000000101110110001010010> + - (0.062500,0.000000) |00000000101110110001010100> + - (0.062500,0.000000) |00000000101110110010001001> + - (0.062500,0.000000) |00000000101110110010001111> + - (0.062500,0.000000) |00000000101110110010010010> + - (0.062500,0.000000) |00000000101110110010010100> + - (0.062500,0.000000) |00000000101110110100100010> + - (0.062500,0.000000) |00000000101110110100100100> + - (0.062500,0.000000) |00000000101110110100111001> + - (0.062500,0.000000) |00000000101110110100111111> + - (0.062500,0.000000) |00000000101110110111100010> + - (0.062500,0.000000) |00000000101110110111100100> + - (0.062500,0.000000) |00000000101110110111111001> + - (0.062500,0.000000) |00000000101110110111111111> + - (0.062500,0.000000) |00000000110101011001001001> + - (0.062500,0.000000) |00000000110101011001001111> + - (0.062500,0.000000) |00000000110101011001010010> + - (0.062500,0.000000) |00000000110101011001010100> + - (0.062500,0.000000) |00000000110101011010001001> + - (0.062500,0.000000) |00000000110101011010001111> + - (0.062500,0.000000) |00000000110101011010010010> + - (0.062500,0.000000) |00000000110101011010010100> + - (0.062500,0.000000) |00000000110101011100100010> + - (0.062500,0.000000) |00000000110101011100100100> + - (0.062500,0.000000) |00000000110101011100111001> + - (0.062500,0.000000) |00000000110101011100111111> + - (0.062500,0.000000) |00000000110101011111100010> + - (0.062500,0.000000) |00000000110101011111100100> + - (0.062500,0.000000) |00000000110101011111111001> + - (0.062500,0.000000) |00000000110101011111111111> + - (0.062500,0.000000) |00000000110101101001001001> + - (0.062500,0.000000) |00000000110101101001001111> + - (0.062500,0.000000) |00000000110101101001010010> + - (0.062500,0.000000) |00000000110101101001010100> + - (0.062500,0.000000) |00000000110101101010001001> + - (0.062500,0.000000) |00000000110101101010001111> + - (0.062500,0.000000) |00000000110101101010010010> + - (0.062500,0.000000) |00000000110101101010010100> + - (0.062500,0.000000) |00000000110101101100100010> + - (0.062500,0.000000) |00000000110101101100100100> + - (0.062500,0.000000) |00000000110101101100111001> + - (0.062500,0.000000) |00000000110101101100111111> + - (0.062500,0.000000) |00000000110101101111100010> + - (0.062500,0.000000) |00000000110101101111100100> + - (0.062500,0.000000) |00000000110101101111111001> + - (0.062500,0.000000) |00000000110101101111111111> + - (0.062500,0.000000) |00000000110110000001001001> + - (0.062500,0.000000) |00000000110110000001001111> + - (0.062500,0.000000) |00000000110110000001010010> + - (0.062500,0.000000) |00000000110110000001010100> + - (0.062500,0.000000) |00000000110110000010001001> + - (0.062500,0.000000) |00000000110110000010001111> + - (0.062500,0.000000) |00000000110110000010010010> + - (0.062500,0.000000) |00000000110110000010010100> + - (0.062500,0.000000) |00000000110110000100100010> + - (0.062500,0.000000) |00000000110110000100100100> + - (0.062500,0.000000) |00000000110110000100111001> + - (0.062500,0.000000) |00000000110110000100111111> + - (0.062500,0.000000) |00000000110110000111100010> + - (0.062500,0.000000) |00000000110110000111100100> + - (0.062500,0.000000) |00000000110110000111111001> + - (0.062500,0.000000) |00000000110110000111111111> + - (0.062500,0.000000) |00000000110110110001001001> + - (0.062500,0.000000) |00000000110110110001001111> + - (0.062500,0.000000) |00000000110110110001010010> + - (0.062500,0.000000) |00000000110110110001010100> + - (0.062500,0.000000) |00000000110110110010001001> + - (0.062500,0.000000) |00000000110110110010001111> + - (0.062500,0.000000) |00000000110110110010010010> + - (0.062500,0.000000) |00000000110110110010010100> + - (0.062500,0.000000) |00000000110110110100100010> + - (0.062500,0.000000) |00000000110110110100100100> + - (0.062500,0.000000) |00000000110110110100111001> + - (0.062500,0.000000) |00000000110110110100111111> + - (0.062500,0.000000) |00000000110110110111100010> + - (0.062500,0.000000) |00000000110110110111100100> + - (0.062500,0.000000) |00000000110110110111111001> + - (0.062500,0.000000) |00000000110110110111111111> + -[>>] binary register: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | -------------------------------------------- -[+] circuit execution time: 0.125054 sec. diff --git a/tests/circuits/rotation_rx.qc b/tests/circuits/rotation_rx.qc new file mode 100644 index 00000000..70198e9a --- /dev/null +++ b/tests/circuits/rotation_rx.qc @@ -0,0 +1,23 @@ +version 1.0 + +# file : rotation_rx.qc +# author : Nader Khammassi +# brief : x rotations test + +qubits 1 + + + .x_pi_rotation + prep_z q[0] + rx q[0],3.141592653589793 + display + + .pauli_x + prep_z q[0] + x q[0] + display + + .measurement + measure q[0] + display + diff --git a/tests/circuits/rotation_ry.qc b/tests/circuits/rotation_ry.qc new file mode 100644 index 00000000..98e08d8e --- /dev/null +++ b/tests/circuits/rotation_ry.qc @@ -0,0 +1,22 @@ +version 1.0 + +# file : rotation_ry.qc +# author : Nader Khammassi +# brief : y rotations test + +qubits 1 + + .y_pi_rotation + prep_z q[0] + ry q[0],3.141592653589793 + display + + .pauli_y + prep_z q[0] + y q[0] + display + + .measurement + measure q[0] + display + diff --git a/tests/circuits/rotation_rz.qc b/tests/circuits/rotation_rz.qc new file mode 100644 index 00000000..ce8b69cf --- /dev/null +++ b/tests/circuits/rotation_rz.qc @@ -0,0 +1,27 @@ +version 1.0 + +# file : rotation_rz.qc +# author : Nader Khammassi +# brief : z rotations test + +qubits 1 + + +.z_pi_rotation + prep_z q[0] + x q[0] + rz q[0],3.141592653589793 + display + +.pauli_z + prep_z q[0] + z q[0] + x q[0] + z q[0] + display + + +.measurement + measure q[0] + display + diff --git a/tests/circuits/rotations.qc b/tests/circuits/rotations.qc new file mode 100644 index 00000000..8838818f --- /dev/null +++ b/tests/circuits/rotations.qc @@ -0,0 +1,48 @@ +version 1.0 + +# file : rotations.qc +# author : Nader Khammassi +# brief : x/y/z rotations test + +qubits 1 + + + .x_pi_rotation + prep_z q[0] + rx q[0],3.141592653589793 + display + + .pauli_x + prep_z q[0] + x q[0] + display + + + .y_pi_rotation + prep_z q[0] + ry q[0],3.141592653589793 + display + + .pauli_y + prep_z q[0] + y q[0] + display + + .z_pi_rotation + prep_z q[0] + x q[0] + rz q[0],3.141592653589793 + display + + .pauli_z + prep_z q[0] + z q[0] + x q[0] + z q[0] + display + + + .measurement + measure q[0] + display + diff --git a/tests/circuits/scaffold_hn.qc b/tests/circuits/scaffold_hn.qc deleted file mode 100644 index a51cdec9..00000000 --- a/tests/circuits/scaffold_hn.qc +++ /dev/null @@ -1,13 +0,0 @@ -qubits 7 -map q0, bits0 -map q1, bits1 -map q2, bits2 -map q3, bits3 -map q4, bits4 - -h bits0 -s bits1 -h bits2 -x bits0 - -# display \ No newline at end of file diff --git a/tests/circuits/test_i32.qc b/tests/circuits/test_i32.qc new file mode 100644 index 00000000..cb8af3da --- /dev/null +++ b/tests/circuits/test_i32.qc @@ -0,0 +1,977 @@ +version 1.0 +# cqasm generated by QI backend for QisKit +qubits 16 + +H q[15] +H q[14] +H q[13] +H q[12] +H q[11] +H q[10] +H q[9] +H q[8] +H q[7] +H q[6] +H q[5] +H q[4] +H q[3] +H q[2] +H q[1] +H q[0] +Rz q[0], 1.5707963267949 +Ry q[0], -1.5707963267949 +Rz q[0], 1.5707963267949 +Rz q[1], 1.5707963267949 +Ry q[1], -1.5707963267949 +Rz q[1], 1.5707963267949 +Rz q[2], 1.5707963267949 +Ry q[2], -1.5707963267949 +Rz q[2], 1.5707963267949 +Rz q[3], 1.5707963267949 +Ry q[3], -1.5707963267949 +Rz q[3], 1.5707963267949 +Rz q[4], 1.5707963267949 +Ry q[4], -1.5707963267949 +Rz q[4], 1.5707963267949 +Rz q[5], 1.5707963267949 +Ry q[5], -1.5707963267949 +Rz q[5], 1.5707963267949 +Rz q[6], 1.5707963267949 +Ry q[6], -1.5707963267949 +Rz q[6], 1.5707963267949 +Rz q[7], 1.5707963267949 +Ry q[7], -1.5707963267949 +Rz q[7], 1.5707963267949 +Rz q[8], 1.5707963267949 +Ry q[8], -1.5707963267949 +Rz q[8], 1.5707963267949 +Rz q[9], 1.5707963267949 +Ry q[9], -1.5707963267949 +Rz q[9], 1.5707963267949 +Rz q[10], 1.5707963267949 +Ry q[10], -1.5707963267949 +Rz q[10], 1.5707963267949 +Rz q[11], 1.5707963267949 +Ry q[11], -1.5707963267949 +Rz q[11], 1.5707963267949 +Rz q[12], 1.5707963267949 +Ry q[12], -1.5707963267949 +Rz q[12], 1.5707963267949 +Rz q[13], 1.5707963267949 +Ry q[13], -1.5707963267949 +Rz q[13], 1.5707963267949 +Rz q[14], 1.5707963267949 +Ry q[14], -1.5707963267949 +Rz q[14], 1.5707963267949 +Rz q[15], 1.5707963267949 +Ry q[15], -1.5707963267949 +Rz q[15], 1.5707963267949 + +CNOT q[1], q[0] +H q[1] +CNOT q[2], q[0] +H q[2] +CNOT q[3], q[0] +H q[3] +CNOT q[4], q[0] +H q[4] +CNOT q[5], q[0] +H q[5] +CNOT q[6], q[0] +H q[6] +CNOT q[7], q[0] +H q[7] +CNOT q[8], q[0] +H q[8] +CNOT q[9], q[0] +H q[9] +CNOT q[10], q[0] +H q[10] +CNOT q[11], q[0] +H q[11] +CNOT q[12], q[0] +H q[12] +CNOT q[13], q[0] +H q[13] +CNOT q[14], q[0] +H q[14] +CNOT q[15], q[0] +H q[15] +H q[0] +Rz q[0], 1.5707963267949 +Ry q[0], -1.5707963267949 +Rz q[0], 1.5707963267949 +Rz q[1], 1.5707963267949 +Ry q[1], -1.5707963267949 +Rz q[1], 1.5707963267949 +Rz q[2], 1.5707963267949 +Ry q[2], -1.5707963267949 +Rz q[2], 1.5707963267949 +Rz q[3], 1.5707963267949 +Ry q[3], -1.5707963267949 +Rz q[3], 1.5707963267949 +Rz q[4], 1.5707963267949 +Ry q[4], -1.5707963267949 +Rz q[4], 1.5707963267949 +Rz q[5], 1.5707963267949 +Ry q[5], -1.5707963267949 +Rz q[5], 1.5707963267949 +Rz q[6], 1.5707963267949 +Ry q[6], -1.5707963267949 +Rz q[6], 1.5707963267949 +Rz q[7], 1.5707963267949 +Ry q[7], -1.5707963267949 +Rz q[7], 1.5707963267949 +Rz q[8], 1.5707963267949 +Ry q[8], -1.5707963267949 +Rz q[8], 1.5707963267949 +Rz q[9], 1.5707963267949 +Ry q[9], -1.5707963267949 +Rz q[9], 1.5707963267949 +Rz q[10], 1.5707963267949 +Ry q[10], -1.5707963267949 +Rz q[10], 1.5707963267949 +Rz q[11], 1.5707963267949 +Ry q[11], -1.5707963267949 +Rz q[11], 1.5707963267949 +Rz q[12], 1.5707963267949 +Ry q[12], -1.5707963267949 +Rz q[12], 1.5707963267949 +Rz q[13], 1.5707963267949 +Ry q[13], -1.5707963267949 +Rz q[13], 1.5707963267949 +Rz q[14], 1.5707963267949 +Ry q[14], -1.5707963267949 +Rz q[14], 1.5707963267949 +Rz q[15], 1.5707963267949 +Ry q[15], -1.5707963267949 +Rz q[15], 1.5707963267949 +CNOT q[1], q[0] +H q[1] +CNOT q[2], q[0] +H q[2] +CNOT q[3], q[0] +H q[3] +CNOT q[4], q[0] +H q[4] +CNOT q[5], q[0] +H q[5] +CNOT q[6], q[0] +H q[6] +CNOT q[7], q[0] +H q[7] +CNOT q[8], q[0] +H q[8] +CNOT q[9], q[0] +H q[9] +CNOT q[10], q[0] +H q[10] +CNOT q[11], q[0] +H q[11] +CNOT q[12], q[0] +H q[12] +CNOT q[13], q[0] +H q[13] +CNOT q[14], q[0] +H q[14] +CNOT q[15], q[0] +H q[15] +H q[0] +Rz q[0], 1.5707963267949 +Ry q[0], -1.5707963267949 +Rz q[0], 1.5707963267949 +Rz q[1], 1.5707963267949 +Ry q[1], -1.5707963267949 +Rz q[1], 1.5707963267949 +Rz q[2], 1.5707963267949 +Ry q[2], -1.5707963267949 +Rz q[2], 1.5707963267949 +Rz q[3], 1.5707963267949 +Ry q[3], -1.5707963267949 +Rz q[3], 1.5707963267949 +Rz q[4], 1.5707963267949 +Ry q[4], -1.5707963267949 +Rz q[4], 1.5707963267949 +Rz q[5], 1.5707963267949 +Ry q[5], -1.5707963267949 +Rz q[5], 1.5707963267949 +Rz q[6], 1.5707963267949 +Ry q[6], -1.5707963267949 +Rz q[6], 1.5707963267949 +Rz q[7], 1.5707963267949 +Ry q[7], -1.5707963267949 +Rz q[7], 1.5707963267949 +Rz q[8], 1.5707963267949 +Ry q[8], -1.5707963267949 +Rz q[8], 1.5707963267949 +Rz q[9], 1.5707963267949 +Ry q[9], -1.5707963267949 +Rz q[9], 1.5707963267949 +Rz q[10], 1.5707963267949 +Ry q[10], -1.5707963267949 +Rz q[10], 1.5707963267949 +Rz q[11], 1.5707963267949 +Ry q[11], -1.5707963267949 +Rz q[11], 1.5707963267949 +Rz q[12], 1.5707963267949 +Ry q[12], -1.5707963267949 +Rz q[12], 1.5707963267949 +Rz q[13], 1.5707963267949 +Ry q[13], -1.5707963267949 +Rz q[13], 1.5707963267949 +Rz q[14], 1.5707963267949 +Ry q[14], -1.5707963267949 +Rz q[14], 1.5707963267949 +Rz q[15], 1.5707963267949 +Ry q[15], -1.5707963267949 +Rz q[15], 1.5707963267949 +CNOT q[1], q[0] +H q[1] +CNOT q[2], q[0] +H q[2] +CNOT q[3], q[0] +H q[3] +CNOT q[4], q[0] +H q[4] +CNOT q[5], q[0] +H q[5] +CNOT q[6], q[0] +H q[6] +CNOT q[7], q[0] +H q[7] +CNOT q[8], q[0] +H q[8] +CNOT q[9], q[0] +H q[9] +CNOT q[10], q[0] +H q[10] +CNOT q[11], q[0] +H q[11] +CNOT q[12], q[0] +H q[12] +CNOT q[13], q[0] +H q[13] +CNOT q[14], q[0] +H q[14] +CNOT q[15], q[0] +H q[15] +H q[0] +Rz q[0], 1.5707963267949 +Ry q[0], -1.5707963267949 +Rz q[0], 1.5707963267949 +Rz q[1], 1.5707963267949 +Ry q[1], -1.5707963267949 +Rz q[1], 1.5707963267949 +Rz q[2], 1.5707963267949 +Ry q[2], -1.5707963267949 +Rz q[2], 1.5707963267949 +Rz q[3], 1.5707963267949 +Ry q[3], -1.5707963267949 +Rz q[3], 1.5707963267949 +Rz q[4], 1.5707963267949 +Ry q[4], -1.5707963267949 +Rz q[4], 1.5707963267949 +Rz q[5], 1.5707963267949 +Ry q[5], -1.5707963267949 +Rz q[5], 1.5707963267949 +Rz q[6], 1.5707963267949 +Ry q[6], -1.5707963267949 +Rz q[6], 1.5707963267949 +Rz q[7], 1.5707963267949 +Ry q[7], -1.5707963267949 +Rz q[7], 1.5707963267949 +Rz q[8], 1.5707963267949 +Ry q[8], -1.5707963267949 +Rz q[8], 1.5707963267949 +Rz q[9], 1.5707963267949 +Ry q[9], -1.5707963267949 +Rz q[9], 1.5707963267949 +Rz q[10], 1.5707963267949 +Ry q[10], -1.5707963267949 +Rz q[10], 1.5707963267949 +Rz q[11], 1.5707963267949 +Ry q[11], -1.5707963267949 +Rz q[11], 1.5707963267949 +Rz q[12], 1.5707963267949 +Ry q[12], -1.5707963267949 +Rz q[12], 1.5707963267949 +Rz q[13], 1.5707963267949 +Ry q[13], -1.5707963267949 +Rz q[13], 1.5707963267949 +Rz q[14], 1.5707963267949 +Ry q[14], -1.5707963267949 +Rz q[14], 1.5707963267949 +Rz q[15], 1.5707963267949 +Ry q[15], -1.5707963267949 +Rz q[15], 1.5707963267949 +CNOT q[1], q[0] +H q[1] +CNOT q[2], q[0] +H q[2] +CNOT q[3], q[0] +H q[3] +CNOT q[4], q[0] +H q[4] +CNOT q[5], q[0] +H q[5] +CNOT q[6], q[0] +H q[6] +CNOT q[7], q[0] +H q[7] +CNOT q[8], q[0] +H q[8] +CNOT q[9], q[0] +H q[9] +CNOT q[10], q[0] +H q[10] +CNOT q[11], q[0] +H q[11] +CNOT q[12], q[0] +H q[12] +CNOT q[13], q[0] +H q[13] +CNOT q[14], q[0] +H q[14] +CNOT q[15], q[0] +H q[15] +H q[0] +Rz q[0], 1.5707963267949 +Ry q[0], -1.5707963267949 +Rz q[0], 1.5707963267949 +Rz q[1], 1.5707963267949 +Ry q[1], -1.5707963267949 +Rz q[1], 1.5707963267949 +Rz q[2], 1.5707963267949 +Ry q[2], -1.5707963267949 +Rz q[2], 1.5707963267949 +Rz q[3], 1.5707963267949 +Ry q[3], -1.5707963267949 +Rz q[3], 1.5707963267949 +Rz q[4], 1.5707963267949 +Ry q[4], -1.5707963267949 +Rz q[4], 1.5707963267949 +Rz q[5], 1.5707963267949 +Ry q[5], -1.5707963267949 +Rz q[5], 1.5707963267949 +Rz q[6], 1.5707963267949 +Ry q[6], -1.5707963267949 +Rz q[6], 1.5707963267949 +Rz q[7], 1.5707963267949 +Ry q[7], -1.5707963267949 +Rz q[7], 1.5707963267949 +Rz q[8], 1.5707963267949 +Ry q[8], -1.5707963267949 +Rz q[8], 1.5707963267949 +Rz q[9], 1.5707963267949 +Ry q[9], -1.5707963267949 +Rz q[9], 1.5707963267949 +Rz q[10], 1.5707963267949 +Ry q[10], -1.5707963267949 +Rz q[10], 1.5707963267949 +Rz q[11], 1.5707963267949 +Ry q[11], -1.5707963267949 +Rz q[11], 1.5707963267949 +Rz q[12], 1.5707963267949 +Ry q[12], -1.5707963267949 +Rz q[12], 1.5707963267949 +Rz q[13], 1.5707963267949 +Ry q[13], -1.5707963267949 +Rz q[13], 1.5707963267949 +Rz q[14], 1.5707963267949 +Ry q[14], -1.5707963267949 +Rz q[14], 1.5707963267949 +Rz q[15], 1.5707963267949 +Ry q[15], -1.5707963267949 +Rz q[15], 1.5707963267949 +CNOT q[1], q[0] +H q[1] +CNOT q[2], q[0] +H q[2] +CNOT q[3], q[0] +H q[3] +CNOT q[4], q[0] +H q[4] +CNOT q[5], q[0] +H q[5] +CNOT q[6], q[0] +H q[6] +CNOT q[7], q[0] +H q[7] +CNOT q[8], q[0] +H q[8] +CNOT q[9], q[0] +H q[9] +CNOT q[10], q[0] +H q[10] +CNOT q[11], q[0] +H q[11] +CNOT q[12], q[0] +H q[12] +CNOT q[13], q[0] +H q[13] +CNOT q[14], q[0] +H q[14] +CNOT q[15], q[0] +H q[15] +H q[0] +Rz q[0], 1.5707963267949 +Ry q[0], -1.5707963267949 +Rz q[0], 1.5707963267949 +Rz q[1], 1.5707963267949 +Ry q[1], -1.5707963267949 +Rz q[1], 1.5707963267949 +Rz q[2], 1.5707963267949 +Ry q[2], -1.5707963267949 +Rz q[2], 1.5707963267949 +Rz q[3], 1.5707963267949 +Ry q[3], -1.5707963267949 +Rz q[3], 1.5707963267949 +Rz q[4], 1.5707963267949 +Ry q[4], -1.5707963267949 +Rz q[4], 1.5707963267949 +Rz q[5], 1.5707963267949 +Ry q[5], -1.5707963267949 +Rz q[5], 1.5707963267949 +Rz q[6], 1.5707963267949 +Ry q[6], -1.5707963267949 +Rz q[6], 1.5707963267949 +Rz q[7], 1.5707963267949 +Ry q[7], -1.5707963267949 +Rz q[7], 1.5707963267949 +Rz q[8], 1.5707963267949 +Ry q[8], -1.5707963267949 +Rz q[8], 1.5707963267949 +Rz q[9], 1.5707963267949 +Ry q[9], -1.5707963267949 +Rz q[9], 1.5707963267949 +Rz q[10], 1.5707963267949 +Ry q[10], -1.5707963267949 +Rz q[10], 1.5707963267949 +Rz q[11], 1.5707963267949 +Ry q[11], -1.5707963267949 +Rz q[11], 1.5707963267949 +Rz q[12], 1.5707963267949 +Ry q[12], -1.5707963267949 +Rz q[12], 1.5707963267949 +Rz q[13], 1.5707963267949 +Ry q[13], -1.5707963267949 +Rz q[13], 1.5707963267949 +Rz q[14], 1.5707963267949 +Ry q[14], -1.5707963267949 +Rz q[14], 1.5707963267949 +Rz q[15], 1.5707963267949 +Ry q[15], -1.5707963267949 +Rz q[15], 1.5707963267949 +CNOT q[1], q[0] +H q[1] +CNOT q[2], q[0] +H q[2] +CNOT q[3], q[0] +H q[3] +CNOT q[4], q[0] +H q[4] +CNOT q[5], q[0] +H q[5] +CNOT q[6], q[0] +H q[6] +CNOT q[7], q[0] +H q[7] +CNOT q[8], q[0] +H q[8] +CNOT q[9], q[0] +H q[9] +CNOT q[10], q[0] +H q[10] +CNOT q[11], q[0] +H q[11] +CNOT q[12], q[0] +H q[12] +CNOT q[13], q[0] +H q[13] +CNOT q[14], q[0] +H q[14] +CNOT q[15], q[0] +H q[15] +H q[0] +Rz q[0], 1.5707963267949 +Ry q[0], -1.5707963267949 +Rz q[0], 1.5707963267949 +Rz q[1], 1.5707963267949 +Ry q[1], -1.5707963267949 +Rz q[1], 1.5707963267949 +Rz q[2], 1.5707963267949 +Ry q[2], -1.5707963267949 +Rz q[2], 1.5707963267949 +Rz q[3], 1.5707963267949 +Ry q[3], -1.5707963267949 +Rz q[3], 1.5707963267949 +Rz q[4], 1.5707963267949 +Ry q[4], -1.5707963267949 +Rz q[4], 1.5707963267949 +Rz q[5], 1.5707963267949 +Ry q[5], -1.5707963267949 +Rz q[5], 1.5707963267949 +Rz q[6], 1.5707963267949 +Ry q[6], -1.5707963267949 +Rz q[6], 1.5707963267949 +Rz q[7], 1.5707963267949 +Ry q[7], -1.5707963267949 +Rz q[7], 1.5707963267949 +Rz q[8], 1.5707963267949 +Ry q[8], -1.5707963267949 +Rz q[8], 1.5707963267949 +Rz q[9], 1.5707963267949 +Ry q[9], -1.5707963267949 +Rz q[9], 1.5707963267949 +Rz q[10], 1.5707963267949 +Ry q[10], -1.5707963267949 +Rz q[10], 1.5707963267949 +Rz q[11], 1.5707963267949 +Ry q[11], -1.5707963267949 +Rz q[11], 1.5707963267949 +Rz q[12], 1.5707963267949 +Ry q[12], -1.5707963267949 +Rz q[12], 1.5707963267949 +Rz q[13], 1.5707963267949 +Ry q[13], -1.5707963267949 +Rz q[13], 1.5707963267949 +Rz q[14], 1.5707963267949 +Ry q[14], -1.5707963267949 +Rz q[14], 1.5707963267949 +Rz q[15], 1.5707963267949 +Ry q[15], -1.5707963267949 +Rz q[15], 1.5707963267949 +CNOT q[1], q[0] +H q[1] +CNOT q[2], q[0] +H q[2] +CNOT q[3], q[0] +H q[3] +CNOT q[4], q[0] +H q[4] +CNOT q[5], q[0] +H q[5] +CNOT q[6], q[0] +H q[6] +CNOT q[7], q[0] +H q[7] +CNOT q[8], q[0] +H q[8] +CNOT q[9], q[0] +H q[9] +CNOT q[10], q[0] +H q[10] +CNOT q[11], q[0] +H q[11] +CNOT q[12], q[0] +H q[12] +CNOT q[13], q[0] +H q[13] +CNOT q[14], q[0] +H q[14] +CNOT q[15], q[0] +H q[15] +H q[0] +Rz q[0], 1.5707963267949 +Ry q[0], -1.5707963267949 +Rz q[0], 1.5707963267949 +Rz q[1], 1.5707963267949 +Ry q[1], -1.5707963267949 +Rz q[1], 1.5707963267949 +Rz q[2], 1.5707963267949 +Ry q[2], -1.5707963267949 +Rz q[2], 1.5707963267949 +Rz q[3], 1.5707963267949 +Ry q[3], -1.5707963267949 +Rz q[3], 1.5707963267949 +Rz q[4], 1.5707963267949 +Ry q[4], -1.5707963267949 +Rz q[4], 1.5707963267949 +Rz q[5], 1.5707963267949 +Ry q[5], -1.5707963267949 +Rz q[5], 1.5707963267949 +Rz q[6], 1.5707963267949 +Ry q[6], -1.5707963267949 +Rz q[6], 1.5707963267949 +Rz q[7], 1.5707963267949 +Ry q[7], -1.5707963267949 +Rz q[7], 1.5707963267949 +Rz q[8], 1.5707963267949 +Ry q[8], -1.5707963267949 +Rz q[8], 1.5707963267949 +Rz q[9], 1.5707963267949 +Ry q[9], -1.5707963267949 +Rz q[9], 1.5707963267949 +Rz q[10], 1.5707963267949 +Ry q[10], -1.5707963267949 +Rz q[10], 1.5707963267949 +Rz q[11], 1.5707963267949 +Ry q[11], -1.5707963267949 +Rz q[11], 1.5707963267949 +Rz q[12], 1.5707963267949 +Ry q[12], -1.5707963267949 +Rz q[12], 1.5707963267949 +Rz q[13], 1.5707963267949 +Ry q[13], -1.5707963267949 +Rz q[13], 1.5707963267949 +Rz q[14], 1.5707963267949 +Ry q[14], -1.5707963267949 +Rz q[14], 1.5707963267949 +Rz q[15], 1.5707963267949 +Ry q[15], -1.5707963267949 +Rz q[15], 1.5707963267949 +CNOT q[1], q[0] +H q[1] +CNOT q[2], q[0] +H q[2] +CNOT q[3], q[0] +H q[3] +CNOT q[4], q[0] +H q[4] +CNOT q[5], q[0] +H q[5] +CNOT q[6], q[0] +H q[6] +CNOT q[7], q[0] +H q[7] +CNOT q[8], q[0] +H q[8] +CNOT q[9], q[0] +H q[9] +CNOT q[10], q[0] +H q[10] +CNOT q[11], q[0] +H q[11] +CNOT q[12], q[0] +H q[12] +CNOT q[13], q[0] +H q[13] +CNOT q[14], q[0] +H q[14] +CNOT q[15], q[0] +H q[15] +H q[0] +Rz q[0], 1.5707963267949 +Ry q[0], -1.5707963267949 +Rz q[0], 1.5707963267949 +Rz q[1], 1.5707963267949 +Ry q[1], -1.5707963267949 +Rz q[1], 1.5707963267949 +Rz q[2], 1.5707963267949 +Ry q[2], -1.5707963267949 +Rz q[2], 1.5707963267949 +Rz q[3], 1.5707963267949 +Ry q[3], -1.5707963267949 +Rz q[3], 1.5707963267949 +Rz q[4], 1.5707963267949 +Ry q[4], -1.5707963267949 +Rz q[4], 1.5707963267949 +Rz q[5], 1.5707963267949 +Ry q[5], -1.5707963267949 +Rz q[5], 1.5707963267949 +Rz q[6], 1.5707963267949 +Ry q[6], -1.5707963267949 +Rz q[6], 1.5707963267949 +Rz q[7], 1.5707963267949 +Ry q[7], -1.5707963267949 +Rz q[7], 1.5707963267949 +Rz q[8], 1.5707963267949 +Ry q[8], -1.5707963267949 +Rz q[8], 1.5707963267949 +Rz q[9], 1.5707963267949 +Ry q[9], -1.5707963267949 +Rz q[9], 1.5707963267949 +Rz q[10], 1.5707963267949 +Ry q[10], -1.5707963267949 +Rz q[10], 1.5707963267949 +Rz q[11], 1.5707963267949 +Ry q[11], -1.5707963267949 +Rz q[11], 1.5707963267949 +Rz q[12], 1.5707963267949 +Ry q[12], -1.5707963267949 +Rz q[12], 1.5707963267949 +Rz q[13], 1.5707963267949 +Ry q[13], -1.5707963267949 +Rz q[13], 1.5707963267949 +Rz q[14], 1.5707963267949 +Ry q[14], -1.5707963267949 +Rz q[14], 1.5707963267949 +Rz q[15], 1.5707963267949 +Ry q[15], -1.5707963267949 +Rz q[15], 1.5707963267949 +CNOT q[1], q[0] +H q[1] +CNOT q[2], q[0] +H q[2] +CNOT q[3], q[0] +H q[3] +CNOT q[4], q[0] +H q[4] +CNOT q[5], q[0] +H q[5] +CNOT q[6], q[0] +H q[6] +CNOT q[7], q[0] +H q[7] +CNOT q[8], q[0] +H q[8] +CNOT q[9], q[0] +H q[9] +CNOT q[10], q[0] +H q[10] +CNOT q[11], q[0] +H q[11] +CNOT q[12], q[0] +H q[12] +CNOT q[13], q[0] +H q[13] +CNOT q[14], q[0] +H q[14] +CNOT q[15], q[0] +H q[15] +H q[0] +Rz q[0], 1.5707963267949 +Ry q[0], -1.5707963267949 +Rz q[0], 1.5707963267949 +Rz q[1], 1.5707963267949 +Ry q[1], -1.5707963267949 +Rz q[1], 1.5707963267949 +Rz q[2], 1.5707963267949 +Ry q[2], -1.5707963267949 +Rz q[2], 1.5707963267949 +Rz q[3], 1.5707963267949 +Ry q[3], -1.5707963267949 +Rz q[3], 1.5707963267949 +Rz q[4], 1.5707963267949 +Ry q[4], -1.5707963267949 +Rz q[4], 1.5707963267949 +Rz q[5], 1.5707963267949 +Ry q[5], -1.5707963267949 +Rz q[5], 1.5707963267949 +Rz q[6], 1.5707963267949 +Ry q[6], -1.5707963267949 +Rz q[6], 1.5707963267949 +Rz q[7], 1.5707963267949 +Ry q[7], -1.5707963267949 +Rz q[7], 1.5707963267949 +Rz q[8], 1.5707963267949 +Ry q[8], -1.5707963267949 +Rz q[8], 1.5707963267949 +Rz q[9], 1.5707963267949 +Ry q[9], -1.5707963267949 +Rz q[9], 1.5707963267949 +Rz q[10], 1.5707963267949 +Ry q[10], -1.5707963267949 +Rz q[10], 1.5707963267949 +Rz q[11], 1.5707963267949 +Ry q[11], -1.5707963267949 +Rz q[11], 1.5707963267949 +Rz q[12], 1.5707963267949 +Ry q[12], -1.5707963267949 +Rz q[12], 1.5707963267949 +Rz q[13], 1.5707963267949 +Ry q[13], -1.5707963267949 +Rz q[13], 1.5707963267949 +Rz q[14], 1.5707963267949 +Ry q[14], -1.5707963267949 +Rz q[14], 1.5707963267949 +Rz q[15], 1.5707963267949 +Ry q[15], -1.5707963267949 +Rz q[15], 1.5707963267949 +CNOT q[1], q[0] +H q[1] +CNOT q[2], q[0] +H q[2] +CNOT q[3], q[0] +H q[3] +CNOT q[4], q[0] +H q[4] +CNOT q[5], q[0] +H q[5] +CNOT q[6], q[0] +H q[6] +CNOT q[7], q[0] +H q[7] +CNOT q[8], q[0] +H q[8] +CNOT q[9], q[0] +H q[9] +CNOT q[10], q[0] +H q[10] +CNOT q[11], q[0] +H q[11] +CNOT q[12], q[0] +H q[12] +CNOT q[13], q[0] +H q[13] +CNOT q[14], q[0] +H q[14] +CNOT q[15], q[0] +H q[15] +H q[0] +Rz q[0], 1.5707963267949 +Ry q[0], -1.5707963267949 +Rz q[0], 1.5707963267949 +Rz q[1], 1.5707963267949 +Ry q[1], -1.5707963267949 +Rz q[1], 1.5707963267949 +Rz q[2], 1.5707963267949 +Ry q[2], -1.5707963267949 +Rz q[2], 1.5707963267949 +Rz q[3], 1.5707963267949 +Ry q[3], -1.5707963267949 +Rz q[3], 1.5707963267949 +Rz q[4], 1.5707963267949 +Ry q[4], -1.5707963267949 +Rz q[4], 1.5707963267949 +Rz q[5], 1.5707963267949 +Ry q[5], -1.5707963267949 +Rz q[5], 1.5707963267949 +Rz q[6], 1.5707963267949 +Ry q[6], -1.5707963267949 +Rz q[6], 1.5707963267949 +Rz q[7], 1.5707963267949 +Ry q[7], -1.5707963267949 +Rz q[7], 1.5707963267949 +Rz q[8], 1.5707963267949 +Ry q[8], -1.5707963267949 +Rz q[8], 1.5707963267949 +Rz q[9], 1.5707963267949 +Ry q[9], -1.5707963267949 +Rz q[9], 1.5707963267949 +Rz q[10], 1.5707963267949 +Ry q[10], -1.5707963267949 +Rz q[10], 1.5707963267949 +Rz q[11], 1.5707963267949 +Ry q[11], -1.5707963267949 +Rz q[11], 1.5707963267949 +Rz q[12], 1.5707963267949 +Ry q[12], -1.5707963267949 +Rz q[12], 1.5707963267949 +Rz q[13], 1.5707963267949 +Ry q[13], -1.5707963267949 +Rz q[13], 1.5707963267949 +Rz q[14], 1.5707963267949 +Ry q[14], -1.5707963267949 +Rz q[14], 1.5707963267949 +Rz q[15], 1.5707963267949 +Ry q[15], -1.5707963267949 +Rz q[15], 1.5707963267949 +CNOT q[1], q[0] +H q[1] +CNOT q[2], q[0] +H q[2] +CNOT q[3], q[0] +H q[3] +CNOT q[4], q[0] +H q[4] +CNOT q[5], q[0] +H q[5] +CNOT q[6], q[0] +H q[6] +CNOT q[7], q[0] +H q[7] +CNOT q[8], q[0] +H q[8] +CNOT q[9], q[0] +H q[9] +CNOT q[10], q[0] +H q[10] +CNOT q[11], q[0] +H q[11] +CNOT q[12], q[0] +H q[12] +CNOT q[13], q[0] +H q[13] +CNOT q[14], q[0] +H q[14] +CNOT q[15], q[0] +H q[15] +H q[0] +Rz q[0], 1.5707963267949 +Ry q[0], -1.5707963267949 +Rz q[0], 1.5707963267949 +Rz q[1], 1.5707963267949 +Ry q[1], -1.5707963267949 +Rz q[1], 1.5707963267949 +Rz q[2], 1.5707963267949 +Ry q[2], -1.5707963267949 +Rz q[2], 1.5707963267949 +Rz q[3], 1.5707963267949 +Ry q[3], -1.5707963267949 +Rz q[3], 1.5707963267949 +Rz q[4], 1.5707963267949 +Ry q[4], -1.5707963267949 +Rz q[4], 1.5707963267949 +Rz q[5], 1.5707963267949 +Ry q[5], -1.5707963267949 +Rz q[5], 1.5707963267949 +Rz q[6], 1.5707963267949 +Ry q[6], -1.5707963267949 +Rz q[6], 1.5707963267949 +Rz q[7], 1.5707963267949 +Ry q[7], -1.5707963267949 +Rz q[7], 1.5707963267949 +Rz q[8], 1.5707963267949 +Ry q[8], -1.5707963267949 +Rz q[8], 1.5707963267949 +Rz q[9], 1.5707963267949 +Ry q[9], -1.5707963267949 +Rz q[9], 1.5707963267949 +Rz q[10], 1.5707963267949 +Ry q[10], -1.5707963267949 +Rz q[10], 1.5707963267949 +Rz q[11], 1.5707963267949 +Ry q[11], -1.5707963267949 +Rz q[11], 1.5707963267949 +Rz q[12], 1.5707963267949 +Ry q[12], -1.5707963267949 +Rz q[12], 1.5707963267949 +Rz q[13], 1.5707963267949 +Ry q[13], -1.5707963267949 +Rz q[13], 1.5707963267949 +Rz q[14], 1.5707963267949 +Ry q[14], -1.5707963267949 +Rz q[14], 1.5707963267949 +Rz q[15], 1.5707963267949 +Ry q[15], -1.5707963267949 +Rz q[15], 1.5707963267949 + +CNOT q[1], q[0] +CNOT q[2], q[0] +CNOT q[3], q[0] +CNOT q[4], q[0] +CNOT q[5], q[0] +CNOT q[6], q[0] +CNOT q[7], q[0] +CNOT q[8], q[0] +CNOT q[9], q[0] +CNOT q[10], q[0] +CNOT q[11], q[0] +CNOT q[12], q[0] +CNOT q[13], q[0] +CNOT q[14], q[0] +CNOT q[15], q[0] + + +display + +.measurement + +measure q[0] +measure q[1] +measure q[2] +measure q[3] +measure q[4] +measure q[5] +measure q[6] +measure q[7] +measure q[8] +measure q[9] +measure q[10] +measure q[11] +measure q[12] +measure q[13] +measure q[14] +measure q[15] +display diff --git a/tests/circuits/tmp.qc b/tests/circuits/tmp.qc deleted file mode 100644 index 26fbc1df..00000000 --- a/tests/circuits/tmp.qc +++ /dev/null @@ -1,8 +0,0 @@ - - -qubits 2 - -h q0 -x q0 -z q0 -cnot q0,q1 \ No newline at end of file diff --git a/tests/circuits/toffoli.qc b/tests/circuits/toffoli.qc index 7a982519..b6a3e1b1 100644 --- a/tests/circuits/toffoli.qc +++ b/tests/circuits/toffoli.qc @@ -1,10 +1,17 @@ +version 1.0 -# simple toffoli gate test +# file : toffoli.qc +# author : Nader Khammassi +# brief : simple toffoli gate test qubits 3 -x q0 -x q1 -display -toffoli q0,q1,q2 -display +.input + x q[0] + x q[1] + display # print input state + +.result + toffoli q[0],q[1],q[2] + measure q[0:2] + display # print the result diff --git a/tests/circuits/untested/benchmark.qc b/tests/circuits/untested/benchmark.qc new file mode 100644 index 00000000..b9b31570 --- /dev/null +++ b/tests/circuits/untested/benchmark.qc @@ -0,0 +1,31 @@ +version 1.0 + +qubits 24 + +h q[0] +cnot q[0],q[1] +cnot q[0],q[2] +cnot q[0],q[2] +cnot q[0],q[3] +cnot q[0],q[4] +cnot q[0],q[5] +cnot q[0],q[6] +cnot q[0],q[7] +cnot q[0],q[8] +cnot q[0],q[9] +cnot q[0],q[10] +cnot q[0],q[11] +cnot q[0],q[12] +cnot q[0],q[13] +cnot q[0],q[14] +cnot q[0],q[15] +cnot q[0],q[16] +cnot q[0],q[17] +cnot q[0],q[18] +cnot q[0],q[19] +cnot q[0],q[20] +cnot q[0],q[21] +cnot q[0],q[22] +cnot q[0],q[23] +measure_all + diff --git a/tests/circuits/untested/epr_test.qc b/tests/circuits/untested/epr_test.qc new file mode 100644 index 00000000..64f2ba32 --- /dev/null +++ b/tests/circuits/untested/epr_test.qc @@ -0,0 +1,14 @@ +version 1.0 + +qubits 2 + + +.bell + h q[0] + cnot q[0],q[1] + display + +.measurement + measure q[0] + measure q[1] + display diff --git a/tests/circuits/fault_tolerant_steane.qc b/tests/circuits/untested/fault_tolerant_steane.qc similarity index 88% rename from tests/circuits/fault_tolerant_steane.qc rename to tests/circuits/untested/fault_tolerant_steane.qc index 7b533750..22d6dcc8 100644 --- a/tests/circuits/fault_tolerant_steane.qc +++ b/tests/circuits/untested/fault_tolerant_steane.qc @@ -1,39 +1,41 @@ +version 1.0 + qubits 24 # define logical qubits -map q0,l0_0 -map q1,l0_1 -map q2,l0_2 -map q3,l0_3 -map q4,l0_4 -map q5,l0_5 -map q6,l0_6 -map q6,phy0 -map q7,l1_0 -map q8,l1_1 -map q9,l1_2 -map q10,l1_3 -map q11,l1_4 -map q12,l1_5 -map q13,l1_6 -map q13,phy1 -map q14,l2_0 -map q15,l2_1 -map q16,l2_2 -map q17,l2_3 -map q18,l2_4 -map q19,l2_5 -map q20,l2_6 -map q20,phy2 +map q[0],l0_0 +map q[1],l0_1 +map q[2],l0_2 +map q[3],l0_3 +map q[4],l0_4 +map q[5],l0_5 +map q[6],l0_6 +map q[6],phy0 +map q[7],l1_0 +map q[8],l1_1 +map q[9],l1_2 +map q[10],l1_3 +map q[11],l1_4 +map q[12],l1_5 +map q[13],l1_6 +map q[13],phy1 +map q[14],l2_0 +map q[15],l2_1 +map q[16],l2_2 +map q[17],l2_3 +map q[18],l2_4 +map q[19],l2_5 +map q[20],l2_6 +map q[20],phy2 # define ancilla qubits -map q21,syn0 -map b21,bsyn0 -map q22,syn1 -map b22,bsyn1 -map q23,syn2 -map b23,bsyn2 +map q[21],syn0 +map b[21],bsyn0 +map q[22],syn1 +map b[22],bsyn1 +map q[23],syn2 +map b[23],bsyn2 .init x phy0 @@ -92,19 +94,19 @@ map b23,bsyn2 # diagnose bitflip on qubit 0 .diagnose_bitflip_l0 - prepz syn0 + prep_z syn0 cnot l0_3,syn0 cnot l0_2,syn0 cnot l0_1,syn0 cnot l0_0,syn0 measure syn0 - prepz syn1 + prep_z syn1 cnot l0_5,syn1 cnot l0_4,syn1 cnot l0_1,syn1 cnot l0_0,syn1 measure syn1 - prepz syn2 + prep_z syn2 cnot l0_6,syn2 cnot l0_4,syn2 cnot l0_2,syn2 @@ -148,19 +150,19 @@ map b23,bsyn2 h l0_4 h l0_5 h l0_6 - prepz syn0 + prep_z syn0 cnot l0_3,syn0 cnot l0_2,syn0 cnot l0_1,syn0 cnot l0_0,syn0 measure syn0 - prepz syn1 + prep_z syn1 cnot l0_5,syn1 cnot l0_4,syn1 cnot l0_1,syn1 cnot l0_0,syn1 measure syn1 - prepz syn2 + prep_z syn2 cnot l0_6,syn2 cnot l0_4,syn2 cnot l0_2,syn2 @@ -176,19 +178,19 @@ map b23,bsyn2 # diagnose bitflip on qubit 1 .diagnose_bitflip_l1 - prepz syn0 + prep_z syn0 cnot l1_3,syn0 cnot l1_2,syn0 cnot l1_1,syn0 cnot l1_0,syn0 measure syn0 - prepz syn1 + prep_z syn1 cnot l1_5,syn1 cnot l1_4,syn1 cnot l1_1,syn1 cnot l1_0,syn1 measure syn1 - prepz syn2 + prep_z syn2 cnot l1_6,syn2 cnot l1_4,syn2 cnot l1_2,syn2 @@ -232,19 +234,19 @@ map b23,bsyn2 h l1_4 h l1_5 h l1_6 - prepz syn0 + prep_z syn0 cnot l1_3,syn0 cnot l1_2,syn0 cnot l1_1,syn0 cnot l1_0,syn0 measure syn0 - prepz syn1 + prep_z syn1 cnot l1_5,syn1 cnot l1_4,syn1 cnot l1_1,syn1 cnot l1_0,syn1 measure syn1 - prepz syn2 + prep_z syn2 cnot l1_6,syn2 cnot l1_4,syn2 cnot l1_2,syn2 @@ -260,19 +262,19 @@ map b23,bsyn2 # diagnose bitflip on qubit 2 .diagnose_bitflip_l2 - prepz syn0 + prep_z syn0 cnot l2_3,syn0 cnot l2_2,syn0 cnot l2_1,syn0 cnot l2_0,syn0 measure syn0 - prepz syn1 + prep_z syn1 cnot l2_5,syn1 cnot l2_4,syn1 cnot l2_1,syn1 cnot l2_0,syn1 measure syn1 - prepz syn2 + prep_z syn2 cnot l2_6,syn2 cnot l2_4,syn2 cnot l2_2,syn2 @@ -316,19 +318,19 @@ map b23,bsyn2 h l2_4 h l2_5 h l2_6 - prepz syn0 + prep_z syn0 cnot l2_3,syn0 cnot l2_2,syn0 cnot l2_1,syn0 cnot l2_0,syn0 measure syn0 - prepz syn1 + prep_z syn1 cnot l2_5,syn1 cnot l2_4,syn1 cnot l2_1,syn1 cnot l2_0,syn1 measure syn1 - prepz syn2 + prep_z syn2 cnot l2_6,syn2 cnot l2_4,syn2 cnot l2_2,syn2 diff --git a/tests/circuits/untested/full_adder.qc b/tests/circuits/untested/full_adder.qc new file mode 100644 index 00000000..93904897 --- /dev/null +++ b/tests/circuits/untested/full_adder.qc @@ -0,0 +1,44 @@ +version 1.0 + +# file : full_adder.qc +# author : Nader Khammassi +# brief : quantum full adder (carry-save addition) + +# define 4 qubits +qubits 4 + +# rename qubits +map q[0],b0 +map q[1],b1 +map q[2],b2 +map q[3],b3 + + +# init inputs to some values +.init + x b0 + x b2 + + display_binary # initial input value + + +# perform addition +.add + + toffoli b1,b2,b3 + cnot b1,b2 + toffoli b0,b2,b3 + cnot b0,b2 + + display_binary # result + +.reverse_add + + cnot b0,b2 + toffoli b0,b2,b3 + cnot b1,b2 + toffoli b1,b2,b3 + + display_binary # result + +# error_model depolarizing_channel, 0.1 diff --git a/tests/circuits/untested/grover_1_5q.qc b/tests/circuits/untested/grover_1_5q.qc new file mode 100644 index 00000000..7054e5e0 --- /dev/null +++ b/tests/circuits/untested/grover_1_5q.qc @@ -0,0 +1,43 @@ +version 1.0 + +qubits 5 + +.init + x q[2] + h q[0] + h q[1] + h q[2] + +# iterating 1 times +.grover(1) + + # oracle_1 + + x q[1] + toffoli q[0],q[1],q[3] + toffoli q[1],q[3],q[4] + cnot q[4],q[2] + toffoli q[1],q[3],q[4] + toffoli q[0],q[1],q[3] + x q[1] + h q[0] + h q[1] + + # inversion + + x q[0] + x q[1] + h q[1] + toffoli q[0],q[1],q[3] + cnot q[3],q[1] + toffoli q[0],q[1],q[3] + h q[1] + x q[0] + x q[1] + h q[0] + h q[1] + +.measurement + h q[2] + measure q[2] + display diff --git a/tests/circuits/initial_quantum_state.qs b/tests/circuits/untested/initial_quantum_state.qs similarity index 100% rename from tests/circuits/initial_quantum_state.qs rename to tests/circuits/untested/initial_quantum_state.qs diff --git a/tests/circuits/load_state.qc b/tests/circuits/untested/load_state.qc similarity index 91% rename from tests/circuits/load_state.qc rename to tests/circuits/untested/load_state.qc index 8d108256..1cf52b6b 100644 --- a/tests/circuits/load_state.qc +++ b/tests/circuits/untested/load_state.qc @@ -1,3 +1,5 @@ +version 1.0 + # # date : 07/04/2016 # author : nader khammassi @@ -5,7 +7,6 @@ # example: loading an arbitrary quantum state from a file # - qubits 3 # display the default initial state : |000> @@ -19,6 +20,6 @@ qubits 3 # apply some gates to the new state .algorithm - x q0 - cnot q0,q1 + x q[0] + cnot q[0],q[1] display # display the fina result diff --git a/tests/circuits/untested/measure_test.qc b/tests/circuits/untested/measure_test.qc new file mode 100644 index 00000000..ae77da9f --- /dev/null +++ b/tests/circuits/untested/measure_test.qc @@ -0,0 +1,18 @@ +version 1.0 + +qubits 17 + + +h q[0] +h q[1] +h q[2] +h q[3] +h q[4] +h q[5] +h q[6] +h q[7] +h q[8] + +measure_all + +display_binary diff --git a/tests/circuits/qec_3q_bit_flip_code_with_correction.qc b/tests/circuits/untested/qec_3q_bit_flip_code.qc similarity index 59% rename from tests/circuits/qec_3q_bit_flip_code_with_correction.qc rename to tests/circuits/untested/qec_3q_bit_flip_code.qc index e01cd989..2ea7f8af 100644 --- a/tests/circuits/qec_3q_bit_flip_code_with_correction.qc +++ b/tests/circuits/untested/qec_3q_bit_flip_code.qc @@ -1,3 +1,4 @@ +version 1.0 # file : qec_3q_bit_flip_code.qc # author : Nader Khammassi @@ -9,53 +10,48 @@ qubits 5 # initialize logical qubit .init - x q0 + x q[0] display # encoding .encoding - cnot q0,q1 - cnot q0,q2 + cnot q[0],q[1] + cnot q[0],q[2] display_binary # error injection .error_injection - x q2 + x q[2] display # parity check .parity_check - cnot q0,q3 - cnot q1,q3 - cnot q0,q4 - cnot q2,q4 - measure q3 - measure q4 + cnot q[0],q[3] + cnot q[1],q[3] + cnot q[0],q[4] + cnot q[2],q[4] + measure q[3] + measure q[4] display_binary # error correction circuit can be described here -.error_correction - # syn : 11 -> q0 - c-x b4,b3,q0 - # syn : 01 -> flip q1 - not b4 - c-x b4,b3,q1 - not b4 - # syn : 10 -> q2 - not b3 - c-x b4,b3,q2 - not b3 +.error_correction + # x q[4] + # toffoli q[3],q[4],q[1] + # x q[4] + # not q[4] + # c-x b3,b4,q[1] display # decoding .decoding - cnot q0,q2 - cnot q0,q1 + cnot q[0],q[2] + cnot q[0],q[1] # display display_binary -# error_model depolarizing_channel,0.1 \ No newline at end of file +# error_model depolarizing_channel,0.1 diff --git a/tests/circuits/qec_3q_bit_flip_code_noisy.qc b/tests/circuits/untested/qec_3q_bit_flip_code_noisy.qc similarity index 52% rename from tests/circuits/qec_3q_bit_flip_code_noisy.qc rename to tests/circuits/untested/qec_3q_bit_flip_code_noisy.qc index 4f16fbeb..c742052d 100644 --- a/tests/circuits/qec_3q_bit_flip_code_noisy.qc +++ b/tests/circuits/untested/qec_3q_bit_flip_code_noisy.qc @@ -1,3 +1,4 @@ +version 1.0 # file : qec_3q_bit_flip_code.qc # author : Nader Khammassi @@ -9,49 +10,49 @@ qubits 5 # initialize logical qubit .qec(100) - prepz q0 - prepz q1 - prepz q2 - prepz q3 - prepz q4 - # x q0 + prep_z q[0] + prep_z q[1] + prep_z q[2] + prep_z q[3] + prep_z q[4] + # x q[0] # display # encoding # .encoding - cnot q0,q1 - cnot q0,q2 + cnot q[0],q[1] + cnot q[0],q[2] # display_binary # error injection # .error_injection -# x q0 +# x q[0] # display # parity check # .parity_check - cnot q0,q3 - cnot q1,q3 - cnot q0,q4 - cnot q2,q4 - measure q3 - measure q4 + cnot q[0],q[3] + cnot q[1],q[3] + cnot q[0],q[4] + cnot q[2],q[4] + measure q[3] + measure q[4] # display_binary # error correction circuit can be described here # .error_correction - # syn : 11 -> q0 - c-x b4,b3,q0 - # syn : 01 -> flip q1 - not b4 - c-x b4,b3,q1 - not b4 - # syn : 10 -> q2 - not b3 - c-x b4,b3,q2 - not b3 + # syn : 11 -> q[0] + c-x q[4],q[3],q[0] + # syn : 01 -> flip q[1] + not q[4] + c-x q[4],q[3],q[1] + not q[4] + # syn : 10 -> q[2] + not q[3] + c-x q[4],q[3],q[2] + not q[3] # display @@ -59,12 +60,12 @@ qubits 5 # decoding # .decoding - cnot q0,q2 - cnot q0,q1 - measure q0 + cnot q[0],q[2] + cnot q[0],q[1] + measure q[0] .result # display display_binary -error_model depolarizing_channel,0.001 \ No newline at end of file +error_model depolarizing_channel,0.001 diff --git a/tests/circuits/qec_3q_bit_flip_code_simple.qc b/tests/circuits/untested/qec_3q_bit_flip_code_simple.qc similarity index 87% rename from tests/circuits/qec_3q_bit_flip_code_simple.qc rename to tests/circuits/untested/qec_3q_bit_flip_code_simple.qc index 9827ea6e..19daed37 100644 --- a/tests/circuits/qec_3q_bit_flip_code_simple.qc +++ b/tests/circuits/untested/qec_3q_bit_flip_code_simple.qc @@ -1,3 +1,4 @@ +version 1.0 # quantum error correction test # 3 qubit bit flip correction code @@ -5,13 +6,13 @@ # qubit definition qubits 3 -map q0,d -map q1,a0 -map q2,a1 +map q[0],d +map q[1],a0 +map q[2],a1 # init logical gate .init -# x q0 +# x q[0] x d display_binary diff --git a/tests/circuits/untested/qec_3q_bit_flip_code_with_correction.qc b/tests/circuits/untested/qec_3q_bit_flip_code_with_correction.qc new file mode 100644 index 00000000..64195f09 --- /dev/null +++ b/tests/circuits/untested/qec_3q_bit_flip_code_with_correction.qc @@ -0,0 +1,62 @@ +version 1.0 + +# file : qec_3q_bit_flip_code.qc +# author : Nader Khammassi +# brief : quantum error correction test +# circuit for a basic 3 qubits bitflip code + +# define 5 qubits : 3 data qubits and 2 ancillas (syndrome qubits) +qubits 5 + +# initialize logical qubit +.init + x q[0] + display + +# encoding +.encoding + cnot q[0],q[1] + cnot q[0],q[2] + display_binary + +# error injection +.error_injection + x q[2] + display + + +# parity check +.parity_check + cnot q[0],q[3] + cnot q[1],q[3] + cnot q[0],q[4] + cnot q[2],q[4] + measure q[3] + measure q[4] + display_binary + + +# error correction circuit can be described here +.error_correction + # syn : 11 -> q[0] + c-x b[4],b[3],q[0] + # syn : 01 -> flip q[1] + not b[4] + c-x b[4],b[3],q[1] + not b[4] + # syn : 10 -> q[2] + not b[3] + c-x b[4],b[3],q[2] + not b[3] + + display + + +# decoding +.decoding + cnot q[0],q[2] + cnot q[0],q[1] + # display + display_binary + +# error_model depolarizing_channel,0.1 diff --git a/tests/circuits/qec_3q_phase_flip_code.qc b/tests/circuits/untested/qec_3q_phase_flip_code.qc similarity index 61% rename from tests/circuits/qec_3q_phase_flip_code.qc rename to tests/circuits/untested/qec_3q_phase_flip_code.qc index 0a830831..fff16933 100644 --- a/tests/circuits/qec_3q_phase_flip_code.qc +++ b/tests/circuits/untested/qec_3q_phase_flip_code.qc @@ -1,3 +1,4 @@ +version 1.0 # quantum error correction test # 3 qubits phase/sign flip correction code @@ -7,32 +8,32 @@ qubits 3 # init logical gate .init - x q0 + x q[0] display_binary # encoding .encoding - cnot q0,q1 - cnot q0,q2 - h q0 - h q1 - h q2 + cnot q[0],q[1] + cnot q[0],q[2] + h q[0] + h q[1] + h q[2] display # error injection .error_injection - z q0 + z q[0] display # decoding .decoding - h q0 - h q1 - h q2 - cnot q0,q1 - cnot q0,q2 - toffoli q1,q2,q0 + h q[0] + h q[1] + h q[2] + cnot q[0],q[1] + cnot q[0],q[2] + toffoli q[1],q[2],q[0] display #error_model depolarizing_channel,0.1 diff --git a/tests/circuits/qft_5q.qc b/tests/circuits/untested/qft_5q.qc similarity index 60% rename from tests/circuits/qft_5q.qc rename to tests/circuits/untested/qft_5q.qc index 8c42b74a..90d97157 100644 --- a/tests/circuits/qft_5q.qc +++ b/tests/circuits/untested/qft_5q.qc @@ -1,3 +1,5 @@ +version 1.0 + # file : qft_5q.qc # author : Nader Khammassi # brief : 5 qubits quantum fourrier transform (QFT) @@ -7,33 +9,33 @@ qubits 5 # init qubits to |0...01> (set your own input state here) .init -# x q0 -# x q2 -# x q3 +# x q[0] +# x q[2] +# x q[3] # display_binary # display the input binary state # main circuit .qft - h q0 - cr q1,q0 - cr q2,q0 - cr q3,q0 - cr q4,q0 - h q1 - cr q2,q1 - cr q3,q1 - cr q4,q1 - h q2 - cr q3,q2 - cr q4,q2 - h q3 - cr q4,q3 - h q4 + h q[0] + cr q[1],q[0] + cr q[2],q[0] + cr q[3],q[0] + cr q[4],q[0] + h q[1] + cr q[2],q[1] + cr q[3],q[1] + cr q[4],q[1] + h q[2] + cr q[3],q[2] + cr q[4],q[2] + h q[3] + cr q[4],q[3] + h q[4] # reverse qubit order .reverse -# swap q0,q4 -# swap q1,q3 +# swap q[0],q[4] +# swap q[1],q[3] display # display the output quantum state diff --git a/tests/circuits/untested/qft_8q.qc b/tests/circuits/untested/qft_8q.qc new file mode 100644 index 00000000..1ec00a46 --- /dev/null +++ b/tests/circuits/untested/qft_8q.qc @@ -0,0 +1,68 @@ +version 1.0 + +# file : qft_8q.qc +# author : Nader Khammassi +# brief : 8 qubits quantum fourrier transform (QFT) + +# define 8 qubits +qubits 8 + +# init qubits to |0...01> (set your own input state here) +.init + x q[0] + x q[2] + x q[4] + x q[6] + display_binary # display the input binary state + +# main qft circuit +.qft + h q[0] + cr q[1],q[0] + cr q[2],q[0] + cr q[3],q[0] + cr q[4],q[0] + cr q[5],q[0] + cr q[6],q[0] + cr q[7],q[0] + h q[1] + cr q[2],q[1] + cr q[3],q[1] + cr q[4],q[1] + cr q[5],q[1] + cr q[6],q[1] + cr q[7],q[1] + h q[2] + cr q[3],q[2] + cr q[4],q[2] + cr q[5],q[2] + cr q[6],q[2] + cr q[7],q[2] + h q[3] + cr q[4],q[3] + cr q[5],q[3] + cr q[6],q[3] + cr q[7],q[3] + h q[4] + cr q[5],q[4] + cr q[6],q[4] + cr q[7],q[4] + h q[5] + cr q[6],q[5] + cr q[7],q[5] + h q[6] + cr q[7],q[6] + h q[7] + +# reverse qubit order +.reverse + swap q[0],q[7] + swap q[1],q[6] + swap q[2],q[5] + swap q[3],q[4] + +# display + + +# to activate error injection, uncomment the next line +# error_model depolarizing_channel,0.001 diff --git a/tests/circuits/untested/rb.qc b/tests/circuits/untested/rb.qc new file mode 100644 index 00000000..8aa7bdb7 --- /dev/null +++ b/tests/circuits/untested/rb.qc @@ -0,0 +1,40 @@ +version 1.0 + +qubits 1 + + +# prep_z q[0] + +.rb(100) + prep_z q[0] + x q[0] + h q[0] + y q[0] + x q[0] + x q[0] + y q[0] + h q[0] + x q[0] + x q[0] + h q[0] + y q[0] + x q[0] + x q[0] + y q[0] + h q[0] + x q[0] + x q[0] + h q[0] + y q[0] + x q[0] + x q[0] + y q[0] + h q[0] + x q[0] + measure q[0] + +.result + + display + +error_model depolarizing_channel,0.001 diff --git a/tests/circuits/untested/rotations_floats.qc b/tests/circuits/untested/rotations_floats.qc new file mode 100644 index 00000000..489fc9a6 --- /dev/null +++ b/tests/circuits/untested/rotations_floats.qc @@ -0,0 +1,14 @@ +version 1.0 +qubits 2 + +# test parsing of different variations of floats + +Rz q[0], 0.123 +Rz q[0], 0 +Rz q[0], 0. +Rz q[0], 123.123 +Rz q[1],12 + +.measurement + measure q[0] + measure q[1] diff --git a/tests/circuits/untested/scaffold_hn.qc b/tests/circuits/untested/scaffold_hn.qc new file mode 100644 index 00000000..65e4c0ed --- /dev/null +++ b/tests/circuits/untested/scaffold_hn.qc @@ -0,0 +1,15 @@ +version 1.0 + +qubits 7 +map q[0], bits0 +map q[1], bits1 +map q[2], bits2 +map q[3], bits3 +map q[4], bits4 + +h bits0 +s bits1 +h bits2 +x bits0 + +# display diff --git a/tests/circuits/shor_9q_code.qc b/tests/circuits/untested/shor_9q_code.qc similarity index 82% rename from tests/circuits/shor_9q_code.qc rename to tests/circuits/untested/shor_9q_code.qc index 5a695dbd..367a5145 100644 --- a/tests/circuits/shor_9q_code.qc +++ b/tests/circuits/untested/shor_9q_code.qc @@ -1,3 +1,5 @@ +version 1.0 + # file : qec_shor9_code.qc # author : Nader Khammassi # brief : quantum error correction (shor's 9 qubits code) @@ -6,21 +8,21 @@ qubits 9 -map q0,p0 -map q1,x00 -map q2,x01 -map q3,p1 -map q4,x10 -map q5,x11 -map q6,p2 -map q7,x20 -map q8,x21 +map q[0],p0 +map q[1],x00 +map q[2],x01 +map q[3],p1 +map q[4],x10 +map q[5],x11 +map q[6],p2 +map q[7],x20 +map q[8],x21 .init rx p0,1.3 ry p0,0.3 - # x q0 + # x q[0] # display .phase_flip_encoding @@ -47,9 +49,9 @@ map q8,x21 .error_injection - x q3 - # z q0 - # x q1 + x q[3] + # z q[0] + # x q[1] .bit_flip_decoding_and_correction diff --git a/tests/circuits/surface_code_17q_ninja_star.qc b/tests/circuits/untested/surface_code_17q_ninja_star.qc similarity index 62% rename from tests/circuits/surface_code_17q_ninja_star.qc rename to tests/circuits/untested/surface_code_17q_ninja_star.qc index f1013c47..5ac22864 100644 --- a/tests/circuits/surface_code_17q_ninja_star.qc +++ b/tests/circuits/untested/surface_code_17q_ninja_star.qc @@ -1,26 +1,27 @@ +version 1.0 # 17 qubits ninja-star stabilizer # qubit definition qubits 17 -map q0,x44 -map q1,d1 -map q2,d3 -map q3,d5 -map q4,z10 -map q5,x2 -map q6,z4 -map q7,d11 -map q8,d13 -map q9,d15 -map q10,z12 -map q11,x14 -map q12,z16 -map q13,d21 -map q14,d23 -map q15,d25 -map q16,x22 +map q[0],x44 +map q[1],d1 +map q[2],d3 +map q[3],d5 +map q[4],z10 +map q[5],x2 +map q[6],z4 +map q[7],d11 +map q[8],d13 +map q[9],d15 +map q[10],z12 +map q[11],x14 +map q[12],z16 +map q[13],d21 +map q[14],d23 +map q[15],d25 +map q[16],x22 # display the previous state (from a previous round if exists) @@ -30,28 +31,28 @@ map q16,x22 # initialization circuit .initialization - # cx b0,x44 # init x44 to zero - prepz x44 + # cx q[0],x44 # init x44 to zero + prep_z x44 h x44 cnot x44,d5 cnot x44,d3 h x44 measure x44 - cz b0,d5 + cz q[0],d5 - # cx b16,x22 # init x22 to zero - prepz x22 + # cx q[16],x22 # init x22 to zero + prep_z x22 h x22 cnot x22,d23 cnot x22,d21 h x22 measure x22 - cz b16,d21 + cz q[16],d21 - # cx b5,x2 # init X2 to zero - prepz x2 + # cx q[5],x2 # init X2 to zero + prep_z x2 h x2 cnot x2,d3 cnot x2,d1 @@ -59,11 +60,11 @@ map q16,x22 cnot x2,d11 h x2 measure x2 - cz b5,d1 + cz q[5],d1 - # cx b11,x14 # init X14 to zero - prepz x14 + # cx q[11],x14 # init X14 to zero + prep_z x14 h x14 cnot x14,d15 cnot x14,d13 @@ -71,7 +72,7 @@ map q16,x22 cnot x14,d23 h x14 measure x14 - cz b11,d25 + cz q[11],d25 display @@ -81,23 +82,23 @@ map q16,x22 # init ancillas # .init_x_z .surface_code_cycle - # cx b0,x44 # init X44 to zero - # cx b4,z10 # init Z10 to zero - # cx b5,x2 # init X2 to zero - # cx b6,z4 # init Z4 to zero - # cx b10,z12 # init Z12 to zero - # cx b11,x14 # init X14 to zero - # cx b12,z16 # init Z16 to zero - # cx b16,x22 # init X22 to zero - - prepz x44 - prepz z10 - prepz x2 - prepz z4 - prepz z12 - prepz x14 - prepz z16 - prepz x22 + # cx q[0],x44 # init X44 to zero + # cx q[4],z10 # init Z10 to zero + # cx q[5],x2 # init X2 to zero + # cx q[6],z4 # init Z4 to zero + # cx q[10],z12 # init Z12 to zero + # cx q[11],x14 # init X14 to zero + # cx q[12],z16 # init Z16 to zero + # cx q[16],x22 # init X22 to zero + + prep_z x44 + prep_z z10 + prep_z x2 + prep_z z4 + prep_z z12 + prep_z x14 + prep_z z16 + prep_z x22 # debug : display intermediate state # display_binary diff --git a/tests/circuits/untested/tmp.qc b/tests/circuits/untested/tmp.qc new file mode 100644 index 00000000..69514d47 --- /dev/null +++ b/tests/circuits/untested/tmp.qc @@ -0,0 +1,8 @@ +version 1.0 + +qubits 2 + +h q[0] +x q[0] +z q[0] +cnot q[0],q[1] diff --git a/tests/circuits/transversal_cnot_on_17q_ninja_star.qc b/tests/circuits/untested/transversal_cnot_on_17q_ninja_star.qc similarity index 70% rename from tests/circuits/transversal_cnot_on_17q_ninja_star.qc rename to tests/circuits/untested/transversal_cnot_on_17q_ninja_star.qc index 0ac474d0..e05368e7 100644 --- a/tests/circuits/transversal_cnot_on_17q_ninja_star.qc +++ b/tests/circuits/untested/transversal_cnot_on_17q_ninja_star.qc @@ -1,3 +1,4 @@ +version 1.0 # 17 qubits ninja-star surface code @@ -5,33 +6,33 @@ qubits 26 -map q0,da1 -map q1,da3 -map q2,da5 -map q3,da11 -map q4,da13 -map q5,da15 -map q6,da21 -map q7,da23 -map q8,da25 -map q9,db1 -map q10,db3 -map q11,db5 -map q12,db11 -map q13,db13 -map q14,db15 -map q15,db21 -map q16,db23 -map q17,db25 - -map q18,x44 -map q19,z10 -map q20,x2 -map q21,z4 -map q22,z12 -map q23,x14 -map q24,z16 -map q25,x22 +map q[0],da1 +map q[1],da3 +map q[2],da5 +map q[3],da11 +map q[4],da13 +map q[5],da15 +map q[6],da21 +map q[7],da23 +map q[8],da25 +map q[9],db1 +map q[10],db3 +map q[11],db5 +map q[12],db11 +map q[13],db13 +map q[14],db15 +map q[15],db21 +map q[16],db23 +map q[17],db25 + +map q[18],x44 +map q[19],z10 +map q[20],x2 +map q[21],z4 +map q[22],z12 +map q[23],x14 +map q[24],z16 +map q[25],x22 # display the previous state (from a previous round if exists) @@ -41,25 +42,25 @@ map q25,x22 # initialization circuit to put qubit A on a logical zero state .initializing_first_qubit_to_logical_0_state - cx b18,x44 # init x44 to zero + c-x b[18],x44 # init x44 to zero h x44 cnot x44,da5 cnot x44,da3 h x44 measure x44 - cz b18,da5 + c-z b[18],da5 - cx b25,x22 # init x22 to zero + c-x b[25],x22 # init x22 to zero h x22 cnot x22,da23 cnot x22,da21 h x22 measure x22 - cz b25,da21 + c-z b[25],da21 - cx b20,x2 # init X2 to zero + c-x b[20],x2 # init X2 to zero h x2 cnot x2,da3 cnot x2,da1 @@ -67,10 +68,10 @@ map q25,x22 cnot x2,da11 h x2 measure x2 - cz b20,da1 + c-z b[20],da1 - cx b23,x14 # init X14 to zero + c-x b[23],x14 # init X14 to zero h x14 cnot x14,da15 cnot x14,da13 @@ -78,19 +79,19 @@ map q25,x22 cnot x14,da23 h x14 measure x14 - cz b23,da25 + c-z b[23],da25 # init ancillas .start_surface_code_cycle - cx b18,x44 # init X44 to zero - cx b19,z10 # init Z10 to zero - cx b20,x2 # init X2 to zero - cx b21,z4 # init Z4 to zero - cx b22,z12 # init Z12 to zero - cx b23,x14 # init X14 to zero - cx b24,z16 # init Z16 to zero - cx b25,x22 # init X22 to zero + c-x b[18],x44 # init X44 to zero + c-x b[19],z10 # init Z10 to zero + c-x b[20],x2 # init X2 to zero + c-x b[21],z4 # init Z4 to zero + c-x b[22],z12 # init Z12 to zero + c-x b[23],x14 # init X14 to zero + c-x b[24],z16 # init Z16 to zero + c-x b[25],x22 # init X22 to zero h x44 h x2 @@ -176,25 +177,25 @@ map q25,x22 .initialize_second_qubit_to_logical_0_state - cx b18,x44 # init x44 to zero + c-x b[18],x44 # init x44 to zero h x44 cnot x44,db5 cnot x44,db3 h x44 measure x44 - cz b18,db5 + c-z b[18],db5 - cx b25,x22 # init x22 to zero + c-x b[25],x22 # init x22 to zero h x22 cnot x22,db23 cnot x22,db21 h x22 measure x22 - cz b25,db21 + c-z b[25],db21 - cx b20,x2 # init X2 to zero + c-x b[20],x2 # init X2 to zero h x2 cnot x2,db3 cnot x2,db1 @@ -202,10 +203,10 @@ map q25,x22 cnot x2,db11 h x2 measure x2 - cz b20,db1 + c-z b[20],db1 - cx b23,x14 # init X14 to zero + c-x b[23],x14 # init X14 to zero h x14 cnot x14,db15 cnot x14,db13 @@ -213,19 +214,19 @@ map q25,x22 cnot x14,db23 h x14 measure x14 - cz b23,db25 + c-z b[23],db25 .start_surface_code_cycle # init ancillas - cx b18,x44 # init X44 to zero - cx b19,z10 # init Z10 to zero - cx b20,x2 # init X2 to zero - cx b21,z4 # init Z4 to zero - cx b22,z12 # init Z12 to zero - cx b23,x14 # init X14 to zero - cx b24,z16 # init Z16 to zero - cx b25,x22 # init X22 to zero + c-x b[18],x44 # init X44 to zero + c-x b[19],z10 # init Z10 to zero + c-x b[20],x2 # init X2 to zero + c-x b[21],z4 # init Z4 to zero + c-x b[22],z12 # init Z12 to zero + c-x b[23],x14 # init X14 to zero + c-x b[24],z16 # init Z16 to zero + c-x b[25],x22 # init X22 to zero # debug : display intermediate state # display_binary diff --git a/tests/circuits/transversal_cnot_on_17q_ninja_star_2.qc b/tests/circuits/untested/transversal_cnot_on_17q_ninja_star_2.qc similarity index 62% rename from tests/circuits/transversal_cnot_on_17q_ninja_star_2.qc rename to tests/circuits/untested/transversal_cnot_on_17q_ninja_star_2.qc index 9ecb762a..b12e3906 100644 --- a/tests/circuits/transversal_cnot_on_17q_ninja_star_2.qc +++ b/tests/circuits/untested/transversal_cnot_on_17q_ninja_star_2.qc @@ -1,3 +1,4 @@ +version 1.0 # 17 qubits ninja-star surface code @@ -5,58 +6,58 @@ qubits 26 -map q0,da1 -map q1,da3 -map q2,da5 -map q3,da11 -map q4,da13 -map q5,da15 -map q6,da21 -map q7,da23 -map q8,da25 -map q9,db1 -map q10,db3 -map q11,db5 -map q12,db11 -map q13,db13 -map q14,db15 -map q15,db21 -map q16,db23 -map q17,db25 - -map q18,x44 -map q19,z10 -map q20,x2 -map q21,z4 -map q22,z12 -map q23,x14 -map q24,z16 -map q25,x22 +map q[0],da1 +map q[1],da3 +map q[2],da5 +map q[3],da11 +map q[4],da13 +map q[5],da15 +map q[6],da21 +map q[7],da23 +map q[8],da25 +map q[9],db1 +map q[10],db3 +map q[11],db5 +map q[12],db11 +map q[13],db13 +map q[14],db15 +map q[15],db21 +map q[16],db23 +map q[17],db25 + +map q[18],x44 +map q[19],z10 +map q[20],x2 +map q[21],z4 +map q[22],z12 +map q[23],x14 +map q[24],z16 +map q[25],x22 # initialization circuit .initialization - cx b18,x44 # init x44 to zero + c-x b[18],x44 # init x44 to zero h x44 cnot x44,da5 cnot x44,da3 h x44 measure x44 - cz b18,da5 + c-z b[18],da5 - cx b25,x22 # init x22 to zero + c-x b[25],x22 # init x22 to zero h x22 cnot x22,da23 cnot x22,da21 h x22 measure x22 - cz b25,da21 + c-z b[25],da21 - cx b20,x2 # init X2 to zero + c-x b[20],x2 # init X2 to zero h x2 cnot x2,da3 cnot x2,da1 @@ -64,10 +65,10 @@ map q25,x22 cnot x2,da11 h x2 measure x2 - cz b20,da1 + c-z b[20],da1 - cx b23,x14 # init X14 to zero + c-x b[23],x14 # init X14 to zero h x14 cnot x14,da15 cnot x14,da13 @@ -75,18 +76,18 @@ map q25,x22 cnot x14,da23 h x14 measure x14 - cz b23,da25 + c-z b[23],da25 # init ancillas .init_x_z - cx b18,x44 # init X44 to zero - cx b19,z10 # init Z10 to zero - cx b20,x2 # init X2 to zero - cx b21,z4 # init Z4 to zero - cx b22,z12 # init Z12 to zero - cx b23,x14 # init X14 to zero - cx b24,z16 # init Z16 to zero - cx b25,x22 # init X22 to zero + c-x b[18],x44 # init X44 to zero + c-x b[19],z10 # init Z10 to zero + c-x b[20],x2 # init X2 to zero + c-x b[21],z4 # init Z4 to zero + c-x b[22],z12 # init Z12 to zero + c-x b[23],x14 # init X14 to zero + c-x b[24],z16 # init Z16 to zero + c-x b[25],x22 # init X22 to zero # debug : display intermediate state diff --git a/tests/qasm/a.out b/tests/qasm/a.out deleted file mode 100755 index 162fcb80..00000000 Binary files a/tests/qasm/a.out and /dev/null differ diff --git a/tests/qasm/qasm_lexer.h b/tests/qasm/qasm_lexer.h deleted file mode 100644 index 24698777..00000000 --- a/tests/qasm/qasm_lexer.h +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @file lexer.h - * @author Nader KHAMMASSI - nader.khammassi@gmail.com - * @date 13-10-15 - * @brief - */ - -#ifndef QX_LEXER_H -#define QX_LEXER_H - -namespace qx -{ - namespace qasm - { - class lexer - { - public: - - private: - - }; - } -} - - - -#endif // QX_LEXER_H - diff --git a/tests/qasm/qasm_loader.cc b/tests/qasm/qasm_loader.cc deleted file mode 100644 index 52568860..00000000 --- a/tests/qasm/qasm_loader.cc +++ /dev/null @@ -1,312 +0,0 @@ -/** - * @file qasm_loader.h - * @author Nader KHAMMASSI - nader.khammassi@gmail.com - * @date 19-10-15 - * @brief - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - - -// #include -// #include - -using namespace str; - -#define println(x) std::cout << x << std::endl; -#define error(x) std::cout << "[x] error : " << x << std::endl; - -typedef enum __gate_type -{ - __hadamard_gate__, - __cnot_gate__, - __swap_gate__, - __phase_gate__, - __cphase_gate__, - __pauli_x_gate__, - __pauli_y_gate__, - __pauli_z_gate__, - __toffoli_gate__ -} gate_type_t; - - -/** - * qasm parser - */ -class qasm_parser -{ - - private: - - std::string file_name; - - int line_index; - bool syntax_error; - - qx::circuit * circuit; - - - public: - - qasm_parser(std::string file_name) : file_name(file_name) - { - } - - uint32_t parse() - { - line_index = 0; - syntax_error = false; - println("[-] loading qasm file '" << file_name << "'..."); - std::ifstream stream(file_name.c_str()); - if (stream) - { - char buf[2048]; - while(stream.getline(buf, 2048)) - { - line_index++; - std::string line = buf; - if (line.length()>0) - process_line(line); - if (syntax_error) - break; - } - stream.close(); - if (syntax_error) - { - exit(-1); - } - } - else error("cannot open file " << file_name); - - // check semantic - /* - if (sampling == 0) - { - std::cerr << "[x] error: sampling rate is not defined or missing !" << std::endl; - clean(); - exit(-1); - } - if (database.length() == 0) - { - std::cerr << "[x] error: source database is not defined or missing !" << std::endl; - clean(); - exit(-1); - } - if (registrations.size() == 0) - { - std::cerr << "[x] error: there is no class definition : nothing to do !" << std::endl; - clean(); - exit(-1); - } - */ - } - - /** - * destructor - */ - virtual ~qasm_parser() - { - // clean(); - } - - - private: - - /** - * @brief process line - */ - void process_line(std::string& line) - { - println("processing line " << line_index << " ..."); - if (line[0] == '#') // skip comments - { - println(" comment."); - return; - } - remove_comment(line,'#'); // remove inline comment - format_line(line); - strings words = word_list(line, " "); - if (words.size() != 2) - { - std::cerr << "[x] syntax error at line " << line_index << ": \n\t" << line << std::endl; - syntax_error = true; - } - - for (int i=0; i " << words[i]); - - if (words[0] == "qubits") // qubit definition - { - println(" => qubits number: " << atoi(words[1].c_str())); - } - else if (words[0] == "h") // hadamard gate - { - println(" => hadamard gate on: " << atoi(words[1].c_str())); - } - else if (words[0] == "cnot") // cnot gate - { - strings params = word_list(words[1],","); - println(" => cnot gate : ctrl_qubit=" << params[0] << ", target_qubit=" << params[1]); - } - else if (words[0] == "swap") // cnot gate - { - strings params = word_list(words[1],","); - println(" => swap gate : qubit_1=" << params[0] << ", qubit_2=" << params[1]); - } - /** - * pauli gates - */ - else if (words[0] == "x") // x gate - { - println(" => pauli x gate on: " << atoi(words[1].c_str())); - } - else if (words[0] == "y") // y gate - { - println(" => pauli y gate on: " << atoi(words[1].c_str())); - } - else if (words[0] == "z") // z gate - { - println(" => pauli z gate on: " << atoi(words[1].c_str())); - } - /** - * rotations gates - */ - else if (words[0] == "rx") // rx gate - { - strings params = word_list(words[1],","); - println(" => rx gate on " << process_qubit(params[0]) << " (angle=" << params[1] << ")"); - } - else if (words[0] == "ry") // ry gate - { - strings params = word_list(words[1],","); - println(" => ry gate on " << process_qubit(params[0]) << " (angle=" << params[1] << ")"); - } - else if (words[0] == "rz") // rz gate - { - strings params = word_list(words[1],","); - println(" => rz gate on " << process_qubit(params[0]) << " (angle=" << params[1] << ")"); - } - /** - * phase - */ - else if (words[0] == "ph") // rx gate - { - strings params = word_list(words[1],","); - println(" => phase gate on " << process_qubit(params[0]) << " (angle=" << params[1] << ")"); - } - /** - * measurement - */ - else if (words[0] == "measure") // measurement - { - println(" => measure qubit " << atoi(words[1].c_str())); - } - /** - * noise - */ - else if (words[0] == "noise") // operational errors - { - strings params = word_list(words[1],","); - println(" => noise (theta=" << params[0].c_str() << ", phi=" << params[1].c_str() << ")"); - } - else if (words[0] == "decoherence") // decoherence - { - println(" => decoherence (dt=" << words[1] << ")"); - } - else if (words[0] == "qec") // decoherence - { - println(" => quantum error correction scheme = " << words[1]); - } - - /* - if (words.size() == 2) // database or sampling line - { - if (words[0] == "qubit") // database - { - process_database(words); - } - else if (words[0] == "h") - { - process_gate(words); - } else - { - std::cerr << "[x] syntax error at line " << line_index << ": \n\t" << line << std::endl; - syntax_error = true; - } - } - else - { - std::cerr << "[x] syntax error at line " << line_index << ": \n\t" << line << std::endl; - syntax_error = true; - } - */ - - } - - uint32_t qubit_id(std::string& str) - { - std::string id = str.substr(1); - println("id=" << id); - return atoi(id.c_str()); - } - - bool is_bit(std::string& str) - { - return (str[0] == 'b'); - } - - std::string process_qubit(std::string& str) - { - // check validity - if ((str[0] != 'q') && (str[0] != 'b')) - { - println("[x] syntax error: invalid qubit/bit identifier !"); - return ""; - } - for (int i=1; i<(str.size()-1); i++) - { - if (!is_digit(str[i])) - { - println("[x] syntax error: invalid qubit/bit identifier !"); - return ""; - } - } - // valid qubit/bit identifier, process it ... - std::string r=""; - r+=(is_bit(str) ? "bit " : "qubit "); - r+= int_to_str(qubit_id(str)); - return r; - } - - /** - * @brief set source database name - */ - void process_gate(strings &words) - { - std::cout << "gate name: " << words[1] << std::endl; - //database = words[1]; - } - - - - -}; - - -int main(int ragc, char ** argv) -{ - qasm_parser qp("test.qc"); - - qp.parse(); - - return 0; -} diff --git a/tests/qasm/qasm_loader.h b/tests/qasm/qasm_loader.h deleted file mode 100644 index f6b0c151..00000000 --- a/tests/qasm/qasm_loader.h +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @file qasm_loader.h - * @author Nader KHAMMASSI - nader.khammassi@gmail.com - * @date 13-10-15 - * @brief - */ - -#include - -namespace qx -{ - class qasm_loader : public circuit_loader - { - public: - - private: - - }; -} // namespace - diff --git a/tests/qasm/qasm_parser.h b/tests/qasm/qasm_parser.h deleted file mode 100644 index d9d82595..00000000 --- a/tests/qasm/qasm_parser.h +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @file parser.h - * @author Nader KHAMMASSI - nader.khammassi@gmail.com - * @date 13-10-15 - * @brief - */ -namespace qx -{ - namespace qasm - { - class parser - { - public: - - private: - - }; - - } // qasm -} // qx diff --git a/tests/qasm/qasm_scanner.h b/tests/qasm/qasm_scanner.h deleted file mode 100644 index 3b9d0be4..00000000 --- a/tests/qasm/qasm_scanner.h +++ /dev/null @@ -1,286 +0,0 @@ -/** - * @file qasm_scanner.h - * @author Nader KHAMMASSI - nader.khammassi@gmail.com - * @date 19-10-15 - * @brief - */ - -#include -#include -#include -#include -#include -//#include - -#include -#include - - -namespace qx -{ - namespace qasm - { - friend class parser; - - public: - - scanner(const char * str) : m_str(str), m_current(0), m_current_line(0), m_current_pos(0) - { - } - - scanner(std::string str) : m_str(str), m_current(0), m_current_line(0), m_current_pos(0) - { - } - - /** - * return next token. if the token is a number (float), its - * value is returned in x - */ - token_t next_token(float * x, std::string &var_name) throw (syntax_error_exception) - { - const char * s = m_str.c_str(); - int len = m_str.length(); - // skip spaces - skip_spaces(); - if (m_current >= len) return __end_token__; - // is a var name : expression must start with var_name = ... - if (is_letter(s[m_current])) - { - std::string str = ""; - str += s[m_current]; - m_current++; m_current_pos++; - while ((is_letter(s[m_current]) || is_digit(s[m_current])) && (m_current= len) return __end_token__; - - // is equal sign - if (s[m_current] == '=') - { - m_current++; m_current_pos++; - return __equal_token__; - } - - // is float : x.yyyy - if (is_digit(s[m_current])) - { - std::string num = ""; - num += s[m_current]; - m_current++; m_current_pos++; - while (is_digit(s[m_current]) && (m_current= len) return __end_token__; - // skip spaces - skip_spaces(); - //while (is_space(s[m_current]) && (m_current= len) return __end_token__; - // is string : var or function - if (is_letter(s[m_current])) - { - std::string str = ""; - str += s[m_current]; - m_current++; m_current_pos++; - while ((is_letter(s[m_current]) || is_digit(s[m_current])) && (m_current= len) return __end_token__; - // is period - if (is_period(s[m_current])) - { - m_current++; m_current_pos++; - return __period_token__; - } - // skip spaces - skip_spaces(); - //while (is_space(s[m_current]) && (m_current= len) return __end_token__; - // operators and paren ... - switch (s[m_current]) - { - case '+': m_current++; m_current_pos++; return __plus_token__; - case '-': m_current++; m_current_pos++; return __minus_token__; - case '*': m_current++; m_current_pos++; return __times_token__; - case '/': m_current++; m_current_pos++; return __divide_token__; - case '(': m_current++; m_current_pos++; return __left_paren_token__; - case ')': m_current++; m_current_pos++; return __right_paren_token__; - case '.': m_current++; m_current_pos++; return __dot_token__; - // default: std::cerr << " error: illegal character " << s[m_current] << std::endl; return __error_token__; // throw exception instead - default: - std::string err = " illegal character '"; err += s[m_current]; // err += "' at line "; err += int_to_str(m_current_line+1); err += " : pos "; err += int_to_str(m_current_pos+1); - throw syntax_error_exception(err,m_current_line+1,m_current_pos+1); return __error_token__; // throw exception instead - } - } - - void init() - { - m_current = 0; - m_current_line = 0; - m_current_pos = 0; - } - - void set_string(std::string s) - { - m_str = s; - init(); - } - - private: - - inline bool is_space(char x) - { - switch (x) - { - case '\f' : return true; - case '\n' : m_current_line++; m_current_pos=-1; return true; - case '\r' : return true; - case '\t' : return true; - case '\v' : return true; - case ' ' : return true; - default : return false; - } - // return ((x == '\f') || (x == '\n') || (x == '\r') || - // (x == '\t') || (x == '\v') || (x == ' ')); - } - - inline bool is_digit(char x) - { - return ((x >= '0') && (x<='9')); - } - - inline bool is_letter(char x) - { - return (((x >= 'a') && (x<='z')) || ((x >= 'A') && (x<='Z')) || (x == '_')); - } - - inline bool is_dot(char x) - { - return (x=='.'); - } - - inline bool is_period(char x) - { - return (x==';'); - } - - inline void skip_spaces() - { - // skip spaces - while (is_space(m_str[m_current]) && (m_current m_tokens; - //std::vector::iterator m_current; - }; - - class scanner - { - public: - - private: - - }; - - /** - * int to str - */ - std::string int_to_str(int i) - { - std::stringstream strm; - std::string num; - strm << i; - strm >> num; - return num; - } - - - } // qasm -} // qx diff --git a/tests/qasm/qasm_tokens.h b/tests/qasm/qasm_tokens.h deleted file mode 100644 index 4c72cc8e..00000000 --- a/tests/qasm/qasm_tokens.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file qasm_tokens.h - * @author Nader KHAMMASSI - nader.khammassi@gmail.com - * @date 19-10-15 - * @brief - */ - -namespace qx -{ - namespace qasm - { - typedef enum - { - // identifier - __id_token__, // id - __val_token__, // val - // qubit definition - __qubit_token__, // qubit - __cbit_token__, // cbit - // measure, zero - __measure_token__, // measure - __zero_token__, // zero - // single-qubit gates - __hadamard_token__, // H - __pauli_x_token__, // X - __pauli_y_token__, // Y - __pauli_z_token__, // Z - __phase_token__, // S - __sqrt_phase_token__,// T - // ctrl-gates - __cnot_token__, // cnot - __toffoli_token__, // toffoli - __ctrl_z_token__, // c-z - // swap - __swap_token__, // swap - // wire - __nop_token__, // nop - // specials - __error_token__ // illegal character - } qasm_token_t; - } // qasm -} // qx diff --git a/tests/qasm/strings.h b/tests/qasm/strings.h deleted file mode 100644 index dd9bedff..00000000 --- a/tests/qasm/strings.h +++ /dev/null @@ -1,213 +0,0 @@ -#ifndef XPU_STRINGS_H -#define XPU_STRINGS_H - - -namespace str -{ - typedef std::vector strings; - - /** - * @param str - * string to be processed - * @param seq - * string to be replaced - * @param rep - * string used to replace seq - * @brief - * replace recursively seq by rep in str - */ - inline void replace_all(std::string &str, std::string seq, std::string rep) - { - int index = str.find(seq); - while (index < str.size()) - { - str.replace(index, seq.size(), rep); - index = str.find(seq); - } - } - - /** - * @param str - * string to be processed - * @param seq - * sequence witch we want count - * occurences - * @return - * occurence count of seq in str - */ - inline int occur_count(std::string &str, std::string seq) - { - int count = 0, index = str.find(seq); - while (index < str.size() && index >= 0 ) - { - count++; - index = str.find(seq, index+1); - } - return count; - } - - - - /** - * @param str - * string to be processed - * @param separator - * words seprator (usually space charachter but can be any string) - * @return - * word list of a given string. - */ - inline strings word_list(std::string &str, std::string separator) - { - strings wrds; - int index = str.find(separator); - int prev = 0; - while (index < str.size() && index >= 0 ) - { - wrds.push_back(str.substr(prev,index-prev)); - prev=index+1; - index = str.find(separator, index+1); - } - wrds.push_back(str.substr(prev)); - return wrds; - } - - /** - * @param str - * string to be processed - * @brief - * convert string to lower case - */ - inline void lower_case(std::string& str) - { - for (int i=0; i='A') - str[i] = c-('Z'-'z'); - } - } - - /** - * @param str - * string to be processed - * @brief - * code line format : words separated by spaces : - * "word word word ...") - */ - inline void format_line(std::string &line) - { - lower_case(line); - replace_all(line, "\t", " "); - replace_all(line, "\n", " "); - replace_all(line, " ", " "); - replace_all(line, ", ", ","); - replace_all(line, " ,", ","); - replace_all(line, " , ", ","); - - if (line[0] == ' ') - line.erase(0, 1); - if (line[line.size()-1] == ' ') - line.erase(line.size()-1, 1); - } - - /** - * @param str - * string to be processed - * @brief - * remove inline comment - */ - inline void remove_comment(std::string &line, char c='#') - { - size_t p = line.find(c); - if (p != std::string::npos) - line = line.substr(0,p); - } - - - /** - * @param str - * string to be processed - * @return - * word count in a line (line format : words - * separated by spaces : "word word word ...") - */ - inline int word_count(std::string &str) - { - // spaces count - int count = occur_count(str, " "); - return count+1; - } - - - /** - * return true is x is a space/return/tab... charcter - */ - inline bool is_space(char x) - { - switch (x) - { - case '\f' : return true; - case '\n' : return true; - case '\r' : return true; - case '\t' : return true; - case '\v' : return true; - case ' ' : return true; - default : return false; - } - } - - /** - * is digit - */ - inline bool is_digit(char x) - { - return ((x >= '0') && (x<='9')); - } - - /** - * is letter - */ - inline bool is_letter(char x) - { - return (((x >= 'a') && (x<='z')) || ((x >= 'A') && (x<='Z')) || (x == '_')); - } - - /** - * is dot - */ - inline bool is_dot(char x) - { - return (x=='.'); - } - - /** - * is period - */ - inline bool is_period(char x) - { - return (x==';'); - } - - /** - * int to string - */ - std::string int_to_str(int i) - { - std::stringstream strm; - std::string num; - strm << i; - strm >> num; - return num; - } - - - - - -} - - - - -#endif // XPU_STRINGS_H - diff --git a/tests/qasm/syntax.note b/tests/qasm/syntax.note deleted file mode 100644 index 68a5f361..00000000 --- a/tests/qasm/syntax.note +++ /dev/null @@ -1,38 +0,0 @@ - - -I. qubits definition - - qubits - - -II. gate definition - - h q - cnot q,q # ctrl_qubit, target_qubit - swap q,q - x q - y q - z q - s q - - toffoli q,q,q - - cx [q|b],q - cy [q|b],q - cz [q|b],q - cs [q|b],q - - rx q,angle - ry q,angle - rz q,angle - -III. error injection - - noise , - decoherence - bitflip - -IV. error correction scheme - - ecc [steans|ninja_star] - diff --git a/tests/qasm/syntax_error_exception.cc b/tests/qasm/syntax_error_exception.cc deleted file mode 100644 index 12e12f17..00000000 --- a/tests/qasm/syntax_error_exception.cc +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @file syntax_error_syntax_error_exception.cc - * @author Nader KHAMMASSI - nader.khammassi@gmail.com - * @date 03-04-12 - * @brief - */ - -/** - * syntax_error_exception implementation - */ - -syntax_error_exception::syntax_error_exception(const std::string &message, - const int line, - const int position) - //const std::string& expected, - //const std::string& found) - throw() -{ - m_user_message = "[x] syntax error exception : at line "; - m_user_message.append(int_to_str(line)); - m_user_message.append(":"); - m_user_message.append(int_to_str(position)); - /* - m_user_message.append(" : expected '"); - m_user_message.append(expected); - m_user_message.append("', found '"); - m_user_message.append(found); - */ - m_user_message.append("' : "); - m_user_message.append(message); -} - -/** - * dtor - */ - -syntax_error_exception::~syntax_error_exception() throw() -{ -} - -/** - * explainatory message - */ - -const char *syntax_error_exception::what() const throw() -{ - return m_user_message.c_str(); -} - diff --git a/tests/qasm/syntax_error_exception.h b/tests/qasm/syntax_error_exception.h deleted file mode 100644 index 064f962e..00000000 --- a/tests/qasm/syntax_error_exception.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @file syntax_error_syntax_error_exception.h - * @author Nader KHAMMASSI - nader.khammassi@gmail.com - * @date 03-04-12 - * @brief - */ -#ifndef __QASM_SYNTAX_ERROR_EXCEPTION_H__ -#define __QASM_SYNTAX_ERROR_EXCEPTION_H__ - -#include // for string -#include // for strerror -#include // for syntax_error_exception -#include // for errno - -#include - -namespace qx -{ - namespace qasm - { - class syntax_error_exception : public std::exception - { - - public: - /** - * construct a syntax_error_exception with a explanatory message. - * - * @param message explanatory message - * @param system_message true if system message (from strerror(errno)) - * should be postfixed to the user provided message - */ - inline syntax_error_exception(const std::string &message, const int line, const int position) throw (); - - /** - * provided just to guarantee that no syntax_error_exceptions are thrown. - */ - inline ~syntax_error_exception() throw(); - - /** - * get the syntax_error_exception message - * @return syntax_error_exception message - */ - inline const char *what() const throw(); - - private: - - std::string m_user_message; // syntax_error_exception message - - }; // class syntax_error_exception - - - #include "syntax_error_exception.cc" - - } -} // namespace qx - -#endif // __XPU_SYNTAX_ERROR_EXCEPTION_H__ - - - diff --git a/tests/qasm/test.qc b/tests/qasm/test.qc deleted file mode 100644 index 5c8b805a..00000000 --- a/tests/qasm/test.qc +++ /dev/null @@ -1,31 +0,0 @@ -# qcode test file - -# qubit definition -qubits 8 - -.first_circuit - h q0 - cnot q0,q1 - x q1 - y q2 - z q3 - -.second_circuit - rx q4,0.453 - ry q5,0.244 - rz q6,0.555 - ph q7,1.378 - -.result -# measurement - measure q1 - -# noise -noise 0.001334,0.0000344 - -# decoherence -decoherence 0.0001 - -# error correction code -qec steans_three_qcode - diff --git a/tests/epr.qc b/tests/qasm_v0.0/epr.qc similarity index 100% rename from tests/epr.qc rename to tests/qasm_v0.0/epr.qc diff --git a/tests/full_adder.qc b/tests/qasm_v0.0/full_adder.qc similarity index 100% rename from tests/full_adder.qc rename to tests/qasm_v0.0/full_adder.qc diff --git a/tests/qec_3q_bit_flip_code.qc b/tests/qasm_v0.0/qec_3q_bit_flip_code.qc similarity index 100% rename from tests/qec_3q_bit_flip_code.qc rename to tests/qasm_v0.0/qec_3q_bit_flip_code.qc diff --git a/tests/qec_3q_bit_flip_code_simple.qc b/tests/qasm_v0.0/qec_3q_bit_flip_code_simple.qc similarity index 100% rename from tests/qec_3q_bit_flip_code_simple.qc rename to tests/qasm_v0.0/qec_3q_bit_flip_code_simple.qc diff --git a/tests/qec_3q_phase_flip_code.qc b/tests/qasm_v0.0/qec_3q_phase_flip_code.qc similarity index 100% rename from tests/qec_3q_phase_flip_code.qc rename to tests/qasm_v0.0/qec_3q_phase_flip_code.qc diff --git a/tests/stabilizer_17q_ninja_star.qc b/tests/qasm_v0.0/stabilizer_17q_ninja_star.qc similarity index 100% rename from tests/stabilizer_17q_ninja_star.qc rename to tests/qasm_v0.0/stabilizer_17q_ninja_star.qc diff --git a/tests/stabilizer_17q_ninja_star_defs.qc b/tests/qasm_v0.0/stabilizer_17q_ninja_star_defs.qc similarity index 100% rename from tests/stabilizer_17q_ninja_star_defs.qc rename to tests/qasm_v0.0/stabilizer_17q_ninja_star_defs.qc diff --git a/tests/test.qc b/tests/qasm_v0.0/test.qc similarity index 100% rename from tests/test.qc rename to tests/qasm_v0.0/test.qc diff --git a/tests/toffoli.qc b/tests/qasm_v0.0/toffoli.qc similarity index 100% rename from tests/toffoli.qc rename to tests/qasm_v0.0/toffoli.qc diff --git a/tests/qft.cc b/tests/qft.cc deleted file mode 100644 index fd1c77ca..00000000 --- a/tests/qft.cc +++ /dev/null @@ -1,51 +0,0 @@ - -#include - -#include -#include - -int main(int argc, char **argv) -{ - uint32_t n=3; - qx::qu_register reg(n); - qx::circuit qft(n); - - // init - qft.add(new qx::pauli_x(0)); - qft.add(new qx::pauli_x(1)); - qft.add(new qx::pauli_x(2)); - - qft.add(new qx::display()); - - // qft - for (uint32_t i=0; i