LIBINT 2.7.2
cgshell_ordering.h
1/*
2 * Copyright (C) 2004-2021 Edward F. Valeev
3 *
4 * This file is part of Libint.
5 *
6 * Libint 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 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. 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 from libint2_params.h */
26#ifndef LIBINT_CARTGAUSS_MAX_AM
27# include <libint2/util/generated/libint2_params.h>
28# define LIBINT_CARTGAUSS_MAX_AM LIBINT2_CARTGAUSS_MAX_AM
29#endif
30#ifndef LIBINT_CGSHELL_ORDERING
31# include <libint2/util/generated/libint2_params.h>
32# define LIBINT_CGSHELL_ORDERING LIBINT2_CGSHELL_ORDERING
33# define LIBINT_CGSHELL_ORDERING_STANDARD LIBINT2_CGSHELL_ORDERING_STANDARD
34# define LIBINT_CGSHELL_ORDERING_INTV3 LIBINT2_CGSHELL_ORDERING_INTV3
35# define LIBINT_CGSHELL_ORDERING_GAMESS LIBINT2_CGSHELL_ORDERING_GAMESS
36# define LIBINT_CGSHELL_ORDERING_ORCA LIBINT2_CGSHELL_ORDERING_ORCA
37# define LIBINT_CGSHELL_ORDERING_BAGEL LIBINT2_CGSHELL_ORDERING_BAGEL
38#endif
39
40namespace libint2 {
41
42 enum CGShellOrdering {
43 CGShellOrdering_Standard = LIBINT_CGSHELL_ORDERING_STANDARD,
44 CGShellOrdering_IntV3 = LIBINT_CGSHELL_ORDERING_INTV3,
45 CGShellOrdering_GAMESS = LIBINT_CGSHELL_ORDERING_GAMESS,
46 CGShellOrdering_ORCA = LIBINT_CGSHELL_ORDERING_ORCA,
47 CGShellOrdering_BAGEL = LIBINT_CGSHELL_ORDERING_BAGEL,
48 CGShellOrdering_MOLDEN
49 };
50
51};
52
53#include <libint2/cgshellinfo.h>
54
55//
56// Macros common to all orderings
57//
58
59/* Computes the number of Cartesian function in a shell given
60 * am = total angular momentum
61 * formula: (am*(am+1))/2 + am+1;
62 */
63namespace libint2 {
64inline int INT_NCART(int am) { return ((am + 2) * (am + 1)) >> 1; }
65}
66LIBINT_DEPRECATED("please use libint2::INT_NCART instead")
67inline int INT_NCART(int am) { return libint2::INT_NCART(am); }
68
69/* For a given ang. mom., am, with n cartesian functions, compute the
70 * number of cartesian functions for am+1 or am-1
71 */
72namespace libint2 {
73inline int INT_NCART_DEC(int am, int n) { return n - am - 1; }
74inline int INT_NCART_INC(int am, int n) { return n + am + 2; }
75}
76LIBINT_DEPRECATED("please use libint2::INT_NCART_DEC instead")
77inline int INT_NCART_DEC(int am, int n) { return libint2::INT_NCART_DEC(am, n); }
78LIBINT_DEPRECATED("please use libint2::INT_NCART_INC instead")
79inline int INT_NCART_INC(int am, int n) { return libint2::INT_NCART_INC(am, n); }
80
81//
82// Macros that define orderings
83//
84
85#if LIBINT_CGSHELL_ORDERING == LIBINT_CGSHELL_ORDERING_STANDARD
86// this piece of code is from https://github.com/ValeevGroup/mpqc/blob/master/src/lib/chemistry/qc/basis/macros_cca.h#L31
87// Copyright Edward Valeev
88
89/* Computes an index to a Cartesian function within a shell given
90 * am = total angular momentum
91 * i = the exponent of x (i is used twice in the macro--beware side effects)
92 * j = the exponent of y
93 * formula: (am - i + 1)*(am - i)/2 + am - i - j unless i==am, then 0
94 * The following loop will generate indices in the proper order:
95 * cartindex = 0;
96 * for (i=am; i>=0; i--) {
97 * for (j=am-i; j>=0; j--) {
98 * do_it_with(cartindex);
99 * cartindex++;
100 * }
101 * }
102 */
103namespace libint2 {
104inline int INT_CARTINDEX(unsigned int am, int i, int j) {
105 return (((am - i + 1) * (am - i)) >> 1) + am - i - j;
106}
107}
108LIBINT_DEPRECATED("please use libint2::INT_CARTINDEX instead")
109inline int INT_CARTINDEX(unsigned int am, int i, int j) { return libint2::INT_CARTINDEX(am, i, j); }
110
111/* This sets up the above loop over cartesian exponents as follows
112 * int i, j, k;
113 * FOR_CART(i,j,k,am)
114 * Stuff using i,j,k.
115 * END_FOR_CART
116 */
117#define FOR_CART(i,j,k,am) for((i)=(am);(i)>=0;(i)--) {\
118 for((j)=(am)-(i);(j)>=0;(j)--) \
119 { (k) = (am) - (i) - (j);
120#define END_FOR_CART }}
121
122// end of code from https://github.com/ValeevGroup/mpqc/blob/master/src/lib/chemistry/qc/basis/macros_cca.h#L31
123
124#endif // STANDARD ordering
125
126#if LIBINT_CGSHELL_ORDERING == LIBINT_CGSHELL_ORDERING_INTV3
127// this piece of code is from MPQC:src/lib/chemistry/qc/intv3/macros.h
128// Copyright Curtis Janssen
129
130/* Computes an index to a Cartesian function within a shell given
131 * am = total angular momentum
132 * i = the exponent of x (i is used twice in the macro--beware side effects)
133 * j = the exponent of y
134 * formula: am*(i+1) - (i*(i+1))/2 + i+1 - j - 1
135 * The following loop will generate indices in the proper order:
136 * cartindex = 0;
137 * for (i=0; i<=am; i++) {
138 * for (k=0; k<=am-i; k++) {
139 * j = am - i - k;
140 * do_it_with(cartindex); // cartindex == INT_CARTINDEX(am,i,j)
141 * cartindex++;
142 * }
143 * }
144 */
145namespace libint2 {
146inline int INT_CARTINDEX(unsigned int am, int i, int j) {
147 return ((((am + 1) << 1)- i) * (i + 1)) >> 1 - j - 1 ;
148}
149}
150LIBINT_DEPRECATED("please use libint2::INT_CARTINDEX instead")
151inline int INT_CARTINDEX(unsigned int am, int i, int j) { return libint2::INT_CARTINDEX(am, i, j); }
152
153/* This sets up the above loop over cartesian exponents as follows
154 * FOR_CART(i,j,k,am)
155 * Stuff using i,j,k.
156 * END_FOR_CART
157 */
158#define FOR_CART(i,j,k,am) for((i)=0;(i)<=(am);(i)++) {\
159 for((k)=0;(k)<=(am)-(i);(k)++) \
160 { (j) = (am) - (i) - (k);
161#define END_FOR_CART }}
162
163#endif // INTV3 ordering
164
165#if LIBINT_CGSHELL_ORDERING == LIBINT_CGSHELL_ORDERING_GAMESS
166// for definition of the ordering see CGShellInfo
167
168/* Computes an index to a Cartesian function within a shell given
169 * am = total angular momentum
170 * i = the exponent of x (i is used twice in the macro--beware side effects)
171 * j = the exponent of y
172 * for this ordering there is no formula
173 */
174namespace libint2 {
175inline int INT_CARTINDEX(unsigned int am, int i, int j) {
177}
178}
179LIBINT_DEPRECATED("please use libint2::INT_CARTINDEX instead")
180inline int INT_CARTINDEX(unsigned int am, int i, int j) { return libint2::INT_CARTINDEX(am, i, j); }
181
182/* This sets up the above loop over cartesian exponents as follows
183 * FOR_CART(i,j,k,am)
184 * Stuff using i,j,k.
185 * END_FOR_CART
186 */
187#define FOR_CART(i,j,k,am) for(int __xyz=0; __xyz<INT_NCART(am); ++__xyz) { \
188 CGShellInfo< CGShellOrderingData<CGShellOrdering_GAMESS> >::cartindex_to_ijk(am,__xyz,i,j,k);
189#define END_FOR_CART }
190
191#endif // GAMESS ordering
192
193#if LIBINT_CGSHELL_ORDERING == LIBINT_CGSHELL_ORDERING_ORCA
194// for definition of the ordering see CGShellInfo
195
196/* Computes an index to a Cartesian function within a shell given
197 * am = total angular momentum
198 * i = the exponent of x (i is used twice in the macro--beware side effects)
199 * j = the exponent of y
200 * for this ordering there is no formula
201 */
202namespace libint2 {
203inline int INT_CARTINDEX(unsigned int am, int i, int j) {
205}
206}
207LIBINT_DEPRECATED("please use libint2::INT_CARTINDEX instead")
208inline int INT_CARTINDEX(unsigned int am, int i, int j) { return libint2::INT_CARTINDEX(am, i, j); }
209
210/* This sets up the above loop over cartesian exponents as follows
211 * FOR_CART(i,j,k,am)
212 * Stuff using i,j,k.
213 * END_FOR_CART
214 */
215#define FOR_CART(i,j,k,am) for(int __xyz=0; __xyz<INT_NCART(am); ++__xyz) { \
216 CGShellInfo< CGShellOrderingData<CGShellOrdering_ORCA> >::cartindex_to_ijk(am,__xyz,i,j,k);
217#define END_FOR_CART }
218
219#endif // ORCA ordering
220
221#if LIBINT_CGSHELL_ORDERING == LIBINT_CGSHELL_ORDERING_BAGEL
222// permuted version of IntV3 (y in IntV3 = x in Bagel, etc.)
223
224/* Computes an index to a Cartesian function within a shell given
225 * all arguments are used multiple times in the macro--beware side effects)
226 * am = total angular momentum
227 * i = the exponent of x
228 * j = the exponent of y
229 * formula: am*(k+1) - (k*(k+1))/2 + k+1 - i - 1 =
230 * The following loop will generate indices in the proper order:
231 * cartindex = 0;
232 * for (k=0; k<=am; k++) {
233 * for (j=0; j<=am-k; j++) {
234 * i = am - j - k;
235 * do_it_with(cartindex); // cartindex == INT_CARTINDEX(am,i,j)
236 * cartindex++;
237 * }
238 * }
239 */
240namespace libint2 {
241inline int INT_CARTINDEX(unsigned int am, int i, int j) {
242 return ((am + (i + j) + 2) * (am - (i + j) + 1) >> 1) - i -1;
243}
244}
245LIBINT_DEPRECATED("please use libint2::INT_CARTINDEX instead")
246inline int INT_CARTINDEX(unsigned int am, int i, int j) { return libint2::INT_CARTINDEX(am, i, j); }
247
248/* This sets up the above loop over cartesian exponents as follows
249 * FOR_CART(i,j,k,am)
250 * Stuff using i,j,k.
251 * END_FOR_CART
252 */
253#define FOR_CART(i,j,k,am) for((k)=0;(k)<=(am);(k)++) {\
254 for((j)=0;(j)<=(am)-(k);(j)++) \
255 { (i) = (am) - (j) - (k);
256#define END_FOR_CART }}
257
258#endif // Bagel ordering
259
261
262namespace libint2 {
263inline int INT_CARTINDEX_MOLDEN(unsigned int am, int i, int j) {
265}
266}
267LIBINT_DEPRECATED("please use libint2::INT_CARTINDEX_MOLDEN instead")
268inline int INT_CARTINDEX_MOLDEN(unsigned int am, int i, int j) { return libint2::INT_CARTINDEX_MOLDEN(am, i, j); }
269
270/* FOR_CART_MOLDEN(i,j,k,am)
271 * END_FOR_CART_MOLDEN
272 */
273#define FOR_CART_MOLDEN(i,j,k,am) for(int __xyz=0; __xyz<INT_NCART(am); ++__xyz) { \
274 CGShellInfo< CGShellOrderingData<CGShellOrdering_MOLDEN,4u> >::cartindex_to_ijk(am,__xyz,i,j,k);
275#define END_FOR_CART_MOLDEN }
276
277#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:464