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

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

Detailed Description

template<typename Mesh, typename Target, typename Layout, int Arity>
class triqs::gfs::block_gf< Mesh, Target, Layout, Arity >

The owning block Green's function container.

triqs::gfs::block_gf is a value-semantic container holding a list of Green's functions (the blocks), each a triqs::gfs::gf, and models the BlockGreenFunction concept.

For Arity == 1 the blocks form a simple vector (a block_gf). For Arity == 2 they form a matrix of blocks (a triqs::gfs::block2_gf).

Each block is accessed by index (or block name) via operator[] (operator() for a block2_gf). Non-owning views are provided by triqs::gfs::block_gf_view.

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.
ArityNumber of block indices (1 for block_gf, 2 for block2_gf).

Definition at line 259 of file block_gf.hpp.

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).
using const_iterator = iterator_impl<true>
 Const block iterator type.
using const_view_type = block_gf_view<Mesh, Target, typename Layout::with_lowest_guarantee_t, 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).
using g_t = gf<Mesh, Target, Layout>
 Type of a single block.
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, typename Layout::with_lowest_guarantee_t, Arity>
 Associated mutable view type.
using real_t = block_gf<Mesh, typename Target::real_t, Layout, Arity>
 The associated real type.
using regular_type = block_gf<Mesh, Target, Layout, Arity>
 Associated regular (owning) type.
using target_t = Target
 Target type of each block.
using view_type = block_gf_view<Mesh, Target, typename Layout::with_lowest_guarantee_t, Arity, false>
 Associated (non const) view type.

Public Member Functions

 block_gf ()=default
 Construct an empty block Green's function (with no blocks).
 block_gf (block_gf &&)=default
 Move constructor.
 block_gf (block_gf const &x)=default
 Copy constructor.
template<typename L, bool Cnst>
 block_gf (block_gf_view< Mesh, Target, L, Arity, Cnst > const &g)
 Construct from a view of the same kind, making a deep copy of the data.
 block_gf (block_names_t b)
 Construct a one-index block_gf with the given block names and default-constructed blocks.
 block_gf (block_names_t b, data_t d)
 Construct from a list of block names and a list of Green's functions.
 block_gf (block_names_t b, g_t const &g)
 Construct a one-index block_gf from block names and one Green's function copied into every block.
 block_gf (data_t V)
 Construct a two-index block2_gf from a matrix of Green's functions.
 block_gf (data_t V)
 Construct a one-index block_gf from a vector of Green's functions (block names default to "0", "1", ...).
template<typename G>
requires (BlockGreenFunction_v<G> and (std::is_same_v<get_target_t<G>, Target> or std::is_same_v<typename get_target_t<G>::complex_t, Target>))
 block_gf (G const &x)
 Construct from any object modeling the BlockGreenFunction concept with a compatible target.
 block_gf (int n)
 Construct a one-index block_gf of n default-constructed blocks.
 block_gf (int n, g_t const &g)
 Construct a one-index block_gf of n copies of a Green's function.
 block_gf (int n, int p, g_t const &g)
 Construct a two-index block2_gf of n x p copies of a Green's function.
 block_gf (Mesh const &m, gf_struct_t const &gf_struct)
 Construct a one-index block_gf from a mesh and a triqs::gfs::gf_struct_t.
template<typename Int>
requires (Arity == 1 && std::is_integral_v<Int>)
 block_gf (Mesh const &m, std::vector< Int > const &bl_sizes)
 Construct a one-index block_gf from a mesh and a vector of block sizes (block names default to "0", ...).
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_gfoperator= (block_gf &&rhs)=default
 Move assignment.
block_gfoperator= (block_gf const &rhs)=default
 Copy assignment.
template<typename RHS>
requires (BlockGreenFunction_v<RHS>)
block_gfoperator= (RHS &&rhs)
 Assign from any object modeling the BlockGreenFunction concept.
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).
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, 2 for block2_gf).
static constexpr bool is_const = false
 Whether this type is a const view (always false for triqs::gfs::block_gf).
