Skip to content

ProductState

A product state of local configurations

Source product_state.hpp

Constructors

ProductState(n_sites::Int64)
ProductState(local_states::Vector{String})
ProductState(int64_t n_sites);
ProductState(std::vector<std::string> const &local_states);
Parameter Description
n_sites construct a product state on n_sites
local_states the local configurations of the product state

Iteration

A Product state can be iterated over, where at each iteration the string of the local configuration is retured. Here is an example:

pstate = ProductState(["Up", "Dn", "Emp", "UpDn"])
for s in pstate
    @show s
end
auto pstate = ProductState({"Up", "Dn", "Emp", "UpDn"});
for (auto s : pstate) {
    Log("{}", s);
}

Methods

n_sites

Returns the number of sites of the product state

n_sites(state::ProductState)
int64_t n_sites() const

size

Returns the number of sites of the product state. Same as "n_sites".

size(state::ProductState)
int64_t size() const

setindex! / operator[]

Sets the local configuration at the given site index to the given string.

setindex!(state::ProductState, local_state::String, idx::Int64)
std::string &operator[](int64_t i);

getindex / operator[]

Returns the string of the local configuration at the given site index.

getindex(state::ProductState, idx::Int64)
std::string const &operator[](int64_t i) const;

push! / push_back

Adds a local configuration add the end of the product state.

push!(state::ProductState, local_state::String
void push_back(std::string l);

Usage Example

pstate = ProductState(["Up", "Dn", "Emp", "UpDn"])
for s in pstate
    @show s
end
@show pstate

pstate = ProductState()
push!(pstate, "Dn")
push!(pstate, "Up")
push!(pstate, "Dn")
@show n_sites(pstate)
for s in pstate
    @show s
end
@show pstate
auto pstate = ProductState({"Up", "Dn", "Emp", "UpDn"});
for (auto s : pstate) {
  Log("{}", s);
}
XDIAG_SHOW(to_string(pstate));

pstate = ProductState();
pstate.push_back("Dn");
pstate.push_back("Up");
pstate.push_back("Dn");
XDIAG_SHOW(pstate.n_sites());
for (auto s : pstate) {
  Log("{}", s);
}
XDIAG_SHOW(to_string(pstate));