37 #include <alps/parser/xmlstream.h>
46 #include <boost/regex.hpp>
47 #include <boost/static_assert.hpp>
52 template<
class Matrix,
class SymmGroup>
61 template <
class Archive>
62 void save(Archive &)
const;
64 virtual void print(std::ostream& os)
const;
66 std::string
const&
name()
const {
return name_; }
89 template<
class Matrix,
class SymmGroup>
95 template <
class Archive,
typename T>
96 void save_val_at_index(Archive & ar, std::string
const& archive_path, T
const& val, std::size_t eig)
99 if (ar.is_data(archive_path.c_str())) ar[archive_path] >> vals;
100 vals.resize( std::max(vals.size(), eig+1) );
102 ar[archive_path] << vals;
105 template<
class Matrix,
class SymmGroup>
106 template <
class Archive>
109 if (vector_results.size() > 0) {
115 if (labels.size() > 0)
126 template<
class Matrix,
class SymmGroup>
129 if (labels.size() > 0) {
130 out << alps::start_tag(
"VECTOR_AVERAGE") << alps::attribute(
"name", name());
131 for (
int i=0; i<labels.size(); ++i) {
132 out << alps::start_tag(
"SCALAR_AVERAGE");
133 out << alps::attribute(
"indexvalue",labels[i]) << alps::no_linebreak;
136 out << alps::start_tag(
"MEAN") << alps::no_linebreak <<
maquis::real(vector_results[i]) << alps::end_tag(
"MEAN");
138 out << alps::start_tag(
"MEAN") << alps::no_linebreak << vector_results[i] << alps::end_tag(
"MEAN");
140 out << alps::end_tag(
"SCALAR_AVERAGE");
143 out << alps::end_tag(
"VECTOR_AVERAGE");
145 out << alps::start_tag(
"SCALAR_AVERAGE") << alps::attribute(
"name", name()) << alps::no_linebreak;
146 out << alps::start_tag(
"MEAN") << alps::no_linebreak << ((cast_to_real) ?
maquis::real(result) : result) << alps::end_tag(
"MEAN");
147 out << alps::end_tag(
"SCALAR_AVERAGE");
152 template<
class Matrix,
class SymmGroup>
155 phys_psi = phys_psi_;
156 is_super_meas =
true;
159 template<
class Matrix,
class SymmGroup>
162 os <<
"MEASURE[" << name_ <<
"]";
165 template<
class Matrix,
class SymmGroup>
166 std::ostream& operator<<(std::ostream& os, measurement<Matrix, SymmGroup>
const& m)
174 template<
class Matrix,
class SymmGroup>
177 return all_true(ops.begin(), ops.end(),
181 template<
class Matrix,
class SymmGroup>
185 for (
int i=0; i<ops.size() && is_herm; ++i)
190 inline std::vector<std::string>
label_strings (
const Lattice& lat,
const std::vector<std::vector<std::size_t> >& labels)
192 std::vector<std::string> ret;
193 ret.reserve(labels.size());
194 for (std::vector<std::vector<std::size_t> >::const_iterator it = labels.begin();
195 it != labels.end(); ++it)
197 std::ostringstream oss;
198 for (std::vector<std::size_t>::const_iterator it2 = it->begin(); it2 != it->end(); ++it2) {
199 oss << lat.
get_prop<std::string>(
"label", *it2);
200 if (it2 + 1 != it->end())
203 ret.push_back(oss.str());
definition of Lattice base class
std::vector< std::string > labels
include all symmetry definitions
virtual void evaluate(MPS< Matrix, SymmGroup > const &, boost::optional< reduced_mps< Matrix, SymmGroup > const & >=boost::none)=0
bool is_hermitian(block_matrix< Matrix, SymmGroup > const &m)
std::string encode(std::string const &s)
void set_super_meas(Index< SymmGroup > const &phys_psi_)
bool all_true(InputIterator first, InputIterator last, Predicate pred)
std::vector< std::string > label_strings(const Lattice &lat, const std::vector< std::vector< std::size_t > > &labels)
declaration of block_matrix class
measurement(std::string const &n="")
void save_val_at_index(Archive &ar, std::string const &archive_path, T const &val, std::size_t eig)
std::vector< typename MPS< Matrix, SymmGroup >::scalar_type > vector_results
bool is_hermitian_meas(std::vector< block_matrix< Matrix, SymmGroup > > const &ops)
UTILITIES.
void write_xml(alps::oxstream &) const
T get_prop(std::string property, pos_t site) const
virtual void print(std::ostream &os) const
algorithms for block_matrix (gemm, svd, etc.)
void save(Archive &) const
measurement * clone() const
Matrix::value_type value_type
Index< SymmGroup > phys_psi
alps::numeric::real_type< T >::type real(T f)
measurement< Matrix, SymmGroup > * new_clone(const measurement< Matrix, SymmGroup > &m)
virtual measurement * do_clone() const =0
std::string const & name() const
int eigenstate_index() const