cbloq_to_quimb#
View source on GitHub
|
Convert a composite bloq into a tensor network.
qualtran.simulation.tensor.cbloq_to_quimb(
cbloq: qualtran.CompositeBloq,
friendly_indices: bool = False
) -> qtn.TensorNetwork
This function will call Bloq.my_tensors on each subbloq in the composite bloq to add
tensors to a quimb tensor network. This method has no default fallback, so you likely want to
call bloq.as_composite_bloq().flatten() to decompose-and-flatten all bloqs down to their
smallest form first. The small bloqs that result from a flattening 1) likely already have
their my_tensors method implemented; and 2) can enable a more efficient tensor contraction
path.
Args
cbloqThe composite bloq.
friendly_indicesIf set to True, the outer indices of the tensor network will be renamed from their Qualtran-computer-readable form to human-friendly strings. This may be useful if you plan on manually manipulating the resulting tensor network but will preclude any further processing by Qualtran functions. The indices are named {soq.reg.name}{soq.idx}_{j}{side}, where j is the individual bit index and side is ‘l’ or ‘r’ for left or right, respectively.
View source on GitHub