Core

Overview

QPanda2 Core Group. More...

// global functions

bool QPanda::init(QMachineType type = CPU);
void QPanda::finalize();
Qubit* QPanda::qAlloc();
Qubit* QPanda::qAlloc(size_t stQubitAddr);
std::map<std::string, bool> QPanda::directlyRun(QProg& qProg);
QVec QPanda::qAllocMany(size_t stQubitNumber);
ClassicalCondition QPanda::cAlloc();
ClassicalCondition QPanda::cAlloc(size_t stCBitaddr);
std::vector<ClassicalCondition> QPanda::cAllocMany(size_t stCBitNumber);
void QPanda::cFree(ClassicalCondition&);
void QPanda::cFreeAll(std::vector<ClassicalCondition> vCBit);
QMachineStatus* QPanda::getstat();
size_t QPanda::getAllocateQubitNum();
prob_tuple QPanda::getProbTupleList(QVec&, int selectMax = -1);
prob_vec QPanda::getProbList(QVec&, int selectMax = -1);
prob_dict QPanda::getProbDict(QVec&, int selectMax = -1);
prob_tuple QPanda::probRunTupleList(QProg&, QVec&, int selectMax = -1);
prob_vec QPanda::probRunList(QProg&, QVec&, int selectMax = -1);
prob_dict QPanda::probRunDict(QProg&, QVec&, int selectMax = -1);
std::map<std::string, size_t> QPanda::runWithConfiguration(QProg&, std::vector<ClassicalCondition>&, int);
std::map<std::string, size_t> QPanda::quickMeasure(QVec&, int);
prob_vec QPanda::accumulateProbability(prob_vec& prob_list);

std::map<std::string, size_t> QPanda::quick_measure(
    QVec& qubit_vector,
    int shots,
    prob_vec& accumulate_probabilites
    );

QStat QPanda::getQState();
QuantumMachine* QPanda::initQuantumMachine(QMachineType type = CPU);
void QPanda::destroyQuantumMachine(QuantumMachine* qvm);
QPanda::QProg QPanda::MeasureAll(QVec, std::vector<ClassicalCondition>);
size_t QPanda::getAllocateCMemNum();
prob_tuple QPanda::pMeasure(QVec& qubit_vector, int select_max);
prob_vec QPanda::pMeasureNoIndex(QVec& qubit_vector);
QMeasure QPanda::Measure(Qubit*, ClassicalCondition);

Detailed Documentation

QPanda2 Core Group.

Global Functions

bool QPanda::init(QMachineType type = CPU)

Init the environment.

Use this at the beginning

Parameters:

QMachineType Quantum machine type

Returns:

bool

See also:

QMachineType

void QPanda::finalize()

Finalize the environment.

Use this at the end

Returns:

void

Qubit* QPanda::qAlloc()

Allocate a qubit.

Call init() before you use this

Returns:

void

Qubit* QPanda::qAlloc(size_t stQubitAddr)

Allocate a qubit.

Call init() before you use this

Parameters:

size_t set qubit address

Returns:

void

std::map<std::string, bool> QPanda::directlyRun(QProg& qProg)

Directly run a quantum program.

Parameters:

QProg& Quantum program

Returns:

std::map<std::string, bool> result

QVec QPanda::qAllocMany(size_t stQubitNumber)

Allocate many qubits.

Call init() before you use this

Parameters:

size_t set qubit number
ClassicalCondition QPanda::cAlloc()

Allocate a cbit.

Call init() before you use this

Returns:

ClassicalCondition cbit

ClassicalCondition QPanda::cAlloc(size_t stCBitaddr)

Allocate a cbit.

Call init() before you use this

Parameters:

size_t set cbit address

Returns:

ClassicalCondition Cbit

std::vector<ClassicalCondition> QPanda::cAllocMany(size_t stCBitNumber)

Allocate many cbits.

Call init() before you use this

Parameters:

size_t set cbit number
void QPanda::cFree(ClassicalCondition&)

Free a cbit.

Parameters:

ClassicalCondition& a reference to a cbit

Returns:

void

void QPanda::cFreeAll(std::vector<ClassicalCondition> vCBit)

Free a list of cbits.

Parameters:

std::vector<ClassicalCondition> a list of cbits

Returns:

void

QMachineStatus* QPanda::getstat()

Get the status(ptr) of the Quantum machine.

Returns:

QPanda::QMachineStatus * Quantum machine status(ptr)

size_t QPanda::getAllocateQubitNum()

Get all allocate qubit num.

Returns:

size_t Qubit num

prob_tuple QPanda::getProbTupleList(QVec&, int selectMax = -1)

