Learn R Programming

qsimulatR (version 1.1.1)

export2qiskit: export2qiskit

Description

export a circuit to IBM's qiskit python format. Note that only gates can be exported where the correspondence in qiskit is known and well defined. Qiskit can then be used for IBM's QASM to run on real hardware.

Usage

export2qiskit(object, varname = "qc", filename = "circuit.py",
  append = FALSE, import = FALSE)

Value

nothing is returned, but a file is created.

Arguments

object

a qstate object

varname

character. The name of the circuit variable

filename

character. The filename of the textfile where to store the circuit

append

boolean. Whether or not to append to the file. For this the file has to exist.

import

boolean. Shall numpy and qiskit be loaded explicitly?

Details

Export to IBM's Qiskit

Currently the following gates can be exported: H, X, Y, Z, S, Tgate, Rz, Rx, Ry, CNOT, SWAP, CCNOT, CSWAP, measure.

note that only standard gates can be exported, not self defined ones. The function will draw a warning in case a gate cannot be exported and indicate it in the output file.

References

https://qiskit.org/documentation/

Examples

Run this code
x <- qstate(2)
x <- H(1) * x
x <- X(2) * x
x <- CNOT(c(1,2)) * x
export2qiskit(measure(x,1)$psi)
cat(readLines("circuit.py"), sep = '\n')
file.remove("circuit.py")

Run the code above in your browser using DataLab