7 #include "vector3_order.h"
8 #ifdef LIBRPA_USE_LIBRI
9 #include <RI/global/Tensor.h>
11 #include "libri_stub.h"
14 template <
typename TA,
typename Tcell>
17 typedef std::array<Tcell, 3> TC;
18 typedef std::pair<TA, TC> TAC;
21 template <
typename TA,
typename Tcell,
typename TAout = TA,
typename Tcellout = Tcell>
22 std::pair<std::set<TAout>, std::set<typename libri_types<TAout, Tcellout>::TAC>>
23 get_s0_s1_for_comm_map2(
const std::vector<std::pair<TA, TA>>& atpairs,
26 std::set<TAout> set_s0;
27 std::set<typename libri_types<TAout, Tcellout>::TAC> set_s1;
28 for (
const auto& atpair: atpairs)
30 set_s0.insert(atpair.first);
31 for (
const auto& cell: cells)
33 typename libri_types<TA, Tcell>::TC c {cell.x, cell.y, cell.z};
34 set_s1.insert({atpair.second, c});
37 return {set_s0, set_s1};
40 template <
typename TA,
typename TAout = TA>
41 std::pair<std::set<TAout>, std::set<TAout>>
42 get_s0_s1_for_comm_map2_first(
const std::vector<std::pair<TA, TA>>& atpairs)
44 std::set<TAout> set_s0;
45 std::set<TAout> set_s1;
46 for (
const auto& atpair: atpairs)
48 set_s0.insert(atpair.first);
49 set_s1.insert(atpair.second);
51 return {set_s0, set_s1};
54 template <
typename TA,
typename TAout = TA>
55 std::pair<std::set<TAout>, std::set<TAout>>
56 get_s0_s1_for_comm_map2_first(
const std::set<std::pair<TA, TA>>& atpairs)
58 std::set<TAout> set_s0;
59 std::set<TAout> set_s1;
60 for (
const auto& atpair: atpairs)
62 set_s0.insert(atpair.first);
63 set_s1.insert(atpair.second);
65 return {set_s0, set_s1};
68 #ifdef LIBRPA_USE_LIBRI
70 std::ostream& operator<<(std::ostream& os,
const RI::Tensor<T>& t)
72 switch (t.shape.size())
76 for (
size_t i0 = 0; i0 < t.shape[0]; ++i0) os << t(i0) <<
" ";
82 for (
size_t i0 = 0; i0 < t.shape[0]; ++i0)
84 for (
size_t i1 = 0; i1 < t.shape[1]; ++i1)
85 os << (std::abs(t(i0, i1)) > 1E-10 ? t(i0, i1) : 0) <<
" ";
92 os <<
"[" << std::endl;
93 for (
size_t i0 = 0; i0 < t.shape[0]; ++i0)
95 for (
size_t i1 = 0; i1 < t.shape[1]; ++i1)
97 for (
size_t i2 = 0; i2 < t.shape[2]; ++i2) os << t(i0, i1, i2) <<
" ";
102 os <<
"]" << std::endl;
106 throw std::invalid_argument(std::string(__FILE__) +
" line " +
107 std::to_string(__LINE__));
Utilies to handle atomic model and related data.
Definition: libri_stub.h:19
Definition: vector3_order.h:15
Definition: libri_utils.h:16