renom_q.utilitys ¶
-
renom_q.utilitys.
plot_histogram
( counts ) ¶ -
Plot the execution result with histogram.
- Args:
-
- counts (dict):
- A dict of the execution result of quantum circuit mesurement.
- Returns:
-
- matplotlib.figure:
- A matplotlib figure object for the execution result of quantum circuit mesurement.
- Example:
-
>>> import renom_q >>> q = renom_q.QuantumRegister(1) >>> c = renom_q.ClassicalRegister(1) >>> qc = renom_q.QuantumCircuit(q, c) >>> qc.measure() >>> r = renom_q.execute(qc) >>> renom_q.plot_histogram(r)
-
renom_q.utilitys.
execute
( circuit , shots=1024 ) ¶ -
Execute the quantum circuit mesurement.
- Args:
-
- circuit (renom_q.QuantumCircuit):
- A class of QuantumCircuit.
- shots (int):
- The number of excutions of quantum circuit mesurement. Defaults to 1024.
- Returns:
-
- (dict):
- A execution result of quantum circuit mesurement. The key is the measured classical bits. The value is the number of classical bits measured.
- Example:
-
>>> import renom_q >>> q = renom_q.QuantumRegister(1) >>> c = renom_q.ClassicalRegister(1) >>> qc = renom_q.QuantumCircuit(q, c) >>> qc.measure() >>> renom_q.execute(qc) {'0': 1024}
-
renom_q.utilitys.
print_matrix
( circuit , tensorgate=False ) ¶ -
Print all matrix calculation of unitary conversion.
- Args:
-
- circuit (renom_q.QuantumCircuit):
- A class of QuantumCircuit.
- tensorgate (bool):
- When set to True, added matrix calculation of quantum gate tensor product. Defaults to False.
- Returns:
-
- matrix(str):
- Strings of the final result of qubit statevector and all matrix calculation of unitary conversion.
- Example:
-
>>> import renom_q >>> q = renom_q.QuantumRegister(1) >>> c = renom_q.ClassicalRegister(1) >>> qc = renom_q.QuantumCircuit(q, c) >>> qc.x(q[0]) >>> renom_q.print_matrix(qc) ---------------- result qubit ---------------- [0.+0.j 1.+0.j] ---------------- x(q[0]) ---------------- [[0. 1.] [1. 0.]]・ \ [[1.+0.j] [0.+0.j]] = \ [[0.+0.j] [1.+0.j]]
-
renom_q.utilitys.
statevector
( circuit ) ¶ -
Get the qubit statevector.
- Args:
-
- circuit (renom_q.QuantumCircuit):
- A class of QuantumCircuit.
- Returns:
-
- (array):
- A array of the qubit statevector.
- Example:
-
>>> import renom_q >>> q = renom_q.QuantumRegister(1) >>> c = renom_q.ClassicalRegister(1) >>> qc = renom_q.QuantumCircuit(q, c) >>> qc.x(q[0]) >>> renom_q.statevector(qc) array([0.+0.j, 1.+0.j])