Get pmeasure result as tuple list.

selectMax can not exceed (1ull << the size of qubits vector)

Parameters:

QVec& pmeasure qubits vector
int Selectmax:the returned value num

Returns:

std::vector<std::pair<size_t, double>> result

prob_vec QPanda::getProbList(QVec&, int selectMax = -1)

Get pmeasure result as list.

SelectMax can not exceed (1ull << the size of qubits vector)

Parameters:

QVec& pmeasure qubits vector
int Selectmax:the returned value num

Returns:

prob_vec result

prob_dict QPanda::getProbDict(QVec&, int selectMax = -1)

Get pmeasure result as dict.

SelectMax can not exceed (1ull << the size of qubits vector)

Parameters:

QVec& pmeasure qubits vector
int Selectmax:the returned value num

Returns:

std::map<std::string, double> result

prob_tuple QPanda::probRunTupleList(QProg&, QVec&, int selectMax = -1)

Get pmeasure result as dict.

SelectMax can not exceed (1ull << the size of qubits vector)

Parameters:

QProg& Quantum program
QVec& pmeasure qubits vector
int Selectmax:the returned value num

Returns:

std::vector<std::pair<size_t, double>> result

prob_vec QPanda::probRunList(QProg&, QVec&, int selectMax = -1)

Get pmeasure result as list.

SelectMax can not exceed (1ull << the size of qubits vector)

Parameters:

QProg& Quantum program
QVec& Pmeasure qubits vector
int selectmax:the returned value num

Returns:

prob_vec result

prob_dict QPanda::probRunDict(QProg&, QVec&, int selectMax = -1)

Get pmeasure result as dict.

SelectMax can not exceed (1ull << the size of qubits vector)

Parameters:

QProg& Quantum program
QVec& pmeasure qubits vector
int Selectmax:the returned value num

Returns:

std::map<std::string, double> result

std::map<std::string, size_t> QPanda::runWithConfiguration(
    QProg&,
    std::vector<ClassicalCondition>&,
    int
    )

Measure run with configuration.

Parameters:

QProg& Quantum program
std::vector<ClassicalCondition>& cbits vector
int Shots:the repeat num of measure operate

Returns:

std::map<std::string, size_t> result

std::map<std::string, size_t> QPanda::quickMeasure(QVec&, int)

Quick measure operate.

Parameters:

QVec& qubits vector
int Shots:the repeat num of measure operate

Returns:

std::map<std::string,size_t> result

prob_vec QPanda::accumulateProbability(prob_vec& prob_list)

AccumulateProbability.

Parameters:

prob_vec & prob_list Abstract Quantum program pointer

Returns:

prob_vec

std::map<std::string, size_t> QPanda::quick_measure(
    QVec& qubit_vector,
    int shots,
    prob_vec& accumulate_probabilites
    )

Quick measure.

Parameters:

QVec& qubits vector
int Shots:the repeat num of measure operate
prob_vec& accumulate Probabilites

Returns:

std::map<std::string,size_t> Results

QStat QPanda::getQState()

Get quantum state.

Returns:

qstat Quantum state vector

QuantumMachine* QPanda::initQuantumMachine(QMachineType type = CPU)

Init a Quantum machine.

default Quantum machine type :cpu

Parameters:

QMachineType  

Returns:

QPanda::QuantumMachine * Quantum machine pointer

See also:

QMachineType

void QPanda::destroyQuantumMachine(QuantumMachine* qvm)

Destroy Quantum machine.

Parameters:

QuantumMachine* Quantum machine pointer

Returns:

void

QPanda::QProg QPanda::MeasureAll(QVec, std::vector<ClassicalCondition>)

Measure All ClassicalCondition.

Parameters:

QVec& qubits vector
std::vector<ClassicalCondition>& Cbits vector

Returns:

QPanda::QProg Quantum program

size_t QPanda::getAllocateCMemNum()

Get allocate cbit number.

Returns:

size_t Cbit number

prob_tuple QPanda::pMeasure(QVec& qubit_vector, int select_max)

pMeasure

Parameters:

QVec& qubit vector
int Selectmax:the returned value num

Returns:

std::vector<std::pair<size_t, double>> result

prob_vec QPanda::pMeasureNoIndex(QVec& qubit_vector)

pMeasure only return result with no index

Parameters:

QVec& qubit vector

Returns:

prob_vec result

QMeasure QPanda::Measure(Qubit*, ClassicalCondition)

QPanda2 basic interface for creating a quantum measure node.

Parameters:

Qubit* qubit address
ClassicalCondition cbit

Returns:

QPanda::QMeasure quantum measure node