LIBINT 2.9.0
shgshell_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_shgshellordering_h_
22#define _libint2_src_bin_libint_shgshellordering_h_
23
24#include <libint2/config.h>
25
26#include <cmath>
27
28namespace libint2 {
29
30enum 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/* Computes an index to a Cartesian function within a shell given
43 * l = total angular momentum
44 * m = real solid harmonic index (|m| = the absolute value of the projection of
45 * the angular momentum on the z axis) m runs from -l to l
46 */
47namespace libint2 {
48inline int INT_SOLIDHARMINDEX_STANDARD(int l, int m) { return m + l; }
49}
50
51/* This sets up the above loop over cartesian exponents as follows
52 * int m;
53 * FOR_SOLIDHARM_STANDARD(l,m)
54 * END_FOR_SOLIDHARM
55 */
56#define FOR_SOLIDHARM_STANDARD(l, m) for ((m) = -(l); (m) <= (l); ++(m)) {
57#define END_FOR_SOLIDHARM }
58
59/* Computes an index to a Cartesian function within a shell given
60 * l = total angular momentum
61 * m = real solid harmonic index (|m| = the absolute value of the projection of
62 * the angular momentum on the z axis) m runs as 0, +1, -1, +2, -2 ... +l, -l
63 */
64namespace libint2 {
65inline int INT_SOLIDHARMINDEX_GAUSSIAN(int l, int m) {
66 return 2 * std::abs(m) + (m > 0 ? -1 : 0);
67}
68}
69
70/* This sets up the above loop over cartesian exponents as follows
71 * int m;
72 * FOR_SOLIDHARM_GAUSSIAN(l,m)
73 * END_FOR_SOLIDHARM
74 */
75#define FOR_SOLIDHARM_GAUSSIAN(l, m) \
76 for ((m) = 0; (m) != (l) + 1; (m) = ((m) > 0 ? -(m) : 1 - (m))) {
80
81namespace libint2 {
82inline int INT_SOLIDHARMINDEX_MOLDEN(int l, int m) {
83 return INT_SOLIDHARMINDEX_GAUSSIAN(l, m);
84}
85}
86
87#define FOR_SOLIDHARM_MOLDEN(l, m) FOR_SOLIDHARM_GAUSSIAN(l, m)
88#define END_FOR_SOLIDHARM_MOLDEN END_FOR_SOLIDHARM
89
90namespace libint2 {
91LIBINT_DEPRECATED(
92 "please use "
93 "libint2::INT_SOLIDHARMINDEX(libint2::solid_harmonics_ordering(), l, m) "
94 "instead. Current function returns the standard or gaussian index based on "
95 "build configuration, not on libint2::set_solid_harmonics_ordering() "
96 "argument.")
97inline int INT_SOLIDHARMINDEX(int l, int m) {
98#if LIBINT_SHGSHELL_ORDERING == LIBINT_SHGSHELL_ORDERING_STANDARD
99 return libint2::INT_SOLIDHARMINDEX_STANDARD(l, m);
100#elif LIBINT_SHGSHELL_ORDERING == LIBINT_SHGSHELL_ORDERING_GAUSSIAN
101 return libint2::INT_SOLIDHARMINDEX_GAUSSIAN(l, m);
102#else
103#error "unknown value of macro LIBINT_SHGSHELL_ORDERING"
104#endif
105}
106
107inline int INT_SOLIDHARMINDEX(int sho, int l, int m) {
108 if (sho == LIBINT_SHGSHELL_ORDERING_STANDARD)
109 return libint2::INT_SOLIDHARMINDEX_STANDARD(l, m);
110 else
111 return libint2::INT_SOLIDHARMINDEX_GAUSSIAN(l, m);
112}
113}
114
115// FOR_SOLIDHARM dispatches to the appropriate FOR_SOLIDHARM_ macro
116#if LIBINT_SHGSHELL_ORDERING == LIBINT_SHGSHELL_ORDERING_STANDARD
117#define FOR_SOLIDHARM FOR_SOLIDHARM_STANDARD
118#elif LIBINT_SHGSHELL_ORDERING == LIBINT_SHGSHELL_ORDERING_GAUSSIAN
119#define FOR_SOLIDHARM FOR_SOLIDHARM_GAUSSIAN
120#else
121#error "unknown value of macro LIBINT_SHGSHELL_ORDERING"
122#endif
123
124#endif // _libint2_src_bin_libint_shgshellordering_h_
Defaults definitions for various parameters assumed by Libint.
Definition algebra.cc:24