sisi4s
Loading...
Searching...
No Matches
Integrals.hpp
Go to the documentation of this file.
1#ifndef __UTIL_INTEGRALS_DEFINED
2#define __UTIL_INTEGRALS_DEFINED
3#include <vector>
4#include <array>
5namespace sisi4s {
6
7// general enum for calculating different parts of the integrals
8enum Index { NO, NV, NP };
9
10template <typename A>
11A permuteIndices(const A &a, size_t i, size_t j) {
12 A b(a);
13 b[i] = a[j];
14 b[j] = a[i];
15 return b;
16}
17
18// p | q
19// r | s
20template <typename A>
21A vSym(const A &a) {
22 return permuteIndices(permuteIndices(a, 0, 1), 2, 3);
23}
24// p q
25// -----
26// r s
27template <typename A>
28A hSym(const A &a) {
29 return permuteIndices(permuteIndices(a, 0, 2), 1, 3);
30}
31// p q
32// -
33// r s
34template <typename A>
35A vlSym(const A &a) {
36 return permuteIndices(a, 0, 2);
37}
38// p|q
39// r s
40template <typename A>
41A upTr(const A &a) {
42 return permuteIndices(a, 0, 1);
43}
44// p q
45// r|s
46template <typename A>
47A downTr(const A &a) {
48 return permuteIndices(a, 2, 3);
49}
50
51// struct used to store information about the names, indices ranges
52// and string indices for ctf. It computes also IntegralInfos for
53// antisymmetry options
55 std::string name;
56 std::array<Index, 4> indices;
57 std::string ids;
58 IntegralInfo(std::string n, std::array<Index, 4> i, std::string is)
59 : name(n)
60 , indices(i)
61 , ids(is) {}
62
63 std::vector<IntegralInfo> getAntisymmetrizers() const {
64 std::vector<IntegralInfo> result;
65 std::vector<IntegralInfo> targets;
66 std::set<std::string> names;
67 // build up targets
68 targets.push_back({upTr(name), upTr(indices), upTr(ids)});
69 targets.push_back({downTr(name), downTr(indices), downTr(ids)});
70 for (auto &t : targets) {
71 std::vector<IntegralInfo> equivalents;
72 // set up the equivalent tensors for the current target
73 equivalents.push_back({vSym(t.name), vSym(t.indices), vSym(t.ids)});
74 equivalents.push_back({hSym(t.name), hSym(t.indices), hSym(t.ids)});
75 equivalents.push_back({vlSym(t.name), vlSym(t.indices), vlSym(t.ids)});
76 for (auto &eq : equivalents) {
77 if (names.count(eq.name) >= 1) continue;
78 names.insert(eq.name);
79 result.push_back({eq.name, eq.indices, eq.ids});
80 }
81 }
82 return result;
83 }
84};
85
86} // namespace sisi4s
87
88#endif
Definition Algorithm.hpp:10
A vlSym(const A &a)
Definition Integrals.hpp:35
A permuteIndices(const A &a, size_t i, size_t j)
Definition Integrals.hpp:11
A vSym(const A &a)
Definition Integrals.hpp:21
A hSym(const A &a)
Definition Integrals.hpp:28
A upTr(const A &a)
Definition Integrals.hpp:41
A downTr(const A &a)
Definition Integrals.hpp:47
Index
Definition Integrals.hpp:8
@ NV
Definition Integrals.hpp:8
@ NO
Definition Integrals.hpp:8
@ NP
Definition Integrals.hpp:8
Definition Integrals.hpp:54
std::vector< IntegralInfo > getAntisymmetrizers() const
Definition Integrals.hpp:63
std::string ids
Definition Integrals.hpp:57
IntegralInfo(std::string n, std::array< Index, 4 > i, std::string is)
Definition Integrals.hpp:58
std::string name
Definition Integrals.hpp:55
std::array< Index, 4 > indices
Definition Integrals.hpp:56