TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
triqs::gfs::gf< M, Target, Layout >

#include <triqs/gfs/gf/gf.hpp>

Detailed Description

template<Mesh M, typename Target, typename Layout>
class triqs::gfs::gf< M, Target, Layout >

The owning Green's function container.

triqs::gfs::gf is the central, value-semantic container of the Green's function module. It owns a mesh and a data array, and represents a function defined on the mesh whose value at each mesh point is fixed by the Target type (see triqs::gfs::scalar_valued, triqs::gfs::matrix_valued, triqs::gfs::tensor_valued).

The data array has rank arity + Target::rank, where arity is the number of mesh dimensions. The function can be accessed at a mesh point with operator[] and evaluated at an arbitrary point with operator() (using the interpolation scheme of the mesh).

Non-owning views are provided by triqs::gfs::gf_view and triqs::gfs::gf_const_view.

Template Parameters
MMesh type, modeling triqs::mesh::Mesh; fixes the domain of definition.
TargetTarget type; fixes the value stored at each mesh point.
LayoutMemory layout policy of the data array.

Definition at line 194 of file gf.hpp.

Classes

struct  target_and_shape_t
 Lightweight handle bundling the target type and its shape. More...

Public Types

using complex_t = gf<M, typename Target::complex_t, Layout>
 Associated complex-valued type.
using const_view_type = gf_const_view<M, Target, typename Layout::with_lowest_guarantee_t>
 Associated const view type.
using data_t = nda::basic_array<scalar_t, data_rank, Layout, 'A', nda::heap<>>
 Type of the data array.
using mesh_index_t = typename mesh_t::index_t
 Type of a mesh index.
using mesh_point_t = typename mesh_t::mesh_point_t
 Type of a mesh point.
using mesh_t = M
 Mesh type.
using mutable_view_type = gf_view<M, Target, typename Layout::with_lowest_guarantee_t>
 Associated mutable view type.
using real_t = gf<M, typename Target::real_t, Layout>
 Associated real-valued type.
using regular_type = gf<M, Target, Layout>
 Associated regular (owning) type.
using scalar_t = typename Target::scalar_t
 Scalar type of the target (real or complex).
using target_shape_t = std::array<long, Target::rank>
 Type of the target shape, i.e. an array holding the extent of each target dimension.
using target_t = Target
 Target type.
using view_type = gf_view<M, Target, typename Layout::with_lowest_guarantee_t>
 Associated (non const) view type.

Public Member Functions

 gf ()=default
 Construct an empty Green's function (with an empty mesh and data array).
template<typename G>
requires (GreenFunction<G>::value and std::is_same_v<mesh_t, typename G::mesh_t>)
 gf (G const &g)
 Construct from any object modeling the GreenFunction concept with the same mesh type.
 gf (gf &&)=default
 Move constructor.
 gf (gf const &x)=default
 Copy constructor.
 gf (gf_const_view< M, Target > const &g)
 Construct from a const view, making a deep copy of the data.
 gf (gf_view< M, Target > const &g)
 Construct from a view, making a deep copy of the data.
 gf (mesh_t m, data_t dat)
 Construct from a mesh and a data array.
 gf (mesh_t m, target_shape_t shape={})
 Construct from a mesh and a target shape.
template<typename Fdata>
auto apply_on_data (Fdata &&fd)
 Build a view of a Green's function whose data is the result of applying a function to the data array.
template<typename Fdata>
auto apply_on_data (Fdata &&fd) const
 Build a const view of a Green's function whose data is the result of applying a function to the data array.
data_tdata () &
 Get the data array.
data_t data () &&
 Get the data array (rvalue overload).
data_t const & data () const &
 Get the data array (const overload).
auto const & data_shape () const
 Get the shape of the data array.
mesh_t const & mesh () const
 Get the mesh of the Green's function.
template<typename... Args>
decltype(auto) operator() (Args &&...1) &
 Lvalue overload of the call operator (delegates to call_impl()).
