From 1811d531794e97a99c7544cfe7168c558818ac4a Mon Sep 17 00:00:00 2001 From: tayral Date: Mon, 20 Jan 2014 14:31:02 +0000 Subject: [PATCH] Added density for scalar_valued gf (and test thereof) --- test/triqs/gfs/gf_scalar.cpp | 4 ++++ triqs/gfs/local/functions.cpp | 5 ++++- triqs/gfs/local/functions.hpp | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/test/triqs/gfs/gf_scalar.cpp b/test/triqs/gfs/gf_scalar.cpp index bcc47dd7..b523ee9e 100644 --- a/test/triqs/gfs/gf_scalar.cpp +++ b/test/triqs/gfs/gf_scalar.cpp @@ -1,5 +1,6 @@ //#define TRIQS_ARRAYS_ENFORCE_BOUNDCHECK #include +#include using namespace triqs::gfs; #define TEST(X) std::cout << BOOST_PP_STRINGIZE((X)) << " ---> "<< (X) < om_; G(om_) << 1/(om_ + 2.3); + auto n = triqs::gfs::density(G); + TEST(n); + // test hdf5 H5::H5File file("gf_scalar.h5", H5F_ACC_TRUNC); h5_write(file, "g", G); diff --git a/triqs/gfs/local/functions.cpp b/triqs/gfs/local/functions.cpp index 239e89d2..430c8ff7 100644 --- a/triqs/gfs/local/functions.cpp +++ b/triqs/gfs/local/functions.cpp @@ -69,7 +69,10 @@ namespace triqs { namespace gfs { return res; } - + double density(gf_view const & g){ + return density(reinterpret_scalar_valued_gf_as_matrix_valued(g))(0,0); + } + arrays::matrix density( gf_view const & gl) { auto sh = gl.data().shape().front_pop(); diff --git a/triqs/gfs/local/functions.hpp b/triqs/gfs/local/functions.hpp index d336ae45..e68016ae 100644 --- a/triqs/gfs/local/functions.hpp +++ b/triqs/gfs/local/functions.hpp @@ -33,6 +33,7 @@ namespace triqs { // ------------------------------------------------------ arrays::matrix density(gf_view const & g); + double density(gf_view const & g); arrays::matrix density(gf_view const & g);