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_shgshellordering_h_
22 #define _libint2_src_bin_libint_shgshellordering_h_
23
24 #include <cmath>
25
26 #include <libint2/config.h>
27
28 namespace libint2 {
29
30 enum SHGShellOrdering {
31 SHGShellOrdering_Standard = LIBINT_SHGSHELL_ORDERING_STANDARD,
32 SHGShellOrdering_Gaussian = LIBINT_SHGSHELL_ORDERING_GAUSSIAN,
33 SHGShellOrdering_MOLDEN // same as Gaussian
34 };
35
36 }
37
38 //
39 // Macros that define orderings
40 //
41
42 #if LIBINT_SHGSHELL_ORDERING == LIBINT_SHGSHELL_ORDERING_STANDARD
43
44 /* Computes an index to a Cartesian function within a shell given
45 * l = total angular momentum
46 * m = real solid harmonic index (|m| = the absolute value of the projection of
47 * the angular momentum on the z axis) m runs from -l to l
48 */
49 namespace libint2 {
INT_SOLIDHARMINDEX(int l,int m)50 inline int INT_SOLIDHARMINDEX(int l, int m) { return m + l; }
51 }
52 LIBINT_DEPRECATED("please use libint2::INT_SOLIDHARMINDEX instead")
INT_SOLIDHARMINDEX(int l,int m)53 inline int INT_SOLIDHARMINDEX(int l, int m) { return libint2::INT_SOLIDHARMINDEX(l, m); }
54
55 /* This sets up the above loop over cartesian exponents as follows
56 * int m;
57 * FOR_SOLIDHARM(l,m)
58 * END_FOR_SOLIDHARM
59 */
60 #define FOR_SOLIDHARM(l, m) for ((m) = -(l); (m) <= (l); ++(m)) {
61 #define END_FOR_SOLIDHARM }
62
63 #endif // Standard ordering
64
65 #if LIBINT_SHGSHELL_ORDERING == LIBINT_SHGSHELL_ORDERING_GAUSSIAN
66
67 /* Computes an index to a Cartesian function within a shell given
68 * l = total angular momentum
69 * m = real solid harmonic index (|m| = the absolute value of the projection of
70 * the angular momentum on the z axis) m runs as 0, +1, -1, +2, -2 ... +l, -l
71 */
72 namespace libint2 {
INT_SOLIDHARMINDEX(int l,int m)73 inline int INT_SOLIDHARMINDEX(int l, int m) {
74 return 2 * std::abs(m) + (m > 0 ? -1 : 0);
75 }
76 }
77 LIBINT_DEPRECATED("please use libint2::INT_SOLIDHARMINDEX instead")
INT_SOLIDHARMINDEX(int l,int m)78 inline int INT_SOLIDHARMINDEX(int l, int m) { return libint2::INT_SOLIDHARMINDEX(l, m); }
79
80 /* This sets up the above loop over cartesian exponents as follows
81 * int m;
82 * FOR_SOLIDHARM(l,m)
83 * END_FOR_SOLIDHARM
84 */
85 #define FOR_SOLIDHARM(l, m) \
86 for ((m) = 0; (m) != (l) + 1; (m) = ((m) > 0 ? -(m) : 1 - (m))) {
87 #define END_FOR_SOLIDHARM }
88
89 #endif // Gaussian ordering
90
91 /// these always-available macros encode orderings assumed by Molden
92
93 namespace libint2 {
INT_SOLIDHARMINDEX_MOLDEN(int l,int m)94 inline int INT_SOLIDHARMINDEX_MOLDEN(int l, int m) {
95 return 2 * std::abs(m) + (m > 0 ? -1 : 0);
96 }
97 }
98 LIBINT_DEPRECATED("please use libint2::INT_SOLIDHARMINDEX_MOLDEN instead")
INT_SOLIDHARMINDEX_MOLDEN(int l,int m)99 inline int INT_SOLIDHARMINDEX_MOLDEN(int l, int m) { return libint2::INT_SOLIDHARMINDEX_MOLDEN(l, m); }
100
101 #define FOR_SOLIDHARM_MOLDEN(l, m) \
102 for ((m) = 0; (m) != (l) + 1; (m) = ((m) > 0 ? -(m) : 1 - (m))) {
103 #define END_FOR_SOLIDHARM_MOLDEN }
104
105 #endif // _libint2_src_bin_libint_shgshellordering_h_
106