3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-26 06:14:14 +01:00

gf : add nearest_point for krylov

To be cleaned, it is redundant.
I put it here to make the krylov app compile properly
This commit is contained in:
Olivier Parcollet 2013-07-25 13:25:15 +02:00
parent 2c77efe619
commit 32814be65e

View File

@ -21,6 +21,10 @@
#ifndef TRIQS_GF_MESH_LINEAR_H #ifndef TRIQS_GF_MESH_LINEAR_H
#define TRIQS_GF_MESH_LINEAR_H #define TRIQS_GF_MESH_LINEAR_H
#include "./mesh_tools.hpp" #include "./mesh_tools.hpp"
// ADDED for Krylov : to be clean and removed if necessary
#include <algorithm>
#include <boost/math/special_functions/round.hpp>
namespace triqs { namespace gf { namespace triqs { namespace gf {
// Three possible meshes // Three possible meshes
@ -88,6 +92,22 @@ namespace triqs { namespace gf {
/// Accessing a point of the mesh /// Accessing a point of the mesh
mesh_point_t operator[](index_t i) const { return mesh_point_t (*this,i);} mesh_point_t operator[](index_t i) const { return mesh_point_t (*this,i);}
// ADDED for krylov : to be CLEANED AND CHANGED
// Find the index of the mesh point which is nearest to x
index_t nearest_index(domain_pt_t x) const {
double x_real = real_or_imag(x, std::is_base_of<std::complex<double>, domain_pt_t>());
using boost::math::round; using std::min; using std::max;
switch(meshk) {
case half_bins:
case full_bins: return min(max(round((x_real-xmin)/del),.0),static_cast<double>(L-1));
case without_last: return min(max(round((x_real-xmin)/del),.0),static_cast<double>(L-2));
}
}
private:
static double real_or_imag(domain_pt_t x, std::false_type) {return x; }
static double real_or_imag(domain_pt_t x, std::true_type) {return imag(x); }
public:
/// Iterating on all the points... /// Iterating on all the points...
typedef mesh_pt_generator<linear_mesh> iterator; typedef mesh_pt_generator<linear_mesh> iterator;
iterator begin() const { return iterator (this);} iterator begin() const { return iterator (this);}