LIBINT 2.9.0
cgshell_ordering.h
1/*
2 * Copyright (C) 2004-2024 Edward F. Valeev
3 *
4 * This file is part of Libint library.
5 *
6 * Libint library is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Libint library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with Libint library. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#ifndef _libint2_src_bin_libint_cgshellordering_h_
22#define _libint2_src_bin_libint_cgshellordering_h_
23
24#include <libint2/config.h>
25/* if this is not defined, then using exported source -- redefine using macro
26 * from libint2_params.h */
27#ifndef LIBINT_CARTGAUSS_MAX_AM
28#include <libint2/util/generated/libint2_params.h>
29#define LIBINT_CARTGAUSS_MAX_AM LIBINT2_CARTGAUSS_MAX_AM
30#endif
31#ifndef LIBINT_CGSHELL_ORDERING
32#include <libint2/util/generated/libint2_params.h>
33#define LIBINT_CGSHELL_ORDERING LIBINT2_CGSHELL_ORDERING
34#define LIBINT_CGSHELL_ORDERING_STANDARD LIBINT2_CGSHELL_ORDERING_STANDARD
35#define LIBINT_CGSHELL_ORDERING_INTV3 LIBINT2_CGSHELL_ORDERING_INTV3
36#define LIBINT_CGSHELL_ORDERING_GAMESS LIBINT2_CGSHELL_ORDERING_GAMESS
37#define LIBINT_CGSHELL_ORDERING_ORCA LIBINT2_CGSHELL_ORDERING_ORCA
38#define LIBINT_CGSHELL_ORDERING_BAGEL LIBINT2_CGSHELL_ORDERING_BAGEL
39#endif
40
41namespace libint2 {
42
43enum CGShellOrdering {
44 CGShellOrdering_Standard = LIBINT_CGSHELL_ORDERING_STANDARD,
45 CGShellOrdering_IntV3 = LIBINT_CGSHELL_ORDERING_INTV3,
46 CGShellOrdering_GAMESS = LIBINT_CGSHELL_ORDERING_GAMESS,
47 CGShellOrdering_ORCA = LIBINT_CGSHELL_ORDERING_ORCA,
48 CGShellOrdering_BAGEL = LIBINT_CGSHELL_ORDERING_BAGEL,
49 CGShellOrdering_MOLDEN
50};
51
52};
53
54#include <libint2/cgshellinfo.h>
55
56//
57// Macros common to all orderings
58//
59
60/* Computes the number of Cartesian function in a shell given
61 * am = total angular momentum
62 * formula: (am*(am+1))/2 + am+1;
63 */
64namespace libint2 {
65inline int INT_NCART(int am) { return ((am + 2) * (am + 1)) >> 1; }
66} // namespace libint2
67LIBINT_DEPRECATED("please use libint2::INT_NCART instead")
68inline int INT_NCART(int am) { return libint2::INT_NCART(am); }
69
70/* For a given ang. mom., am, with n cartesian functions, compute the
71 * number of cartesian functions for am+1 or am-1
72 */
73namespace libint2 {
74inline int INT_NCART_DEC(int am, int n) { return n - am - 1; }
75inline int INT_NCART_INC(int am, int n) { return n + am + 2; }
76} // namespace libint2
77LIBINT_DEPRECATED("please use libint2::INT_NCART_DEC instead")
78inline int INT_NCART_DEC(int am, int n) {
79 return libint2::INT_NCART_DEC(am, n);
80}
81LIBINT_DEPRECATED("please use libint2::INT_NCART_INC instead")
82inline int INT_NCART_INC(int am, int n) {
83 return libint2::INT_NCART_INC(am, n);
84}
85
86//
87// Macros that define orderings
88//
89
90#if LIBINT_CGSHELL_ORDERING == LIBINT_CGSHELL_ORDERING_STANDARD
91// this piece of code is from
92// https://github.com/ValeevGroup/mpqc/blob/master/src/lib/chemistry/qc/basis/macros_cca.h#L31
93// Copyright Edward Valeev
94
95/* Computes an index to a Cartesian function within a shell given
96 * am = total angular momentum
97 * i = the exponent of x (i is used twice in the macro--beware side effects)
98 * j = the exponent of y
99 * formula: (am - i + 1)*(am - i)/2 + am - i - j unless i==am, then 0
100 * The following loop will generate indices in the proper order:
101 * cartindex = 0;
102 * for (i=am; i>=0; i--) {
103 * for (j=am-i; j>=0; j--) {
104 * do_it_with(cartindex);
105 * cartindex++;
106 * }
107 * }
108 */
109namespace libint2 {
110inline int INT_CARTINDEX(unsigned int am, int i, int j) {
111 return (((am - i + 1) * (am - i)) >> 1) + am - i - j;
112}
113} // namespace libint2
114LIBINT_DEPRECATED("please use libint2::INT_CARTINDEX instead")
115inline int INT_CARTINDEX(unsigned int am, int i, int j) {
116 return libint2::INT_CARTINDEX(am, i, j);
117}
118
119/* This sets up the above loop over cartesian exponents as follows
120 * int i, j, k;
121 * FOR_CART(i,j,k,am)
122 * Stuff using i,j,k.
123 * END_FOR_CART
124 */
125#define FOR_CART(i, j, k, am) \
126 for ((i) = (am); (i) >= 0; (i)--) { \
127 for ((j) = (am) - (i); (j) >= 0; (j)--) { \
128 (k) = (am) - (i) - (j);
129#define END_FOR_CART \
130 } \
131 }
132
133// end of code from
134// https://github.com/ValeevGroup/mpqc/blob/master/src/lib/chemistry/qc/basis/macros_cca.h#L31
135
136#endif // STANDARD ordering
137
138#if LIBINT_CGSHELL_ORDERING == LIBINT_CGSHELL_ORDERING_INTV3
139// this piece of code is from MPQC:src/lib/chemistry/qc/intv3/macros.h
140// Copyright Curtis Janssen
141
142/* Computes an index to a Cartesian function within a shell given
143 * am = total angular momentum
144 * i = the exponent of x (i is used twice in the macro--beware side effects)
145 * j = the exponent of y
146 * formula: am*(i+1) - (i*(i+1))/2 + i+1 - j - 1
147 * The following loop will generate indices in the proper order:
148 * cartindex = 0;
149 * for (i=0; i<=am; i++) {
150 * for (k=0; k<=am-i; k++) {
151 * j = am - i - k;
152 * do_it_with(cartindex); // cartindex == INT_CARTINDEX(am,i,j)
153 * cartindex++;
154 * }
155 * }
156 */
157namespace libint2 {
158inline int INT_CARTINDEX(unsigned int am, int i, int j) {
159 return ((((am + 1) << 1) - i) * (i + 1)) >> 1 - j - 1;
160}
161} // namespace libint2
162LIBINT_DEPRECATED("please use libint2::INT_CARTINDEX instead")
163inline int INT_CARTINDEX(unsigned int am, int i, int j) {
164 return libint2::INT_CARTINDEX(am, i, j);
165}
166
167/* This sets up the above loop over cartesian exponents as follows
168 * FOR_CART(i,j,k,am)
169 * Stuff using i,j,k.
170 * END_FOR_CART
171 */
172#define FOR_CART(i, j, k, am) \
173 for ((i) = 0; (i) <= (am); (i)++) { \
174 for ((k) = 0; (k) <= (am) - (i); (k)++) { \
175 (j) = (am) - (i) - (k);
176#define END_FOR_CART \
177 } \
178 }
179
180#endif // INTV3 ordering
181
182#if LIBINT_CGSHELL_ORDERING == LIBINT_CGSHELL_ORDERING_GAMESS
183// for definition of the ordering see CGShellInfo
184
185/* Computes an index to a Cartesian function within a shell given
186 * am = total angular momentum
187 * i = the exponent of x (i is used twice in the macro--beware side effects)
188 * j = the exponent of y
189 * for this ordering there is no formula
190 */
191namespace libint2 {
192inline int INT_CARTINDEX(unsigned int am, int i, int j) {
194 libint2::CGShellOrdering_GAMESS>>::cartindex(am, i, j);
195}
196} // namespace libint2
197LIBINT_DEPRECATED("please use libint2::INT_CARTINDEX instead")
198inline int INT_CARTINDEX(unsigned int am, int i, int j) {
199 return libint2::INT_CARTINDEX(am, i, j);
200}
201
202/* This sets up the above loop over cartesian exponents as follows
203 * FOR_CART(i,j,k,am)
204 * Stuff using i,j,k.
205 * END_FOR_CART
206 */
207#define FOR_CART(i, j, k, am) \
208 for (int __xyz = 0; __xyz < INT_NCART(am); ++__xyz) { \
209 CGShellInfo< \
210 CGShellOrderingData<CGShellOrdering_GAMESS>>::cartindex_to_ijk(am, \
211 __xyz, \
212 i, j, \
213 k);
214#define END_FOR_CART }
215
216#endif // GAMESS ordering
217
218#if LIBINT_CGSHELL_ORDERING == LIBINT_CGSHELL_ORDERING_ORCA
219// for definition of the ordering see CGShellInfo
220
221/* Computes an index to a Cartesian function within a shell given
222 * am = total angular momentum
223 * i = the exponent of x (i is used twice in the macro--beware side effects)
224 * j = the exponent of y
225 * for this ordering there is no formula
226 */
227namespace libint2 {
228inline int INT_CARTINDEX(unsigned int am, int i, int j) {
230 libint2::CGShellOrdering_ORCA>>::cartindex(am, i, j);
231}
232} // namespace libint2
233LIBINT_DEPRECATED("please use libint2::INT_CARTINDEX instead")
234inline int INT_CARTINDEX(unsigned int am, int i, int j) {
235 return libint2::INT_CARTINDEX(am, i, j);
236}
237
238/* This sets up the above loop over cartesian exponents as follows
239 * FOR_CART(i,j,k,am)
240 * Stuff using i,j,k.
241 * END_FOR_CART
242 */
243#define FOR_CART(i, j, k, am) \
244 for (int __xyz = 0; __xyz < INT_NCART(am); ++__xyz) { \
245 CGShellInfo<CGShellOrderingData<CGShellOrdering_ORCA>>::cartindex_to_ijk( \
246 am, __xyz, i, j, k);
247#define END_FOR_CART }
248
249#endif // ORCA ordering
250
251#if LIBINT_CGSHELL_ORDERING == LIBINT_CGSHELL_ORDERING_BAGEL
252// permuted version of IntV3 (y in IntV3 = x in Bagel, etc.)
253
254/* Computes an index to a Cartesian function within a shell given
255 * all arguments are used multiple times in the macro--beware side effects)
256 * am = total angular momentum
257 * i = the exponent of x
258 * j = the exponent of y
259 * formula: am*(k+1) - (k*(k+1))/2 + k+1 - i - 1 =
260 * The following loop will generate indices in the proper order:
261 * cartindex = 0;
262 * for (k=0; k<=am; k++) {
263 * for (j=0; j<=am-k; j++) {
264 * i = am - j - k;
265 * do_it_with(cartindex); // cartindex == INT_CARTINDEX(am,i,j)
266 * cartindex++;
267 * }
268 * }
269 */
270namespace libint2 {
271inline int INT_CARTINDEX(unsigned int am, int i, int j) {
272 return ((am + (i + j) + 2) * (am - (i + j) + 1) >> 1) - i - 1;
273}
274} // namespace libint2
275LIBINT_DEPRECATED("please use libint2::INT_CARTINDEX instead")
276inline int INT_CARTINDEX(unsigned int am, int i, int j) {
277 return libint2::INT_CARTINDEX(am, i, j);
278}
279
280/* This sets up the above loop over cartesian exponents as follows
281 * FOR_CART(i,j,k,am)
282 * Stuff using i,j,k.
283 * END_FOR_CART
284 */
285#define FOR_CART(i, j, k, am) \
286 for ((k) = 0; (k) <= (am); (k)++) { \
287 for ((j) = 0; (j) <= (am) - (k); (j)++) { \
288 (i) = (am) - (j) - (k);
289#define END_FOR_CART \
290 } \
291 }
292
293#endif // Bagel ordering
294
296
297namespace libint2 {
298inline int INT_CARTINDEX_MOLDEN(unsigned int am, int i, int j) {
300 libint2::CGShellOrdering_MOLDEN, 4u>>::cartindex(am, i, j);
301}
302} // namespace libint2
303LIBINT_DEPRECATED("please use libint2::INT_CARTINDEX_MOLDEN instead")
304inline int INT_CARTINDEX_MOLDEN(unsigned int am, int i, int j) {
305 return libint2::INT_CARTINDEX_MOLDEN(am, i, j);
306}
307
308/* FOR_CART_MOLDEN(i,j,k,am)
309 * END_FOR_CART_MOLDEN
310 */
311#define FOR_CART_MOLDEN(i, j, k, am) \
312 for (int __xyz = 0; __xyz < INT_NCART(am); ++__xyz) { \
313 CGShellInfo<CGShellOrderingData<CGShellOrdering_MOLDEN, 4u>>:: \
314 cartindex_to_ijk(am, __xyz, i, j, k);
315#define END_FOR_CART_MOLDEN }
316
317#endif // header guard
Defaults definitions for various parameters assumed by Libint.
Definition algebra.cc:24
provides ordering maps for up to angular momentum lmax and ordering specified by CGShellOrderingSpec
Definition cgshellinfo.h:462
Definition cgshellinfo.h:434