TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches

Detailed Description

Lazy expression templates and arithmetic operations on Green's functions.

Arithmetic on Green's functions is lazy: an expression such as g1 + g2 or 2 * g does not compute a new Green's function immediately. Instead it builds a lightweight expression node (triqs::gfs::gf_expr for binary operations, triqs::gfs::gf_unary_m_expr for the unary minus) that models the GreenFunction concept and is only evaluated element by element when the expression is assigned to a container or accessed. This fuses chained operations and avoids intermediate temporaries.

The operators are generated by macros, so they do not appear individually in the member list below. The complete set of supported operations is, with g, g1, g2 Green's functions and s a scalar (an integer, real or complex number):

Binary operators (build a lazy triqs::gfs::gf_expr):

  • g1 + g2, g1 - g2 — element-wise addition / subtraction of two Green's functions.
  • g1 * g2, g1 / g2 — element-wise product / quotient of two Green's functions.
  • s * g, g * s — multiplication by a scalar from either side.
  • s / g, g / s — scalar divided by a Green's function, and Green's function divided by a scalar.
  • Note: addition and subtraction with a bare scalar are not available as binary expressions (only * and / accept a scalar operand); use the in-place += / -= operators below instead.

Unary operator:

Compound assignment (in-place, defined for both triqs::gfs::gf and triqs::gfs::gf_view and implemented as g = g OP x):

  • g += x, g -= x, g *= x, g /= x, where x is another Green's function or a scalar.

In-place operations with a matrix or scalar:

  • g += m, g -= m — add / subtract a matrix m at every mesh point of a matrix-valued Green's function.
  • g += s, g -= s — for a matrix-valued Green's function, add / subtract s times the identity matrix at every mesh point; for a scalar-valued Green's function, add / subtract the scalar s directly.

Compatibility rules enforced when combining two Green's functions:

  • The meshes must be identical, otherwise a triqs::runtime_error is thrown; the data and target shapes must match as well (a scalar operand adopts the shape of the other operand).
  • For products and quotients on an imaginary-time mesh (triqs::mesh::imtime, triqs::mesh::dlr_imtime) the particle statistics of the result is the parity sum of the operand statistics (e.g. fermion \( \times \) fermion \( \to \) boson).
  • On a product mesh (triqs::mesh::prod) the rules are applied component by component.

Block Green's functions (triqs::gfs::block_gf) support the analogous set of arithmetic operations, applied block by block.

Classes

struct  triqs::gfs::bgf_expr< Tag, L, R >
 Lazy expression node representing a binary operation between two block Green's function operands. More...
struct  triqs::gfs::bgf_unary_m_expr< L >
 Lazy expression node representing the unary minus of a block Green's function operand. More...
struct  triqs::gfs::gf_expr< Tag, L, R >
 Lazy expression node representing a binary operation between two Green's function operands. More...
struct  triqs::gfs::gf_unary_m_expr< L >
 Lazy expression node representing the unary minus of a Green's function operand. More...
struct  triqs::gfs::is_gf_expr< T >
 Trait to detect whether a type is a Green's function expression node. More...

Functions

template<typename M>
gf< M, matrix_valuedtriqs::gfs::inverse (gf< M, matrix_valued > g)
 Return the matrix inverse of a matrix-valued Green's function (inverts the target matrix at each mesh point).
template<typename M>
gf< M, matrix_valuedtriqs::gfs::inverse (gf_const_view< M, matrix_valued > g)
template<typename M>
gf< M, matrix_valuedtriqs::gfs::inverse (gf_view< M, matrix_valued > g)
template<typename M>
void triqs::gfs::invert_in_place (gf_view< M, matrix_valued > g)
 Invert, in place, the target matrix at each mesh point of a matrix-valued Green's function.
template<typename M, typename T>
gf< M, matrix_valuedtriqs::gfs::operator* (gf< M, matrix_valued > g, matrix< T > r)
 Right-multiply a matrix-valued Green's function by a matrix at every mesh point.
template<typename M, typename T>
gf< M, matrix_valuedtriqs::gfs::operator* (matrix< T > l, gf< M, matrix_valued > g)
 Left-multiply a matrix-valued Green's function by a matrix at every mesh point.
template<Mesh M>
void triqs::gfs::operator+= (gf_view< M > g, dcomplex a)
 In-place addition of a scalar (times the identity) to a matrix-valued Green's function.
template<Mesh M, nda::MemoryMatrix Mat>
void triqs::gfs::operator+= (gf_view< M > g, Mat const &mat)
 In-place addition of a matrix to every mesh point of a matrix-valued Green's function.
