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

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

Detailed Description

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

A mutable, non-owning view of a Green's function.

triqs::gfs::gf_view refers to the mesh and data of an existing Green's function (or a slice thereof) without owning them. Assigning to a view writes through to the underlying data. See triqs::gfs::gf for the owning container and triqs::gfs::gf_const_view for the read-only 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 view.

Definition at line 48 of file gf_view.hpp.

Inheritance diagram for triqs::gfs::gf_view< M, Target, Layout >:
triqs::is_view_tag

Classes

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

Public Types

using complex_t = gf_view<M, typename Target::complex_t, Layout>
 Associated complex-valued type.
using const_view_type = gf_const_view<M, Target, Layout>
 Associated const view type.
using data_t = nda::basic_array_view<scalar_t, data_rank, Layout>
 Type of the data array view.
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, Layout>
 Associated mutable view type.
using real_t = gf_view<M, typename Target::real_t, Layout>
 Associated real-valued type.
using regular_type = gf<M, Target, typename Layout::contiguous_t>
 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, Layout>
 Associated (non const) view type.

Public Member Functions

 gf_view ()=default
 Construct an empty view, not bound to any data.
template<typename L>
 gf_view (gf< M, Target, L > &&g) noexcept
 Construct a view onto an rvalue Green's function.
template<typename L>
 gf_view (gf< M, Target, L > &g)
 Construct a view onto a (non const) Green's function.
template<typename L>
 gf_view (gf< M, Target, L > const &g)=delete
 Deleted: a mutable view cannot be built from a const Green's function.
 gf_view (gf_const_view< M, Target > const &g)=delete
 Deleted: a mutable view cannot be built from a const view.
 gf_view (gf_view &&)=default
 Move constructor.
 gf_view (gf_view const &x)=default
 Copy constructor (shallow: the new view refers to the same data).
 gf_view (mesh_t m, data_t dat)
 Build a view on top of a mesh and a data array.
template<typename Fdata>
auto apply_on_data (Fdata &&fd)
 Build a view 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 whose data is the result of applying a function to the data array.
data_tdata () &
 Get the data array view.
data_t data () &&
 Get the data array view (rvalue overload).
data_t const & data () const &
 Get the data array view (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()).
gf_viewoperator= (gf_view const &rhs)
 Copy assignment: copy the data through the view without resizing it.
template<typename RHS>
gf_viewoperator= (RHS const &rhs)
 Assign from any compatible right hand side, writing through the view without resizing it.
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.
void rebind (gf_view< M, Target > const &g) noexcept
 Rebind the view to refer to the mesh and data of another view.
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 (arity + target_rank).
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_view).
static constexpr bool is_view = true
 Whether this type is a view (always true for triqs::gfs::gf_view).
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.
void swap (gf_view &a, gf_view &b) noexcept
 Swap two views.

Constructor & Destructor Documentation

◆ gf_view() [1/4]

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

Copy constructor (shallow: the new view refers to the same data).

Parameters
xView to copy from.

◆ gf_view() [2/4]

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

Construct a view onto a (non const) Green's function.

Template Parameters
LLayout of the Green's function.
Parameters
gGreen's function to view.

Definition at line 213 of file gf_view.hpp.

◆ gf_view() [3/4]

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

Construct a view onto an rvalue Green's function.

Template Parameters
LLayout of the Green's function.
Parameters
gGreen's function to view.

Definition at line 221 of file gf_view.hpp.

◆ gf_view() [4/4]

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

Build a view on top of a mesh and a data array.

Parameters
mMesh.
datData array (view).

Definition at line 229 of file gf_view.hpp.

Member Function Documentation

◆ apply_on_data() [1/2]

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

Build a view whose data is the result of applying a function to the data 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 view's mesh.

Definition at line 289 of file gf_view.hpp.

◆ apply_on_data() [2/2]

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

Build a const view whose data is the result of applying a function to the data 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 view's mesh.

Definition at line 303 of file gf_view.hpp.

◆ call_impl()

template<Mesh M, typename Target, typename Layout>
template<typename Self, typename... Args>
decltype(auto) triqs::gfs::gf_view< 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_view.hpp.

◆ data() [1/3]

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

Get the data array view.

Returns
A reference to the data array view.

Definition at line 131 of file gf_view.hpp.

◆ data() [2/3]

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

Get the data array view (rvalue overload).

Returns
The data array view, moved out of the (expiring) view.

Definition at line 143 of file gf_view.hpp.

◆ data() [3/3]

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

Get the data array view (const overload).

Returns
A const reference to the data array view.

Definition at line 137 of file gf_view.hpp.

◆ data_shape()

template<Mesh M, typename Target, typename Layout>
auto const & triqs::gfs::gf_view< 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 153 of file gf_view.hpp.

◆ hdf5_format()

template<Mesh M, typename Target, typename Layout>
std::string triqs::gfs::gf_view< 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_view.hpp.

◆ mesh()

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

Get the mesh of the Green's function.

Returns
A const reference to the mesh.

Definition at line 125 of file gf_view.hpp.

◆ operator=() [1/2]

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

Copy assignment: copy the data through the view without resizing it.

Warning
If the size of this is not the same as rhs, the behaviour is undefined.
Parameters
rhsView to copy from.
Returns
A reference to this view.

Definition at line 259 of file gf_view.hpp.

◆ operator=() [2/2]

template<Mesh M, typename Target, typename Layout>
template<typename RHS>
gf_view & triqs::gfs::gf_view< M, Target, Layout >::operator= ( RHS const & rhs)
inline

Assign from any compatible right hand side, writing through the view without resizing it.

rhs can be a scalar (assigned to every mesh point) or any Green's function (object/view/expression) with the same mesh.

Template Parameters
RHSType of the right hand side.
Parameters
rhsObject to assign from.
Returns
A reference to this view.

Definition at line 274 of file gf_view.hpp.

◆ operator[]() [1/3]

template<Mesh M, typename Target, typename Layout>
template<typename... Arg>
requires (sizeof...(Arg) == arity)
decltype(auto) triqs::gfs::gf_view< 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_view.hpp.

◆ operator[]() [2/3]

template<Mesh M, typename Target, typename Layout>
template<typename... T>
requires (sizeof...(T) == arity)
decltype(auto) triqs::gfs::gf_view< 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_view.hpp.

◆ operator[]() [3/3]

template<Mesh M, typename Target, typename Layout>
decltype(auto) triqs::gfs::gf_view< 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_view.hpp.

◆ rebind()

template<Mesh M, typename Target, typename Layout>
void triqs::gfs::gf_view< M, Target, Layout >::rebind ( gf_view< M, Target > const & g)
inlinenoexcept

Rebind the view to refer to the mesh and data of another view.

Parameters
gView to rebind onto.

Definition at line 245 of file gf_view.hpp.

◆ target()

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

Get a handle to the target and its shape.

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

Definition at line 159 of file gf_view.hpp.

◆ target_indices()

template<Mesh M, typename Target, typename Layout>
auto triqs::gfs::gf_view< 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 171 of file gf_view.hpp.

◆ target_shape()

template<Mesh M, typename Target, typename Layout>
std::array< long, Target::rank > triqs::gfs::gf_view< 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 165 of file gf_view.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_view.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_view.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_view.hpp.

◆ swap

template<Mesh M, typename Target, typename Layout>
void swap ( gf_view< M, Target, Layout > & a,
gf_view< M, Target, Layout > & b )
friend

Swap two views.

Parameters
aFirst view.
bSecond view.

Definition at line 238 of file gf_view.hpp.


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