tnpy.matrix_product_state.MatrixProductState
1.2. tnpy.matrix_product_state.MatrixProductState#
- class tnpy.matrix_product_state.MatrixProductState(*args, **kwargs)[source]#
Bases:
quimb.tensor.tensor_1d.MatrixProductState
Matrix product state (MPS) for a finite size system.
- Parameters
*args – Positional arguments for
quimb.tensor.MatrixProductState
.**kwargs – Keyword arguments for
quimb.tensor.MatrixProductState
.
Note
This class inherits directly from
quimb.tensor.MatrixProductState
, with some added features. But, note that the underlying tensors are in the shape ‘lpr’, which differs from the parent classquimb.tensor.MatrixProductState
.- __init__(*args, **kwargs)[source]#
Matrix product state (MPS) for a finite size system.
- Parameters
*args – Positional arguments for
quimb.tensor.MatrixProductState
.**kwargs – Keyword arguments for
quimb.tensor.MatrixProductState
.
Note
This class inherits directly from
quimb.tensor.MatrixProductState
, with some added features. But, note that the underlying tensors are in the shape ‘lpr’, which differs from the parent classquimb.tensor.MatrixProductState
.
Methods
__init__
(*args, **kwargs)Matrix product state (MPS) for a finite size system.
add
(t[, virtual, check_collisions])Add Tensor, TensorNetwork or sequence thereof to self.
add_MPS
(other[, inplace])Add another MatrixProductState to this one.
add_MPS_
(other, *[, inplace])add_tag
(tag[, where, which])Add tag to every tensor in this network, or if
where
is specified, the tensors matching those tags -- i.e. adds the tag to all tensors inself.select_tensors(where, which=which)
.add_tensor
(tensor[, tid, virtual])Add a single tensor to this network - mangle its tid if neccessary.
add_tensor_network
(tn[, virtual, ...])align
(*[, ind_ids, trace, inplace])Align an arbitrary number of tensor networks in a stack-like geometry.
align_
(*[, ind_ids, trace, inplace])all_inds
()Return a tuple of all indices in this network.
amplitude
(b)Compute the amplitude of configuration
b
.antidiag_gauge
([output_inds, atol, cache, ...])Flip the order of any bonds connected to antidiagonal tensors.
antidiag_gauge_
([output_inds, atol, cache, ...])apply_to_arrays
(fn)Modify every tensor's array inplace by applying
fn
to it.as_cyclic
([inplace])Convert this flat, 1D, TN into cyclic form by adding a dummy bond between the first and last sites.
as_network
([virtual])Matching method (for ensuring object is a tensor network) to
as_network()
, which simply returnsself
ifvirtual=True
.aslinearoperator
(left_inds, right_inds[, ...])View this
TensorNetwork
as aTNLinearOperator
.astype
(dtype[, inplace])Convert the type of all tensors in this network to
dtype
.astype_
(dtype, *[, inplace])balance_bonds
([inplace])Apply
tensor_balance_bond()
to all bonds in this tensor network.balance_bonds_
(*[, inplace])bipartite_schmidt_state
(sz_a[, get, info])Compute the reduced state for a bipartition of an OBC MPS, in terms of the minimal left/right schmidt basis.
bond
(i, j)Get the name of the index defining the bond between sites i and j.
bond_size
(i, j)Return the size of the bond between site
i
andj
.bond_sizes
()calc_current_orthog_center
()Calculate the site(s) of the current orthogonality center.
canonicalize
(where[, cur_orthog, info, bra, ...])Gauge this MPS into mixed canonical form, implying.
canonicalize_
(where[, cur_orthog, info, ...])canonize
(where[, cur_orthog, info, bra, inplace])canonize_around
(tags[, which, min_distance, ...])Expand a locally canonical region around
tags
.canonize_around_
(tags[, which, ...])canonize_between
(tags1, tags2[, absorb])'Canonize' the bond between the two single tensors in this network specified by
tags1
andtags2
usingtensor_canonize_bond
.canonize_cyclic
(i[, bra, method, inv_tol])Bring this MatrixProductState into (possibly only approximate) canonical form at site(s)
i
.check
()Check some basic diagnostics of the tensor network.
column_reduce
([output_inds, atol, cache, ...])Find bonds on this tensor network which have tensors where all but one column (of the respective index) is non-zero, allowing the 'cutting' of that bond.
column_reduce_
([output_inds, atol, cache, ...])combine
(other, *[, virtual, check_collisions])Combine this tensor network with another, returning a new tensor network.
compress
([form])Compress this 1D Tensor Network, possibly into canonical form.
compress_all
([max_bond, cutoff, canonize, ...])Compress all bonds one by one in this network.
compress_all_
([max_bond, cutoff, canonize, ...])compress_all_1d
([max_bond, cutoff, ...])Compress a tensor network that you know has a 1D topology, this proceeds by generating a spanning 'tree' from around the least central tensor, then optionally canonicalizing all bonds outwards and compressing inwards.
compress_all_1d_
([max_bond, cutoff, ...])compress_all_simple
([max_bond, cutoff, ...])compress_all_simple_
([max_bond, cutoff, ...])compress_all_tree
([inplace])Canonically compress this tensor network, assuming it to be a tree.
compress_all_tree_
(*[, inplace])compress_between
(tags1, tags2[, max_bond, ...])Compress the bond between the two single tensors in this network specified by
tags1
andtags2
usingtensor_compress_bond()
.compress_simplify
([output_inds, atol, ...])compress_simplify_
([output_inds, atol, ...])compress_site
(i[, canonize, info, bra])Compress the bonds adjacent to site
i
, by default first setting the orthogonality center to that site.compute_centralities
()compute_contracted_inds
(*tids[, output_inds])Get the indices describing the tensor contraction of tensors corresponding to
tids
.compute_hierarchical_grouping
(max_group_size)Group
tids
(by default, all tensors) into groups of sizemax_group_size
or less, using a hierarchical clustering.compute_hierarchical_linkage
([tids, method, ...])compute_hierarchical_ordering
([tids, ...])compute_hierarchical_ssa_path
([tids, ...])Compute a hierarchical grouping of
tids
, as assa_path
.compute_local_expectation
(terms, max_bond, ...)Compute the local expectations of many local operators, by approximately contracting the full overlap tensor network.
compute_local_expectation_cluster
(terms, *)Compute all local expectations of the given terms, either treating the environment beyond
max_distance
as the identity, or using simple update style bond gauges as supplied ingauges
.compute_local_expectation_exact
(terms[, ...])Compute the local expectations of many operators, by exactly contracting the full overlap tensor network.
compute_local_expectation_rehearse
(terms, ...)compute_local_expectation_simple
(terms, *[, ...])Compute all local expectations of the given terms, either treating the environment beyond
max_distance
as the identity, or using simple update style bond gauges as supplied ingauges
.compute_local_expectation_tn
(terms, ...[, ...])compute_reduced_factor
(side, left_inds, ...)Compute either the left or right 'reduced factor' of this tensor network.
compute_shortest_distances
([tids, exclude_inds])Compute the minimum graph distances between all or some nodes
tids
.conj
([mangle_inner, mangle_outer])Create a conjugated copy of this
MatrixProductState
instance.conj_
([mangle_inner, inplace])contract
([tags, output_inds, optimize, get, ...])Contract some, or all, of the tensors in this network.
contract_
([tags, output_inds, optimize, ...])contract_around
(tags[, which, min_distance, ...])Perform a compressed contraction inwards towards the tensors identified by
tags
.contract_around_
(tags[, which, ...])contract_around_center
(**opts)contract_around_corner
(**opts)contract_between
(tags1, tags2, **contract_opts)Contract the two tensors specified by
tags1
andtags2
respectively.contract_compressed
(optimize[, output_inds, ...])contract_compressed_
(optimize[, ...])contract_cumulative
(tags_seq[, output_inds, ...])Cumulative contraction of tensor network.
contract_ind
(ind[, output_inds])Contract tensors connected by
ind
.contract_structured
(tag_slice[, ...])Perform a structured contraction, translating
tag_slice
from aslice
or ... to a cumulative sequence of tags.contract_tags
(tags[, which, output_inds, ...])Contract the tensors that match any or all of
tags
.contract_tags_
(tags[, which, output_inds, ...])contraction_cost
([optimize])Compute the 'contraction cost' of this tensor network.
contraction_info
([optimize])Compute the
opt_einsum.PathInfo
object decsribing the contraction of this entire tensor network using path optimizeroptimize
.contraction_path
([optimize])Compute the contraction path, a sequence of (int, int), for the contraction of this entire tensor network using path optimizer
optimize
.contraction_tree
([optimize, output_inds])Return the
cotengra.ContractionTree
corresponding to contracting this entire tensor network with path finderoptimize
.contraction_width
([optimize])Compute the 'contraction width' of this tensor network.
convert_to_zero
()Inplace conversion of this network to an all zero tensor network.
copy
([virtual, deep])Copy this
TensorNetwork
.correlation
(A, i, j[, B])Correlation of operator
A
betweeni
andj
.count_canonized
()cut_between
(left_tags, right_tags, left_ind, ...)Cut the bond between the tensors specified by
left_tags
andright_tags
, giving them the new indsleft_ind
andright_ind
respectively.cut_bond
(bond[, new_left_ind, new_right_ind])Cut the bond index specified by
bond
between the tensors it connects.cut_iter
(*inds)Cut and iterate over one or more indices in this tensor network.
delete
(tags[, which])Delete any tensors which match all or any of
tags
.diagonal_reduce
([output_inds, atol, cache, ...])Find tensors with diagonal structure and collapse those axes.
diagonal_reduce_
([output_inds, atol, cache, ...])distance
(tnB[, xAA, xAB, xBB, method, ...])Compute the Frobenius norm distance between two tensor networks:
distance_normalized
(tnB[, xAA, xAB, xBB, ...])distribute_exponent
()Distribute the exponent
p
of this tensor network (i.e.drape_bond_between
(tagsa, tagsb, tags_target)Take the bond(s) connecting the tensors tagged at
tagsa
andtagsb
, and 'drape' it through the tensor tagged attags_target
, effectively adding an identity tensor between the two and contracting it with the third.drape_bond_between_
(tagsa, tagsb, tags_target)draw
([color, show_inds, show_tags, ...])Plot this tensor network as a networkx graph using matplotlib, with edge width corresponding to bond dimension.
draw_3d
([color, show_inds, show_tags, ...])draw_3d_interactive
([color, show_inds, ...])draw_interactive
([color, show_inds, ...])draw_tree_span
(tags[, which, min_distance, ...])Visualize a generated tree span out of the tensors tagged by
tags
.drop_tags
([tags])Remove a tag or tags from this tensor network, defaulting to all.
enlarge_bond_dim
(new_bond_dim, method)entropy
(i[, info, method])The entropy of bipartition between the left block of
i
sites and the rest.equalize_norms
([value, inplace])Make the Frobenius norm of every tensor in this TN equal without changing the overall value if
value=None
, or set the norm of every tensor tovalue
by scalar multiplication only.equalize_norms_
([value, inplace])expand_bond_dimension
(new_bond_dim[, ...])Expand the bond dimensions of this 1D tensor network to at least
new_bond_dim
.expand_bond_dimension_
(new_bond_dim[, mode, ...])expec
(*[, compress, eps])Compute the expectation of several 1D TNs, using transfer matrix compression if any are periodic.
filter_valid_site_tags
(tags)Get the valid site tags from
tags
.fit
(tn_target[, method, tol, inplace, progbar])Optimize the entries of this tensor network with respect to a least squares fit of
tn_target
which should have the same outer indices.fit_
(tn_target[, method, tol, inplace, progbar])flip
([inplace])Reverse the order of the sites in the MPS, such that site
i
is now at siteL - i - 1
.flip_
(inds, *[, inplace])from_TN
(tn[, like, inplace])Construct a specific tensor network subclass (i.e.
from_dense
(psi[, dims, tags, site_ind_id, ...])Create a
MatrixProductState
directly from a dense vectorfrom_fill_fn
(fill_fn, L, bond_dim[, ...])Create an MPS by supplying a 'filling' function to generate the data for each site.
full_simplify
([seq, output_inds, atol, ...])Perform a series of tensor network 'simplifications' in a loop until there is no more reduction in the number of tensors or indices.
full_simplify_
([seq, output_inds, atol, ...])fuse_multibonds
([gauges, include, exclude, ...])Fuse any multi-bonds (more than one index shared by the same pair of tensors) into a single bond.
fuse_multibonds_
([gauges, include, exclude, ...])gate
(G, where[, contract, tags, ...])Act with the gate
G
on siteswhere
, maintaining the outer indices of the 1D tensor network.gate_
(G, where[, contract, tags, ...])gate_fit_local_
(G, where[, max_distance, ...])gate_inds
(G, inds[, contract, tags, info, ...])Apply the 'gate'
G
to indicesinds
, propagating them to the outside, as if applyingG @ x
.gate_inds_
(G, inds[, contract, tags, info, ...])gate_inds_with_tn
(inds, gate, ...[, inplace])Gate some indices of this tensor network with another tensor network. That is, rewire and then combine them such that the new tensor network has the same outer indices as before, but now includes gate::.
gate_inds_with_tn_
(inds, gate, ...[, inplace])gate_nonlocal
(G, where[, dims, method, ...])Apply a potentially non-local gate to this MPS by first decomposing it into an MPO, then compressing the MPS with MPO only on the minimal set of sites covering where.
gate_nonlocal_
(G, where[, dims, method, ...])gate_simple_
(G, where, gauges[, renorm])Apply a gate to this vector tensor network at sites
where
, using simple update style gauging of the tensors first, as supplied ingauges
.gate_split
(G, where[, inplace])Apply a two-site gate and then split resulting tensor to retrieve a MPS form.
gate_split_
(G, where, *[, inplace])gate_with_auto_swap
(G, where[, info, ...])Perform a two site gate on this MPS by, if necessary, swapping and compressing the sites until they are adjacent, using
gate_split
, then unswapping the sites back to their original position.gate_with_auto_swap_
(G, where[, info, ...])gate_with_mpo
(mpo[, method, transpose, ...])Gate this MPS with an MPO and compress the result with one of various methods back to MPS form.
gate_with_mpo_
(mpo[, method, transpose, ...])gate_with_op_lazy
(A[, transpose, inplace])Act lazily with the operator tensor network
A
, which should have matching structure, on this vector/state tensor network, likeA @ x
.gate_with_op_lazy_
(A[, transpose, inplace])gate_with_submpo
(submpo[, where, method, ...])Apply an MPO, which only acts on a subset of sites, to this MPS, compressing the MPS with the MPO only on the minimal set of sites covering where, keeping the MPS form.
gate_with_submpo_
(submpo[, where, method, ...])gauge_all
([method])Gauge all bonds in this network using one of several strategies.
gauge_all_
([method])gauge_all_canonize
([max_iterations, absorb, ...])Iterative gauge all the bonds in this tensor network with a basic 'canonization' strategy.
gauge_all_canonize_
([max_iterations, ...])gauge_all_random
([max_iterations, unitary, ...])Gauge all the bonds in this network randomly.
gauge_all_random_
([max_iterations, unitary, ...])gauge_all_simple
([max_iterations, tol, ...])Iterative gauge all the bonds in this tensor network with a 'simple update' like strategy.
gauge_all_simple_
([max_iterations, tol, ...])gauge_local
(tags[, which, max_distance, ...])Iteratively gauge all bonds in the tagged sub tensor network according to one of several strategies.
gauge_local_
(tags[, which, max_distance, ...])gauge_simple_insert
(gauges[, remove, ...])Insert the simple update style bond gauges found in
gauges
if they are present in this tensor network.gauge_simple_remove
([outer, inner])Remove the simple update style bond gauges inserted by
gauge_simple_insert
.gauge_simple_temp
(gauges[, smudge, ...])Context manager that temporarily inserts simple update style bond gauges into this tensor network, before optionally ungauging them.
gen_inds_connected
(max_length)Generate all index 'patches' of size up to
max_length
.gen_inds_from_coos
(coos)Generate the site inds corresponding to the given coordinates.
gen_inds_loops
([max_loop_length])Generate all sequences of indices, up to a specified length, that represent loops in this tensor network.
gen_loops
([max_loop_length])Generate sequences of tids that represent loops in the TN.
gen_site_coos
()Generate the coordinates of all possible sites.
gen_sites_present
()Generate the sites which are currently present (e.g.
gen_tags_from_coos
(coos)Generate the site tags corresponding to the given coordinates.
geometry_hash
([output_inds, strict_index_order])A hash of this tensor network's shapes & geometry.
get_equation
([output_inds])Get the 'equation' describing this tensor network, in
einsum
style with a single unicode letter per index.get_hyperinds
([output_inds])Get a tuple of all 'hyperinds', defined as those indices which don't appear exactly twice on either the tensors or in the 'outer' (i.e.
get_inputs_output_size_dict
([output_inds])Get a tuple of
inputs
,output
andsize_dict
suitable for e.g.get_multibonds
([include, exclude])Get a dict of 'multibonds' in this tensor network, i.e. groups of two or more indices that appear on exactly the same tensors and thus could be fused, for example.
get_params
()Get a pytree of the 'parameters', i.e. all underlying data arrays.
get_symbol_map
()Get the mapping of the current indices to
einsum
style single unicode characters.get_tree_span
(tids[, min_distance, ...])Generate a tree on the tensor network graph, fanning out from the tensors identified by
tids
, up to a maximum ofmax_distance
away.graph
([color, show_inds, show_tags, ...])Plot this tensor network as a networkx graph using matplotlib, with edge width corresponding to bond dimension.
graph_tree_span
(tags[, which, min_distance, ...])Visualize a generated tree span out of the tensors tagged by
tags
.hyperinds_resolve
([mode, sorter, ...])Convert this into a regular tensor network, where all indices appear at most twice, by inserting COPY tensor or tensor networks for each hyper index.
hyperinds_resolve_
([mode, sorter, ...])ind_size
(ind)Find the size of
ind
.ind_sizes
()Get dict of each index mapped to its size.
inds_size
(inds)Return the total size of dimensions corresponding to
inds
.inner_inds
()Tuple of interior indices, assumed to be any indices that appear twice or more (this only holds generally for non-hyper tensor networks).
insert_compressor_between_regions
(ltags, rtags)Compute and insert a pair of 'oblique' projection tensors (see for example https://arxiv.org/abs/1905.02351) that effectively compresses between two regions of the tensor network.
insert_compressor_between_regions_
(ltags, rtags)insert_gauge
(U, where1, where2[, Uinv, tol])Insert the gauge transformation
U^-1 @ U
into the bond between the tensors,T1
andT2
, defined bywhere1
andwhere2
.insert_operator
(A, where1, where2[, tags, ...])Insert an operator on the bond between the specified tensors, e.g..
insert_operator_
(A, where1, where2[, tags, ...])iscomplex
()isconnected
()Check whether this tensor network is connected, i.e. whether there is a path between any two tensors, (including size 1 indices).
isel
(selectors[, inplace])Select specific values for some dimensions/indices of this tensor network, thereby removing them.
isel_
(selectors, *[, inplace])isometrize
([method, allow_no_left_inds, inplace])Project every tensor in this network into an isometric form, assuming they have
left_inds
marked.isometrize_
([method, allow_no_left_inds, ...])istree
()Check if this tensor network has a tree structure, (treating multibonds as a single edge).
item
()Return the scalar value of this tensor network, if it is a scalar.
largest_element
()Return the 'largest element', in terms of absolute magnitude, of this tensor network.
least_central_tid
()left_canonicalize
([stop, start, normalize, ...])Left canonicalize all or a portion of this TN (i.e. sweep the orthogonality center to the right). If this is a MPS, this implies that::.
left_canonicalize_
([stop, start, normalize, ...])left_canonize
([stop, start, normalize, bra, ...])left_canonize_site
(i[, bra])Left canonize this TN's ith site, inplace.
left_compress
([start, stop, bra])Compress this 1D TN, from left to right, such that it becomes left-canonical (unless
absorb != 'right'
).left_compress_site
(i[, bra])Left compress this 1D TN's ith site, such that the site is then left unitary with its right bond (possibly) reduced in dimension.
load
(filename)Initialize the underlying tensors of
MatrixProductState
from a file.local_expectation
(G, where, max_bond, optimize)Compute the local expectation of operator
G
at site(s)where
by approximately contracting the full overlap tensor network.local_expectation_cluster
(G, where[, ...])Approximately compute a single local expectation value of the gate
G
at siteswhere
, either treating the environment beyondmax_distance
as the identity, or using simple update style bond gauges as supplied ingauges
.local_expectation_exact
(G, where[, ...])Compute the local expectation of operator
G
at site(s)where
by exactly contracting the full overlap tensor network.local_expectation_simple
(G, where[, ...])Approximately compute a single local expectation value of the gate
G
at siteswhere
, either treating the environment beyondmax_distance
as the identity, or using simple update style bond gauges as supplied ingauges
.logneg_subsys
(sysa, sysb[, compress_opts, ...])Compute the logarithmic negativity between subsytem blocks, e.g..
loop_simplify
([output_inds, ...])Try and simplify this tensor network by identifying loops and checking for low-rank decompositions across groupings of the loops outer indices.
loop_simplify_
([output_inds, ...])magnetization
(i[, direction, info])Compute the magnetization at site
i
.make_norm
([mangle_append, layer_tags, ...])Make the norm tensor network of this tensor network
tn.H & tn
.make_tids_consecutive
([tid0])Reset the tids - node identifies - to be consecutive integers.
mangle_inner_
([append, which])Generate new index names for internal bonds, meaning that when this tensor network is combined with another, there should be no collisions.
max_bond
()Return the size of the largest bond in this network.
maybe_convert_coo
(x)Check if
x
is an integer and convert to the corresponding site tag if so.measure
(site[, remove, outcome, renorm, ...])Measure this MPS at
site
, including projecting the state.measure_
(site[, remove, outcome, renorm, ...])most_central_tid
()multiply
(x[, inplace, spread_over])Scalar multiplication of this tensor network with
x
.multiply_
(x, *[, inplace, spread_over])multiply_each
(x[, inplace])Scalar multiplication of each tensor in this tensor network with
x
.multiply_each_
(x, *[, inplace])negate
([inplace])Negate this tensor network.
negate_
(*[, inplace])new
([like])Create a new tensor network, without any tensors, of type
cls
, with all the requisite properties specified bykwargs
or inherited fromlike
.new_bond
(tags1, tags2, **opts)Inplace addition of a dummmy (size 1) bond between the single tensors specified by by
tags1
andtags2
.norm
(**contract_opts)Frobenius norm of this tensor network.
normalize
([bra, eps, insert])Normalize this MPS, optional with co-vector
bra
.outer_dims_inds
()Get the 'outer' pairs of dimension and indices, i.e. as if this tensor network was fully contracted.
outer_inds
()Tuple of exterior indices, assumed to be any lone indices (this only holds generally for non-hyper tensor networks).
outer_size
()Get the total size of the 'outer' indices, i.e. as if this tensor network was fully contracted.
pair_simplify
([cutoff, output_inds, ...])pair_simplify_
([cutoff, output_inds, ...])partial_trace
(keep[, upper_ind_id, ...])Partially trace this matrix product state, producing a matrix product operator.
partial_trace_compress
(sysa, sysb[, eps, ...])Perform a compressed partial trace using singular value lateral then vertical decompositions of transfer matrix products.
partition
(tags[, which, inplace])Split this TN into two, based on which tensors have any or all of
tags
.partition_tensors
(tags[, inplace, which])Split this TN into a list of tensors containing any or all of
tags
and aTensorNetwork
of the the rest.permute_arrays
([shape])Permute the indices of each tensor in this MPS to match
shape
.pop_tensor
(tid)Remove tensor with
tid
from this network, and return it.ptr
(keep[, upper_ind_id, rescale_sites])Alias of
partial_trace()
.random
(n, bond_dim, phys_dim, **kwargs)Create a randomly initialized
MatrixProductState
.randomize
([dtype, seed, inplace])Randomize every tensor in this TN - see
quimb.tensor.tensor_core.Tensor.randomize()
.randomize_
([dtype, seed, inplace])rank_simplify
([output_inds, equalize_norms, ...])Simplify this tensor network by performing contractions that don't increase the rank of any tensors.
rank_simplify_
([output_inds, ...])reduce_inds_onto_bond
(inda, indb[, tags, ...])Use QR factorization to 'pull' the indices
inda
andindb
off of their respective tensors and onto the bond between them.reindex
(index_map[, inplace])Rename indices for all tensors in this network, optionally in-place.
reindex_
(index_map, *[, inplace])reindex_all
(new_id[, inplace])Reindex all physical sites and change the
site_ind_id
.reindex_all_
(new_id, *[, inplace])reindex_sites
(new_id[, where, inplace])Update the physical site index labels to a new string specifier.
reindex_sites_
(new_id[, where, inplace])remove_all_tensors
()Remove all tensors from this network.
replace_section_with_svd
(start, stop, eps, ...)Take a 1D tensor network, and replace a section with a SVD.
replace_with_identity
(where[, which, inplace])Replace all tensors marked by
where
with an identity. E.g. ifX
denotewhere
tensors::.replace_with_svd
(where, left_inds, eps, *[, ...])Replace all tensors marked by
where
with an iteratively constructed SVD. E.g. ifX
denotewhere
tensors::.replace_with_svd_
(where, left_inds, eps, *)reset_cached_properties
()Reset any cached properties, one should call this when changing the actual geometry of a TN inplace, for example.
retag
(tag_map[, inplace])Rename tags for all tensors in this network, optionally in-place.
retag_
(tag_map, *[, inplace])retag_all
(new_id[, inplace])Retag all sites and change the
site_tag_id
.retag_all_
(new_id, *[, inplace])retag_sites
(new_id[, where, inplace])Modify the site tags for all or some tensors in this tensor network (without changing the
site_tag_id
).right_canonicalize
([stop, start, normalize, ...])Right canonicalize all or a portion of this TN (i.e.
right_canonicalize_
([stop, start, ...])right_canonize
([stop, start, normalize, ...])right_canonize_site
(i[, bra])Right canonize this TN's ith site, inplace.
right_compress
([start, stop, bra])Compress this 1D TN, from right to left, such that it becomes right-canonical (unless
absorb != 'left'
).right_compress_site
(i[, bra])Right compress this 1D TN's ith site, such that the site is then right unitary with its left bond (possibly) reduced in dimension.
save
(filename)Save the underlying tensors of this
MatrixProductState
in the order of indices'lpr'
into file.schmidt_gap
(i[, info, method])The schmidt gap of bipartition between the left block of
i
sites and the rest.schmidt_values
(i[, info, method])Find the schmidt values associated with the bipartition of this MPS between sites on either site of
i
. In other words,i
is the number of sites in the left hand partition::.select
(tags[, which, virtual])Get a TensorNetwork comprising tensors that match all or any of
tags
, inherit the network properties/structure fromself
.select_all
(tags, *[, which, virtual])select_any
(tags, *[, which, virtual])select_local
(tags[, which, max_distance, ...])Select a local region of tensors, based on graph distance
max_distance
to any tagged tensors.select_neighbors
(tags[, which])Select any neighbouring tensors to those specified by
tags
.selfselect_tensors
(tags[, which])Return the sequence of tensors that match
tags
.set_params
(params)Take a pytree of the 'parameters', i.e. all underlying data arrays, as returned by
get_params
and set them.shift_orthogonality_center
(current, new[, bra])Move the orthogonality center of this MPS.
show
([max_width])singular_values
(i[, info, method])Find the singular values associated with the ith bond.
site_ind
(i)Get the physical index name of site
i
.site_tag
(i)The name of the tag specifiying the tensor at site
i
.slice2sites
(tag_slice)Take a slice object, and work out its implied start, stop and step, taking into account cyclic boundary conditions.
split
(left_inds[, method, get, absorb, ...])Decompose this tensor into two tensors.
split_simplify
([atol, equalize_norms, ...])Find tensors which have low rank SVD decompositions across any combination of bonds and perform them.
split_simplify_
([atol, equalize_norms, ...])split_tensor
(site, direction)Split the tensor at given
site
into two tensors, and multiply the one on left or rightdirection
into its neighbouring tensor.squeeze
([fuse, include, exclude, inplace])Drop singlet bonds and dimensions from this tensor network.
squeeze_
([fuse, include, exclude, inplace])strip_exponent
(tid_or_tensor[, value])Scale the elements of tensor corresponding to
tid
so that the norm of the array is some value, which defaults to1
.subgraphs
([virtual])Split this tensor network into disconneceted subgraphs.
sum_reduce
(ind[, inplace])Sum over the index
ind
of this tensor network, removing it.sum_reduce_
(ind, *[, inplace])swap_site_to
(i, f[, info, inplace])Swap site
i
to sitef
, compressing the bond after each swap.swap_site_to_
(i, f[, info, inplace])swap_sites_with_compress
(i, j[, info, inplace])Swap sites
i
andj
by contracting, then splitting with the physical indices swapped.swap_sites_with_compress_
(i, j[, info, inplace])tensors_sorted
()Return a tuple of tensors sorted by their respective tags, such that the tensors of two networks with the same tag structure can be iterated over pairwise.
tids_are_connected
(tids)Check whether nodes
tids
are connected.to_dense
(*inds_seq[, to_qarray, to_ket])Contract this tensor network 'vector' into a dense array.
to_qarray
(*inds_seq[, to_qarray, to_ket])trace
(left_inds, right_inds, **contract_opts)Trace over
left_inds
joined withright_inds
unitize
([method, allow_no_left_inds, inplace])Project every tensor in this network into an isometric form, assuming they have
left_inds
marked.unitize_
Method descriptor with partial application of the given arguments and keywords.
vector_reduce
(ind, v[, inplace])Contract the vector
v
with the indexind
of this tensor network, removing it.vector_reduce_
(ind, v, *[, inplace])view_as
(cls[, inplace])View this tensor network as subclass
cls
.view_as_
(cls, *[, inplace])view_like
(like[, inplace])View this tensor network as the same subclass
cls
aslike
inheriting its extra properties as well.view_like_
(like, *[, inplace])visualize_tensors
([mode, r, r_scale, figsize])Visualize all the entries of every tensor in this network.
Attributes
H
Conjugate all the tensors in this network (leaves all indices).
L
The number of sites, i.e. length.
arrays
Get the tuple of raw arrays containing all the tensor network data.
The bond dimensions.
dtype
The dtype of this TensorNetwork, this is the minimal common type of all the tensors data.
nsites
The number of sites.
num_indices
The total number of indices in the tensor network.
num_tensors
The total number of tensors in the tensor network.
Physical dimensions of local state.
shape
Actual, i.e. exterior, shape of this TensorNetwork.
site_ind_id
The string specifier for the physical indices.
site_inds
Return a tuple of all site indices.
site_inds_present
All of the site inds still present in this tensor network.
site_tag_id
The string specifier for tagging each site of this tensor network.
site_tags
All of the site tags.
site_tags_present
All of the site tags still present in this tensor network.
sites
Tuple of the possible sites in this tensor network.
tags
tensors
Get the tuple of tensors in this tensor network.
- __init__(*args, **kwargs)[source]#
Matrix product state (MPS) for a finite size system.
- Parameters
*args – Positional arguments for
quimb.tensor.MatrixProductState
.**kwargs – Keyword arguments for
quimb.tensor.MatrixProductState
.
Note
This class inherits directly from
quimb.tensor.MatrixProductState
, with some added features. But, note that the underlying tensors are in the shape ‘lpr’, which differs from the parent classquimb.tensor.MatrixProductState
.
- property n_sites: int#
- property phys_dim: int#
Physical dimensions of local state.
- property bond_dim: int#
The bond dimensions.
Notes
The actual bond dimensions can be smaller than this one at the boundaries.
- permute_arrays(shape='lrp')[source]#
Permute the indices of each tensor in this MPS to match
shape
. This doesn’t change how the overall object interacts with other tensor networks but may be useful for extracting the underlying arrays consistently. This is an inplace operation.- Parameters
shape (str) – A permutation of
'lrp'
specifying the desired order of the left, right, and physical indices respectively.
- conj(mangle_inner=False, mangle_outer=False)[source]#
Create a conjugated copy of this
MatrixProductState
instance.- Parameters
mangle_inner (bool) – Whether to rename the inner indices, so that there will be no conflict with the original one when contracting the network.
mangle_outer (bool) – Whether to rename the outer indices, so that there will be no conflict with the original one when contracting the network.
- Return type
conj_mps
- save(filename)[source]#
Save the underlying tensors of this
MatrixProductState
in the order of indices'lpr'
into file. Only accepts suffix'.hdf5'
or'.npz'
as file extension.- Parameters
filename (str) – Absolute path to file in local disk.
Returns:
- classmethod load(filename)[source]#
Initialize the underlying tensors of
MatrixProductState
from a file. Tensors in the file should take the order of indices'lpr'
. Only accepts suffix'.hdf5'
or'.npz'
as file extension.- Parameters
filename (str) – Absolute path to file in local disk.
- Return type
mps
- classmethod random(n, bond_dim, phys_dim, **kwargs)[source]#
Create a randomly initialized
MatrixProductState
.- Parameters
n (int) – The system size.
bond_dim (int) – The bond dimensions.
phys_dim (int) – Physical dimensions of local state.
- Return type
Returns:
- split_tensor(site, direction)[source]#
Split the tensor at given
site
into two tensors, and multiply the one on left or rightdirection
into its neighbouring tensor. This is an inplace operation.- Parameters
site (int) –
direction (tnpy.matrix_product_state.Direction) –
Returns: