3
0
mirror of https://github.com/triqs/dft_tools synced 2024-10-31 19:23:45 +01:00

gf: fix upper bound in out of bounds check in linear mesh

This commit is contained in:
Olivier Parcollet 2013-07-29 11:51:52 +02:00
parent bd4926157c
commit 65bdc65da1
2 changed files with 8 additions and 2 deletions

View File

@ -14,6 +14,8 @@ using triqs::arrays::array;
int main() { int main() {
try {
//typedef gf<two_real_times> Gf_type; //typedef gf<two_real_times> Gf_type;
//typedef gf_view<two_real_times> Gf_view_type; //typedef gf_view<two_real_times> Gf_view_type;
@ -31,7 +33,9 @@ int main() {
std::cout <<A << std::endl ; std::cout <<A << std::endl ;
G(t_,tp_) << t_ - 3*tp_; G(t_,tp_) << t_ - 3*tp_;
//G2(t_,tp_) << t_ + 3*tp_; G2(t_,tp_) << t_ + 3*tp_;
G2(t_,tp_) << 2* G(tp_,t_);
TEST( G(1,1) ); TEST( G(1,1) );
TEST( G[G.mesh()(1,1) ]); TEST( G[G.mesh()(1,1) ]);
@ -45,4 +49,6 @@ int main() {
//TEST( G2(2,1,3) ); // should not compile //TEST( G2(2,1,3) ); // should not compile
}
catch( std::exception const &e) { std::cout << e.what()<< std::endl;}
} }

View File

@ -191,7 +191,7 @@ namespace triqs { namespace gfs {
std::tuple<bool, size_t, double> windowing ( linear_mesh<D> const & mesh, typename D::point_t const & x) { std::tuple<bool, size_t, double> windowing ( linear_mesh<D> const & mesh, typename D::point_t const & x) {
double a = (x - mesh.x_min())/mesh.delta(); double a = (x - mesh.x_min())/mesh.delta();
long i = floor(a); long i = floor(a);
bool in = (! ((i<0) || (i>=long(mesh.size())-1))); bool in = (! ((i<0) || (i>long(mesh.size())-1)));
double w = a-i; double w = a-i;
// std::cerr << " window "<< i << " "<< in << " "<< w<< std::endl ; // std::cerr << " window "<< i << " "<< in << " "<< w<< std::endl ;
return std::make_tuple(in, (in ? size_t(i) : 0),w); return std::make_tuple(in, (in ? size_t(i) : 0),w);