UnitaryBuilder
- class UnitaryBuilder(num_qudits, radixes=[])[source]
Bases:
Unitary
An object for fast unitary accumulation using tensor networks.
A UnitaryBuilder is similar to a StringBuilder in the sense that it is an efficient way to string together or accumulate
Unitary
objects. This class uses concepts from tensor networks to efficiently multiply unitary matrices.- __init__(num_qudits, radixes=[])[source]
UnitaryBuilder constructor.
- Parameters:
num_qudits (
int
) – The number of qudits to build a Unitary for.radixes (
Sequence[int]
) – A sequence with its length equal to num_qudits. Each element specifies the base of a qudit. Defaults to qubits.
- Raises:
ValueError – If num_qudits is nonpositive.
ValueError – If the length of radixes is not equal to num_qudits.
Examples
>>> builder = UnitaryBuilder(4) # Creates a 4-qubit builder.
Attributes
The matrix dimension for this unitary.
The number of real parameters this unitary-valued function takes.
The number of qudits this unitary can act on.
The number of orthogonal states for each qudit.
Methods
apply_left
(utry, location[, inverse, ...])Apply the specified unitary on the left of this UnitaryBuilder.
apply_right
(utry, location[, inverse, ...])Apply the specified unitary on the right of this UnitaryBuilder.
calc_env_matrix
(location)Calculates the environment matrix w.r.t.
check_parameters
(params)Check parameters are valid and match the unitary.
eval_apply_left
(M, location)Evaluate the application of M on the left of this UnitaryBuilder.
eval_apply_right
(M, location)Evaluate the application of M on the right of this UnitaryBuilder.
get_unitary
([params])Build the unitary, see
Unitary.get_unitary()
for more.Return true if this unitary doesn't take parameters.
Return true if this unitary is parameterized.
Return true if this unitary can only act on qubits.
is_qudit_only
(radix)Return true if this unitary can only act on radix-qudits.
Return true if this unitary can only act on qutrits.
is_self_inverse
([params])Checks whether the unitary is its own inverse.