ExpressionTemplates
Expression templates are a C++ programming technique that allows for the creation of high-performance libraries, particularly in the domain of linear algebra and numerical computation. The core idea is to avoid intermediate object creation that often occurs with traditional operator overloading. Instead of evaluating an expression immediately and storing the result in a temporary object, expression templates defer the evaluation until the final result is needed. This is achieved by representing operations not as actual computations, but as expression trees.
These expression trees are composed of objects that represent operands and operators. When an expression is
The actual computation happens only when a function, such as an assignment or an output operation, is