c3.utils.qt_utils
¶
Useful functions to get basis vectors and matrices of the right size.
Module Contents¶
- c3.utils.qt_utils.pauli_basis(dims=[2])[source]¶
Qutip implementation of the Pauli basis.
- Parameters
dims (list) – List of dimensions of each subspace.
- Returns
A square matrix containing the Pauli basis of the product space
- Return type
np.array
- c3.utils.qt_utils.expand_dims(op, dim)[source]¶
pad operator with zeros to be of dimension dim Attention! Not related to the TensorFlow function
- c3.utils.qt_utils.hilbert_space_kron(op, indx, dims)[source]¶
Extend an operator op to the full product hilbert space given by dimensions in dims.
- Parameters
op (np.array) – Operator to be extended.
indx (int) – Position of which subspace to extend.
dims (list) – New dimensions of the subspace.
- Returns
Extended operator.
- Return type
np.array
- c3.utils.qt_utils.rotation(phase: float, xyz: numpy.array) numpy.array [source]¶
General Rotation using Euler’s formula.
- Parameters
phase (np.float) – Rotation angle.
xyz (np.array) – Normal vector of the rotation axis.
- Returns
Unitary matrix
- Return type
np.array
- c3.utils.qt_utils.basis(lvls: int, pop_lvl: int) numpy.array [source]¶
Construct a basis state vector.
- Parameters
lvls (int) – Dimension of the state.
pop_lvl (int) – The populated entry.
- Returns
A normalized state vector with one populated entry.
- Return type
np.array
- c3.utils.qt_utils.xy_basis(lvls: int, vect: str)[source]¶
Construct basis states on the X, Y and Z axis.
- Parameters
lvls (int) – Dimensions of the Hilbert space.
vect (str) –
Identifier of the state. Options:
’zp’, ‘zm’, ‘xp’, ‘xm’, ‘yp’, ‘ym’
- Returns
A state on one of the axis of the Bloch sphere.
- Return type
np.array
- c3.utils.qt_utils.projector(dims, indices, outdims=None)[source]¶
Computes the projector to cut down a matrix to the computational space. The subspaces indicated in indeces will be projected to the lowest two states, the rest is projected onto the lowest state. If outdims is defined projection will be performed to those states.
- c3.utils.qt_utils.kron_ids(dims, indices, matrices)[source]¶
Kronecker product of matrices at specified indices with identities everywhere else.
- c3.utils.qt_utils.get_basis_matrices(dim)[source]¶
Basis matrices with single ones of the matrices with given dimensions.
- c3.utils.qt_utils.insert_mat_kron(dims, target_ids, matrix) numpy.ndarray [source]¶
Insert matrix at given indices. All other spaces are filled with zeros.
- Parameters
dims (dimensions of each qubit subspace) –
target_ids (qubits to apply matrix to) –
matrix (matrix to be applied) –
- Return type
composed matrix
- c3.utils.qt_utils.pad_matrix(matrix, dim, padding)[source]¶
Fills matrix dimensions with zeros or identity.
- c3.utils.qt_utils.perfect_parametric_gate(paulis_str, ang, dims)[source]¶
Construct an ideal parametric gate.
- Parameters
paulis_str (str) –
- Names for the Pauli matrices that identify the rotation axis. Example:
”X” for a single-qubit rotation about the X axis
”Z:X” for an entangling rotation about Z on the first and X on the second qubit
ang (float) – Angle of the rotation
dims (list) – Dimensions of the subspaces.
- Returns
Ideal gate.
- Return type
np.array
- c3.utils.qt_utils.perfect_single_q_parametric_gate(pauli_str, target, ang, dims)[source]¶
Construct an ideal parametric gate.
- Parameters
paulis_str (str) –
- Name for the Pauli matrices that identify the rotation axis. Example:
”X” for a single-qubit rotation about the X axis
ang (float) – Angle of the rotation
dims (list) – Dimensions of the subspaces.
- Returns
Ideal gate.
- Return type
np.array
- c3.utils.qt_utils.two_qubit_gate_tomography(gate)[source]¶
Sequences to generate tomography for evaluating a two qubit gate.
- c3.utils.qt_utils.T1_sequence(length, target)[source]¶
Generate a gate sequence to measure relaxation time in a two-qubit chip.
- Parameters
length (int) – Number of Identity gates.
target (int) – Which qubit is measured.
- Returns
Relaxation sequence.
- Return type
list
- c3.utils.qt_utils.ramsey_sequence(length, target)[source]¶
Generate a gate sequence to measure dephasing time in a two-qubit chip.
- Parameters
length (int) – Number of Identity gates.
target (str) – Which qubit is measured. Options: “left” or “right”
- Returns
Dephasing sequence.
- Return type
list
- c3.utils.qt_utils.ramsey_echo_sequence(length, target)[source]¶
Generate a gate sequence to measure dephasing time in a two-qubit chip including a flip in the middle. This echo reduce effects detrimental to the dephasing measurement.
- Parameters
length (int) – Number of Identity gates. Should be even.
target (str) – Which qubit is measured. Options: “left” or “right”
- Returns
Dephasing sequence.
- Return type
list
- c3.utils.qt_utils.single_length_RB(RB_number: int, RB_length: int, target: int = 0) List[List[str]] [source]¶
Given a length and number of repetitions it compiles Randomized Benchmarking sequences.
- Parameters
RB_number (int) – The number of sequences to construct.
RB_length (int) – The number of Cliffords in each individual sequence.
target (int) – Index of the target qubit
- Returns
List of RB sequences.
- Return type
list