template<Mesh M>
void triqs::gfs::operator+= (gf_view< M, scalar_valued > g, dcomplex a)
 In-place addition of a scalar to a scalar-valued Green's function.
template<typename A1>
requires (BlockGreenFunction<A1>::value)
auto triqs::gfs::operator- (A1 &&a1)
 Unary minus operator returning a lazy triqs::gfs::bgf_unary_m_expr node.
template<Mesh M>
void triqs::gfs::operator-= (gf_view< M > g, dcomplex a)
 In-place subtraction of a scalar (times the identity) from a matrix-valued Green's function.
template<Mesh M, nda::MemoryMatrix Mat>
void triqs::gfs::operator-= (gf_view< M > g, Mat const &mat)
 In-place subtraction of a matrix from every mesh point of a matrix-valued Green's function.
template<Mesh M>
void triqs::gfs::operator-= (gf_view< M, scalar_valued > g, dcomplex a)
 In-place subtraction of a scalar from a scalar-valued Green's function.
template<typename G1, typename G2, typename M>
void triqs::gfs::set_from_L_G_R (G1 &g1, M const &l, G2 const &g2, M const &r)
 Set g1 = l * g2 * r at every mesh point (in place, optimized for speed).

Function Documentation

◆ inverse() [1/3]

template<typename M>
gf< M, matrix_valued > triqs::gfs::inverse ( gf< M, matrix_valued > g)

#include <triqs/gfs/functions/functions2.hpp>

Return the matrix inverse of a matrix-valued Green's function (inverts the target matrix at each mesh point).

Template Parameters
MMesh type.
Parameters
gThe matrix-valued Green's function.
Returns
A new Green's function holding the per-mesh-point matrix inverse.

Definition at line 285 of file functions2.hpp.

◆ inverse() [2/3]

template<typename M>
gf< M, matrix_valued > triqs::gfs::inverse ( gf_const_view< M, matrix_valued > g)

#include <triqs/gfs/functions/functions2.hpp>

Const-view overload of triqs::gfs::inverse (makes a regular copy first).

Definition at line 296 of file functions2.hpp.

◆ inverse() [3/3]

template<typename M>
gf< M, matrix_valued > triqs::gfs::inverse ( gf_view< M, matrix_valued > g)

#include <triqs/gfs/functions/functions2.hpp>

View overload of triqs::gfs::inverse (makes a regular copy first).

Definition at line 292 of file functions2.hpp.

◆ invert_in_place()

template<typename M>
void triqs::gfs::invert_in_place ( gf_view< M, matrix_valued > g)

#include <triqs/gfs/functions/functions2.hpp>

Invert, in place, the target matrix at each mesh point of a matrix-valued Green's function.

Template Parameters
MMesh type.
Parameters
gThe matrix-valued Green's function view, inverted in place.

Definition at line 271 of file functions2.hpp.

◆ operator*() [1/2]

template<typename M, typename T>
gf< M, matrix_valued > triqs::gfs::operator* ( gf< M, matrix_valued > g,
matrix< T > r )

#include <triqs/gfs/functions/functions2.hpp>

Right-multiply a matrix-valued Green's function by a matrix at every mesh point.

Template Parameters
MMesh type.
TScalar type of the matrix.
Parameters
gThe matrix-valued Green's function.
rThe matrix multiplied from the right.
Returns
The resulting Green's function.

Definition at line 429 of file functions2.hpp.

◆ operator*() [2/2]

template<typename M, typename T>
gf< M, matrix_valued > triqs::gfs::operator* ( matrix< T > l,
gf< M, matrix_valued > g )

#include <triqs/gfs/functions/functions2.hpp>

Left-multiply a matrix-valued Green's function by a matrix at every mesh point.

Template Parameters
MMesh type.
TScalar type of the matrix.
Parameters
lThe matrix multiplied from the left.
gThe matrix-valued Green's function.
Returns
The resulting Green's function.

Definition at line 444 of file functions2.hpp.

◆ set_from_L_G_R()

template<typename G1, typename G2, typename M>
void triqs::gfs::set_from_L_G_R ( G1 & g1,
M const & l,
G2 const & g2,
M const & r )

#include <triqs/gfs/functions/functions2.hpp>

Set g1 = l * g2 * r at every mesh point (in place, optimized for speed).

Template Parameters
G1Type of the output Green's function.
G2Type of the input Green's function.
MMatrix type.
Parameters
g1The output Green's function (overwritten).
lThe left matrix factor.
g2The input Green's function.
rThe right matrix factor.

Definition at line 478 of file functions2.hpp.