TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >

#include <triqs/gfs/block/block_gf_view.hpp>

Detailed Description

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
class triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >

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

triqs::gfs::block_gf_view refers to the blocks of an existing block Green's function without owning them. Whether it is read-only is fixed by the IsConst template parameter (see the triqs::gfs::block_gf_const_view alias). Assigning to a mutable view writes through to the underlying blocks. See triqs::gfs::block_gf for the owning container.

Template Parameters
MeshMesh type of each block, modeling triqs::mesh::Mesh.
TargetTarget type of each block.
LayoutMemory layout policy of each block's data array view.
ArityNumber of block indices (1 for block_gf_view, 2 for block2_gf_view).
IsConstWhether the view is read-only.

Definition at line 53 of file block_gf_view.hpp.

Inheritance diagram for triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >:
triqs::is_view_tag

Classes

class  iterator_impl
 Forward iterator over the blocks of a block Green's function. More...

Public Types

using block_names_t = std::conditional_t<Arity == 1, std::vector<std::string>, std::vector<std::vector<std::string>>>
 Type storing the block names (a vector of names, or vector of vectors for a block2_gf_view).
using const_iterator = iterator_impl<true>
 Const block iterator type.
using const_view_type = block_gf_view<Mesh, Target, Layout, Arity, true>
 Associated const view type.
using data_t = std::conditional_t<Arity == 1, std::vector<g_t>, std::vector<std::vector<g_t>>>
 Type storing the blocks (a vector of blocks, or vector of vectors for a block2_gf_view).
using g_t = std::conditional_t<IsConst, gf_const_view<Mesh, Target, Layout>, gf_view<Mesh, Target, Layout>>
 Type of a single block (a const or mutable view depending on IsConst).
using iterator = iterator_impl<false>
 Mutable block iterator type.
using mesh_t = Mesh
 Mesh type of each block.
using mutable_view_type = block_gf_view<Mesh, Target, Layout, Arity>
 Associated mutable view type.
using real_t = block_gf_view<Mesh, typename Target::real_t, Layout, Arity, IsConst>
 The associated real type.
using regular_type = block_gf<Mesh, Target, typename Layout::contiguous_t, Arity>
 Associated regular (owning) type.
using target_t = Target
 Target type of each block.
using view_type = block_gf_view<Mesh, Target, Layout, Arity, false>
 Associated (non const) view type.

Public Member Functions

 block_gf_view ()=default
 Construct an empty view, not bound to any data.
template<typename L>
 block_gf_view (block_gf< Mesh, Target, L, Arity > &&g) noexcept
 Construct a view onto an rvalue block Green's function.
template<typename L>
requires (!IsConst)
 block_gf_view (block_gf< Mesh, Target, L, Arity > &g)
 Construct a mutable view onto a (non const) block Green's function.
template<typename L>
requires (IsConst)
 block_gf_view (block_gf< Mesh, Target, L, Arity > const &g)
 Construct a const view onto a block Green's function.
 block_gf_view (block_gf_view &&)=default
 Move constructor.
 block_gf_view (block_gf_view const &x)=default
 Copy constructor (shallow: the new view refers to the same blocks).
template<typename L>
requires (IsConst)
 block_gf_view (block_gf_view< Mesh, Target, L, Arity, !IsConst > const &g)
 Construct a const view from a mutable view of the same kind.
 block_gf_view (block_names_t b, data_t d)
 Construct from a list of block names and a list of Green's function views.
iterator begin ()
 Get an iterator to the first block.
const_iterator begin () const
 Get a const iterator to the first block.
block_names_t const & block_names () const
 Get the block names.
std::vector< int > block_sizes () const
 Get the matrix size of each block.
auto cbegin ()
 Get a const iterator to the first block.
auto cend ()
 Get a const iterator past the last block.
data_tdata ()
 Direct access to the blocks.
data_t const & data () const
 Direct access to the blocks (const overload).
iterator end ()
 Get an iterator past the last block.
const_iterator end () const
 Get a const iterator past the last block.
gf_struct_t gf_struct () const
 Get the block structure.
view_type operator() ()
 Make a view of *this if it is non const.
const_view_type operator() () const
 Make a const view of *this.
template<typename... Args>
requires (nda::clef::is_clef_expression<Args...>)
auto operator() (Args &&...1) &
 Make a lazy CLEF call expression (lvalue overload).
template<typename... Args>
requires (nda::clef::is_clef_expression<Args...>)
auto operator() (Args &&...1) &&
 Rvalue overload of the lazy CLEF call (see the lvalue overload).
template<typename... Args>
requires (nda::clef::is_clef_expression<Args...>)
auto operator() (Args &&...1) const &
 Const lvalue overload of the lazy CLEF call (see the lvalue overload).
decltype(auto) operator() (int n) const
 Access the n-th block of a one-index block Green's function.
decltype(auto) operator() (int n1, int n2)
 Access block (n1, n2) of a two-index block Green's function.
decltype(auto) operator() (int n1, int n2) const
 Access block (n1, n2) of a two-index block Green's function (const overload).
block_gf_viewoperator= (block_gf_view const &rhs)
 ------------— Operator = -----------------—
template<typename L, typename G>
requires (not IsConst)
block_gf_viewoperator= (lazy_transform_t< L, G > const &rhs)
 Assignment operator overload specific for triqs::gfs::lazy_transform_t objects.
template<typename RHS>
requires (not IsConst)
block_gf_viewoperator= (RHS const &rhs)
 Assign from any compatible right hand side, writing through the view without resizing it.
template<typename Arg>
requires (nda::clef::is_clef_expression<Arg>)
auto operator[] (Arg &&arg) &
 Lvalue overload of the lazy CLEF subscript (see the const lvalue overload).
template<typename Arg>
requires (nda::clef::is_clef_expression<Arg>)
auto operator[] (Arg &&arg) &&
 Rvalue overload of the lazy CLEF subscript (see the const lvalue overload).
template<typename Arg>
requires (nda::clef::is_clef_expression<Arg>)
auto operator[] (Arg &&arg) const &
 Make a lazy CLEF subscript expression (const lvalue overload).
decltype(auto) operator[] (int n)
 Access the n-th block of a one-index block Green's function.
decltype(auto) operator[] (int n) const
 Access the n-th block of a one-index block Green's function (const overload).
void rebind (block_gf< Mesh, Target, Layout, Arity > &X) noexcept
 Rebind a view onto a (non const) block Green's function.
void rebind (block_gf< Mesh, Target, Layout, Arity > const &X) noexcept
 Rebind a const view onto a block Green's function.
void rebind (block_gf_view x) noexcept
 Rebind the view to refer to the blocks of another view of the same kind.
void rebind (block_gf_view< Mesh, Target, Layout, Arity, !IsConst > const &X) noexcept
 Rebind a const view onto a mutable view of the same kind.
int size () const
 Get the total number of blocks.
int size1 () const
 Get the number of blocks along the first index (block2_gf only).
int size2 () const
 Get the number of blocks along the second index (block2_gf only).

Static Public Member Functions

static std::string hdf5_format ()
 Get the HDF5 format tag of a block Green's function.

Public Attributes

std::string name
 Name of the block Green's function.

Static Public Attributes

static constexpr int arity = Arity
 Number of block indices (1 for block_gf_view, 2 for block2_gf_view).
static constexpr bool is_const = IsConst
 Whether this view is read-only.
static constexpr bool is_view = true
 Whether this type is a view (always true for triqs::gfs::block_gf_view).

Friends

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

Constructor & Destructor Documentation

◆ block_gf_view() [1/6]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::block_gf_view ( block_gf_view< Mesh, Target, Layout, Arity, IsConst > const & x)
default

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

Parameters
xView to copy from.

◆ block_gf_view() [2/6]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::block_gf_view ( block_names_t b,
data_t d )
inline

Construct from a list of block names and a list of Green's function views.

The two lists must have matching sizes (throws a triqs::runtime_error otherwise).

Parameters
bBlock names.
dBlocks (Green's function views).

Definition at line 128 of file block_gf_view.hpp.

◆ block_gf_view() [3/6]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
template<typename L>
requires (IsConst)
triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::block_gf_view ( block_gf< Mesh, Target, L, Arity > const & g)
inline

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

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

Definition at line 152 of file block_gf_view.hpp.

◆ block_gf_view() [4/6]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
template<typename L>
requires (!IsConst)
triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::block_gf_view ( block_gf< Mesh, Target, L, Arity > & g)
inline

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

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

Definition at line 162 of file block_gf_view.hpp.

◆ block_gf_view() [5/6]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
template<typename L>
triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::block_gf_view ( block_gf< Mesh, Target, L, Arity > && g)
inlinenoexcept

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

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

Definition at line 171 of file block_gf_view.hpp.

◆ block_gf_view() [6/6]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
template<typename L>
requires (IsConst)
triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::block_gf_view ( block_gf_view< Mesh, Target, L, Arity, !IsConst > const & g)
inline

Construct a const view from a mutable view of the same kind.

Template Parameters
LLayout of the view.
Parameters
gView to copy from.

Definition at line 179 of file block_gf_view.hpp.

Member Function Documentation

◆ block_names()

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
block_names_t const & triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::block_names ( ) const
inline

Get the block names.

Returns
A const reference to the block names.

Definition at line 53 of file block_gf_view.hpp.

◆ block_sizes()

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
std::vector< int > triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::block_sizes ( ) const
inline

Get the matrix size of each block.

Only valid for matrix-valued blocks (rank-2 target); requires each block to have a square target shape.

Returns
A vector holding the size of each block.

Definition at line 62 of file block_gf_view.hpp.

◆ data() [1/2]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
data_t & triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::data ( )
inline

Direct access to the blocks.

Returns
A reference to the block storage.

Definition at line 41 of file block_gf_view.hpp.

◆ data() [2/2]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
data_t const & triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::data ( ) const
inline

Direct access to the blocks (const overload).

Returns
A const reference to the block storage.

Definition at line 47 of file block_gf_view.hpp.

◆ gf_struct()

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
gf_struct_t triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::gf_struct ( ) const
inline

Get the block structure.

Will fail if the target shape is non-square, because block_sizes() will fail.

Returns
A triqs::gfs::gf_struct_t pairing each block name with its size.

Definition at line 79 of file block_gf_view.hpp.

◆ hdf5_format()

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
std::string triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::hdf5_format ( )
inlinestaticnodiscard

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

Returns
The string "BlockGf" ("Block2Gf" for a block2_gf).

Definition at line 267 of file block_gf_view.hpp.

◆ operator()() [1/4]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
template<typename... Args>
requires (nda::clef::is_clef_expression<Args...>)
auto triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::operator() ( Args &&... 1) &
inline

Make a lazy CLEF call expression (lvalue overload).

Template Parameters
ArgsTypes of the lazy CLEF arguments.
Returns
A lazy call expression.

Definition at line 184 of file block_gf_view.hpp.

◆ operator()() [2/4]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
decltype(auto) triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::operator() ( int n) const
inline

Access the n-th block of a one-index block Green's function.

Parameters
nBlock index.
Returns
The n-th block.

Definition at line 146 of file block_gf_view.hpp.

◆ operator()() [3/4]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
decltype(auto) triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::operator() ( int n1,
int n2 )
inline

Access block (n1, n2) of a two-index block Green's function.

Parameters
n1First block index.
n2Second block index.
Returns
The block at (n1, n2).

Definition at line 170 of file block_gf_view.hpp.

◆ operator()() [4/4]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
decltype(auto) triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::operator() ( int n1,
int n2 ) const
inline

Access block (n1, n2) of a two-index block Green's function (const overload).

Parameters
n1First block index.
n2Second block index.
Returns
The block at (n1, n2).

Definition at line 158 of file block_gf_view.hpp.

◆ operator=() [1/3]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
block_gf_view & triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::operator= ( block_gf_view< Mesh, Target, Layout, Arity, IsConst > const & rhs)
inline

------------— Operator = -----------------—

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

Parameters
rhsView to copy from.
Returns
A reference to this view.

Definition at line 190 of file block_gf_view.hpp.

◆ operator=() [2/3]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
template<typename L, typename G>
requires (not IsConst)
block_gf_view & triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::operator= ( lazy_transform_t< L, G > const & rhs)
inline

Assignment operator overload specific for triqs::gfs::lazy_transform_t objects.

Applies the deferred lambda block by block, e.g. the lazy object returned by fourier(my_block_gf).

Template Parameters
LType of the deferred lambda.
GType of the deferred value.
Parameters
rhsThe lazy object returned e.g. by fourier(my_block_gf).
Returns
A reference to this view.

Definition at line 236 of file block_gf_view.hpp.

◆ operator=() [3/3]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
template<typename RHS>
requires (not IsConst)
block_gf_view & triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::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 block) or anything with .block_names() and [n] returning a Green's function. For a non-scalar right hand side the number of blocks must match (throws otherwise).

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

Definition at line 208 of file block_gf_view.hpp.

◆ operator[]() [1/3]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
template<typename Arg>
requires (nda::clef::is_clef_expression<Arg>)
auto triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::operator[] ( Arg && arg) const &
inline

Make a lazy CLEF subscript expression (const lvalue overload).

Template Parameters
ArgType of the lazy CLEF argument.
Parameters
argLazy CLEF argument.
Returns
A lazy subscript expression.

Definition at line 239 of file block_gf_view.hpp.

◆ operator[]() [2/3]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
decltype(auto) triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::operator[] ( int n)
inline

Access the n-th block of a one-index block Green's function.

Parameters
nBlock index.
Returns
The n-th block.

Definition at line 224 of file block_gf_view.hpp.

◆ operator[]() [3/3]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
decltype(auto) triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::operator[] ( int n) const
inline

Access the n-th block of a one-index block Green's function (const overload).

Parameters
nBlock index.
Returns
The n-th block.

Definition at line 213 of file block_gf_view.hpp.

◆ rebind() [1/4]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
void triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::rebind ( block_gf< Mesh, Target, Layout, Arity > & X)
inlinenoexcept

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

Parameters
XBlock Green's function to rebind onto.

Definition at line 285 of file block_gf_view.hpp.

◆ rebind() [2/4]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
void triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::rebind ( block_gf< Mesh, Target, Layout, Arity > const & X)
inlinenoexcept

Rebind a const view onto a block Green's function.

Parameters
XBlock Green's function to rebind onto.

Definition at line 275 of file block_gf_view.hpp.

◆ rebind() [3/4]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
void triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::rebind ( block_gf_view< Mesh, Target, Layout, Arity, IsConst > x)
inlinenoexcept

Rebind the view to refer to the blocks of another view of the same kind.

Parameters
xView to rebind onto.

Definition at line 255 of file block_gf_view.hpp.

◆ rebind() [4/4]

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
void triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::rebind ( block_gf_view< Mesh, Target, Layout, Arity, !IsConst > const & X)
inlinenoexcept

Rebind a const view onto a mutable view of the same kind.

Parameters
XView to rebind onto.

Definition at line 265 of file block_gf_view.hpp.

◆ size()

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
int triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::size ( ) const
inline

Get the total number of blocks.

Returns
The number of blocks (the product of both dimensions for a block2_gf).

Definition at line 109 of file block_gf_view.hpp.

◆ size1()

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
int triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::size1 ( ) const
inline

Get the number of blocks along the first index (block2_gf only).

Returns
The number of blocks along the first index.

Definition at line 89 of file block_gf_view.hpp.

◆ size2()

template<typename Mesh, typename Target, typename Layout, int Arity, bool IsConst>
int triqs::gfs::block_gf_view< Mesh, Target, Layout, Arity, IsConst >::size2 ( ) const
inline

Get the number of blocks along the second index (block2_gf only).

Returns
The number of blocks along the second index.

Definition at line 99 of file block_gf_view.hpp.

◆ h5_read

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

Read a block Green's function from HDF5.

Throws a triqs::runtime_error if the HDF5 format tag does not correspond to the expected block format.

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

Definition at line 305 of file block_gf_view.hpp.

◆ h5_write

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

Write a block Green's function to HDF5.

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

Definition at line 281 of file block_gf_view.hpp.


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