52 template <
typename Mesh,
typename Target,
typename Layout,
int Arity,
bool IsConst>
54 using this_t = block_gf_view;
64 static constexpr int arity = Arity;
79 using view_type = block_gf_view<Mesh, Target, Layout, Arity, false>;
85 using real_t = block_gf_view<Mesh, typename Target::real_t, Layout, Arity, IsConst>;
91 using data_t = std::conditional_t<Arity == 1, std::vector<g_t>, std::vector<std::vector<g_t>>>;
94 using block_names_t = std::conditional_t<Arity == 1, std::vector<std::string>, std::vector<std::vector<std::string>>>;
129 if constexpr (Arity == 1) {
130 if (_glist.size() != _block_names.size())
131 TRIQS_RUNTIME_ERROR <<
"block_gf(vector<string>, vector<gf>) : the two vectors do not have the same size !";
133 if (_glist.size() != _block_names[0].size())
134 TRIQS_RUNTIME_ERROR <<
"block2_gf(vector<vector<string>>, vector<vector<gf>>) : Outer vectors have different sizes !";
135 if (_glist.size() != 0)
137 TRIQS_RUNTIME_ERROR <<
"block2_gf(vector<vector<string>>, vector<vector<gf>>) : Inner vectors have different sizes !";
151 template <
typename L>
154 : block_gf_view(impl_tag{}, g) {}
161 template <
typename L>
164 : block_gf_view(impl_tag{}, g) {}
178 template <
typename L>
181 : block_gf_view(impl_tag{}, g) {}
191 requires(not IsConst)
207 template <
typename RHS>
209 requires(not IsConst)
211 if constexpr (not nda::is_scalar_v<RHS>) {
215 if constexpr (Arity == 1) {
216 for (
auto &y : _glist) y = rhs;
218 for (
auto &x : _glist)
219 for (
auto &y : x) y = rhs;
235 template <
typename L,
typename G>
236 block_gf_view &
operator=(lazy_transform_t<L, G>
const &rhs)
237 requires(not IsConst)
239 if constexpr (Arity == 1) {
240 for (
int i = 0; i < rhs.value.size(); ++i) (*
this)[i] = rhs.lambda(rhs.value[i]);
243 for (
int i = 0; i < rhs.value.size1(); ++i)
244 for (
int j = 0; j < rhs.value.size2(); ++j) (*
this)(i, j) = rhs.lambda(rhs.value(i, j));
256 _block_names = x._block_names;
257 _glist =
data_t{x._glist};
265 void rebind(block_gf_view<Mesh, Target, Layout, Arity, !IsConst>
const &X)
noexcept
291 friend std::ostream &
operator<<(std::ostream &out, block_gf_view
const &) {
return out <<
"block_gf_view"; }
305 template <
typename Mesh,
typename Target,
typename Layout,
int Arity,
bool IsConst>
Member code shared by triqs::gfs::block_gf and triqs::gfs::block_gf_view.
data_t & data()
Direct access to the blocks.
block_names_t const & block_names() const
Get the block names.
Provides the block Green's function container.
T factory(U &&...x)
Generic factory to construct an object of a given type from an arbitrary parameter pack of arguments.
A non-owning view of a block Green's function.
static constexpr bool is_view
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.
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.
block_gf_view(block_gf_view &&)=default
Move constructor.
block_gf_view()=default
Construct an empty view, not bound to any data.
block_gf_view< M, T, Layout, Arity > mutable_view_type
block_gf_view(block_gf_view const &x)=default
Copy constructor (shallow: the new view refers to the same blocks).
block_gf_view & operator=(lazy_transform_t< L, G > const &rhs)
Assignment operator overload specific for triqs::gfs::lazy_transform_t objects.
void rebind(block_gf< Mesh, Target, Layout, Arity > &X) noexcept
Rebind a view onto a (non const) block Green's function.
block_gf_view(block_gf< Mesh, Target, L, Arity > &g)
Construct a mutable view onto a (non const) block Green's function.
int size() const
Get the total number of blocks.
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.
std::conditional_t< Arity==1, std::vector< std::string >, std::vector< std::vector< std::string > > > block_names_t
std::conditional_t< IsConst, gf_const_view< M, T, Layout >, gf_view< M, T, Layout > > g_t
block_gf_view(block_gf< Mesh, Target, L, Arity > const &g)
Construct a const view onto a block Green's function.
block_gf_view< M, T, Layout, Arity, true > const_view_type
block_gf_view(block_gf< Mesh, Target, L, Arity > &&g) noexcept
Construct a view onto an rvalue block Green's function.
friend std::ostream & operator<<(std::ostream &out, block_gf_view const &)
Writing a block Green's function to an output stream is not supported.
block_gf_view< M, typename T::real_t, Layout, Arity, IsConst > real_t
std::conditional_t< Arity==1, std::vector< g_t >, std::vector< std::vector< g_t > > > data_t
void rebind(block_gf< Mesh, Target, Layout, Arity > const &X) noexcept
Rebind a const view onto a block Green's function.
block_gf< M, T, typename Layout::contiguous_t, Arity > regular_type
block_gf_view< M, T, Layout, Arity, false > view_type
block_gf_view & operator=(RHS const &rhs)
Assign from any compatible right hand side, writing through the view without resizing it.
static constexpr bool is_const
block_gf_view & operator=(block_gf_view const &rhs)
------------— Operator = -----------------—
static constexpr int arity
void rebind(block_gf_view x) noexcept
Rebind the view to refer to the blocks of another view of the same kind.
The owning block Green's function container.
A mutable, non-owning view of a Green's function.
TRIQS exception hierarchy and related macros.
#define TRIQS_RUNTIME_ERROR
Throw a triqs::runtime_error with the current source location.
#define TRIQS_CONCEPT_TAG_NAME(MyBeautifulConcept)
Helper macro that produces the name of the tag for TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT.
Empty tag inherited by every view type in TRIQS. See also is_view.