template<typename... Args>
decltype(auto) operator() (Args &&...1) &&
 Rvalue overload of the call operator (delegates to call_impl()).
template<typename... Args>
decltype(auto) operator() (Args &&...1) const &
 Const lvalue overload of the call operator (delegates to call_impl()).
gfoperator= (gf &&rhs) noexcept
 Move assignment.
gfoperator= (gf const &rhs)=default
 Copy assignment.
template<typename RHS>
requires (GreenFunction<RHS>::value and not std::is_same_v<std::decay_t<RHS>, gf>)
gfoperator= (RHS &&rhs)
 Assign from any object modeling the GreenFunction concept.
template<typename... Arg>
requires (sizeof...(Arg) == arity)
decltype(auto) operator[] (Arg &&...arg) &&noexcept(has_no_boundcheck)
 Rvalue overload of the variadic operator[] (see the const lvalue overload).
template<typename... Arg>
requires (sizeof...(Arg) == arity)
decltype(auto) operator[] (Arg &&...arg) &noexcept(has_no_boundcheck)
 Lvalue overload of the variadic operator[] (see the const lvalue overload).
template<typename... Arg>
requires (sizeof...(Arg) == arity)
decltype(auto) operator[] (Arg &&...arg) const &noexcept(has_no_boundcheck)
 Access the Green's function at a mesh point/index (const lvalue overload).
template<typename... T>
requires (sizeof...(T) == arity)
decltype(auto) operator[] (std::tuple< T... > const &tu) const noexcept(has_no_boundcheck)
 Access the Green's function at a mesh point/index passed as a tuple (const overload).
template<typename... T>
requires (sizeof...(T) == arity)
decltype(auto) operator[] (std::tuple< T... > const &tu) noexcept(has_no_boundcheck)
 Non-const overload of the tuple operator[] (see the const overload).
decltype(auto) operator[] (typename mesh_t::index_t const &index) noexcept(has_no_boundcheck)
 Access a single-variable Green's function by a mesh index.
target_and_shape_t target () const
 Get a handle to the target and its shape.
auto target_indices () const
 Get a generator over the multi-indices of the target space.
std::array< long, Target::rank > target_shape () const
 Get the shape of the target.

Static Public Member Functions

template<typename Self, typename... Args>
static decltype(auto) call_impl (Self &&self, Args &&...1)
 Evaluate the Green's function at the given arguments.
static std::string hdf5_format ()
 Get the HDF5 format tag of a Green's function.

Static Public Attributes

static constexpr int arity = n_variables<M>
 Arity of the function, i.e. the number of mesh variables.
static constexpr int data_rank = arity + Target::rank
 Rank of the data array representing the function.
static constexpr bool has_no_boundcheck = true
 Whether bound checking of the data array is disabled (controlled by NDA_ENFORCE_BOUNDCHECK).
static constexpr bool is_const = false
 Whether this type is a const view (always false for triqs::gfs::gf).
static constexpr bool is_view = false
 Whether this type is a view (always false for triqs::gfs::gf).
static constexpr int target_rank = Target::rank
 Rank of the target.

Friends

void h5_read (h5::group fg, std::string const &subgroup_name, this_t &g)
 Read a Green's function from HDF5.
void h5_write (h5::group fg, std::string const &subgroup_name, this_t const &g)
 Write a Green's function to HDF5.
std::ostream & operator<< (std::ostream &out, this_t const &)
 Write a Green's function to an output stream.

Constructor & Destructor Documentation

◆ gf() [1/6]

template<Mesh M, typename Target, typename Layout>
triqs::gfs::gf< M, Target, Layout >::gf ( gf< M, Target, Layout > const & x)
default

Copy constructor.

Parameters
xGreen's function to copy from.

◆ gf() [2/6]