static constexpr bool is_view = false
 Whether this type is a view (always false for triqs::gfs::block_gf).

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 const &)
 Writing a block Green's function to an output stream is not supported.

Constructor & Destructor Documentation

◆ block_gf() [1/13]

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

Copy constructor.

Parameters
xBlock Green's function to copy from.

◆ block_gf() [2/13]

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

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

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

Parameters
bBlock names.
dBlocks (Green's functions).

Definition at line 333 of file block_gf.hpp.

◆ block_gf() [3/13]

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

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

Template Parameters
LLayout of the view.
CnstWhether the view is const.
Parameters
gView to copy from.

Definition at line 356 of file block_gf.hpp.

◆ block_gf() [4/13]

template<typename Mesh, typename Target, typename Layout, int Arity>
template<typename G>
requires (BlockGreenFunction_v<G> and (std::is_same_v<get_target_t<G>, Target> or std::is_same_v<typename get_target_t<G>::complex_t, Target>))
triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::block_gf ( G const & x)
inline

Construct from any object modeling the BlockGreenFunction concept with a compatible target.

The block Green's function is default constructed and then assigned from x, which resizes it accordingly.

Template Parameters
GA type modeling BlockGreenFunction with the same (or complex-promoted) target type and same arity.
Parameters
xObject to construct from (e.g. another block Green's function or a lazy expression).

Definition at line 369 of file block_gf.hpp.

◆ block_gf() [5/13]

template<typename Mesh, typename Target, typename Layout, int Arity>
triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::block_gf ( data_t V)
inline

Construct a one-index block_gf from a vector of Green's functions (block names default to "0", "1", ...).

Parameters
VBlocks (Green's functions).

Definition at line 380 of file block_gf.hpp.

◆ block_gf() [6/13]

template<typename Mesh, typename Target, typename Layout, int Arity>
triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::block_gf ( int n)
inline

Construct a one-index block_gf of n default-constructed blocks.

Parameters
nNumber of blocks.

Definition at line 388 of file block_gf.hpp.

◆ block_gf() [7/13]

template<typename Mesh, typename Target, typename Layout, int Arity>
triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::block_gf ( int n,
g_t const & g )
inline

Construct a one-index block_gf of n copies of a Green's function.

Parameters
nNumber of blocks.
gGreen's function to copy into each block.

Definition at line 398 of file block_gf.hpp.

◆ block_gf() [8/13]

template<typename Mesh, typename Target, typename Layout, int Arity>
triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::block_gf ( block_names_t b,
g_t const & g )
inline

Construct a one-index block_gf from block names and one Green's function copied into every block.

Parameters
bBlock names.
gGreen's function to copy into each block.

Definition at line 408 of file block_gf.hpp.

◆ block_gf() [9/13]

template<typename Mesh, typename Target, typename Layout, int Arity>
triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::block_gf ( block_names_t b)
inline

Construct a one-index block_gf with the given block names and default-constructed blocks.

Parameters
bBlock names.

Definition at line 416 of file block_gf.hpp.

◆ block_gf() [10/13]

template<typename Mesh, typename Target, typename Layout, int Arity>
triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::block_gf ( Mesh const & m,
gf_struct_t const & gf_struct )
inline

Construct a one-index block_gf from a mesh and a triqs::gfs::gf_struct_t.

One block is created per entry of the structure, sized according to the block size (scalar-valued targets ignore the size).

Parameters
mMesh shared by all blocks.
gf_structBlock structure (block name and size for each block).

Definition at line 429 of file block_gf.hpp.

◆ block_gf() [11/13]

template<typename Mesh, typename Target, typename Layout, int Arity>
template<typename Int>
requires (Arity == 1 && std::is_integral_v<Int>)
triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::block_gf ( Mesh const & m,
std::vector< Int > const & bl_sizes )
inline

Construct a one-index block_gf from a mesh and a vector of block sizes (block names default to "0", ...).

Template Parameters
IntIntegral type of the block sizes.
Parameters
mMesh shared by all blocks.
bl_sizesSize of each block.

Definition at line 450 of file block_gf.hpp.

◆ block_gf() [12/13]

template<typename Mesh, typename Target, typename Layout, int Arity>
triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::block_gf ( int n,
int p,
g_t const & g )
inline

Construct a two-index block2_gf of n x p copies of a Green's function.

Parameters
nNumber of blocks along the first index.
pNumber of blocks along the second index.
gGreen's function to copy into each block.

Definition at line 470 of file block_gf.hpp.

◆ block_gf() [13/13]

template<typename Mesh, typename Target, typename Layout, int Arity>
triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::block_gf ( data_t V)
inline

Construct a two-index block2_gf from a matrix of Green's functions.

Parameters
VBlocks (vector of vectors of Green's functions).

Definition at line 478 of file block_gf.hpp.

Member Function Documentation

◆ block_names()

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

Get the block names.

Returns
A const reference to the block names.

Definition at line 53 of file block_gf.hpp.

◆ block_sizes()

template<typename Mesh, typename Target, typename Layout, int Arity>
std::vector< int > triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::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.hpp.

◆ data() [1/2]

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

Direct access to the blocks.

Returns
A reference to the block storage.

Definition at line 41 of file block_gf.hpp.

◆ data() [2/2]

template<typename Mesh, typename Target, typename Layout, int Arity>
data_t const & triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::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.hpp.

◆ gf_struct()

template<typename Mesh, typename Target, typename Layout, int Arity>
gf_struct_t triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::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.hpp.

◆ hdf5_format()

template<typename Mesh, typename Target, typename Layout, int Arity>
std::string triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::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.hpp.

◆ operator()() [1/4]

template<typename Mesh, typename Target, typename Layout, int Arity>
template<typename... Args>
requires (nda::clef::is_clef_expression<Args...>)
auto triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::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.hpp.

◆ operator()() [2/4]

template<typename Mesh, typename Target, typename Layout, int Arity>
decltype(auto) triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::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.hpp.

◆ operator()() [3/4]

template<typename Mesh, typename Target, typename Layout, int Arity>
decltype(auto) triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::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.hpp.

◆ operator()() [4/4]

template<typename Mesh, typename Target, typename Layout, int Arity>
decltype(auto) triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::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.hpp.

◆ operator=() [1/3]

template<typename Mesh, typename Target, typename Layout, int Arity>
block_gf & triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::operator= ( block_gf< Mesh, Target, Layout, Arity > && rhs)
default

Move assignment.

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

◆ operator=() [2/3]

template<typename Mesh, typename Target, typename Layout, int Arity>
block_gf & triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::operator= ( block_gf< Mesh, Target, Layout, Arity > const & rhs)
default

Copy assignment.

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

◆ operator=() [3/3]

template<typename Mesh, typename Target, typename Layout, int Arity>
template<typename RHS>
requires (BlockGreenFunction_v<RHS>)
block_gf & triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::operator= ( RHS && rhs)
inline

Assign from any object modeling the BlockGreenFunction concept.

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

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

Definition at line 513 of file block_gf.hpp.

◆ operator[]() [1/3]

template<typename Mesh, typename Target, typename Layout, int Arity>
template<typename Arg>
requires (nda::clef::is_clef_expression<Arg>)
auto triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::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.hpp.

◆ operator[]() [2/3]

template<typename Mesh, typename Target, typename Layout, int Arity>
decltype(auto) triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::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.hpp.

◆ operator[]() [3/3]

template<typename Mesh, typename Target, typename Layout, int Arity>
decltype(auto) triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::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.hpp.

◆ size()

template<typename Mesh, typename Target, typename Layout, int Arity>
int triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::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.hpp.

◆ size1()

template<typename Mesh, typename Target, typename Layout, int Arity>
int triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::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.hpp.

◆ size2()

template<typename Mesh, typename Target, typename Layout, int Arity>
int triqs::gfs::block_gf< Mesh, Target, Layout, Arity >::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.hpp.

◆ h5_read

template<typename Mesh, typename Target, typename Layout, int Arity>
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.hpp.

◆ h5_write

template<typename Mesh, typename Target, typename Layout, int Arity>
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.hpp.


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