pdft.bases.CircuitBasis#
- class pdft.bases.CircuitBasis(m, n, tensors=None, code=None, inv_code=None)[source]#
Bases:
BasisTransformsA basis that is a gate circuit on
mrow qubits andncolumn qubits.tensorsholds one tensor per gate, Hadamards first (Julia’sperm_vec);programsays which gate each one is and when it acts.codeandinv_codeare the program’s forward and inverse appliers; they compare by program, so they andprogramare left out of therepr. To compare two bases usebases_allclose:==compares the tensor lists and raises as soon as it reaches two distinct arrays (it isTrueonly when every tensor is the same object).programis derived, never passed in, which keepsdataclasses.replace(basis, tensors=...)working on the bases whose fields are all constructor arguments.Every subclass is registered as a JAX pytree: the leaves are
tensors, in order, which is the contracttrain_basisrelies on. Every other attribute of the instance is aux data, so it must be hashable. Unflattening restores the attributes without running the constructor, so no gate list is rebuilt.A family whose circuit depends on
mandnalone setsemitto its gate emitter and is done. One with options of its own defines a constructor that emits its gates and hands them to_init.Methods
__init__(m, n[, tensors, code, inv_code])forward_transform(pic)inverse_transform(pic)conj(tensors)throughinv_code, exactly like Julia'sbasis.inverse_code(conj.(basis.tensors)..., ...).Attributes
image_sizeinv_tensorsThe tensor list itself.
num_parameters