29#include <itertools/itertools.hpp>
102 using data_t = nda::basic_array_view<scalar_t, data_rank, Layout>;
159 target_and_shape_t
target()
const {
return target_and_shape_t{stdutil::front_mpop<arity>(_data.shape())}; }
190 void swap_impl(
gf_view &b)
noexcept {
192 swap(this->_mesh, b._mesh);
193 swap(this->_data, b._data);
246 this->_mesh = g._mesh;
247 this->_data.rebind(g._data);
260 triqs_gf_view_assign_delegation(*
this, rhs);
275 triqs_gf_view_assign_delegation(*
this, rhs);
290 auto d2 = std::forward<Fdata>(fd)(_data);
293 return gv_t{
mesh(), d2};
304 auto d2 = std::forward<Fdata>(fd)(_data);
307 return gv_t{
mesh(), d2};
320 template <
typename M,
typename T,
typename L,
typename RHS>
void triqs_gf_view_assign_delegation(gf_view<M, T, L> g, RHS
const &rhs) {
321 if constexpr (nda::is_scalar_v<RHS>) {
322 for (
auto w : g.mesh()) g[w] = rhs;
324 if (!(g.mesh() == rhs.mesh()))
TRIQS_RUNTIME_ERROR <<
"Gf Assignment in View : incompatible mesh \n" << g.mesh() <<
"\n vs \n" << rhs.mesh();
325 for (
auto w : g.mesh()) g[w] = rhs[w];
335 template <
typename M,
typename Target>
void swap(triqs::gfs::gf_view<M, Target> &a, triqs::gfs::gf_view<M, Target> &b) =
delete;
Member code shared by triqs::gfs::gf, triqs::gfs::gf_view and triqs::gfs::gf_const_view.
A read-only, non-owning view of a Green's function.
gf< M, T, typename Layout::contiguous_t > regular_type
data_t data() &&
Get the data array view (rvalue overload).
static constexpr bool is_view
gf_view(gf< M, Target, L > const &g)=delete
Deleted: a mutable view cannot be built from a const Green's function.
static constexpr int data_rank
gf_view(gf< M, Target, L > &g)
Construct a view onto a (non const) Green's function.
auto target_indices() const
Get a generator over the multi-indices of the target space.
static constexpr int arity
std::array< long, Target::rank > target_shape() const
Get the shape of the target.
gf_view & operator=(gf_view const &rhs)
Copy assignment: copy the data through the view without resizing it.
gf_view & operator=(RHS const &rhs)
Assign from any compatible right hand side, writing through the view without resizing it.
gf_view< M, typename T::complex_t, Layout > complex_t
static constexpr int target_rank
gf_view< M, T, Layout > view_type
data_t & data() &
Get the data array view.
friend void swap(gf_view &a, gf_view &b) noexcept
Swap two views.
static constexpr bool is_const
mesh_t const & mesh() const
Get the mesh of the Green's function.
auto apply_on_data(Fdata &&fd) const
Build a const view whose data is the result of applying a function to the data array.
gf_view(gf< M, Target, L > &&g) noexcept
Construct a view onto an rvalue Green's function.
auto apply_on_data(Fdata &&fd)
Build a view whose data is the result of applying a function to the data array.
typename mesh_t::mesh_point_t mesh_point_t
typename T::scalar_t scalar_t
gf_view< M, typename T::real_t, Layout > real_t
gf_view(mesh_t m, data_t dat)
Build a view on top of a mesh and a data array.
data_t const & data() const &
Get the data array view (const overload).
gf_const_view< M, T, Layout > const_view_type
nda::basic_array_view< scalar_t, data_rank, Layout > data_t
typename mesh_t::index_t mesh_index_t
gf_view()=default
Construct an empty view, not bound to any data.
auto const & data_shape() const
Get the shape of the data array.
gf_view(gf_const_view< M, Target > const &g)=delete
Deleted: a mutable view cannot be built from a const view.
target_and_shape_t target() const
Get a handle to the target and its shape.
gf_view(gf_view const &x)=default
Copy constructor (shallow: the new view refers to the same data).
void rebind(gf_view< M, Target > const &g) noexcept
Rebind the view to refer to the mesh and data of another view.
std::array< long, T::rank > target_shape_t
gf_view(gf_view &&)=default
Move constructor.
gf_view< M, T, Layout > mutable_view_type
The owning Green's function container.
static constexpr int n_variables
Constexpr variable that holds the number of meshes in a triqs::mesh::Mesh type ( for non-product mes...
TRIQS exception hierarchy and related macros.
Provides the Green's function class.
typename _target_from_type_rank< typename std::decay_t< typename std::decay_t< A >::value_type >, std::decay_t< A >::rank - nvar >::type target_from_array
Deduce the target type of a Green's function from its data array type and arity.
#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.
Lightweight handle bundling the target type and its shape.
target_shape_t const & shape() const
Get the shape of the target.
target_shape_t _shape
The shape of the target.
Target target_t
The target type.
Empty tag inherited by every view type in TRIQS. See also is_view.