MPQC 2.3.1

- Main Page
- Related Pages
- Classes
- Files

- File List

intv3/macros.h
1 /*
2 * macros.h
3 *
4 * Copyright (C) 1996 Limit Point Systems, Inc.
5 *
6 * Author: Curtis Janssen <cljanss@ca.sandia.gov>
7 * Maintainer: LPS
8 *
9 * This file is part of the SC Toolkit.
10 *
11 * The SC Toolkit is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU Library General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
14 * any later version.
15 *
16 * The SC Toolkit is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * You should have received a copy of the GNU Library General Public License
22 * along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 * The U.S. Government is granted a limited license as per AL 91-7.
26 */
27
28 /* True if the integral is nonzero. */
29 #define INT_NONZERO(x) (((x)< -1.0e-10)||((x)> 1.0e-10))
30
31 /* Computes an index to a Cartesian function within a shell given
32 * am = total angular momentum
33 * i = the exponent of x (i is used twice in the macro--beware side effects)
34 * j = the exponent of y
35 * formula: am*(i+1) - (i*(i+1))/2 + i+1 - j - 1
36 * The following loop will generate indices in the proper order:
37 * cartindex = 0;
38 * for (i=0; i<=am; i++) {
39 * for (k=0; k<=am-i; k++) {
40 * j = am - i - k;
41 * do_it_with(cartindex); // cartindex == INT_CARTINDEX(am,i,j)
42 * cartindex++;
43 * }
44 * }
45 */
46 #define INT_CARTINDEX(am,i,j) (((((((am)+1)<<1)-(i))*((i)+1))>>1)-(j)-1)
47
48 /* This sets up the above loop over cartesian exponents as follows
49 * FOR_CART(i,j,k,am)
50 * Stuff using i,j,k.
51 * END_FOR_CART
52 */
53 #define FOR_CART(i,j,k,am) for((i)=0;(i)<=(am);(i)++) {\
54 for((k)=0;(k)<=(am)-(i);(k)++) \
55 { (j) = (am) - (i) - (k);
56 #define END_FOR_CART }}
57
58 /* This sets up a loop over all of the generalized contractions
59 * and all of the cartesian exponents.
60 * gc is the number of the gen con
61 * index is the index within the current gen con.
62 * i,j,k are the angular momentum for x,y,z
63 * sh is the shell pointer
64 */
65 #define FOR_GCCART(gc,index,i,j,k,sh)\
66 for ((gc)=0; (gc)<(sh)->ncon; (gc)++) {\
67 (index)=0;\
68 FOR_CART(i,j,k,(sh)->type[gc].am)
69
70 #define FOR_GCCART_GS(gc,index,i,j,k,sh)\
71 for ((gc)=0; (gc)<(sh)->ncontraction(); (gc)++) {\
72 (index)=0;\
73 FOR_CART(i,j,k,(sh)->am(gc))
74
75 #define END_FOR_GCCART(index)\
76 (index)++;\
77 END_FOR_CART\
78 }
79
80 #define END_FOR_GCCART_GS(index)\
81 (index)++;\
82 END_FOR_CART\
83 }
84
85 /* These are like the above except no index is kept track of. */
86 #define FOR_GCCART2(gc,i,j,k,sh)\
87 for ((gc)=0; (gc)<(sh)->ncon; (gc)++) {\
88 FOR_CART(i,j,k,(sh)->type[gc].am)
89
90 #define END_FOR_GCCART2\
91 END_FOR_CART\
92 }
93
94 /* These are used to loop over shells, given the centers structure
95 * and the center index, and shell index. */
96 #define FOR_SHELLS(c,i,j) for((i)=0;(i)<(c)->n;i++) {\
97 for((j)=0;(j)<(c)->center[(i)].basis.n;j++) {
98 #define END_FOR_SHELLS }}
99
100 /* Computes the number of Cartesian function in a shell given
101 * am = total angular momentum
102 * formula: (am*(am+1))/2 + am+1;
103 */
104 #define INT_NCART(am) ((am>=0)?((((am)+2)*((am)+1))>>1):0)
105
106 /* Like INT_NCART, but only for nonnegative arguments. */
107 #define INT_NCART_NN(am) ((((am)+2)*((am)+1))>>1)
108
109 /* For a given ang. mom., am, with n cartesian functions, compute the
110 * number of cartesian functions for am+1 or am-1
111 */
112 #define INT_NCART_DEC(am,n) ((n)-(am)-1)
113 #define INT_NCART_INC(am,n) ((n)+(am)+2)
114
115 /* Computes the number of pure angular momentum functions in a shell
116 * given am = total angular momentum
117 */
118 #define INT_NPURE(am) (2*(am)+1)
119
120 /* Computes the number of functions in a shell given
121 * pu = pure angular momentum boolean
122 * am = total angular momentum
123 */
124 #define INT_NFUNC(pu,am) ((pu)?INT_NPURE(am):INT_NCART(am))
125
126 /* Given a centers pointer and a shell number, this evaluates the
127 * pointer to that shell. */
128 #define INT_SH(c,s) ((c)->center[(c)->center_num[s]].basis.shell[(c)->shell_num[s]])
129
130 /* Given a centers pointer and a shell number, get the angular momentum
131 * of that shell. */
132 #define INT_SH_AM(c,s) ((c)->center[(c)->center_num[s]].basis.shell[(c)->shell_num[s]].type.am)
133
134 /* Given a centers pointer and a shell number, get pure angular momentum
135 * boolean for that shell. */
136 #define INT_SH_PU(c,s) ((c)->center[(c)->center_num[s]].basis.shell[(c)->shell_num[s]].type.puream)
137
138 /* Given a centers pointer, a center number, and a shell number,
139 * get the angular momentum of that shell. */
140 #define INT_CE_SH_AM(c,a,s) ((c)->center[(a)].basis.shell[(s)].type.am)
141
142 /* Given a centers pointer, a center number, and a shell number,
143 * get pure angular momentum boolean for that shell. */
144 #define INT_CE_SH_PU(c,a,s) ((c)->center[(a)].basis.shell[(s)].type.puream)
145
146 /* Given a centers pointer and a shell number, compute the number
147 * of functions in that shell. */
148 /* #define INT_SH_NFUNC(c,s) INT_NFUNC(INT_SH_PU(c,s),INT_SH_AM(c,s)) */
149 #define INT_SH_NFUNC(c,s) ((c)->center[(c)->center_num[s]].basis.shell[(c)->shell_num[s]].nfunc)
150
151 /* These macros assist in looping over the unique integrals
152 * in a shell quartet. The exy variables are booleans giving
153 * information about the equivalence between shells x and y. The nx
154 * variables give the number of functions in each shell, x. The
155 * i,j,k are the current values of the looping indices for shells 1, 2, and 3.
156 * The macros return the maximum index to be included in a summation
157 * over indices 1, 2, 3, and 4.
158 * These macros require canonical integrals. This requirement comes
159 * from the need that integrals of the shells (1 2|2 1) are not
160 * used. The integrals (1 2|1 2) must be used with these macros to
161 * get the right nonredundant integrals.
162 */
163 #define INT_MAX1(n1) ((n1)-1)
164 #define INT_MAX2(e12,i,n2) ((e12)?(i):((n2)-1))
165 #define INT_MAX3(e13e24,i,n3) ((e13e24)?(i):((n3)-1))
166 #define INT_MAX4(e13e24,e34,i,j,k,n4) \
167 ((e34)?(((e13e24)&&((k)==(i)))?(j):(k)) \
168 :((e13e24)&&((k)==(i)))?(j):(n4)-1)
169 /* A note on integral symmetries:
170 * There are 15 ways of having equivalent indices.
171 * There are 8 of these which are important for determining the
172 * nonredundant integrals (that is there are only 8 ways of counting
173 * the number of nonredundant integrals in a shell quartet)
174 * Integral type Integral Counting Type
175 * 1 (1 2|3 4) 1
176 * 2 (1 1|3 4) 2
177 * 3 (1 2|1 4) ->1
178 * 4 (1 2|3 1) ->1
179 * 5 (1 1|1 4) 3
180 * 6 (1 1|3 1) ->2
181 * 7 (1 2|1 1) ->5
182 * 8 (1 1|1 1) 4
183 * 9 (1 2|2 4) ->1
184 * 10 (1 2|3 2) ->1
185 * 11 (1 2|3 3) 5
186 * 12 (1 1|3 3) 6
187 * 13 (1 2|1 2) 7
188 * 14 (1 2|2 1) 8 reduces to 7 thru canonicalization
189 * 15 (1 2|2 2) ->5
190 */