Utilities¶
Overview¶
Detailed Documentation¶
Typedefs¶
Apply Quantum Gate on a series of Qubit.
Parameters:
qubit vector |
|
std::function<QGate(Qubit*)> |
QGate function |
Returns:
Global Functions¶
OriginIR Transform To Quantum Program.
Parameters:
std::string |
OriginIR file path |
QuantumMachine* |
quantum machine pointer |
qubit pointer |
|
std::vector<ClassicalCondition> |
classical register vector |
Returns:
QProg quantum program
Convert OriginIR To Quantum Program.
Parameters:
std::string |
OriginIR file path |
QuantumMachine* |
quantum machine pointer |
Returns:
QProg quantum program
Convert OriginIR To Quantum Program.
Parameters:
std::string |
OriginIR file path |
QuantumMachine* |
quantum machine pointer |
qubit pointer vector |
|
std::vector<ClassicalCondition> |
classical register vector |
Returns:
QProg quantum program
Convert OriginIR String To Quantum Program.
Parameters:
std::string |
OriginIR String |
QuantumMachine* |
quantum machine pointer |
Returns:
QProg quantum program
Convert OriginIR String To Quantum Program.
Parameters:
std::string |
OriginIR String |
QuantumMachine* |
quantum machine pointer |
qubit pointer |
|
std::vector<ClassicalCondition> |
classical register vector |
Returns:
QProg quantum program
QASM Transform To Quantum Program.
Parameters:
std::string |
QASM file path |
QuantumMachine* |
quantum machine pointer |
Returns:
QProg quantum program
QASM Transform To Quantum Program.
Parameters:
std::string |
QASM file path |
QuantumMachine* |
quantum machine pointer |
qubit pointer vector |
|
std::vector<ClassicalCondition> |
classical register vector |
Returns:
QProg quantum program
QASM Transform To Quantum Program.
Parameters:
std::string |
QASM string |
QuantumMachine* |
quantum machine pointer |
Returns:
QProg quantum program
QASM Transform To Quantum Program.
Parameters:
std::string |
QASM string |
QuantumMachine* |
quantum machine pointer |
qubit pointer vector |
|
std::vector<ClassicalCondition> |
classical register vector @retur |
Parse quantum program interface for binary data vector.
Parameters:
QuantumMachine* |
quantum machine pointer |
std::vector<uint8_t>& |
data binary data vector |
QVec& |
qubits |
std::vector<ClassicalCondition>& |
cbits |
QProg& |
Quantum program |
Returns:
bool
Parse quantum program interface for binary file.
Parameters:
QuantumMachine* |
quantum machine pointer |
std::string& |
binary file name |
QVec& |
qubits |
std::vector<ClassicalCondition>& |
cbits |
QProg& |
Quantum program |
Returns:
bool
Parse quantum program interface for binary data vector.
Parameters:
QuantumMachine* |
quantum machine pointer |
std::vector<uint8_t>& |
data binary data vector |
QVec& |
qubits |
std::vector<ClassicalCondition>& |
cbits |
QProg& |
Quantum program |
Returns:
bool
Parse quantum program interface for binary file.
Parameters:
QuantumMachine* |
quantum machine pointer |
std::string& |
binary file name |
QVec& |
qubits |
std::vector<ClassicalCondition>& |
cbits |
QProg& |
Quantum program |
Returns:
bool
Get quantum program binary data.
Parameters:
QProg& |
quantum program |
QuantumMachine& |
quantum |
Returns:
std::vector<uint8_t> quantum program binary data
Store quantum program in binary file.
Parameters:
QProg& |
quantum program |
QuantumMachine* |
quantum machine |
std::string& |
binary filename |
Returns:
void
Get quantum program binary data.
Parameters:
QProg& |
quantum program |
QuantumMachine& |
quantum |
Returns:
std::vector<uint8_t> quantum program binary data
Store quantum program in binary file.
Parameters:
QProg& |
quantum program |
QuantumMachine* |
quantum machine |
std::string& |
binary filename |
Returns:
void
Quantum Program Transform To OriginIR
Parameters:
_Ty& |
quantum program, quantum circuit, quantum while or quantum if |
Returns:
std::string OriginIR instruction set
See also:
Convert Quantum Program To OriginIR.
Parameters:
_Ty& |
quantum program, quantum circuit, quantum while or quantum if |
QuantumMachine* |
quantum machine |
Returns:
std::string OriginIR instruction set
write prog to originir file
Parameters:
QProg& |
Quantum Program |
QuantumMachine* |
quantum machine pointer |
const |
std::string originir file name |
Returns:
Convert Quantum program to QASM instruction set.
Parameters:
QProg& |
Quantum Program |
QuantumMachine* |
quantum machine pointer |
IBMQBackends |
ibmBackend = IBMQ_QASM_SIMULATOR |
Returns:
std::string QASM instruction set
write prog to qasm file
Parameters:
QProg& |
Quantum Program |
QuantumMachine* |
quantum machine pointer |
const |
std::string qasm file name |
Returns:
Quantum program transform to quil instruction set interface.
Parameters:
QProg& |
quantum program |
QuantumMachine* |
quantum machine pointer |
Returns:
std::string instruction set
See also:
Quantum program transform to quil instruction set interface.
Parameters:
QProg& |
quantum program |
QuantumMachine* |
quantum machine pointer |
Returns:
std::string instruction set
QRunes instruction set transform to quantum program interface.
Parameters:
QProg& |
empty quantum program |
Returns:
void
Quantum chip adaptive conversion.
Parameters:
QProg& |
Quantum Program |
QuantumMachine* |
quantum machine pointer |
QVec& |
Quantum bits after mapping. Note: if b_mapping is false, the input QVec will be misoperated. |
bool |
whether or not perform the mapping operation. |
const |
std::string It can be configuration file or configuration data, which can be distinguished by file suffix, so the configuration file must be end with “.json”, default is CONFIG_PATH |
Returns:
Judge if the metadata’s type is arbitrary rotation.
Parameters:
std::vector<std::string>& |
the gates is judged |
std::vector<std::string>& |
output the valid gates |
Returns:
Return the style of metadata validity
Judge if the metadata’s type is double continuous.
Parameters:
std::vector<std::string>& |
the gates is judged |
std::vector<std::string>& |
output the valid gates |
Returns:
Return the style of metadata validity
Judge if the metadata’s type is single continuous and discrete.
Parameters:
std::vector<std::string>& |
the gates is judged |
std::vector<std::string>& |
output the valid gates |
Returns:
Return the style of metadata validity
Judge if the metadata’s type is double discrete.
Parameters:
std::vector<std::string>& |
the gates is judged |
std::vector<std::string>& |
output the valid gates |
Returns:
Return the style of metadata validity
Judge double gate type.
Parameters:
std::vector<std::string>& |
the gates is judged |
std::vector<std::string>& |
output the valid gates |
Returns:
Return the style of metadata validity
Verify the validity of single quantum gates.
Parameters:
std::vector<std::string>& |
gates vertor |
std::vector<std::string>& |
output the valid gates |
Returns:
int single quantum gate type
judge the Qgate if match the target topologic structure of quantum circuit
Parameters:
vector<vector<double>>& |
the target topologic structure of quantum circuit |
Returns:
if the Qgate match the target topologic structure return true, or else return false
See also:
JsonConfigParam::readAdjacentMatrix(TiXmlElement *, int&, std::vector<std::vector<int>>&)
get the adjacent quantum gates’s(the front one and the back one) type
Parameters:
nodeItr |
the specialed NodeIter |
std::vector<NodeInfo>& |
adjacentNodes the front node and the back node |
Returns:
result string.
See also:
judge the specialed two NodeIters whether can be exchanged
If the two input nodeIters are in different sub-prog, they are unswappable.
Parameters:
nodeItr1 |
the first NodeIter |
nodeItr2 |
the second NodeIter |
Returns:
if the two NodeIters can be exchanged, return true, otherwise retuen false.
judge if the target node is a base QGate type
Parameters:
nodeItr |
the target NodeIter |
Returns:
if the target node is a base QGate type, return true, otherwise retuen false.
See also:
get the target matrix between the input two Nodeiters
Parameters:
const |
bool Qubit order mark of output matrix, true for positive sequence(Bid Endian), false for inverted order(Little Endian), default is false |
nodeItrStart |
the start NodeIter |
nodeItrEnd |
the end NodeIter |
Returns:
the target matrix include all the QGate ‘s matrix (multiply).
See also:
pick up the nodes of srcProg between nodeItrStart and nodeItrEnd to outPutProg
Parameters:
outPutProg |
the output prog |
srcProg |
The source prog |
nodeItrStart |
The start pos of source prog |
nodeItrEnd |
The end pos of source prog |
reject_node_types |
vector of the reject node types. |
bDagger |
daggger flag @ Note: If there are any Qif/Qwhile nodes between nodeItrStart and nodeItrEnd, Or the nodeItrStart and the nodeItrEnd are in different sub-circuit, an exception will be throw. |
Get all the used quantum bits in the input prog.
Parameters:
prog |
the input prog |
vecQuBitsInUse |
The vector of used quantum bits, sorted from small to large; |
Returns:
return the size of used qubits,sorted by physical address, in descending order
Get all the used class bits in the input prog.
Parameters:
prog |
the input prog |
vecClBitsInUse |
The vector of used class bits, sorted from small to large; |
Returns:
return the size of used class bits
Get all the measure-info in the input prog.
Parameters:
prog |
the input prog |
std::vector<std::pair<uint32_t |
|
uint32_t>> |
The vector of measure-info: std::pair<measured-qubit, target-cbit> |
Returns:
return the size of measure-info
output all the node type of the target prog
Parameters:
the |
target prog |
Returns:
return the output string
get gate parameter
Parameters:
pGate |
the target gate pointer |
para_str |
parameter string |
Returns:
Check if it is a valid dagger.
Parameters:
bool |
Returns:
bool true for valid dagger
Count quantum gate num under quantum program, quantum circuit, quantum while, quantum if.
Parameters:
_Ty& |
quantum program, quantum circuit, quantum while or quantum if |
Returns:
size_t Quantum gate num
See also:
Get quantum program clock cycle.
Parameters:
& quantum program |
|
QuantumMachine* |
quantum machine pointer |
See also:
Get quantum program clock cycle.
Parameters:
& quantum program |
|
QuantumMachine* |
quantum machine pointer |
output a quantum prog/circuit to console by text-pic(UTF-8 code), and will save the text-pic in file named QCircuitTextPic.txt in the same time in current path.
All the output characters are UTF-8 encoded.
Parameters:
prog |
the source prog |
itr_start |
The start pos, default is the first node of the prog |
itr_end |
The end pos, default is the end node of the prog |
Returns:
the output string
output a quantum prog/circuit by time sequence to console by text-pic(UTF-8 code), and will save the text-pic in file named QCircuitTextPic.txt in the same time in current path.
All the output characters are GBK encoded on windows, UTF-8 encoded on other OS.
Parameters:
prog |
the source prog |
const |
std::string It can be configuration file or configuration data, which can be distinguished by file suffix, so the configuration file must be end with “.json”, default is CONFIG_PATH |
itr_start |
The start pos, default is the first node of the prog |
itr_end |
The end pos, default is the end node of the prog |
Returns:
the output string
Overload operator <<.
Parameters:
std::ostream& |
ostream |
quantum program |
Returns:
std::ostream
A Contextual Duration-Aware Qubit Mapping for V arious NISQ Devices.
QCodarGridDevice : SIMPLE_TYPE It’s a simple undirected topology graph, build a topology based on the values of m and n 0 = 1 = 2 = 3
eg: m = 2, n = 4
Parameters:
quantum program |
|
qubit vector |
|
QuantumMachine* |
quantum machine |
size_t |
m : the length of the topology |
size_t |
n : the width of the topology |
size_t |
run_times : the number of times run the remapping, better parameters get better results |
Returns:
QProg mapped quantum program