QPanda integrates a large number of quantum algorithms and provides interfaces to help you build applications quickly. User API reference documentation
Quantum library
Only quantum algorithms can be run on quantum computers. We integrate common and common quantum algorithms to avoid the long learning time of the algorithm. QPanda lets you focus on how to configure your application.QPanda adopts C++ for design and development. User API reference documentation
Reasonable interface design
QPanda hides implementation details and provides an interface that is intuitive and simple for anyone to use.Detailed interface description
We encapsulate common operations and provide you with a detailed set of API documentationQPanda defines a program model suitable for running a quantum computer, which enables the dynamic allocation and release of resources in a quantum program. User API reference documentation
Static quantum machine
QPanda abstracts the features of quantum computers and standardizes the creation and operation of quantum applicationsQuantum bit pool
By virtualizing the actual quantum chip, you can apply, use, and release the quantum bits through the quantum bit pool. Additional work on QPanda has been done for you.Quantum computer adaptation
Worried that quantum computers support different sets of instructions that make quantum applications incompatible? QPanda can help you adapt automatically.QPanda use C++ to build quantum programs to avoid the tedious code of quantum assembly.User API reference documentation
Quantum circuit module
QPanda integrates common quantum circuits, saving a lot of repetitive work.Quantum control flow
You can configure any combination of q-if and q-while in QPanda to easily build complex quantum-classical hybrids.QPanda Framework is a quantum software development package launched by Origin Quantum. Using the QPanda Framework, you can:
- Create any quantum - classical hybrid application
- quantum programs on different quantum computers or on the back end of virtual machines
QPanda Framework is a quantum software development package launched by Origin Quantum. Using the QPanda Framework, you can:
- Create any quantum - classical hybrid application
- quantum programs on different quantum computers or on the back end of virtual machines
QPanda integrates a large number of quantum algorithms and provides interfaces to help you build applications quickly. User API reference documentation
Quantum library
Only quantum algorithms can be run on quantum computers. We integrate common and common quantum algorithms to avoid the long learning time of the algorithm. QPanda lets you focus on how to configure your application.QPanda use C++ to build quantum programs to avoid the tedious code of quantum assembly.User API reference documentation
Quantum circuit module
QPanda integrates common quantum circuits, saving a lot of repetitive work.Quantum control flow
You can configure any combination of q-if and q-while in QPanda to easily build complex quantum-classical hybrids.QPanda defines a program model suitable for running a quantum computer, which enables the dynamic allocation and release of resources in a quantum program. User API reference documentation
Static quantum machine
QPanda abstracts the features of quantum computers and standardizes the creation and operation of quantum applicationsQuantum bit pool
By virtualizing the actual quantum chip, you can apply, use, and release the quantum bits through the quantum bit pool. Additional work on QPanda has been done for you.Quantum computer adaptation
Worried that quantum computers support different sets of instructions that make quantum applications incompatible? QPanda can help you adapt automatically.QPanda adopts C++ for design and development. User API reference documentation
Reasonable interface design
QPanda hides implementation details and provides an interface that is intuitive and simple for anyone to use.Detailed interface description
We encapsulate common operations and provide you with a detailed set of API documentation#include "DJ_Algorithm.h" QProg & Two_Qubit_DJ_Algorithm_Circuit( Qubit * qubit1, Qubit * qubit2, CBit * cbit, vector< bool> oracle_function) { auto &prog = CreateEmptyQProg(); //Firstly, create a circuit container prog << H(qubit1) << H(qubit2); // Perform Hadamard gate on all qubits if (oracle_function[0] == false && oracle_function[1] == false) // different oracle leads to different circuit // f(x) = oracle_function[x] { // f(x) = 0, do nothing } else if (oracle_function[0] == false && oracle_function[1] == true ) { // f(x) = x; prog << CNOT(qubit1, qubit2); } else if (oracle_function[0] == true && oracle_function[1] == false ) { // f(x) = x + 1; prog << RX(qubit2) << CNOT(qubit1, qubit2) << RX(qubit2); } else if (oracle_function[0] == true && oracle_function[1] == true ) { // f(x) = 1 prog << RX(qubit2); } // Finally, Hadamard the first qubit and measure it prog << H(qubit1) << Measure(qubit1, cbit); return prog; }
#include "Grover_Algorithm.h" QProg& Grover(vector<Qubit*> qVec, vector<CBit*> cVec, int target) { QProg & grover = CreateEmptyQProg(); OriginQCircuit & init = CreateEmptyCircuit(); OriginQCircuit & oracle = CreateEmptyCircuit(); OriginQCircuit & reverse = CreateEmptyCircuit(); init << H(qVec[0]) << H(qVec[1]) << RX(qVec[2]) << H(qVec[2]); vector<Qubit *> controlVector; controlVector.push_back(qVec[0]); controlVector.push_back(qVec[1]); //QSingleGate sqrtH(0.5*PI, 0, 0.25*PI, PI); OriginQGateNode &toff = RX(qVec[2]); toff.setControl(controlVector); switch (target) { case 0: oracle << RX(qVec[0]) << RX(qVec[1]) << toff << RX(qVec[0]) << RX(qVec[1]); break; case 1: oracle << RX(qVec[0]) << toff << RX(qVec[0]); break; case 2: oracle << RX(qVec[1]) << toff << RX(qVec[1]); break; case 3: oracle << toff; break; } reverse << H(qVec[0]) << H(qVec[1]) << RX(qVec[0]) << RX(qVec[1]) << H(qVec[1]) << CNOT(qVec[0], qVec[1]); reverse << H(qVec[1]) << RX(qVec[0]) << RX(qVec[1]) << H(qVec[0]) << H(qVec[1]) << RX(qVec[2]); grover << init << oracle << reverse << Measure(qVec[0], cVec[0]) << Measure(qVec[1], cVec[1]); return grover; }
#include "HHL_Algorithm.h" QProg& hhl (vector<Qubit*> qVec,vector<CBit*> cVec) { ClassicalCondition *cc0=bind_a_cbit(cVec[0]); // meaningless sentence OriginQCircuit & ifcircuit = CreateEmptyCircuit(); OriginQCircuit & PSEcircuit = hhlPse(qVec);//PSE OriginQCircuit & CRot = CRotate(qVec);//control-lambda OriginQCircuit & PSEcircuitdag = hhlPse(qVec); //hhl circuit QProg & PSEdagger = CreateEmptyQProg(); PSEdagger << PSEcircuitdag.dagger() << Measure(qVec[3], cVec[1]); QIfNode & ifnode = CreateIfProg(cc0, &PSEdagger); QProg & hhlProg = CreateEmptyQProg(); //hhlProg << PSEcircuit <<CRot<< Measure(qVec[0], cVec[0])<<ifnode; hhlProg << PSEcircuit << CRot << Measure(qVec[0], cVec[0]) << ifnode; return hhlProg; } OriginQCircuit& hhlPse(vector<Qubit*> qVec) { OriginQCircuit & PSEcircuit = CreateEmptyCircuit(); PSEcircuit << H(qVec[1]) << H(qVec[2]) << RZ(qVec[2], 0.75*PI); OriginQGateNode & gat1 = QDouble(PI, 1.5*PI, -0.5*PI, PI / 2, qVec[2], qVec[3]); OriginQGateNode & gat2 = QDouble(PI, 1.5*PI, -PI, PI / 2, qVec[1], qVec[3]); }
#include "Nonlocal_Game.h" bool Winning_Test(pair<bool, bool> question, pair<bool, bool> answer) { bool question_condition = question.first && question.second; bool answer_condition = answer.first || answer.second; if (question_condition == answer_condition) { return true; // Alice and Bob win the game. } else { return false; // Alice and Bob lose the game. } } pair<bool, bool> getRefereeQuestion() { bool toAlice, toBob; srand(time(0)); toAlice = static_cast<bool>(rand() % 2); toBob = static_cast<bool>(rand() % 2); // Random number simulation function is used to // simulate the problem that Referee will ask Alice and Bob. return make_pair(toAlice, toBob); } QProg& Game( Qubit* alice_qubit, Qubit* bob_qubit, CBit* alice_meas, CBit* bob_meas, pair<bool, bool> &question) { auto & game = CreateEmptyQProg(); auto & entangled = CreateEmptyCircuit(); auto & oracle = CreateEmptyCircuit(); auto & Gate_I = RY(alice_qubit, 0); auto & Gate_T = RZ(bob_qubit, PI / 4); auto & Gate_T_Daga = RZ(bob_qubit, - PI / 4); // Custom Quantum logic Gates entangled << H(alice_qubit) << CNOT(bob_qubit, alice_qubit); // Make two qubit entangled, Here alice_qubit represent the qubit of Alice, and bob_qubit represent the qubit of bob. question = getRefereeQuestion(); if (question.first) { if (question.second) { oracle << H(alice_qubit) << S(bob_qubit) << H(bob_qubit) << Gate_T_Daga << H(bob_qubit); } else { oracle << H(alice_qubit) << S(bob_qubit) << H(bob_qubit) << Gate_T << H(bob_qubit); } } else { if (question.second) { oracle << Gate_I << S(bob_qubit) << H(bob_qubit) << Gate_T_Daga << H(bob_qubit); } else { oracle << Gate_I << S(bob_qubit) << H(bob_qubit) << Gate_T << H(bob_qubit); } } game << entangled << oracle << Measure(alice_qubit, alice_meas) << Measure(bob_qubit, bob_meas); return game; } void Nonlocal_Game(){ size_t Round = 10; size_t win = 0; size_t lose = 0; for (size_t i = 0; i < Round; i++) { init(); auto alice_qubit = qAlloc(); auto bob_qubit = qAlloc(); auto alice_meas = cAlloc(); auto bob_meas = cAlloc(); pair<bool, bool> question; auto &GameProg = Game(alice_qubit,bob_qubit,alice_meas,bob_meas, question); load(GameProg); run(); auto alice_answer = getCBitValue(alice_meas); auto bob_answer = getCBitValue(bob_meas); bool final_result = Winning_Test(question, make_pair(alice_answer, bob_answer)); if (final_result==true) { win++; } else { lose++; } cout << "The number of times player have won is;" << win; cout << "The number of times player have lose is;" << lose; finalize(); } }