Utilities¶
In utils.py you will find functions that are shared among one or more modules.
Common Functions¶
is_pos_pow_two(x) |
Simple check that an integer is a positive power of two. |
bit_array_to_int(bit_array) |
Converts a bit array into an integer where the right-most bit is least significant. |
int_to_bit_array(num, n_bits) |
Converts a number into an array of bits where the right-most bit is least significant. |
pack_shot_data(shot_data) |
|
bloch_vector_to_standard_basis(theta, phi) |
Converts the Bloch vector representation of a 1q state given in spherical coordinates to the standard representation of that state in the computational basis. |
standard_basis_to_bloch_vector(qubit_state) |
Converts a standard representation of a single qubit state in the computational basis to the spherical coordinates theta, phi of its representation on the Bloch sphere. |
prepare_state_on_bloch_sphere(qubit, theta, phi) |
Returns a program which prepares the given qubit in the state (theta, phi) on the bloch sphere, assuming the initial state |0> where (theta=0, phi=0). |
transform_pauli_moments_to_bit(mean_p, var_p) |
Changes the first of a Pauli operator to the moments of a bit (a Bernoulli process). |
transform_bit_moments_to_pauli(mean_c, var_c) |
Changes the first two moments of a bit (a Bernoulli process) to Pauli operator moments. |
parameterized_bitstring_prep(qubits, …) |
Produces a parameterized program for the given group of qubits, where each qubit is prepared in the 0 or 1 state depending on the parameterization specified at run-time. |
bitstring_prep(qubits, bitstring, …) |
Produces a program that prepares the given bitstring on the given qubits. |
metadata_save(qc, repo_path, filename) |
This helper function saves metadata related to your run on a Quantum computer. |
Pauli Functions¶
str_to_pauli_term(pauli_str[, qubit_labels]) |
Convert a string into a PauliTerm. |
all_traceless_pauli_terms(qubits) |
Generate list of all Pauli terms (with weight > 0) on N qubits. |
all_traceless_pauli_choice_terms(qubits, …) |
Generate list of all Pauli terms (with weight > 0) on N qubits with choice pauli. |
all_traceless_pauli_z_terms(qubits) |
Generate list of all Pauli Z terms (with weight > 0) on N qubits |
local_pauli_eig_prep(op, qubit) |
Generate gate sequence to prepare a the +1 eigenstate of a Pauli operator, assuming we are starting from the ground state ( the +1 eigenstate of \(Z^{\otimes n}\)) |
local_pauli_eigs_prep(op, qubit) |
Generate all gate sequences to prepare all eigenstates of a (local) Pauli operator, assuming we are starting from the ground state. |
random_local_pauli_eig_prep(prog, op, qubit) |
Generate gate sequence to prepare a random local eigenstate of a Pauli operator, assuming we are starting from the ground state. |
local_pauli_eig_meas(op, qubit) |
Generate gate sequence to measure in the eigenbasis of a Pauli operator, assuming we are only able to measure in the Z eigenbasis. |
prepare_prod_pauli_eigenstate(pauli_term) |
Returns a circuit to prepare a +1 eigenstate of the Pauli operator described in PauliTerm. |
measure_prod_pauli_eigenstate(pauli_term) |
|
prepare_random_prod_pauli_eigenstate(pauli_term) |
|
prepare_all_prod_pauli_eigenstates(pauli_term) |
Operator Basis¶
OperatorBasis(labels_ops) |
Encapsulate a complete set of basis operators. |
n_qubit_pauli_basis(n) |
Construct the tensor product operator basis of n PAULI_BASIS’s. |
n_qubit_computational_basis(n) |
Construct the tensor product operator basis of n COMPUTATIONAL_BASIS’s. |