Expression templates

Expression Templates is a C++ technique for passing expressions as function arguments. The expression can be inlined into the function body, which results in faster and more convenient code than C-style callback functions. This technique can also be used to evaluate vector and matrix expressions in a single pass without temporaries. In preliminary benchmark results, one compiler evaluates vector expressions at 95-99.5 percent efficiency of hand-coded C using this technique (for long vectors). The speed is 2-15 times that of a conventional C++ vector class. [Definition quoted from the abstract of Todd Veldhuizen's paper on expression templates, C++ Report, Vol. 7, No. 5, June 1995, pp26031].

There are several c++ class libraries that implement expression templates. ohmms classes are built on PETE library, for its compactness and easy-to-customize features. The interfaces, member functions and operators, of the classes in OhmmsPETE and ParticleBase are almost compatible to those of blitz++ library. This makes it possible for the users to switch the underlying expression template library to blitz++. With g++ compiler (3.2 or higher), there isn't any significant performance discrepancy between PETE, blitz++ or boost::ublas. On a regular basis, the ohmms developers test the expression template libraries with various C++ compilers on the main platforms where their applications run and their relative performance is used to determine the default library for the expression templates.

More on expression templates and implementations can be found: