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

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

Detailed Description

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

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

triqs::gfs::gf_const_view refers to the mesh and data of an existing Green's function (or a slice thereof) without owning them and without allowing modification of the underlying data. See triqs::gfs::gf for the owning container and triqs::gfs::gf_view for the mutable 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 47 of file gf_const_view.hpp.

Inheritance diagram for triqs::gfs::gf_const_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_const_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<const scalar_t, data_rank, Layout>
 Type of the (const) 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_const_view<M, typename Target::real_t, Layout>
 Associated real-valued type.
using regular_type = gf<M, Target>
 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_const_view<M, Target, Layout>
 Associated (non const) view type.

Public Member Functions

 gf_const_view ()=default
 Construct an empty view, not bound to any data.
 gf_const_view (gf< M, Target > &&g) noexcept
 Construct a const view onto an rvalue Green's function.
 gf_const_view (gf< M, Target > &g)
 Construct a const view onto a (non const) Green's function.
 gf_const_view (gf< M, Target > const &g)
 Construct a const view onto a const Green's function.
 gf_const_view (gf_const_view &&)=default
 Move constructor.
 gf_const_view (gf_const_view const &x)=default
 Copy constructor (shallow: the new view refers to the same data).
 gf_const_view (gf_view< M, Target > const &g)
 Construct a const view from a (mutable) view.
 gf_const_view (mesh_t m, data_t dat)
 Build a const view on top of a mesh and a data array.
template<typename Fdata>
auto apply_on_data (Fdata &&fd)
 Build a const 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 (const overload).
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_const_viewoperator= (gf_const_view const &)=delete
 Deleted: a const view cannot be assigned to.
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_const_view< M, Target > const &g) noexcept
 Rebind the const view to refer to the mesh and data of another const view.
void rebind (gf_view< M, Target > const &X) noexcept
 Rebind the const view onto a (mutable) 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 = true
 Whether this type is a const view (always true for triqs::gfs::gf_const_view).
static constexpr bool is_view = true
 Whether this type is a view (always true for triqs::gfs::gf_const_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_const_view &a, gf_const_view &b) noexcept
 Swap two const views.

Constructor & Destructor Documentation

◆ gf_const_view() [1/6]

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

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

Parameters
xView to copy from.

◆ gf_const_view() [2/6]

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

Construct a const view from a (mutable) view.

Parameters
gView to view as const.

Definition at line 205 of file gf_const_view.hpp.

◆ gf_const_view() [3/6]

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

Construct a const view onto a const Green's function.

Parameters
gGreen's function to view.

Definition at line 211 of file gf_const_view.hpp.

◆ gf_const_view() [4/6]

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

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

Parameters
gGreen's function to view.

Definition at line 217 of file gf_const_view.hpp.

◆ gf_const_view() [5/6]

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

Construct a const view onto an rvalue Green's function.

Parameters
gGreen's function to view.

Definition at line 224 of file gf_const_view.hpp.

◆ gf_const_view() [6/6]

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

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

Parameters
mMesh.
datData array (view).

Definition at line 232 of file gf_const_view.hpp.

Member Function Documentation

◆ apply_on_data() [1/2]

template<Mesh M, typename Target, typename Layout>
template<typename Fdata>
auto triqs::gfs::gf_const_view< M, Target, Layout >::apply_on_data ( Fdata && fd)
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 275 of file gf_const_view.hpp.

◆ apply_on_data() [2/2]

template<Mesh M, typename Target, typename Layout>
template<typename Fdata>
auto triqs::gfs::gf_const_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 (const overload).

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 289 of file gf_const_view.hpp.

◆ call_impl()

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

◆ data() [1/3]

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

Get the data array view.

Returns
A reference to the (const) data array view.

Definition at line 130 of file gf_const_view.hpp.

◆ data() [2/3]

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

Get the data array view (rvalue overload).

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

Definition at line 142 of file gf_const_view.hpp.

◆ data() [3/3]

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

Get the data array view (const overload).

Returns
A const reference to the (const) data array view.

Definition at line 136 of file gf_const_view.hpp.

◆ data_shape()

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

◆ hdf5_format()

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

◆ mesh()

template<Mesh M, typename Target, typename Layout>
mesh_t const & triqs::gfs::gf_const_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 124 of file gf_const_view.hpp.

◆ operator[]() [1/3]

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

◆ operator[]() [2/3]

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

◆ operator[]() [3/3]

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

◆ rebind() [1/2]

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

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

Parameters
gConst view to rebind onto.

Definition at line 249 of file gf_const_view.hpp.

◆ rebind() [2/2]

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

Rebind the const view onto a (mutable) view.

Parameters
XView to rebind onto.

Definition at line 258 of file gf_const_view.hpp.

◆ target()

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

Get a handle to the target and its shape.

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

Definition at line 158 of file gf_const_view.hpp.

◆ target_indices()

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

◆ target_shape()

template<Mesh M, typename Target, typename Layout>
std::array< long, Target::rank > triqs::gfs::gf_const_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 164 of file gf_const_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_const_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_const_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_const_view.hpp.

◆ swap

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

Swap two const views.

Parameters
aFirst view.
bSecond view.

Definition at line 241 of file gf_const_view.hpp.


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