Overview

Quantum algorithm
The user interface
Quantum machine
Quantum program
QPanda

量子算法 Quantum Algorithm

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.

用户接口 User Interface

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

量子机器模型 Quantum Machine Model

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 applications

Quantum 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.

量子程序 Quantum Program

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

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 is released to GitHub in accordance with the Apache Licence 2.0 open source protocol. Your valuable comments and Suggestions are welcome!
  • QPanda
  • Quantum algorithm
  • Quantum program
  • Quantum machine
  • The user interface

QPanda Framework

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 is released to GitHub in accordance with the Apache Licence 2.0 open source protocol. Your valuable comments and Suggestions are welcome!

量子算法 Quantum Algorithm

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.

量子程序 Quantum Program

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.

量子机器模型 Quantum Machine Model

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 applications

Quantum 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.

用户接口 User Interface

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

Advantage

支持控制流
Support Quantum Control Flow
Either q-if or q-while, you can put them in any combination and insert them anywhere in the quantum circuit.
轻松编写混合算法
Easy to make hybrid algorithm
The data in the quantum computer can be easily imported and exported using the built-in API, and the quantum - classical computer is seamless.
完全使用经典语言
Enable full classical language
Worried about the cost of learning a quantum language? QPanda gives you more choices. Now, any quantum algorithm can be created using C++ alone.
  • 支持控制流
    Support Quantum Control Flow
    Either q-if or q-while, you can put them in any combination and insert them anywhere in the quantum circuit.
  • 轻松编写混合算法
    Easy to make hybrid algorithm
    The data in the quantum computer can be easily imported and exported using the built-in API, and the quantum - classical computer is seamless.
  • 完全使用经典语言
    Enable full classical language
    Worried about the cost of learning a quantum language? QPanda gives you more choices. Now, any quantum algorithm can be created using C++ alone.

Algorithm

D-J
Make a snap judgment
Once upon a time
View details
Grover
Quick target search
Big data weapon
View details
HHL
Solve linear equations
Assist machine learning
View details
Game strategy
Non-local game
Game new world
View details
View details
Make a snap judgment,Once upon a time
The Deutsch-Jozsa algorithm is the first quantum algorithm discovered by humans, which achieves exponential acceleration relative to classic computers. Data that needs to be traversed on a classical computer can be judged instantaneously on a quantum computer.
The Deutsch-Jozsa algorithm is used to determine whether a function is a constant function or an equilibrium function. Although the deutsch-jozsa algorithm currently has few practical applications, it made people realize the huge potential of quantum computing for the first time...

D-J circuit diagram:

Refer code: Copy
#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;
}
                                        
View details
Quick target search,Big data weapon
The age of big data has created the panic of big data. Nowadays, the amount of data generated every day is more than the sum accumulated in the past decade. Massive data poses huge challenges for information processing.
The quantum search algorithm achieves the time complexity of $O(\sqrt{N})$ for the search problem.A problem that requires 100 million calculations to solve on a classical computer, quantum computing takes 10,000. As the problem increases, the acceleration factor increases, and that's the power of quantum computing!

Grover circuit diagram:

Refer code: Copy
#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;
}
                                        
View details
Solve linear equations,Assist machine learning
Non-local Game, also known as telepathy-testing. This game is a classic case, the player free will participate in the game, through the statistics of many times, the game's victory and defeat distribution. Typically, players win no more than 75% of the games, and when they integrate quantum resources into their strategies, they find that they can win more, up to 85%.
The game raises a lot of questions, especially in the absence of communication, from 75 to 85 percent of the time, how does a quantum bit actually affect our real world?

HHL circuit diagram :

Refer code: Copy
#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]);
}

                                        
View details
Non-local game,Game new world

Game strategy circuit diagram:

Refer code: Copy
#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();

	}
}                                        

Download

QPanda Framework
version:2.0
Updated date:2018-06-04
System Supported:Windows版
量子软件开发包 QPanda
version:1.0
Updated date:2018-06-04
System Supported:Windows版