MicroQiskit Library Reference

A version of Qiskit made for educational purposes. See https://qiskit.org for more on Qiskit.

simulate(qc,get,counts):

This is the MicroQiskit equivalent of the execute function in Qiskit.

Runs the quantum circuit qc. Results are given from multiple runs, the number of which is specified by shots. The type of output is specified by get, which can be set to 'counts', 'memory' or 'statevector'. If no shots is supplied, a default value of 1024 is used.

Note that, for a 'statevector' output, complex numbers are specified as a two element table instead of Python complex number notation. So a number a+bj will become {a,b}.

Note that the 'counts' output is generated by a sampling process, which can be too slow for some use cases. This can be avoided by using 'expected_counts', which instead returns the expectation value of the counts.

class QuantumCircuit

Contains a quantum circuit, which is essentially a list of quantum gates that are applied to a register of qubits. At the end, a binary output is recorded on a register of bits.

This is the MicroQiskit version of the identically named class in Qiskit.

classmethod set_registers(num_qubits, num_bits)

Initializes a circuit with num_qubits qubits and num_bits output bits. The latter need not be supplied in the case of a 'statevector' output.

Note that, in the full version of Qiskit, this information is supplied when initializing QuantumCircuit.

classmethod initialize(ket)

Initializes a circuit with the state described by the statevector ket.

classmethod x(qubit)

Adds an x gate to the circuit on the given qubit.

classmethod rx(theta, qubit)

Adds rotation around the x axis to the circuit on the given qubit. The angle is given by theta.

classmethod ry(theta, qubit)

Adds rotation around the y axis to the circuit on the given qubit. The angle is given by theta.

classmethod rz(theta, qubit)

Adds rotation around the z axis to the circuit on the given qubit. The angle is given by theta.

classmethod h(qubit)

Adds an h gate to the circuit on the given qubit.

classmethod cx(control, target)

Adds a cx gate to the circuit for the given control and target qubits.

classmethod measure(qubit, bit)

Adds a measure gate, which extracts a bit of output from the given qubit. Note that, unlike in the full version of Qiskit, measurements are always applied at the end, irrespective of where they are placed in the circuit.

num_qubits

Returns the number of qubits in the circuit.

num_clbits

Returns the number of classical bits in the circuit.