2013-10-16 23:55:26 +02:00
|
|
|
#define TRIQS_ARRAYS_ENFORCE_BOUNDCHECK
|
|
|
|
#include <triqs/gfs.hpp>
|
|
|
|
using namespace triqs::gfs;
|
|
|
|
using namespace triqs::arrays;
|
2013-07-17 19:24:07 +02:00
|
|
|
#define TEST(X) std::cout << BOOST_PP_STRINGIZE((X)) << " ---> "<< (X) <<std::endl<<std::endl;
|
2013-10-16 23:55:26 +02:00
|
|
|
#include <triqs/gfs/local/functions.hpp>
|
2013-07-17 19:24:07 +02:00
|
|
|
|
|
|
|
// example
|
|
|
|
//template<typename T> using block_gf = gf<block_index, gf<T>>;
|
|
|
|
// block_gf<imtime> ...
|
|
|
|
// but not on gcc 4.6 !
|
|
|
|
//
|
|
|
|
|
|
|
|
int main() {
|
2013-10-16 23:55:26 +02:00
|
|
|
try {
|
|
|
|
triqs::gfs::freq_infty inf;
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
double beta =1;
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
auto G = gf<imfreq>{ {beta, Fermion}, {2,2} };
|
|
|
|
auto Gc = gf<imfreq>{ {beta, Fermion}, {2,2} };
|
|
|
|
auto G3 = gf<imfreq>{ {beta, Fermion}, {2,2} };
|
|
|
|
auto Gt = gf<imtime>{ {beta, Fermion}, {2,2} };
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
auto Gv = G();
|
|
|
|
TEST( G( 0) ) ;
|
|
|
|
Gv.on_mesh(0) = 20;
|
|
|
|
TEST( Gv( 0) ) ;
|
|
|
|
TEST( G( 0) ) ;
|
|
|
|
Gv.on_mesh(0) = 0;
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-06 22:10:42 +02:00
|
|
|
auto Gv2 = slice_target(G(),range(0,1),range(0,1));
|
2013-10-16 23:55:26 +02:00
|
|
|
TEST( Gv2( 0) ) ;
|
|
|
|
Gv2.on_mesh(0) = 10;
|
|
|
|
TEST( Gv2( 0) ) ;
|
|
|
|
TEST( G( 0) ) ;
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
triqs::clef::placeholder<0> om_;
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
TEST( G(om_) ) ;
|
|
|
|
TEST( eval(G(om_), om_=0) ) ;
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
TEST( Gv(om_) ) ;
|
|
|
|
TEST( eval(Gv(om_), om_=0) ) ;
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
std::cout <<"-------------lazy assign 1 ------------------"<<std::endl;
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
Gv(om_) << (0.2 + om_ + 2.1);
|
|
|
|
TEST(G(0));
|
|
|
|
TEST(G(inf));
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
std::cout <<"-------------lazy assign 2 ------------------"<<std::endl;
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
G(om_) << 1/(om_ + 2.3);
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
TEST(G(0));
|
|
|
|
TEST(G(inf));
|
|
|
|
TEST(inverse(G(inf)));
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
std::cout <<"----------------- 3 --------------------"<<std::endl;
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
TEST( Gv(om_) ) ;
|
|
|
|
TEST( eval(Gv(om_), om_=0) ) ;
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-01 20:18:59 +02:00
|
|
|
// tail
|
|
|
|
auto t = G(inf);
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
TEST(t.order_min());
|
|
|
|
TEST( t( 2) ) ;
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
TEST( Gv2(inf)( 2) ) ;
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
// copy
|
|
|
|
Gc = G;
|
|
|
|
TEST( G( 0) ) ;
|
|
|
|
TEST( Gc( 0) ) ;
|
2013-07-17 19:24:07 +02:00
|
|
|
|
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
// operations on gf
|
|
|
|
G3 = G +2* Gc;
|
|
|
|
G3 = G + Gc;
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
// TEST( G3( 0) ) ;
|
|
|
|
// G3 = G3 /2.0;
|
|
|
|
// TEST( G3( 0) ) ;
|
|
|
|
|
|
|
|
// does not compile : ok
|
|
|
|
// G3 = G + Gt;
|
|
|
|
//
|
|
|
|
std::cout <<"----------------- 4 --------------------"<<std::endl;
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
// test for density
|
|
|
|
TEST( density(G3) );
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
// should not compile
|
|
|
|
//G3 = G + Gt;
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
//#define ALL_TEST
|
2013-07-17 19:24:07 +02:00
|
|
|
#ifdef ALL_TEST
|
2013-10-16 23:55:26 +02:00
|
|
|
for (int u=0; u<10; ++u) {
|
|
|
|
TEST( (G + 2.0* Gc)( u) ) ;
|
|
|
|
TEST( (8.0*G + 2.0* Gc)( u) ) ;
|
|
|
|
TEST( (8.0*G - 2.0* Gc)( u) ) ;
|
|
|
|
TEST( (G - Gc)( u) ) ;
|
|
|
|
TEST( (G - 2.0* Gc)( u) ) ;
|
|
|
|
TEST( (G * Gc)( u) ) ;
|
|
|
|
}
|
2013-07-17 19:24:07 +02:00
|
|
|
#endif
|
2013-10-16 23:55:26 +02:00
|
|
|
TEST( G( 0) ) ;
|
|
|
|
TEST(G(inf)(2));
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
TEST( ( G(inf) + G(inf) ) (2));
|
|
|
|
TEST( ( G(inf) * G(inf) ) (4));
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
TEST( t(1));
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
//tqa::array<double,9> A(1,2,3,4,5,6,7,8,9); A()=0;
|
|
|
|
//auto x = local::impl::gf_impl<triqs::gfs::meshes::imfreq, true>::wrap_infty (G.tail_view()) + 2.0;
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
// test hdf5
|
|
|
|
H5::H5File file("ess_gf.h5", H5F_ACC_TRUNC );
|
|
|
|
h5_write(file, "g", G);
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
}
|
|
|
|
TRIQS_CATCH_AND_ABORT;
|
2013-07-17 19:24:07 +02:00
|
|
|
|
|
|
|
}
|