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

gf:fourier Add missing function in no_tail case

- one only the Matsubara case.
- TODO: the real omega case : decide and implement.
- impl: remove superfluous dispatch in x_impl
This commit is contained in:
tayral 2013-10-30 17:47:41 +00:00 committed by Olivier Parcollet
parent 6326c2b4eb
commit 4c1c14b989
5 changed files with 54 additions and 35 deletions

View File

@ -5,12 +5,12 @@ using namespace triqs::arrays;
#define TEST(X) std::cout << BOOST_PP_STRINGIZE((X)) << " ---> "<< (X) <<std::endl<<std::endl;
#include <triqs/gfs/local/fourier_matsubara.hpp>
namespace triqs { namespace gfs {
namespace triqs { namespace gfs {
// defined in the cpp file
void fourier_impl (gf_view<imfreq,scalar_valued> gw , gf_const_view<imtime,scalar_valued> gt, scalar_valued);
void fourier_impl (gf_view<imfreq,matrix_valued> gw , gf_const_view<imtime,matrix_valued> gt, matrix_valued);
void inverse_fourier_impl (gf_view<imtime,scalar_valued> gt, gf_const_view<imfreq,scalar_valued> gw, scalar_valued);
void inverse_fourier_impl (gf_view<imtime,matrix_valued> gt, gf_const_view<imfreq,matrix_valued> gw, matrix_valued);
void inverse_fourier_impl(gf_view<imtime, scalar_valued> gt, gf_const_view<imfreq, scalar_valued> gw);
void inverse_fourier_impl(gf_view<imtime, matrix_valued> gt, gf_const_view<imfreq, matrix_valued> gw);
template <typename Opt> void fourier_impl(gf_view<imfreq, scalar_valued, Opt> gw, gf_const_view<imtime, scalar_valued, Opt> gt);
template <typename Opt> void fourier_impl(gf_view<imfreq, matrix_valued, Opt> gw, gf_const_view<imtime, matrix_valued, Opt> gt);
}}
int main() {
@ -30,7 +30,7 @@ int main() {
h5_write(file, "Gw1", Gw1); // the original lorentzian
auto Gt1 = gf<imtime> {{beta, Fermion, N}, {1,1}};
inverse_fourier_impl( Gt1, Gw1, triqs::gfs::matrix_valued() );
inverse_fourier_impl(Gt1, Gw1);
// for(auto const& t:Gt1.mesh()){
// std::cout<<"t="<<t<<", expected="<<exp(-E*t) * ( (t>0?-1:0)+1/(1+exp(E*beta)) )<<std::endl;
// }
@ -38,7 +38,7 @@ int main() {
///verification that TF(TF^-1)=Id
auto Gw1b = gf<imfreq> {{beta, Fermion, N}, {1,1}};
fourier_impl(Gw1b, Gt1, triqs::gfs::matrix_valued());
fourier_impl<void>(Gw1b, Gt1);
for(auto const& w:Gw1.mesh()){
// std::cout<<"w="<<std::complex<double>(w)<<",Gw1b=" << Gw1b(w)(0,0)<<std::endl;
// std::cout<<"w="<<std::complex<double>(w)<<",Delta Gw1b=" << Gw1b(w)(0,0)-Gw1(w)(0,0)<<std::endl;

View File

@ -500,8 +500,8 @@ namespace triqs { namespace gfs {
}
// tool for lazy transformation
template <typename Tag, typename D, typename Target = matrix_valued> struct gf_keeper {
gf_const_view<D, Target> g;
template <typename Tag, typename D, typename Target = matrix_valued, typename Opt=void> struct gf_keeper {
gf_const_view<D, Target, Opt> g;
};
// ---------------------------------- slicing ------------------------------------

View File

@ -50,7 +50,10 @@ namespace gfs {
gw.singularity() = gt.singularity(); // set tail
}
void direct(gf_view<imfreq, scalar_valued,no_tail> gw, gf_const_view<imtime, scalar_valued,no_tail> gt) =delete;
void direct(gf_view<imfreq, scalar_valued, no_tail> gw, gf_const_view<imtime, scalar_valued, no_tail> gt) {
auto ta = local::tail();
direct_impl(gw, gt, ta);
}
//-------------------------------------
@ -166,12 +169,14 @@ namespace gfs {
//--------------------------------------------
void fourier_impl(gf_view<imfreq, scalar_valued> gw, gf_const_view<imtime, scalar_valued> gt, scalar_valued) {
template <typename Opt>
void fourier_impl(gf_view<imfreq, scalar_valued, Opt> gw, gf_const_view<imtime, scalar_valued, Opt> gt) {
impl_worker w;
w.direct(gw, gt);
}
void fourier_impl(gf_view<imfreq, matrix_valued> gw, gf_const_view<imtime, matrix_valued> gt, matrix_valued) {
template <typename Opt>
void fourier_impl(gf_view<imfreq, matrix_valued, Opt> gw, gf_const_view<imtime, matrix_valued, Opt> gt) {
impl_worker w;
for (size_t n1 = 0; n1 < gt.data().shape()[1]; n1++)
for (size_t n2 = 0; n2 < gt.data().shape()[2]; n2++) {
@ -183,12 +188,12 @@ namespace gfs {
//---------------------------------------------------------------------------
void inverse_fourier_impl(gf_view<imtime, scalar_valued> gt, gf_const_view<imfreq, scalar_valued> gw, scalar_valued) {
void inverse_fourier_impl(gf_view<imtime, scalar_valued> gt, gf_const_view<imfreq, scalar_valued> gw) {
impl_worker w;
w.inverse(gt, gw);
}
void inverse_fourier_impl(gf_view<imtime, matrix_valued> gt, gf_const_view<imfreq, matrix_valued> gw, matrix_valued) {
void inverse_fourier_impl(gf_view<imtime, matrix_valued> gt, gf_const_view<imfreq, matrix_valued> gw) {
impl_worker w;
for (size_t n1 = 0; n1 < gw.data().shape()[1]; n1++)
for (size_t n2 = 0; n2 < gw.data().shape()[2]; n2++) {
@ -201,19 +206,27 @@ namespace gfs {
//---------------------------------------------------------------------------
void triqs_gf_view_assign_delegation(gf_view<imfreq, scalar_valued> g,
gf_keeper<tags::fourier, imtime, scalar_valued> const& L) {
fourier_impl(g, L.g, scalar_valued());
fourier_impl(g, L.g);
}
void triqs_gf_view_assign_delegation(gf_view<imfreq, matrix_valued> g,
gf_keeper<tags::fourier, imtime, matrix_valued> const& L) {
fourier_impl(g, L.g, matrix_valued());
fourier_impl(g, L.g);
}
void triqs_gf_view_assign_delegation(gf_view<imtime, scalar_valued> g,
gf_keeper<tags::fourier, imfreq, scalar_valued> const& L) {
inverse_fourier_impl(g, L.g, scalar_valued());
inverse_fourier_impl(g, L.g);
}
void triqs_gf_view_assign_delegation(gf_view<imtime, matrix_valued> g,
gf_keeper<tags::fourier, imfreq, matrix_valued> const& L) {
inverse_fourier_impl(g, L.g, matrix_valued());
inverse_fourier_impl(g, L.g);
}
void triqs_gf_view_assign_delegation(gf_view<imfreq, scalar_valued, no_tail> g,
gf_keeper<tags::fourier, imtime, scalar_valued, no_tail> const& L) {
fourier_impl(g, L.g);
}
void triqs_gf_view_assign_delegation(gf_view<imfreq, matrix_valued, no_tail> g,
gf_keeper<tags::fourier, imtime, matrix_valued, no_tail> const& L) {
fourier_impl(g, L.g);
}
}
}

View File

@ -29,19 +29,24 @@ namespace triqs {
namespace gfs {
template <typename Target, typename Opt, bool V, bool C>
gf_keeper<tags::fourier, imtime, Target> fourier(gf_impl<imtime, Target, Opt, V, C> const& g) {
gf_keeper<tags::fourier, imtime, Target, Opt> fourier(gf_impl<imtime, Target, Opt, V, C> const& g) {
return {g};
}
template <typename Target, typename Opt, bool V, bool C>
gf_keeper<tags::fourier, imfreq, Target> inverse_fourier(gf_impl<imfreq, Target, Opt, V, C> const& g) {
gf_keeper<tags::fourier, imfreq, Target, Opt> inverse_fourier(gf_impl<imfreq, Target, Opt, V, C> const& g) {
return {g};
}
// The fourier transform with the tail
void triqs_gf_view_assign_delegation(gf_view<imfreq, scalar_valued> g, gf_keeper<tags::fourier, imtime, scalar_valued> const& L);
void triqs_gf_view_assign_delegation(gf_view<imfreq, matrix_valued> g, gf_keeper<tags::fourier, imtime, matrix_valued> const& L);
void triqs_gf_view_assign_delegation(gf_view<imtime, scalar_valued> g, gf_keeper<tags::fourier, imfreq, scalar_valued> const& L);
void triqs_gf_view_assign_delegation(gf_view<imtime, matrix_valued> g, gf_keeper<tags::fourier, imfreq, matrix_valued> const& L);
// The version without tail : only possible in one direction
void triqs_gf_view_assign_delegation(gf_view<imfreq, scalar_valued, no_tail> g, gf_keeper<tags::fourier, imtime, scalar_valued, no_tail> const& L);
void triqs_gf_view_assign_delegation(gf_view<imfreq, matrix_valued, no_tail> g, gf_keeper<tags::fourier, imtime, matrix_valued, no_tail> const& L);
template <typename Opt> gf_mesh<imfreq, Opt> make_mesh_fourier_compatible(gf_mesh<imtime, Opt> const& m) {
int L = m.size() - (m.kind() == full_bins ? 1 : 0);
return {m.domain(), L};
@ -54,15 +59,16 @@ namespace gfs {
}
template <typename Target, typename Opt, bool V, bool C>
gf_view<imfreq, Target> make_gf_from_fourier(gf_impl<imtime, Target, Opt, V, C> const& gt) {
auto gw = gf<imfreq, Target>{make_mesh_fourier_compatible(gt.mesh()), get_target_shape(gt)};
gf_view<imfreq, Target, Opt> make_gf_from_fourier(gf_impl<imtime, Target, Opt, V, C> const& gt) {
auto gw = gf<imfreq, Target, Opt>{make_mesh_fourier_compatible(gt.mesh()), get_target_shape(gt)};
gw() = fourier(gt);
return gw;
}
template <typename Target, typename Opt, bool V, bool C>
gf_view<imtime, Target> make_gf_from_inverse_fourier(gf_impl<imfreq, Target, Opt, V, C> const& gw, mesh_kind mk = full_bins) {
auto gt = gf<imtime, Target>{make_mesh_fourier_compatible(gw.mesh(), mk), get_target_shape(gw)};
gf_view<imtime, Target, Opt> make_gf_from_inverse_fourier(gf_impl<imfreq, Target, Opt, V, C> const& gw,
mesh_kind mk = full_bins) {
auto gt = gf<imtime, Target, Opt>{make_mesh_fourier_compatible(gw.mesh(), mk), get_target_shape(gw)};
gt() = inverse_fourier(gw);
return gt;
}

View File

@ -90,18 +90,18 @@ namespace triqs { namespace gfs {
}
friend nothing operator +( nothing, nothing) { return nothing();}
template<typename RHS> friend void assign_from_expression(nothing & ,RHS) {}
};
template<typename T> nothing operator+(nothing, T const &) { return nothing();}
template<typename T> nothing operator-(nothing, T const &) { return nothing();}
template<typename T> nothing operator*(nothing, T const &) { return nothing();}
template<typename T> nothing operator/(nothing, T const &) { return nothing();}
template<typename T> TYPE_DISABLE_IF(nothing, std::is_same<T,nothing>) operator+(T const &, nothing) { return nothing();}
template<typename T> TYPE_DISABLE_IF(nothing, std::is_same<T,nothing>) operator-(T const &, nothing) { return nothing();}
template<typename T> TYPE_DISABLE_IF(nothing, std::is_same<T,nothing>) operator*(T const &, nothing) { return nothing();}
template<typename T> TYPE_DISABLE_IF(nothing, std::is_same<T,nothing>) operator/(T const &, nothing) { return nothing();}
//------------------------------------------------------
};
template <typename... T> nothing slice_target(nothing, T...) { return nothing(); }
template <typename T> nothing operator+(nothing, T const &) { return nothing(); }
template <typename T> nothing operator-(nothing, T const &) { return nothing(); }
template <typename T> nothing operator*(nothing, T const &) { return nothing(); }
template <typename T> nothing operator/(nothing, T const &) { return nothing(); }
template <typename T> TYPE_DISABLE_IF(nothing, std::is_same<T, nothing>) operator+(T const &, nothing) { return nothing(); }
template <typename T> TYPE_DISABLE_IF(nothing, std::is_same<T, nothing>) operator-(T const &, nothing) { return nothing(); }
template <typename T> TYPE_DISABLE_IF(nothing, std::is_same<T, nothing>) operator*(T const &, nothing) { return nothing(); }
template <typename T> TYPE_DISABLE_IF(nothing, std::is_same<T, nothing>) operator/(T const &, nothing) { return nothing(); }
}}
#endif