1#ifndef XPED_ONE_SITE_OBSERVABLE_HPP_
2#define XPED_ONE_SITE_OBSERVABLE_HPP_
6#include <highfive/H5DataSpace.hpp>
16template <
typename,
typename, std::
size_t,
bool, Opts::CTMCheckpo
int>
19template <
typename Scalar,
typename Symmetry,
bool HERMITIAN = true>
32 if(std::all_of(charges.
cbegin(), charges.
cend(), [](
auto c) { return c == Symmetry::qvacuum(); })) {
return *
this; }
34 for(
int x = 0; x <
data.pat.Lx; ++x) {
35 for(
int y = 0; y <
data.pat.Ly; ++y) {
36 if(not
data.pat.isUnique(x, y)) {
continue; }
42 auto tmp =
data(x, y).template contract<std::array{-1, -3}, std::array{-2, -4}, 2>(id);
44 {{
data(x, y).uncoupledCodomain()[0].combine(c).forgetHistory()}});
46 out.
data(x, y) = tmp.template contract<std::array{-1, -2, 1, 2}, std::array{1, 2, -3}, 2>(fuser)
47 .
template contract<std::array{1, 2, -2}, std::array{-1, 1, 2}, 1>(fuser.adjoint().eval().twist(1).twist(2));
53 virtual std::string
getResString(
const std::string& offset)
const override
56 fmt::format_to(std::back_inserter(res),
57 "{}{:<10}: avg={:+.2f}, vals={::+.4f}",
65 virtual void toFile(HighFive::File& file,
const std::string& root =
"/")
const override
67 if(not file.exist(root + this->name)) {
68 HighFive::DataSpace dataspace = HighFive::DataSpace({0, 0}, {HighFive::DataSpace::UNLIMITED, HighFive::DataSpace::UNLIMITED});
71 HighFive::DataSetCreateProps props;
72 props.add(HighFive::Chunking(std::vector<hsize_t>{2, 2}));
75 HighFive::DataSet dataset = file.createDataSet(root + this->
name, dataspace, HighFive::create_datatype<ObsScalar>(), props);
77 auto d = file.getDataSet(root + this->
name);
78 std::vector<std::vector<ObsScalar>>
data;
80 std::size_t curr_size = d.getDimensions()[0];
81 d.resize({curr_size + 1,
data[0].size()});
82 d.select({curr_size, 0}, {1,
data[0].size()}).write(
data);
Definition: Qbasis.hpp:39
void push_back(const qType &q, const size_t &inner_dim)
Definition: Qbasis.cpp:32
Definition: Tensor.hpp:40
Definition: ObservableBase.hpp:11
std::string name
Definition: ObservableBase.hpp:24
Definition: OneSiteObservable.hpp:21
virtual std::string getResString(const std::string &offset) const override
Definition: OneSiteObservable.hpp:53
OneSiteObservable< Scalar, Symmetry, HERMITIAN > shiftQN(const TMatrix< typename Symmetry::qType > &charges)
Definition: OneSiteObservable.hpp:30
TMatrix< ObsScalar > obs
Definition: OneSiteObservable.hpp:86
std::conditional_t< HERMITIAN, typename ScalarTraits< Scalar >::Real, typename ScalarTraits< Scalar >::Comp > ObsScalar
Definition: OneSiteObservable.hpp:22
TMatrix< Tensor< Scalar, 1, 1, Symmetry, false > > data
Definition: OneSiteObservable.hpp:85
virtual void toFile(HighFive::File &file, const std::string &root="/") const override
Definition: OneSiteObservable.hpp:65
OneSiteObservable(const Pattern &pat, const std::string &name_in="")
Definition: OneSiteObservable.hpp:24
Definition: Pattern.hpp:18
Definition: ScalarTraits.hpp:10
Definition: TMatrix.hpp:13
Ttype sum() const
Definition: TMatrix.hpp:77
auto cbegin() const
Definition: TMatrix.hpp:70
std::size_t size() const
Definition: TMatrix.hpp:38
std::vector< Ttype > uncompressedVector() const
Definition: TMatrix.hpp:85
auto cend() const
Definition: TMatrix.hpp:71