29 #ifndef MAQUIS_DMRG_lattice_hpp
30 #define MAQUIS_DMRG_lattice_hpp
37 #include <boost/lexical_cast.hpp>
60 std::vector<pos_t> ret;
69 std::vector<pos_t> ret;
81 boost::any
get_prop_(std::string
const & property, std::vector<pos_t>
const & pos)
const
83 if (property ==
"label" && pos.size() == 1)
84 return boost::any( site_label(pos[0]) );
85 else if (property ==
"label" && pos.size() == 2)
86 return boost::any( bond_label(pos[0], pos[1]) );
87 else if (property ==
"type" && pos.size() == 1)
88 return boost::any( 0 );
89 else if (property ==
"type" && pos.size() == 2)
90 return boost::any( 0 );
91 else if (property ==
"x" && pos.size() == 1)
92 return boost::any( a * pos[0] );
93 else if (property ==
"at_open_boundary" && pos.size() == 1)
94 return boost::any( (!pbc) && (pos[0]==0 || pos[0]==L-1) );
95 else if (property ==
"at_open_left_boundary" && pos.size() == 1)
96 return boost::any( (!pbc) && pos[0]==0 );
97 else if (property ==
"at_open_right_boundary" && pos.size() == 1)
98 return boost::any( (!pbc) && pos[0]==L-1 );
99 else if (property ==
"wraps_pbc" && pos.size() == 2)
100 return boost::any( (pos[0] < pos[1]) );
102 std::ostringstream ss;
103 ss <<
"No property '" <<
property <<
"' with " << pos.size() <<
" points implemented.";
104 throw std::runtime_error(ss.str());
121 std::string site_label (
int i)
const
123 return "( " + boost::lexical_cast<std::string>(a * i) +
" )";
126 std::string bond_label (
int i,
int j)
const
128 return (
"( " + boost::lexical_cast<std::string>(a * i) +
" )"
130 +
"( " + boost::lexical_cast<std::string>(a * j) +
" )");
158 std::vector<int> ret;
159 if (p+1 < L_*W_ && (p+1) % W_ != 0)
171 std::vector<int>
all(
int p)
const
173 std::vector<int> ret =
forward(p);
174 if (p >= 1 && p % W_ != 0)
182 int size()
const {
return L_*W_; }
190 boost::any
get_prop_(std::string
const & property, std::vector<pos_t>
const & pos)
const
192 if (property ==
"label" && pos.size() == 1)
193 return boost::any( site_label(pos[0]) );
194 else if (property ==
"label" && pos.size() == 2)
195 return boost::any( bond_label(pos[0], pos[1]) );
196 else if (property ==
"type" && pos.size() == 1)
197 return boost::any( 0 );
198 else if (property ==
"type" && pos.size() == 2)
199 return boost::any( 0 );
200 else if (property ==
"x" && pos.size() == 1)
201 return boost::any( x(pos[0]) );
202 else if (property ==
"y" && pos.size() == 1)
203 return boost::any( y(pos[0]) );
204 else if (property ==
"wraps_pbc" && pos.size() == 2)
205 return boost::any(
false );
207 std::ostringstream ss;
208 ss <<
"No property '" <<
property <<
"' with " << pos.size() <<
" points implemented.";
209 throw std::runtime_error(ss.str());
218 double x (
int i)
const
219 {
return a * int(i/W_); }
220 double y (
int i)
const
221 {
return a * (i%W_); }
223 std::string site_label (
int i)
const
225 return "( " + ( boost::lexical_cast<std::string>(x(i))
226 +
"," + boost::lexical_cast<std::string>(y(i)) ) +
" )";
229 std::string bond_label (
int i,
int j)
const
231 return (
"( " + ( boost::lexical_cast<std::string>(x(i))
232 +
"," + boost::lexical_cast<std::string>(y(i)) ) +
" )"
234 +
"( " + ( boost::lexical_cast<std::string>(x(j))
235 +
"," + boost::lexical_cast<std::string>(y(j)) ) +
" )" );
definition of Lattice base class
std::vector< int > forward(int p) const
ChainLattice(BaseParameters &parms, bool pbc_=false)
SquareLattice(BaseParameters &parms)
std::vector< pos_t > forward(pos_t i) const
std::vector< pos_t > all(pos_t i) const
std::vector< int > all(int p) const
lattice_impl::pos_t pos_t
int maximum_vertex_type() const
boost::any get_prop_(std::string const &property, std::vector< pos_t > const &pos) const
boost::any get_prop_(std::string const &property, std::vector< pos_t > const &pos) const
ChainLattice(int L_, bool pbc_=false, double a_=1.)
int maximum_vertex_type() const