10 #ifndef EIGEN_CXX11_TENSORSYMMETRY_DYNAMICSYMMETRY_H 11 #define EIGEN_CXX11_TENSORSYMMETRY_DYNAMICSYMMETRY_H 24 void add(
int one,
int two,
int flags = 0);
26 template<
typename Gen_>
27 inline void add(Gen_) {
add(Gen_::One, Gen_::Two, Gen_::Flags); }
33 template<
typename Op,
typename RV,
typename Index, std::size_t
N,
typename... Args>
34 inline RV
apply(
const std::array<Index, N>& idx, RV initial, Args&&...
args)
const 36 eigen_assert(N >=
m_numIndices &&
"Can only apply symmetry group to objects that have at least the required amount of indices.");
37 for (std::size_t i = 0; i <
size(); i++)
38 initial =
Op::run(
h_permute(i, idx,
typename internal::gen_numeric_list<int, N>::type()),
m_elements[i].flags, initial, std::forward<Args>(
args)...);
42 template<
typename Op,
typename RV,
typename Index,
typename... Args>
43 inline RV
apply(
const std::vector<Index>& idx, RV initial, Args&&...
args)
const 45 eigen_assert(idx.size() >=
m_numIndices &&
"Can only apply symmetry group to objects that have at least the required amount of indices.");
46 for (std::size_t i = 0; i <
size(); i++)
54 template<
typename Tensor_,
typename... IndexTypes>
57 static_assert(
sizeof...(otherIndices) + 1 == Tensor_::NumIndices,
"Number of indices used to access a tensor coefficient must be equal to the rank of the tensor.");
58 return operator()(tensor, std::array<typename Tensor_::Index, Tensor_::NumIndices>{{firstIndex, otherIndices...}});
61 template<
typename Tensor_>
72 for (std::size_t i = 0; i < representation.size(); i++)
73 if (i != (
size_t)representation[i])
82 constexpr
inline Generator(
int one_,
int two_,
int flags_) : one(one_), two(two_), flags(flags_) {}
90 template<
typename Index, std::size_t
N,
int... n>
91 inline std::array<Index, N>
h_permute(std::size_t which,
const std::array<Index, N>& idx, internal::numeric_list<int, n...>)
const 93 return std::array<Index, N>{{ idx[n >= m_numIndices ? n : m_elements[which].representation[n]]... }};
96 template<
typename Index>
97 inline std::vector<Index>
h_permute(std::size_t which, std::vector<Index> idx)
const 99 std::vector<Index> result;
100 result.reserve(idx.size());
102 result.push_back(idx[k]);
103 for (std::size_t i = m_numIndices; i < idx.size(); i++)
104 result.push_back(idx[i]);
114 if (k == (std::size_t)g.
one)
116 else if (k == (std::size_t)g.
two)
127 return mul(
ge(g1), g2);
132 return mul(g1,
ge(g2));
142 for (
auto ee : m_elements) {
144 return ee.flags ^ e.
flags;
153 template<
typename... Gen>
167 template<
typename Gen1,
typename... GenNext>
189 result.representation.push_back(v);
202 std::size_t newNumIndices = (one > two) ? one : two + 1;
204 gelem.representation.reserve(newNumIndices);
205 for (std::size_t i =
m_numIndices; i < newNumIndices; i++)
206 gelem.representation.push_back(i);
238 for (std::size_t i = 1; i < coset_order; i++)
242 std::size_t coset_rep = coset_order;
250 for (std::size_t i = 1; i < coset_order; i++)
256 coset_rep += coset_order;
262 switch (flagDiffOfSameGenerator) {
289 #endif // EIGEN_CXX11_TENSORSYMMETRY_DYNAMICSYMMETRY_H
GroupElement mul(GroupElement g1, Generator g2) const
RV apply(const std::array< Index, N > &idx, RV initial, Args &&...args) const
internal::tensor_symmetry_value_setter< Tensor_, DynamicSGroup > operator()(Tensor_ &tensor, typename Tensor_::Index firstIndex, IndexTypes...otherIndices) const
GroupElement mul(GroupElement, GroupElement) const
GroupElement mul(Generator g1, GroupElement g2) const
std::vector< GroupElement > m_elements
RV apply(const std::vector< Index > &idx, RV initial, Args &&...args) const
void updateGlobalFlags(int flagDiffOfSameGenerator)
DynamicSGroup & operator=(DynamicSGroup &&o)
DynamicSGroupFromTemplateArgs< Gen... > & operator=(DynamicSGroupFromTemplateArgs< Gen... > &&o)
int findElement(GroupElement e) const
DynamicSGroupFromTemplateArgs< Gen... > & operator=(const DynamicSGroupFromTemplateArgs< Gen... > &o)
DynamicSGroup & operator=(const DynamicSGroup &o)
void addAntiHermiticity(int one, int two)
std::vector< int > representation
GroupElement mul(Generator g1, Generator g2) const
DynamicSGroupFromTemplateArgs(DynamicSGroupFromTemplateArgs &&other)
GroupElement ge(Generator const &g) const
DynamicSGroupFromTemplateArgs(DynamicSGroupFromTemplateArgs const &other)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
std::vector< Generator > m_generators
void addSymmetry(int one, int two)
DynamicSGroup(const DynamicSGroup &o)
DynamicSGroup(DynamicSGroup &&o)
void addHermiticity(int one, int two)
void add_all(internal::type_list<>)
void add_all(internal::type_list< Gen1, GenNext... >)
internal::tensor_symmetry_value_setter< Tensor_, DynamicSGroup > operator()(Tensor_ &tensor, std::array< typename Tensor_::Index, Tensor_::NumIndices > const &indices) const
constexpr Generator(int one_, int two_, int flags_)
void add(int one, int two, int flags=0)
#define eigen_internal_assert(x)
DynamicSGroupFromTemplateArgs()
void run(Expr &expr, Dev &dev)
std::vector< Index > h_permute(std::size_t which, std::vector< Index > idx) const
void swap(mpfr::mpreal &x, mpfr::mpreal &y)
void addAntiSymmetry(int one, int two)
std::array< Index, N > h_permute(std::size_t which, const std::array< Index, N > &idx, internal::numeric_list< int, n... >) const