38template <
class FirstSite,
class SecondSite,
class SingularValues,
class Truncation>
struct TwoSiteMpsSplit
69concept SplitBondSpace =
74concept SplitPhysicalSpace =
78template <
class Storage,
class Scalar>
83template <
class Tensor, std::
size_t Index>
86template <
class Tensor, std::
size_t Index>
89template <
class Tensor>
90concept TwoSiteSvdCenter =
94 SplitPhysicalSpace<split_domain_space_t<Tensor, 1>> && SplitPhysicalSpace<split_domain_space_t<Tensor, 2>> &&
95 SplitBondSpace<split_codomain_space_t<Tensor, 0>>;
97template <SparseBlockStorage OutputStorage, BlockTensorView Source>
98auto materialize_block_tensor_copy(Source
const& source)
102 using key_type =
typename output_type::key_type;
103 std::vector<key_type> keys(source.stored_keys().begin(), source.stored_keys().end());
105 if constexpr (
requires {
106 output_type(
uninitialized, source.symmetry(), source.domain(), source.codomain(), keys,
107 source.allocation_context());
109 return output_type(
uninitialized, source.symmetry(), source.domain(), source.codomain(), std::move(keys),
110 source.allocation_context());
112 return output_type(
uninitialized, source.symmetry(), source.domain(), source.codomain(), std::move(keys));
114 for (std::size_t ordinal = 0; ordinal < result.stored_block_count(); ++ordinal)
116 auto output_block = result.block_by_ordinal(ordinal);
117 auto input_block = source.block_by_ordinal(ordinal);
136template <detail::TwoSiteSvdCenter Center,
class Measurements,
class Event>
139 Measurements& measurements, Event batch_event)
141 auto matrix = repartition<MorphismSide::Domain, BoundaryEnd::Right>(center);
142 return block_svd(matrix, options, measurements, batch_event);
150template <detail::TwoSiteSvdCenter Center>
171template <SparseBlockStorage OutputStorage = SeparateSparseBlockStorage<>,
class Decomposition>
172 requires detail::MpsSiteStorage<OutputStorage, typename Decomposition::scalar_type>
178 static_assert(Decomposition::domain_type::size() == 2,
"two-site MPS decomposition requires a two-factor domain");
179 static_assert(Decomposition::codomain_type::size() == 2,
"two-site MPS decomposition requires a two-factor codomain");
180 if (selection.
state_ids().empty())
throw std::invalid_argument(
"two-site MPS split requires a retained state");
182 throw std::invalid_argument(
"two-site MPS split has an invalid sweep direction");
186 auto factors = uni20::detail::materialize_svd_with_absorption(decomposition, selection, std::move(options),
187 absorb_left, absorb_right);
190 auto first_site = detail::materialize_block_tensor_copy<OutputStorage>(factors.right_singular_vectors_adjoint);
191 auto second_view = repartition<MorphismSide::Codomain, BoundaryEnd::Right>(factors.left_singular_vectors);
192 auto second_site = detail::materialize_block_tensor_copy<OutputStorage>(second_view);
193 return TwoSiteMpsSplit{.first_site = std::move(first_site),
194 .second_site = std::move(second_site),
195 .singular_values = std::move(factors.singular_values),
196 .truncation = std::move(factors.truncation),
197 .direction = direction};
200 auto first_site = detail::materialize_block_tensor_copy<OutputStorage>(factors.right_singular_vectors_adjoint);
201 auto second_view = repartition<MorphismSide::Codomain, BoundaryEnd::Right>(factors.left_singular_vectors);
202 auto second_site = detail::materialize_block_tensor_copy<OutputStorage>(second_view);
203 return TwoSiteMpsSplit{.first_site = std::move(first_site),
204 .second_site = std::move(second_site),
205 .singular_values = std::move(factors.singular_values),
206 .truncation = std::move(factors.truncation),
207 .direction = direction};
222template <
typename Scalar, Space Bond, Space Physical, BlockTensorStorage SiteStorage,
class Decomposition>
223 requires std::same_as<Bond, BlockSpace> && detail::MpsSiteStorage<SiteStorage, Scalar>
225 std::size_t first_index, Decomposition
const& decomposition,
229 auto split = materialize_two_site_mps_split<SiteStorage>(decomposition, selection, direction, std::move(options));
230 mps.
replace_pair(first_index, std::move(split.first_site), std::move(split.second_site));
231 return InstalledMpsBond{.singular_values = std::move(split.singular_values),
232 .truncation = std::move(split.truncation),
233 .direction = direction};
Defines local pairwise BlockTensor contraction.
Defines structure-preserving linear operations on BlockTensor values.
Defines zero-copy bosonic edge repartition views.
Classifies tensor spaces for block-key and dense-block storage.
Staged host singular value decompositions of bosonic Abelian BlockTensor values.
Arbitrary paired-state selection from a block-SVD spectrum.
Definition block_tensor_svd.hpp:92
auto state_ids() const noexcept -> std::span< BlockSvdStateId const >
Return selected state identities in global spectrum order.
Definition block_tensor_svd.hpp:95
Fixed-order tensor whose blocks obey a bosonic abelian selection rule.
Definition block_tensor.hpp:161
Homogeneous finite MPS owner with exact bond connectivity.
Definition finite_chain.hpp:32
void replace_pair(std::size_t first_index, site_type first, site_type second)
Replace adjacent sites while permitting their shared bond to change.
Definition finite_chain.hpp:97
Local BlockTensor storage with one independently scheduled async value per block.
Definition block_tensor_storage.hpp:142
Tensor space with an explicit block-coordinate/dense-axis classification.
Definition block_tensor_space_traits.hpp:71
Tensor-level view of a symmetry-preserving collection of dense blocks.
Definition block_tensor_concepts.hpp:52
BlockTensor storage whose stored numerical blocks are generalized diagonals.
Definition block_tensor_storage.hpp:71
Concept for scalar types with a configured dense LAPACK backend.
Definition scalar_concepts.hpp:147
BlockTensor storage whose blocks reside within one local process.
Definition block_tensor_storage.hpp:118
BlockTensor storage whose stored key set may omit legal blocks.
Definition block_tensor_storage.hpp:58
Owns validated finite MPS and MPO chains.
Definition right_first_rabc.hpp:34
auto materialize_two_site_mps_split(Decomposition const &decomposition, BlockSvdSelection< typename Decomposition::real_type > const &selection, MpsSweepDirection direction, BlockSvdMaterializationOptions options={})
Materialize selected SVD states as a directional pair of owning MPS sites.
Definition two_site_split.hpp:173
auto replace_two_site_from_svd(FiniteMps< Scalar, Bond, Physical, SiteStorage > &mps, std::size_t first_index, Decomposition const &decomposition, BlockSvdSelection< typename Decomposition::real_type > const &selection, MpsSweepDirection direction, BlockSvdMaterializationOptions options={})
Materialize and install a selected two-site split in a finite MPS.
Definition two_site_split.hpp:224
MpsSweepDirection
Direction in which a two-site split moves the MPS canonical center.
Definition two_site_split.hpp:28
@ left_to_right
Absorb singular values into the right site.
@ right_to_left
Absorb singular values into the left site.
auto decompose_two_site_center(Center const ¢er, linalg::SvdOptions options, Measurements &measurements, Event batch_event)
Factorize a canonical two-site MPS center by its internal cut with performance measurements.
Definition two_site_split.hpp:138
constexpr uninitialized_t uninitialized
Explicit allocation tag for overwrite outputs and scratch space.
Definition common/initialization.hpp:22
std::remove_cvref_t< Tensor > block_tensor_type_t
Cvref-stripped BlockTensor-level object type.
Definition block_tensor_concepts.hpp:22
typename block_tensor_type_t< Tensor >::domain_type block_tensor_domain_t
Ordered domain type exposed by a BlockTensor-level object.
Definition block_tensor_concepts.hpp:31
void copy(BackendSelector selector, async::Async< OutputTensor > &output, async::Async< InputTensor > const &input)
Schedule a Tensor copy through an explicit backend selector.
Definition linalg/async/copy.hpp:174
typename block_tensor_type_t< Tensor >::codomain_type block_tensor_codomain_t
Ordered codomain type exposed by a BlockTensor-level object.
Definition block_tensor_concepts.hpp:34
Options controlling one selected block-SVD materialization.
Definition block_tensor_svd.hpp:132
Compile-time storage properties of one BlockTensor boundary space.
Definition block_tensor_space_traits.hpp:27
Output-shape options for an exact singular value decomposition.
Definition operation_tags.hpp:255
Bond data retained after installing a two-site MPS split.
Definition two_site_split.hpp:56
Truncation truncation
Statistics for the selected and discarded singular states.
Definition two_site_split.hpp:60
SingularValues singular_values
Selected singular values over the installed internal bond.
Definition two_site_split.hpp:58
MpsSweepDirection direction
Direction used to absorb the singular values.
Definition two_site_split.hpp:62
Directionally absorbed two-site MPS factors and retained bond data.
Definition two_site_split.hpp:39
SecondSite second_site
Owning right MPS site.
Definition two_site_split.hpp:43
SingularValues singular_values
Selected singular values over the new internal bond.
Definition two_site_split.hpp:45
MpsSweepDirection direction
Direction used to absorb the singular values.
Definition two_site_split.hpp:49
Truncation truncation
Statistics for the selected and discarded singular states.
Definition two_site_split.hpp:47
FirstSite first_site
Owning left MPS site.
Definition two_site_split.hpp:41