3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-26 14:23:38 +01:00
dft_tools/test/triqs/gfs/array_gf.cpp
Olivier Parcollet 1c9d6dacfa arrays: h5 read/write for arrays of complex types
- array of complex type (not fundamental) can now be saved/loaded to
  h5
- with a test with array<gf<...>>
2014-02-13 21:46:23 +01:00

41 lines
966 B
C++

#include <triqs/gfs.hpp>
#define TEST(X) std::cout << BOOST_PP_STRINGIZE((X)) << " ---> " << (X) << std::endl << std::endl;
using namespace triqs::gfs;
using namespace triqs::arrays;
int main(int argc, char* argv[]) {
try {
triqs::clef::placeholder<0> w_;
auto agf = array<gf<imfreq>, 2>{2, 3};
auto bgf = array<gf<imfreq>, 2>{2, 3};
agf() = gf<imfreq>{{10.0, Fermion}, {1, 1}};
agf(0, 0)(w_) << 1 / (w_ + 2);
array<double,2> A(2,2); A()=0;A(0,0) = 1.3; A(1,1) = -8.2;
array<array<double,2>, 1> aa(2), bb;
aa(0) = A;
aa(1) = 2 * A;
bb = aa;
{
H5::H5File file("ess_array_gf.h5", H5F_ACC_TRUNC);
h5_write(file, "Agf", agf);
h5_write(file, "aa", aa);
}
{
H5::H5File file("ess_array_gf.h5", H5F_ACC_RDONLY);
h5_read(file, "Agf", bgf);
h5_read(file, "aa", bb);
}
{
H5::H5File file("ess_array_gf2.h5", H5F_ACC_TRUNC);
h5_write(file, "Agf", bgf);
h5_write(file, "aa", bb);
}
}
TRIQS_CATCH_AND_ABORT;
}