Interaction with CLEF expressions

The gf containers and their view classes can be used with the ../clef/contents library:

  • They can be called with CLEF expressions.
  • Automatic assignment has been set up.

Using the CLEF library offers a quick and efficient way to fill an array with multiple advantages:

  • It is simpler and more readeable than a series of for loops.
  • It is more optimal since the loops are automatically written in the best order for memory traversal.


#include <triqs/gfs.hpp>
#include <triqs/mesh.hpp>
using namespace triqs::gfs;
using namespace triqs::mesh;
using nda::clef::placeholder;
int main() {

  // Cf gf<imfreq> specialisation page for the constructor
  double beta = 10;
  int Nfreq   = 100;
  auto g      = gf<imfreq>{{beta, Fermion, Nfreq}, {1, 1}};

  // Filling the gf with something...
  placeholder<0> wn_;
  g(wn_) << 1 / (wn_ + 2);
  g(wn_) << 1 / (wn_ + 2 + g(wn_));


The LHS uses () and not brackets, even though it is on the mesh, because of the strange C++ limitation that [] cannot be overloaded for several variables…