.. index:: pair: group; Core .. _doxid-group___core: Core ==== .. toctree:: :hidden: group_QuantumCircuit.rst group_QuantumMachine.rst group_Utilities.rst group_Variational.rst group_VirtualQuantumProcessor.rst Overview ~~~~~~~~ QPanda2 Core Group. :ref:`More...` | :ref:`QuantumCircuit` | :ref:`QuantumMachine` | :ref:`Utilities` | :ref:`Variational` | :ref:`VirtualQuantumProcessor` .. ref-code-block:: cpp :class: doxyrest-overview-code-block // global functions bool :ref:`QPanda::init`(:ref:`QMachineType` type = :ref:`CPU`); void :ref:`QPanda::finalize`(); :ref:`Qubit`* :ref:`QPanda::qAlloc`(); :ref:`Qubit`* :ref:`QPanda::qAlloc`(size_t stQubitAddr); std::map :ref:`QPanda::directlyRun`(:ref:`QProg`& qProg); :ref:`QVec` :ref:`QPanda::qAllocMany`(size_t stQubitNumber); :ref:`ClassicalCondition` :ref:`QPanda::cAlloc`(); :ref:`ClassicalCondition` :ref:`QPanda::cAlloc`(size_t stCBitaddr); std::vector<:ref:`ClassicalCondition`> :ref:`QPanda::cAllocMany`(size_t stCBitNumber); void :ref:`QPanda::cFree`(:ref:`ClassicalCondition`&); void :ref:`QPanda::cFreeAll`(std::vector<:ref:`ClassicalCondition`> vCBit); :ref:`QMachineStatus`* :ref:`QPanda::getstat`(); size_t :ref:`QPanda::getAllocateQubitNum`(); :ref:`prob_tuple` :ref:`QPanda::getProbTupleList`(:ref:`QVec`, int selectMax = -1); :ref:`prob_vec` :ref:`QPanda::getProbList`(:ref:`QVec`, int selectMax = -1); :ref:`prob_dict` :ref:`QPanda::getProbDict`(:ref:`QVec`, int selectMax = -1); :ref:`prob_tuple` :ref:`QPanda::probRunTupleList`(:ref:`QProg`&, :ref:`QVec`, int selectMax = -1); :ref:`prob_vec` :ref:`QPanda::probRunList`(:ref:`QProg`&, :ref:`QVec`, int selectMax = -1); :ref:`prob_dict` :ref:`QPanda::probRunDict`(:ref:`QProg`&, :ref:`QVec`, int selectMax = -1); std::map :ref:`QPanda::runWithConfiguration`(:ref:`QProg`&, std::vector<:ref:`ClassicalCondition`>&, int); std::map :ref:`QPanda::quickMeasure`(:ref:`QVec`, int); :ref:`prob_vec` :ref:`QPanda::accumulateProbability`(:ref:`prob_vec`& prob_list); std::map :ref:`QPanda::quick_measure`( :ref:`QVec` qubit_vector, int shots, :ref:`prob_vec`& accumulate_probabilites ); :ref:`QStat` :ref:`QPanda::getQState`(); :ref:`QuantumMachine`* :ref:`QPanda::initQuantumMachine`(:ref:`QMachineType` type = :ref:`CPU`); void :ref:`QPanda::destroyQuantumMachine`(:ref:`QuantumMachine`* qvm); :ref:`QPanda::QProg` :ref:`QPanda::MeasureAll`(:ref:`QVec`, std::vector<:ref:`ClassicalCondition`>); size_t :ref:`QPanda::getAllocateCMemNum`(); :ref:`prob_tuple` :ref:`QPanda::pMeasure`(:ref:`QVec` qubit_vector, int select_max); :ref:`prob_vec` :ref:`QPanda::pMeasureNoIndex`(:ref:`QVec` qubit_vector); :ref:`QMeasure` :ref:`QPanda::Measure`(:ref:`Qubit`*, :ref:`ClassicalCondition`); :ref:`QMeasure` :ref:`QPanda::Measure`(int, int); .. _details-group___core: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ QPanda2 Core Group. Global Functions ---------------- .. index:: pair: function; init .. _doxid-group___core_1gabc82d3c6d644397619115a284fd8fcc0: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool QPanda::init(:ref:`QMachineType` type = :ref:`CPU`) Init the environment. Use this at the beginning .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - QMachineType - Quantum machine type .. rubric:: Returns: bool .. rubric:: See also: :ref:`QMachineType ` .. index:: pair: function; finalize .. _doxid-group___core_1gacd2f5cfc79160543f03c5bef34d27185: .. ref-code-block:: cpp :class: doxyrest-title-code-block void QPanda::finalize() Finalize the environment. Use this at the end .. rubric:: Returns: void .. index:: pair: function; qAlloc .. _doxid-group___core_1ga9a81705d142b143260f86f742adf0d86: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Qubit`* QPanda::qAlloc() Allocate a qubit. Call :ref:`init() ` before you use this .. rubric:: Returns: void .. index:: pair: function; qAlloc .. _doxid-group___core_1ga2a307b5ad8cdee51c52bdbf0d299e509: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Qubit`* QPanda::qAlloc(size_t stQubitAddr) Allocate a qubit. Call :ref:`init() ` before you use this .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - size_t - set qubit address .. rubric:: Returns: void .. index:: pair: function; directlyRun .. _doxid-group___core_1ga65ef685dd053d017b2f9e48f38c03370: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::map QPanda::directlyRun(:ref:`QProg`& qProg) Directly run a quantum program. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - QProg& - Quantum program .. rubric:: Returns: std::map result .. index:: pair: function; qAllocMany .. _doxid-group___core_1ga9dcf62b20ef64d5b561e7919e7903a97: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`QVec` QPanda::qAllocMany(size_t stQubitNumber) Allocate many qubits. Call :ref:`init() ` before you use this .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - size_t - set qubit number .. index:: pair: function; cAlloc .. _doxid-group___core_1ga5fcf81bd208ecf4ba4e53249599fdb4d: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`ClassicalCondition` QPanda::cAlloc() Allocate a cbit. Call :ref:`init() ` before you use this .. rubric:: Returns: :ref:`ClassicalCondition ` cbit .. index:: pair: function; cAlloc .. _doxid-group___core_1ga792cdfc228747df979116019ab869dca: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`ClassicalCondition` QPanda::cAlloc(size_t stCBitaddr) Allocate a cbit. Call :ref:`init() ` before you use this .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - size_t - set cbit address .. rubric:: Returns: :ref:`ClassicalCondition ` Cbit .. index:: pair: function; cAllocMany .. _doxid-group___core_1ga820833650151100c4a29aafc2f345863: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::vector<:ref:`ClassicalCondition`> QPanda::cAllocMany(size_t stCBitNumber) Allocate many cbits. Call :ref:`init() ` before you use this .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - size_t - set cbit number .. index:: pair: function; cFree .. _doxid-group___core_1ga95bc1fb6ac649bd590680a2676e71ea6: .. ref-code-block:: cpp :class: doxyrest-title-code-block void QPanda::cFree(:ref:`ClassicalCondition`&) Free a cbit. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - ClassicalCondition& - a reference to a cbit .. rubric:: Returns: void .. index:: pair: function; cFreeAll .. _doxid-group___core_1gaa438f340325085ab44936e0413c2d40d: .. ref-code-block:: cpp :class: doxyrest-title-code-block void QPanda::cFreeAll(std::vector<:ref:`ClassicalCondition`> vCBit) Free a list of cbits. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - std::vector - a list of cbits .. rubric:: Returns: void .. index:: pair: function; getstat .. _doxid-group___core_1ga2dcbb445a1e5c3b5cdec9b44e1325096: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`QMachineStatus`* QPanda::getstat() Get the status(ptr) of the Quantum machine. .. rubric:: Returns: :ref:`QPanda::QMachineStatus ` \* Quantum machine status(ptr) .. index:: pair: function; getAllocateQubitNum .. _doxid-group___core_1ga9f99c54c66e54057d1f635b0bf4ed26e: .. ref-code-block:: cpp :class: doxyrest-title-code-block size_t QPanda::getAllocateQubitNum() Get all allocate qubit num. .. rubric:: Returns: size_t :ref:`Qubit ` num .. index:: pair: function; getProbTupleList .. _doxid-group___core_1gaf33bb76aa471e94acb73c6f826929f88: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`prob_tuple` QPanda::getProbTupleList(:ref:`QVec`, int selectMax = -1) Get pmeasure result as tuple list. selectMax can not exceed (1ull << the size of qubits vector) .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - :ref:`QVec ` - pmeasure qubits vector * - int - Selectmax:the returned value num .. rubric:: Returns: std::vector> result .. index:: pair: function; getProbList .. _doxid-group___core_1ga7366e4bf7003a2d2af60320b58f3d1a7: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`prob_vec` QPanda::getProbList(:ref:`QVec`, int selectMax = -1) Get pmeasure result as list. SelectMax can not exceed (1ull << the size of qubits vector) .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - :ref:`QVec ` - pmeasure qubits vector * - int - Selectmax:the returned value num .. rubric:: Returns: prob_vec result .. index:: pair: function; getProbDict .. _doxid-group___core_1ga7d80ef096c4293c404eca95a3dc40079: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`prob_dict` QPanda::getProbDict(:ref:`QVec`, int selectMax = -1) Get pmeasure result as dict. SelectMax can not exceed (1ull << the size of qubits vector) .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - :ref:`QVec ` - pmeasure qubits vector * - int - Selectmax:the returned value num .. rubric:: Returns: std::map result .. index:: pair: function; probRunTupleList .. _doxid-group___core_1ga4d656a29d06a17473a5bf90709b97b2c: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`prob_tuple` QPanda::probRunTupleList(:ref:`QProg`&, :ref:`QVec`, int selectMax = -1) Get pmeasure result as dict. SelectMax can not exceed (1ull << the size of qubits vector) .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - QProg& - Quantum program * - :ref:`QVec ` - pmeasure qubits vector * - int - Selectmax:the returned value num .. rubric:: Returns: std::vector> result .. index:: pair: function; probRunList .. _doxid-group___core_1ga706f85efb9f4ed6792b4ebf140e6f205: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`prob_vec` QPanda::probRunList(:ref:`QProg`&, :ref:`QVec`, int selectMax = -1) Get pmeasure result as list. SelectMax can not exceed (1ull << the size of qubits vector) .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - QProg& - Quantum program * - :ref:`QVec ` - Pmeasure qubits vector * - int - selectmax:the returned value num .. rubric:: Returns: prob_vec result .. index:: pair: function; probRunDict .. _doxid-group___core_1ga9765f5328a72fa839b1c503d94646977: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`prob_dict` QPanda::probRunDict(:ref:`QProg`&, :ref:`QVec`, int selectMax = -1) Get pmeasure result as dict. SelectMax can not exceed (1ull << the size of qubits vector) .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - QProg& - Quantum program * - :ref:`QVec ` - pmeasure qubits vector * - int - Selectmax:the returned value num .. rubric:: Returns: std::map result .. index:: pair: function; runWithConfiguration .. _doxid-group___core_1gaac240d65f6c9c0e955a583b7d7a7735b: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::map QPanda::runWithConfiguration( :ref:`QProg`&, std::vector<:ref:`ClassicalCondition`>&, int ) Measure run with configuration. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - QProg& - Quantum program * - std::vector& - cbits vector * - int - Shots:the repeat num of measure operate .. rubric:: Returns: std::map result .. index:: pair: function; quickMeasure .. _doxid-group___core_1gaab1e9c0f76888f6252953e5ffc001c02: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::map QPanda::quickMeasure(:ref:`QVec`, int) Quick measure operate. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - :ref:`QVec ` - qubits vector * - int - Shots:the repeat num of measure operate .. rubric:: Returns: std::map result .. index:: pair: function; accumulateProbability .. _doxid-group___core_1gab7fa40c4a3d8d4b6c9dc5a5bf389162f: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`prob_vec` QPanda::accumulateProbability(:ref:`prob_vec`& prob_list) AccumulateProbability. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - prob_vec - & prob_list Abstract Quantum program pointer .. rubric:: Returns: prob_vec .. index:: pair: function; quick_measure .. _doxid-group___core_1ga5953c0ff383295f2bcea4d3cff1f1a29: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::map QPanda::quick_measure( :ref:`QVec` qubit_vector, int shots, :ref:`prob_vec`& accumulate_probabilites ) Quick measure. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - :ref:`QVec ` - qubits vector * - int - Shots:the repeat num of measure operate * - prob_vec& - accumulate Probabilites .. rubric:: Returns: std::map Results .. index:: pair: function; getQState .. _doxid-group___core_1gacaafce8fec4c04e15a492fb695176bb1: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`QStat` QPanda::getQState() Get quantum state. .. rubric:: Returns: qstat Quantum state vector .. index:: pair: function; initQuantumMachine .. _doxid-group___core_1gab28a403fe4f2894e330ccd90e01295e4: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`QuantumMachine`* QPanda::initQuantumMachine(:ref:`QMachineType` type = :ref:`CPU`) Init a Quantum machine. default Quantum machine type :cpu .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - QMachineType - .. rubric:: Returns: :ref:`QPanda::QuantumMachine ` \* Quantum machine pointer .. rubric:: See also: :ref:`QMachineType ` .. index:: pair: function; destroyQuantumMachine .. _doxid-group___core_1ga40086744d5e1d0ee04381ebd63ae40c7: .. ref-code-block:: cpp :class: doxyrest-title-code-block void QPanda::destroyQuantumMachine(:ref:`QuantumMachine`* qvm) Destroy Quantum machine. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - QuantumMachine\* - Quantum machine pointer .. rubric:: Returns: void .. index:: pair: function; MeasureAll .. _doxid-group___core_1ga5d448b1c38b2b3a13022c5c3a3587b40: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`QPanda::QProg` QPanda::MeasureAll(:ref:`QVec`, std::vector<:ref:`ClassicalCondition`>) Measure All :ref:`ClassicalCondition `. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - QVec& - qubits vector * - std::vector - Cbits vector .. rubric:: Returns: :ref:`QPanda::QProg ` Quantum program .. index:: pair: function; getAllocateCMemNum .. _doxid-group___core_1gaa455e0e99622f5f997c6931981bb33ea: .. ref-code-block:: cpp :class: doxyrest-title-code-block size_t QPanda::getAllocateCMemNum() Get allocate cbit number. .. rubric:: Returns: size_t Cbit number .. index:: pair: function; pMeasure .. _doxid-group___core_1ga757f4450197cae9577316a69ee7977b8: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`prob_tuple` QPanda::pMeasure(:ref:`QVec` qubit_vector, int select_max) pMeasure .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - :ref:`QVec ` - qubit vector * - int - Selectmax:the returned value num .. rubric:: Returns: std::vector> result .. index:: pair: function; pMeasureNoIndex .. _doxid-group___core_1ga0ead8a3eab7a3d51c26d887acbb410c0: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`prob_vec` QPanda::pMeasureNoIndex(:ref:`QVec` qubit_vector) pMeasure only return result with no index .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - :ref:`QVec ` - qubit vector .. rubric:: Returns: prob_vec result .. index:: pair: function; Measure .. _doxid-group___core_1ga15b15ba85d24d7355880ad63fd4c2107: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`QMeasure` QPanda::Measure(:ref:`Qubit`*, :ref:`ClassicalCondition`) QPanda2 basic interface for creating a quantum measure node. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - Qubit\* - qubit address * - :ref:`ClassicalCondition ` - cbit .. rubric:: Returns: :ref:`QPanda::QMeasure ` quantum measure node .. index:: pair: function; Measure .. _doxid-group___core_1ga61455ff3714ff88b9d15f4be9fbbd3d3: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`QMeasure` QPanda::Measure(int, int) QPanda2 basic interface for creating a quantum measure node. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - int - qubit address * - int - cbit address .. rubric:: Returns: :ref:`QPanda::QMeasure ` quantum measure node