triqs.gfs.lazy_expressions

Small expression-tree library used by Green’s-function descriptors.

The LazyExpr / LazyExprTerminal pair lets TRIQS defer arithmetic on Green’s functions and descriptors until << evaluates the resulting tree on a concrete target. For example,

>>> g << iOmega_n + 0.5 - SemiCircular(1.0)

is parsed by the operator overloads on LazyExprTerminal into a binary tree of + and - nodes whose leaves are the descriptors and scalars, and that tree is then walked by eval_expr_with_context() inside __lshift__().

End users do not need to touch this module directly; it is documented mainly so that authors of new descriptors understand the protocol.

Functions

all_terminals(expr)

Walk expr and yield each terminal's payload in left-to-right order.

eval_expr(expr)

Reduce expr using an evaluation context discovered in its terminals.

eval_expr_with_context(eval_term, expr)

Recursively reduce expr using eval_term on every leaf.

lazy_function(name, F)

Wrap a Python callable so it can be applied to lazy expressions.

make_lazy(x)

Wrap x in a LazyExpr terminal node.

transform(expr, Fnode[, Fterm])

Recursively map Fnode / Fterm over a lazy expression.

Classes

LazyExpr(*args)

A node in a lazy expression tree.

LazyExprTerminal()

Base class for any object that can appear as a leaf of a LazyExpr.