3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-26 06:14:14 +01:00

gf: correct auto_assign

- g(om_)(i_,j_) was not working.
- add the triqs_clef_auto_assign function for matrix_proxy.
- simplified a bit the triqs_clef_auto_assign for gf.
This commit is contained in:
Olivier Parcollet 2014-04-07 13:21:36 +02:00
parent 2fdba13bc5
commit e1e9ee20fd
2 changed files with 8 additions and 9 deletions

View File

@ -120,6 +120,8 @@ namespace arrays {
friend std::ostream &operator<<(std::ostream &out, matrix_tensor_proxy const &x) { friend std::ostream &operator<<(std::ostream &out, matrix_tensor_proxy const &x) {
return out << view_type{x}; return out << view_type{x};
} }
template <typename F> friend void triqs_clef_auto_assign(matrix_tensor_proxy x, F &&f) { foreach(x(), std::forward<F>(f)); }
}; };
template <typename A, bool IsMatrix> template <typename A, bool IsMatrix>

View File

@ -345,22 +345,20 @@ namespace gfs {
triqs_clef_auto_assign(g, rhs); triqs_clef_auto_assign(g, rhs);
} }
template <bool B, typename G, typename RHS> template <typename G, typename RHS> void triqs_gf_clef_auto_assign_impl_aux_assign(G &&g, RHS &&rhs) {
void triqs_gf_clef_auto_assign_impl_aux_assign(G &&g, RHS &&rhs, std::integral_constant<bool, B>) {
std::forward<G>(g) = std::forward<RHS>(rhs); std::forward<G>(g) = std::forward<RHS>(rhs);
} }
template <typename G, bool B, typename Expr, int... Is> template <typename G, typename Expr, int... Is>
void triqs_gf_clef_auto_assign_impl_aux_assign(G &&g, clef::make_fun_impl<Expr, Is...> &&rhs, std::integral_constant<bool, B>) { void triqs_gf_clef_auto_assign_impl_aux_assign(G &&g, clef::make_fun_impl<Expr, Is...> &&rhs) {
triqs_clef_auto_assign_impl(std::forward<G>(g), std::forward<clef::make_fun_impl<Expr, Is...>>(rhs), triqs_clef_auto_assign(std::forward<G>(g), std::forward<clef::make_fun_impl<Expr, Is...>>(rhs));
std::integral_constant<bool, B>());
} }
template <typename RHS, typename Variable, typename Target, typename Opt, bool IsView> template <typename RHS, typename Variable, typename Target, typename Opt, bool IsView>
void triqs_clef_auto_assign_impl(gf_impl<Variable, Target, Opt, IsView, false> &g, RHS const &rhs, void triqs_clef_auto_assign_impl(gf_impl<Variable, Target, Opt, IsView, false> &g, RHS const &rhs,
std::integral_constant<bool, false>) { std::integral_constant<bool, false>) {
for (auto const &w : g.mesh()) { for (auto const &w : g.mesh()) {
triqs_gf_clef_auto_assign_impl_aux_assign(g[w], rhs(w), std::integral_constant<bool, false>()); triqs_gf_clef_auto_assign_impl_aux_assign(g[w], rhs(w));
//(*this)[w] = rhs(w); //(*this)[w] = rhs(w);
} }
} }
@ -369,8 +367,7 @@ namespace gfs {
void triqs_clef_auto_assign_impl(gf_impl<Variable, Target, Opt, IsView, false> &g, RHS const &rhs, void triqs_clef_auto_assign_impl(gf_impl<Variable, Target, Opt, IsView, false> &g, RHS const &rhs,
std::integral_constant<bool, true>) { std::integral_constant<bool, true>) {
for (auto const &w : g.mesh()) { for (auto const &w : g.mesh()) {
triqs_gf_clef_auto_assign_impl_aux_assign(g[w], triqs::tuple::apply(rhs, w.components_tuple()), triqs_gf_clef_auto_assign_impl_aux_assign(g[w], triqs::tuple::apply(rhs, w.components_tuple()));
std::integral_constant<bool, true>());
//(*this)[w] = triqs::tuple::apply(rhs, w.components_tuple()); //(*this)[w] = triqs::tuple::apply(rhs, w.components_tuple());
} }
} }