apply
Contraction-compression of an MPO with an MPS or another MPO.
A thin wrapper around src_method.stack.src for two-train stacks:
- MPO-MPS randomized contraction-compression.
- MPO-MPO randomized contraction-compression.
funcapply(left_tensor, right_tensor, chi_out, *, cutoff=0.0, dtype=None, seed=None, device='cpu', resources=None) -> list[NDArray]Applies the Successive Randomized Compression (SRC) algorithm.
Equivalent to src(left_tensor, right_tensor, ...) restricted to an MPO on
the left; see src_method.stack.src for the conventions, deeper stacks and the
bra form. The train type is inferred from the rank of the first site tensor,
and dispatch follows:
- MPO-MPS:
left_tensoris an MPO andright_tensoris an MPS. Results in an MPS. - MPO-MPO: both
left_tensorandright_tensorare MPOs. Results in an MPO.
Raises
TypeError: Ifchi_outis not an integer or the combination of input tensor types is unsupported.ValueError: Ifchi_outis not positive, ifcutoffis not in[0.0, 1.0), if a train is not open-boundary, if the two trains differ in length or in the physical dimensions they join, if a sub-three-site train is not exactly two sites, or ifdeviceis not recognised.ImportError: Ifdevice="gpu"but cupy is not installed.
paramleft_tensorSequence[Site]The site arrays of the left tensor network (MPO).
paramright_tensorSequence[Site]The site arrays of the right tensor network (MPO or MPS).
paramchi_outint | np.integerThe desired maximum bond dimension of the output tensor network.
paramcutofffloat= 0.0Relative singular-value cutoff for adaptive bond truncation.
When positive, bonds are trimmed to their effective rank by
discarding singular values below cutoff * sigma_max at each
site during the right-to-left sweep. The SVD operates on the
small (chi_out, chi_out) R factor from QR, so overhead is
minimal. Set to 0.0 (default) to keep all bonds at chi_out.
paramdtypeDTypeLike | None= NoneData type of the random sketches. Defaults to the promoted floating dtype of the inputs; an explicit dtype can promote the result.
paramseedint | None= NoneAn optional seed for the random number generator.
paramdevicestr= 'cpu'"cpu" (default, numpy) or "gpu" (cupy). Requires
the optional cupy dependency for GPU execution.
paramresourcesResources | None= NoneMemory budgets and scratch space; see src_method.stack.src.
Returns
listThe site arrays of the compressed tensor network (MPS or MPO).