template<Mesh M, typename Target, typename Layout>
triqs::gfs::gf< M, Target, Layout >::gf ( mesh_t m,
data_t dat )
inline

Construct from a mesh and a data array.

Note
The mesh and data array are passed by value and moved into the Green's function.
Parameters
mMesh.
datData array.

Definition at line 366 of file gf.hpp.

◆ gf() [3/6]

template<Mesh M, typename Target, typename Layout>
triqs::gfs::gf< M, Target, Layout >::gf ( mesh_t m,
target_shape_t shape = {} )
inline

Construct from a mesh and a target shape.

The data array is allocated to match the mesh and the requested target shape, and value-initialized.

Parameters
mMesh.
shapeTarget shape (defaults to an empty shape, appropriate for scalar targets).

Definition at line 376 of file gf.hpp.

◆ gf() [4/6]

template<Mesh M, typename Target, typename Layout>
triqs::gfs::gf< M, Target, Layout >::gf ( gf_view< M, Target > const & g)
inlineexplicit

Construct from a view, making a deep copy of the data.

Parameters
gView to copy from.

Definition at line 382 of file gf.hpp.

◆ gf() [5/6]

template<Mesh M, typename Target, typename Layout>
triqs::gfs::gf< M, Target, Layout >::gf ( gf_const_view< M, Target > const & g)
inlineexplicit

Construct from a const view, making a deep copy of the data.

Parameters
gConst view to copy from.

Definition at line 388 of file gf.hpp.

◆ gf() [6/6]

template<Mesh M, typename Target, typename Layout>
template<typename G>
requires (GreenFunction<G>::value and std::is_same_v<mesh_t, typename G::mesh_t>)
triqs::gfs::gf< M, Target, Layout >::gf ( G const & g)
inlineexplicit

Construct from any object modeling the GreenFunction concept with the same mesh type.

The Green's function is default constructed and then assigned from g, which resizes the mesh and data accordingly. The constructor is explicit to avoid unintended conversions.

