33 #ifndef MADNESS_MRA_DISPLACEMENTS_H__INCLUDED
34 #define MADNESS_MRA_DISPLACEMENTS_H__INCLUDED
38 template <std::
size_t NDIM>
41 static std::vector< Key<NDIM> > disp;
42 static std::vector< Key<NDIM> > disp_periodicsum[64];
47 if (
NDIM == 1) bmax = 7;
48 else if (
NDIM == 2) bmax = 5;
49 else if (
NDIM == 3) bmax = 3;
50 else if (
NDIM == 6) bmax = 3;
60 static bool cmp_keys_periodicsum(
const Key<NDIM>& a,
const Key<NDIM>& b) {
63 uint64_t suma=0, sumb=0;
64 for (std::size_t d=0; d<
NDIM; ++d) {
66 if (la > twonm1) la -= twonm1*2;
67 if (la <-twonm1) la += twonm1*2;
71 if (lb > twonm1) lb -= twonm1*2;
72 if (lb <-twonm1) lb += twonm1*2;
78 static void make_disp(
int bmax) {
80 Vector<Translation,NDIM> d(0);
83 for (std::size_t i=0; i<
NDIM; ++i) num *= (2*bmax + 1);
84 disp.resize(num,Key<NDIM>(0));
88 for (d[0]=-bmax; d[0]<=bmax; ++d[0])
89 disp[num++] = Key<NDIM>(0,d);
92 for (d[0]=-bmax; d[0]<=bmax; ++d[0])
93 for (d[1]=-bmax; d[1]<=bmax; ++d[1])
94 disp[num++] = Key<NDIM>(0,d);
97 for (d[0]=-bmax; d[0]<=bmax; ++d[0])
98 for (d[1]=-bmax; d[1]<=bmax; ++d[1])
99 for (d[2]=-bmax; d[2]<=bmax; ++d[2])
100 disp[num++] = Key<NDIM>(0,d);
102 else if (NDIM == 4) {
103 for (d[0]=-bmax; d[0]<=bmax; ++d[0])
104 for (d[1]=-bmax; d[1]<=bmax; ++d[1])
105 for (d[2]=-bmax; d[2]<=bmax; ++d[2])
106 for (d[3]=-bmax; d[3]<=bmax; ++d[3])
107 disp[num++] = Key<NDIM>(0,d);
109 else if (NDIM == 5) {
110 for (d[0]=-bmax; d[0]<=bmax; ++d[0])
111 for (d[1]=-bmax; d[1]<=bmax; ++d[1])
112 for (d[2]=-bmax; d[2]<=bmax; ++d[2])
113 for (d[3]=-bmax; d[3]<=bmax; ++d[3])
114 for (d[4]=-bmax; d[4]<=bmax; ++d[4])
116 disp[num++] = Key<NDIM>(0,d);
118 else if (NDIM == 6) {
119 for (d[0]=-bmax; d[0]<=bmax; ++d[0])
120 for (d[1]=-bmax; d[1]<=bmax; ++d[1])
121 for (d[2]=-bmax; d[2]<=bmax; ++d[2])
122 for (d[3]=-bmax; d[3]<=bmax; ++d[3])
123 for (d[4]=-bmax; d[4]<=bmax; ++d[4])
124 for (d[5]=-bmax; d[5]<=bmax; ++d[5])
125 disp[num++] = Key<NDIM>(0,d);
131 std::sort(disp.begin(), disp.end(), cmp_keys);
134 static void make_disp_periodicsum(
int bmax,
Level n) {
137 if (bmax > (twon-1)) bmax=twon-1;
144 if ((lx < 0) && (lx+twon > bmax)) b[i++] = lx + twon;
145 if ((lx > 0) && (lx-twon <-bmax)) b[i++] = lx - twon;
147 MADNESS_ASSERT(i <= 4*bmax+1);
150 disp_periodicsum[n] = std::vector< Key<NDIM> >();
151 Vector<long,NDIM> lim(numb);
152 for (IndexIterator index(lim); index; ++index) {
153 Vector<Translation,NDIM> d;
154 for (std::size_t i=0; i<
NDIM; ++i) {
157 disp_periodicsum[n].push_back(Key<NDIM>(n,d));
160 std::sort(disp_periodicsum[n].begin(), disp_periodicsum[n].end(), cmp_keys_periodicsum);
168 if (disp.size() == 0) {
180 MADNESS_ASSERT(NDIM <= 3);
181 return disp_periodicsum[n];
190 #endif // MADNESS_MRA_DISPLACEMENTS_H__INCLUDED
const int NDIM
Definition: tdse1.cc:44
Displacements()
Definition: displacements.h:167
uint64_t distsq() const
Definition: key.h:230
static int bmax_default()
Definition: displacements.h:45
Holds displacements for applying operators to avoid replicating for all operators.
Definition: displacements.h:39
FLOAT a(int j, FLOAT z)
Definition: y1.cc:86
const std::vector< Key< NDIM > > & get_disp(Level n, bool isperiodicsum)
Definition: displacements.h:178
int Level
Definition: key.h:58
#define MADNESS_EXCEPTION(msg, value)
Definition: worldexc.h:88
int64_t Translation
Definition: key.h:57
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
FLOAT b(int j, FLOAT z)
Definition: y1.cc:79
Key is the index for a node of the 2^NDIM-tree.
Definition: key.h:69