31template <
typename Scalar, Space Bond, Space Physical, BlockTensorStorage Storage = SeparateSparseBlockStorage<>>
50 auto size() const noexcept ->
std::
size_t {
return sites_.size(); }
58 auto site(std::size_t index)
const ->
site_type const& {
return sites_.at(index); }
66 auto revision(std::size_t index)
const -> std::size_t {
return revisions_.at(index); }
77 site_type const& current = sites_.at(index);
81 throw std::invalid_argument(
"FiniteMps replacement site must preserve every space");
83 sites_[index] = std::move(replacement);
99 if (first_index >= this->
size() || first_index + 1 >= this->
size())
100 throw std::out_of_range(
"FiniteMps pair index is out of range");
102 site_type const& current_first = sites_[first_index];
103 site_type const& current_second = sites_[first_index + 1];
104 if (first.
symmetry() != this->symmetry() || second.
symmetry() != this->symmetry() ||
106 second.
domain().template space<1>() != current_second.
domain().template space<1>() ||
107 first.
codomain().template space<0>() != second.
domain().template space<0>())
109 throw std::invalid_argument(
"FiniteMps replacement pair has incompatible spaces");
112 sites_[first_index] = std::move(first);
113 sites_[first_index + 1] = std::move(second);
114 ++revisions_[first_index];
115 ++revisions_[first_index + 1];
119 void validate()
const
121 if (sites_.empty())
throw std::invalid_argument(
"FiniteMps requires at least one site");
122 Symmetry const chain_symmetry = sites_.front().symmetry();
123 for (std::size_t index = 0; index < sites_.size(); ++index)
125 if (sites_[index].
symmetry() != chain_symmetry)
126 throw std::invalid_argument(
"FiniteMps sites must share one symmetry");
127 if (index + 1 < sites_.size() &&
128 sites_[index].codomain().template space<0>() != sites_[index + 1].domain().template space<0>())
130 throw std::invalid_argument(
"FiniteMps adjacent bond spaces must compare exactly equal");
135 std::vector<site_type> sites_;
136 std::vector<std::size_t> revisions_;
146template <
typename Scalar, Space Auxiliary, Space Physical, BlockTensorStorage Storage = SeparateSparseBlockStorage<>>
165 auto size() const noexcept ->
std::
size_t {
return sites_.size(); }
173 auto site(std::size_t index)
const ->
site_type const& {
return sites_.at(index); }
181 auto revision(std::size_t index)
const -> std::size_t {
return revisions_.at(index); }
190 site_type const& current = sites_.at(index);
194 throw std::invalid_argument(
"FiniteMpo replacement site must preserve every space");
196 sites_[index] = std::move(replacement);
201 void validate()
const
203 if (sites_.empty())
throw std::invalid_argument(
"FiniteMpo requires at least one site");
204 Symmetry const chain_symmetry = sites_.front().symmetry();
205 for (std::size_t index = 0; index < sites_.size(); ++index)
207 if (sites_[index].
symmetry() != chain_symmetry)
208 throw std::invalid_argument(
"FiniteMpo sites must share one symmetry");
209 if (index + 1 < sites_.size() &&
210 sites_[index].codomain().template space<0>() != sites_[index + 1].domain().template space<0>())
212 throw std::invalid_argument(
"FiniteMpo adjacent auxiliary spaces must compare exactly equal");
217 std::vector<site_type> sites_;
218 std::vector<std::size_t> revisions_;
Defines local sparse and packed-complete BlockTensor storage policies.
Fixed-order tensor whose blocks obey a bosonic abelian selection rule.
Definition block_tensor.hpp:161
auto symmetry() const -> Symmetry
Return the explicit symmetry context.
Definition block_tensor.hpp:304
auto codomain() const -> codomain_type const &
Return the ordered codomain value.
Definition block_tensor.hpp:310
auto domain() const -> domain_type const &
Return the ordered domain value.
Definition block_tensor.hpp:307
Public handle to a canonicalized direct-product symmetry specification.
Definition symmetry.hpp:24
Homogeneous finite MPO owner with exact auxiliary connectivity.
Definition finite_chain.hpp:147
void replace_site(std::size_t index, site_type replacement)
Replace one MPO site without changing any of its spaces.
Definition finite_chain.hpp:188
Auxiliary auxiliary_space_type
Definition finite_chain.hpp:150
FiniteMpo(std::vector< site_type > sites)
Construct a nonempty chain and validate every shared auxiliary.
Definition finite_chain.hpp:159
auto size() const noexcept -> std::size_t
Return the number of sites.
Definition finite_chain.hpp:165
auto symmetry() const -> Symmetry
Return the common symmetry context.
Definition finite_chain.hpp:168
auto site(std::size_t index) const -> site_type const &
Return one read-only site.
Definition finite_chain.hpp:173
auto sites() const noexcept -> std::span< site_type const >
Return all sites in left-to-right order.
Definition finite_chain.hpp:176
Storage storage_policy
Definition finite_chain.hpp:152
auto revision(std::size_t index) const -> std::size_t
Return the revision of one site.
Definition finite_chain.hpp:181
std::remove_cv_t< Scalar > value_type
Definition finite_chain.hpp:149
Physical physical_space_type
Definition finite_chain.hpp:151
Homogeneous finite MPS owner with exact bond connectivity.
Definition finite_chain.hpp:32
auto size() const noexcept -> std::size_t
Return the number of sites.
Definition finite_chain.hpp:50
void replace_site(std::size_t index, site_type replacement)
Replace one site without changing any of its spaces.
Definition finite_chain.hpp:75
auto site(std::size_t index) const -> site_type const &
Return one read-only site.
Definition finite_chain.hpp:58
Physical physical_space_type
Definition finite_chain.hpp:36
Storage storage_policy
Definition finite_chain.hpp:37
auto symmetry() const -> Symmetry
Return the common symmetry context.
Definition finite_chain.hpp:53
std::remove_cv_t< Scalar > value_type
Definition finite_chain.hpp:34
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
auto revision(std::size_t index) const -> std::size_t
Return the revision of one site.
Definition finite_chain.hpp:66
FiniteMps(std::vector< site_type > sites)
Construct a nonempty chain and validate every shared bond.
Definition finite_chain.hpp:44
auto sites() const noexcept -> std::span< site_type const >
Return all sites in left-to-right order.
Definition finite_chain.hpp:61
Bond bond_space_type
Definition finite_chain.hpp:35
Definition right_first_rabc.hpp:34
std::size_t span
Definition presentation.cpp:2017
Defines canonical BlockTensor types for matrix-product networks.
Defines the common tensor-space concepts.