Template Parameters
GA type modeling GreenFunction with the same mesh type.
Parameters
gObject to construct from (e.g. another Green's function or a lazy expression).

Definition at line 400 of file gf.hpp.

Member Function Documentation

◆ apply_on_data() [1/2]

template<Mesh M, typename Target, typename Layout>
template<typename Fdata>
auto triqs::gfs::gf< M, Target, Layout >::apply_on_data ( Fdata && fd)
inline

Build a view of a Green's function whose data is the result of applying a function to the data array.

The target type of the returned view is deduced from the rank of the transformed array via triqs::gfs::target_from_array.

Template Parameters
FdataType of the callable applied to the data array.
Parameters
fdCallable taking the data array and returning a transformed array.
Returns
A triqs::gfs::gf_view onto the transformed data, sharing this Green's function's mesh.

Definition at line 462 of file gf.hpp.

◆ apply_on_data() [2/2]

template<Mesh M, typename Target, typename Layout>
template<typename Fdata>
auto triqs::gfs::gf< M, Target, Layout >::apply_on_data ( Fdata && fd) const
inline

Build a const view of a Green's function whose data is the result of applying a function to the data array.

Const overload of triqs::gfs::gf::apply_on_data. The target type of the returned view is deduced from the rank of the transformed array via triqs::gfs::target_from_array.

Template Parameters
FdataType of the callable applied to the data array.
Parameters
fdCallable taking the data array and returning a transformed array.
Returns
A triqs::gfs::gf_const_view onto the transformed data, sharing this Green's function's mesh.

Definition at line 479 of file gf.hpp.

◆ call_impl()

template<Mesh M, typename Target, typename Layout>
template<typename Self, typename... Args>
decltype(auto) triqs::gfs::gf< M, Target, Layout >::call_impl ( Self && self,
Args &&... 1 )
inlinestatic

Evaluate the Green's function at the given arguments.

With no argument, returns a (const) view of the whole Green's function. Otherwise, the number of arguments must equal the arity of the mesh; if any argument is a lazy CLEF expression a lazy call expression is returned, else the Green's function is evaluated using the mesh's interpolation scheme (triqs::gfs::gf_evaluator).

Template Parameters
SelfDeduced (explicit object parameter) type of the Green's function.
ArgsTypes of the evaluation arguments (one per mesh dimension).
Returns
A view (no argument), a lazy expression (lazy arguments) or the interpolated value.

Definition at line 49 of file gf.hpp.

◆ data() [1/3]

template<Mesh M, typename Target, typename Layout>
data_t & triqs::gfs::gf< M, Target, Layout >::data ( ) &
inline

Get the data array.

Returns
A reference to the data array.

Definition at line 280 of file gf.hpp.

◆ data() [2/3]

template<Mesh M, typename Target, typename Layout>
data_t triqs::gfs::gf< M, Target, Layout >::data ( ) &&
inline

Get the data array (rvalue overload).

Returns
The data array, moved out of the (expiring) Green's function.

Definition at line 292 of file gf.hpp.

◆ data() [3/3]

template<Mesh M, typename Target, typename Layout>
data_t const & triqs::gfs::gf< M, Target, Layout >::data ( ) const &
inline

Get the data array (const overload).

Returns
A const reference to the data array.

Definition at line 286 of file gf.hpp.

◆ data_shape()

template<Mesh M, typename Target, typename Layout>
auto const & triqs::gfs::gf< M, Target, Layout >::data_shape ( ) const
inline

Get the shape of the data array.

Needed for generic code: expressions of Green's functions (e.g. g1 + g2) have a data shape but no data array.

Returns
A const reference to the shape of the data array.

Definition at line 302 of file gf.hpp.

◆ hdf5_format()

template<Mesh M, typename Target, typename Layout>
std::string triqs::gfs::gf< M, Target, Layout >::hdf5_format ( )
inlinestaticnodiscard

Get the HDF5 format tag of a Green's function.

Returns
The string "Gf".

Definition at line 210 of file gf.hpp.

◆ mesh()

template<Mesh M, typename Target, typename Layout>
mesh_t const & triqs::gfs::gf< M, Target, Layout >::mesh ( ) const
inline

Get the mesh of the Green's function.

Returns
A const reference to the mesh.

Definition at line 274 of file gf.hpp.

◆ operator=() [1/3]

template<Mesh M, typename Target, typename Layout>
gf & triqs::gfs::gf< M, Target, Layout >::operator= ( gf< M, Target, Layout > && rhs)
inlinenoexcept

Move assignment.

Parameters
rhsGreen's function to move from.
Returns
A reference to this Green's function.

Definition at line 421 of file gf.hpp.

◆ operator=() [2/3]

template<Mesh M, typename Target, typename Layout>
gf & triqs::gfs::gf< M, Target, Layout >::operator= ( gf< M, Target, Layout > const & rhs)
default

Copy assignment.

Parameters
rhsGreen's function to assign from.
Returns
A reference to this Green's function.

◆ operator=() [3/3]

template<Mesh M, typename Target, typename Layout>
template<typename RHS>
requires (GreenFunction<RHS>::value and not std::is_same_v<std::decay_t<RHS>, gf>)
gf & triqs::gfs::gf< M, Target, Layout >::operator= ( RHS && rhs)
inline

Assign from any object modeling the GreenFunction concept.

The assignment resizes the mesh and the data to match rhs, invalidating all existing pointers/views into them. rhs can be any object modeling the Green's function concept, in particular a lazy expression of Green's functions.

Template Parameters
RHSType of the right hand side; must model GreenFunction.
Parameters
rhsObject to assign from.
Returns
A reference to this Green's function.

Definition at line 438 of file gf.hpp.

◆ operator[]() [1/3]

template<Mesh M, typename Target, typename Layout>
template<typename... Arg>
requires (sizeof...(Arg) == arity)
decltype(auto) triqs::gfs::gf< M, Target, Layout >::operator[] ( Arg &&... arg) const &
inlinenoexcept

Access the Green's function at a mesh point/index (const lvalue overload).

Unlike operator(), this accesses the stored value directly (no interpolation). Passing all_t for one or more dimensions returns a (const) view sliced over the remaining mesh, and lazy arguments return a lazy subscript expression.

Template Parameters
ArgTypes of the access arguments (one per mesh dimension).
Parameters
argMesh points, indices or all_t selectors.
Returns
The stored value, a sliced view, or a lazy expression.

Definition at line 170 of file gf.hpp.

◆ operator[]() [2/3]

template<Mesh M, typename Target, typename Layout>
template<typename... T>
requires (sizeof...(T) == arity)
decltype(auto) triqs::gfs::gf< M, Target, Layout >::operator[] ( std::tuple< T... > const & tu) const
inlinenoexcept

Access the Green's function at a mesh point/index passed as a tuple (const overload).

Flattens the tuple into the variadic operator[]. Ensures backward compatibility and easy use when the arguments are stored in a tuple.

Template Parameters
TTypes of the tuple elements (one per mesh dimension).
Parameters
tuTuple of mesh points/indices.
Returns
The value (or sub-view) at the given point.

Definition at line 93 of file gf.hpp.

◆ operator[]() [3/3]

template<Mesh M, typename Target, typename Layout>
decltype(auto) triqs::gfs::gf< M, Target, Layout >::operator[] ( typename mesh_t::index_t const & index)
inlinenoexcept

Access a single-variable Green's function by a mesh index.

Parameters
indexMesh index.
Returns
The stored value at the corresponding mesh point.

Definition at line 198 of file gf.hpp.

◆ target()

template<Mesh M, typename Target, typename Layout>
target_and_shape_t triqs::gfs::gf< M, Target, Layout >::target ( ) const
inline

Get a handle to the target and its shape.

Returns
A triqs::gfs::gf::target_and_shape_t bundling the target type and shape (the mesh dimensions are dropped).

Definition at line 308 of file gf.hpp.

◆ target_indices()

template<Mesh M, typename Target, typename Layout>
auto triqs::gfs::gf< M, Target, Layout >::target_indices ( ) const
inline

Get a generator over the multi-indices of the target space.

Returns
A range iterating over all index tuples of the target.

Definition at line 320 of file gf.hpp.

◆ target_shape()

template<Mesh M, typename Target, typename Layout>
std::array< long, Target::rank > triqs::gfs::gf< M, Target, Layout >::target_shape ( ) const
inline

Get the shape of the target.

Returns
An array holding the extent of each target dimension.

Definition at line 314 of file gf.hpp.

◆ h5_read

template<Mesh M, typename Target, typename Layout>
void h5_read ( h5::group fg,
std::string const & subgroup_name,
this_t & g )
friend

Read a Green's function from HDF5.

Throws a triqs::runtime_error if the HDF5 format tag does not correspond to a Green's function.

Parameters
fgh5::group to read from.
subgroup_nameName of the subgroup to read.
gGreen's function to read into.

Definition at line 237 of file gf.hpp.

◆ h5_write

template<Mesh M, typename Target, typename Layout>
void h5_write ( h5::group fg,
std::string const & subgroup_name,
this_t const & g )
friend

Write a Green's function to HDF5.

Parameters
fgh5::group to write into.
subgroup_nameName of the subgroup to create.
gGreen's function to write.

Definition at line 222 of file gf.hpp.

◆ operator<<

template<Mesh M, typename Target, typename Layout>
std::ostream & operator<< ( std::ostream & out,
this_t const &  )
friend

Write a Green's function to an output stream.

Parameters
outstd::ostream output stream.
Returns
Reference to the output stream.

Definition at line 253 of file gf.hpp.


The documentation for this class was generated from the following file: