~ubuntu-branches/ubuntu/vivid/psicode/vivid

« back to all changes in this revision

Viewing changes to src/bin/detci/s3.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck, Michael Banck, Daniel Leidert
  • Date: 2009-02-23 00:12:02 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090223001202-rutldoy3dimfpesc
Tags: 3.4.0-1
* New upstream release.

[ Michael Banck ]
* debian/patches/01_DESTDIR.dpatch: Refreshed.
* debian/patches/02_FHS.dpatch: Removed, applied upstream.
* debian/patches/03_debian_docdir: Likewise.
* debian/patches/04_man.dpatch: Likewise.
* debian/patches/06_466828_fix_gcc_43_ftbfs.dpatch: Likewise.
* debian/patches/07_464867_move_executables: Fixed and refreshed.
* debian/patches/00list: Adjusted.
* debian/control: Improved description.
* debian/patches-held: Removed.
* debian/rules (install/psi3): Do not ship the ruby bindings for now.

[ Daniel Leidert ]
* debian/rules: Fix txtdir via DEB_MAKE_INSTALL_TARGET.
* debian/patches/01_DESTDIR.dpatch: Refreshed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
** S3.C
3
 
** 
4
 
** Routines for calculating a block of the sigma3 (alpha-beta) vector
5
 
**
6
 
** C. David Sherrill
7
 
** Center for Computational Quantum Chemistry
8
 
** University of Georgia
9
 
** 21 June 1995
10
 
**
11
 
*/
12
 
 
13
 
#include <stdio.h>
14
 
#include <libciomr/libciomr.h>
15
 
#include "structs.h"
16
 
#define EXTERN
17
 
#include "globals.h"
18
 
 
19
 
#define MIN0(a,b) (((a)<(b)) ? (a) : (b))
20
 
#define MAX0(a,b) (((a)>(b)) ? (a) : (b))
21
 
#define INDEX(i,j) ((i>j) ? (ioff[(i)]+(j)) : (ioff[(j)]+(i)))
22
 
 
23
 
 
24
 
/*
25
 
** S3_BLOCK()
26
 
**
27
 
** Calculate a block of the sigma3 vector in equation (9c) of
28
 
** Olsen, Roos, et al.
29
 
**
30
 
*/
31
 
void s3_block(struct stringwr *alplist, struct stringwr *betlist,
32
 
      double **C, double **S, double *tei, int nas, int nbs,
33
 
      int Ja_list, int Jb_list)
34
 
{
35
 
   struct stringwr *Ia, *Ib ;
36
 
   unsigned int Ia_ex, Ib_ex;
37
 
   int Ia_idx, Ib_idx ;
38
 
   int Ja_idx, Jb_idx ;
39
 
   int Ja_sgn, Jb_sgn ;
40
 
   int ij, kl, ijkl ;
41
 
   double tval ;
42
 
 
43
 
   int Iacnt, Jbcnt, *Iaij, *Ibij;
44
 
   unsigned int *Iaridx, *Ibridx;
45
 
   signed char *Iasgn, *Ibsgn;
46
 
   int nirreps;
47
 
   double *Tptr;
48
 
 
49
 
   nirreps = CalcInfo.nirreps;
50
 
 
51
 
   /* loop over Ia */
52
 
   for (Ia=alplist,Ia_idx=0; Ia_idx < nas; Ia_idx++,Ia++) {
53
 
 
54
 
      /* loop over excitations E^a_{kl} from |A(I_a)> */
55
 
      Iacnt = Ia->cnt[Ja_list];
56
 
      Iaridx = Ia->ridx[Ja_list];
57
 
      Iasgn = Ia->sgn[Ja_list];
58
 
      Iaij = Ia->ij[Ja_list];
59
 
      for (Ia_ex=0; Ia_ex < Iacnt; Ia_ex++) {
60
 
         kl = *Iaij++;
61
 
         Tptr = tei + ioff[kl];
62
 
         Ja_idx = *Iaridx++;
63
 
         Ja_sgn = *Iasgn++;
64
 
 
65
 
         /* loop over Ib */
66
 
         for (Ib=betlist, Ib_idx=0; Ib_idx < nbs; Ib_idx++, Ib++) {
67
 
 
68
 
            /* loop over excitations E^b_{ij} from |B(I_b)> */
69
 
            Jbcnt = Ib->cnt[Jb_list];
70
 
            Ibridx = Ib->ridx[Jb_list];
71
 
            Ibsgn = Ib->sgn[Jb_list];
72
 
            Ibij = Ib->ij[Jb_list];
73
 
                  
74
 
            tval = 0.0;
75
 
            for (Ib_ex=0; Ib_ex < Jbcnt; Ib_ex++) {
76
 
               ij = *Ibij++;
77
 
               Jb_idx = *Ibridx++;
78
 
               Jb_sgn = *Ibsgn++;
79
 
               ijkl = ioff[MAX0(ij,kl)] + MIN0(ij,kl);
80
 
               tval += tei[ijkl] * C[Ja_idx][Jb_idx] * 
81
 
                  (double) Ja_sgn * (double) Jb_sgn;
82
 
               }
83
 
            S[Ia_idx][Ib_idx] += tval;
84
 
 
85
 
            } /* end loop over Ib */
86
 
         } /* end loop over Ia excitations */
87
 
   } /* end loop over Ia */
88
 
}
89
 
 
90
 
 
91
 
 
92
 
/*
93
 
** S3_BLOCK_DIAG()
94
 
**
95
 
** Calculate a block of the sigma3 vector in equation (9c) of
96
 
** Olsen, Roos, et al.  For diagonal blocks of sigma.
97
 
**
98
 
** currently assumes that (ij|ij)'s have not been halved
99
 
**
100
 
*/
101
 
void s3_block_diag(struct stringwr *alplist, struct stringwr *betlist,
102
 
      double **C, double **S, double *tei, int nas, int nbs,
103
 
      int Ja_list, int Jb_list)
104
 
{
105
 
   struct stringwr *Ia, *Ib;
106
 
   unsigned int Ia_ex, Ib_ex;
107
 
   int Ia_idx, Ib_idx;
108
 
   int Ja_idx, Jb_idx;
109
 
   int Ja_sgn, Jb_sgn;
110
 
   int ij, kl;
111
 
   double tval,tval2;
112
 
 
113
 
   int Iacnt, Jbcnt, *Iaij, *Ibij;
114
 
   unsigned int *Iaridx, *Ibridx;
115
 
   signed char *Iasgn, *Ibsgn;
116
 
   double *Tptr, *Cptr, *Sptr;
117
 
 
118
 
   /* loop over Ia */
119
 
   for (Ia=alplist,Ia_idx=0; Ia_idx < nas; Ia_idx++,Ia++) {
120
 
 
121
 
      /* loop over excitations E^a_{kl} from |A(I_a)> */
122
 
 
123
 
      Iacnt = Ia->cnt[Ja_list];
124
 
      Iaridx = Ia->ridx[Ja_list];
125
 
      Iasgn = Ia->sgn[Ja_list];
126
 
      Iaij = Ia->ij[Ja_list];
127
 
      for (Ia_ex=0; Ia_ex < Iacnt; Ia_ex++) {
128
 
 
129
 
         Sptr = S[Ia_idx];
130
 
 
131
 
         kl = *Iaij++;
132
 
         Tptr = tei + ioff[kl];
133
 
         Ja_idx = *Iaridx++;
134
 
         Cptr = C[Ja_idx];
135
 
         Ja_sgn = *Iasgn++;
136
 
 
137
 
         /* loop over Ib */
138
 
         for (Ib=betlist, Ib_idx=0; Ib_idx < nbs; Ib_idx++, Ib++) {
139
 
 
140
 
            /* loop over excitations E^b_{ij} from |B(I_b)> */
141
 
            Jbcnt = Ib->cnt[Jb_list];
142
 
            Ibridx = Ib->ridx[Jb_list];
143
 
            Ibsgn = Ib->sgn[Jb_list];
144
 
            Ibij = Ib->ij[Jb_list];
145
 
               
146
 
            tval = 0.0;
147
 
            for (Ib_ex=0; Ib_ex < Jbcnt && (ij = *Ibij++)<=kl; Ib_ex++) {
148
 
               Jb_idx = *Ibridx++;
149
 
               Jb_sgn = *Ibsgn++ * Ja_sgn;
150
 
               tval2 = Tptr[ij] * Cptr[Jb_idx] * Jb_sgn;
151
 
               if (ij == kl) tval2 *= 0.5; 
152
 
               tval += tval2;
153
 
               }
154
 
            *Sptr++ += tval;
155
 
            } /* end loop over Ib */
156
 
         } /* end loop over Ia excitations */
157
 
      } /* end loop over Ia */
158
 
}
159
 
 
160
 
 
161
 
 
162
 
 
163
 
/*
164
 
** S3_BLOCK_ROTF()
165
 
**
166
 
** Calculate a block of the sigma3 (alpha-beta) vector for a diagonal
167
 
**   block of sigma.  The string replacements are fed in through arrays.
168
 
**   Assumes that (ij|ij)'s have not been halved
169
 
**
170
 
** David Sherrill, 13 August 1995
171
 
**
172
 
*/
173
 
void s3_block_rotf(int *Cnt[2], int **Ij[2], 
174
 
      int **Ridx[2], signed char **Sgn[2], double **C, double **S,
175
 
      double *tei, int nas, int nbs)
176
 
{
177
 
   int Ia_ex, Ib_ex;
178
 
   int Ia_idx, Ib_idx ;
179
 
   int Ja_idx, Jb_idx ;
180
 
   int Ja_sgn, Jb_sgn ;
181
 
   int ij, kl, ijkl ;
182
 
   double tval;
183
 
 
184
 
   int Iacnt, Jbcnt, *Iaij, *Ibij;
185
 
   int *Iaridx, *Ibridx;
186
 
   signed char *Iasgn, *Ibsgn;
187
 
   double *Tptr;
188
 
 
189
 
 
190
 
   /* loop over Ia */
191
 
   for (Ia_idx=0; Ia_idx < nas; Ia_idx++) {
192
 
 
193
 
      /* loop over excitations E^a_{kl} from |A(I_a)> */
194
 
      Iacnt = Cnt[0][Ia_idx];
195
 
      Iaridx = Ridx[0][Ia_idx];
196
 
      Iasgn = Sgn[0][Ia_idx];
197
 
      Iaij = Ij[0][Ia_idx];
198
 
      for (Ia_ex=0; Ia_ex < Iacnt; Ia_ex++) {
199
 
         kl = *Iaij++;
200
 
         Tptr = tei + ioff[kl];
201
 
         Ja_idx = *Iaridx++;
202
 
         Ja_sgn = *Iasgn++;
203
 
 
204
 
         /* loop over Ib */
205
 
         for (Ib_idx=0; Ib_idx < nbs; Ib_idx++) {
206
 
 
207
 
            /* loop over excitations E^b_{ij} from |B(I_b)> */
208
 
            Jbcnt = Cnt[1][Ib_idx];
209
 
            Ibridx = Ridx[1][Ib_idx];
210
 
            Ibsgn = Sgn[1][Ib_idx];
211
 
            Ibij = Ij[1][Ib_idx];
212
 
               
213
 
            tval = 0.0;
214
 
            for (Ib_ex=0; Ib_ex < Jbcnt; Ib_ex++) {
215
 
               ij = *Ibij++;
216
 
               Jb_idx = *Ibridx++;
217
 
               Jb_sgn = *Ibsgn++;
218
 
               ijkl = ioff[MAX0(ij,kl)] + MIN0(ij,kl);
219
 
               tval += tei[ijkl] * C[Ja_idx][Jb_idx] * 
220
 
                  (double) Ja_sgn * (double) Jb_sgn;
221
 
               }
222
 
            S[Ia_idx][Ib_idx] += tval;
223
 
            } /* end loop over Ib */
224
 
         } /* end loop over Ia excitations */
225
 
      } /* end loop over Ia */
226
 
}
227
 
 
228
 
 
229
 
/*
230
 
** S3_BLOCK_DIAG_ROTF()
231
 
**
232
 
** Calculate a block of the sigma3 vector in equation 
233
 
** (9c) of Olsen, Roos, et al.  For diagonal blocks of sigma.
234
 
** The string replacements are fed in through arrays.  
235
 
** Assumes that (ij|ij)'s have not been halved.
236
 
**
237
 
*/
238
 
void s3_block_diag_rotf(int *Cnt[2], int **Ij[2], 
239
 
      int **Ridx[2], signed char **Sgn[2], double **C, double **S,
240
 
      double *tei, int nas, int nbs)
241
 
{
242
 
   int Ia_ex, Ib_ex;
243
 
   int Ia_idx, Ib_idx ;
244
 
   int Ja_idx, Jb_idx ;
245
 
   int Ja_sgn, Jb_sgn ;
246
 
   int ij, kl, ijkl ;
247
 
   double tval,tval2 ;
248
 
 
249
 
   int Iacnt, Jbcnt, *Iaij, *Ibij;
250
 
   int *Iaridx, *Ibridx;
251
 
   signed char *Iasgn, *Ibsgn;
252
 
   double *Tptr;
253
 
 
254
 
 
255
 
   /* loop over Ia */
256
 
   for (Ia_idx=0; Ia_idx < nas; Ia_idx++) {
257
 
 
258
 
      /* loop over excitations E^a_{kl} from |A(I_a)> */
259
 
      Iacnt = Cnt[0][Ia_idx];
260
 
      Iaridx = Ridx[0][Ia_idx];
261
 
      Iasgn = Sgn[0][Ia_idx];
262
 
      Iaij = Ij[0][Ia_idx];
263
 
      for (Ia_ex=0; Ia_ex < Iacnt; Ia_ex++) {
264
 
         kl = *Iaij++;
265
 
         Tptr = tei + ioff[kl];
266
 
         Ja_idx = *Iaridx++;
267
 
         Ja_sgn = *Iasgn++;
268
 
 
269
 
         /* loop over Ib */
270
 
         for (Ib_idx=0; Ib_idx < nbs; Ib_idx++) {
271
 
 
272
 
            /* loop over excitations E^b_{ij} from |B(I_b)> */
273
 
            Jbcnt = Cnt[1][Ib_idx];
274
 
            Ibridx = Ridx[1][Ib_idx];
275
 
            Ibsgn = Sgn[1][Ib_idx];
276
 
            Ibij = Ij[1][Ib_idx];
277
 
               
278
 
            tval = 0.0;
279
 
            for (Ib_ex=0; Ib_ex < Jbcnt; Ib_ex++) {
280
 
               ij = *Ibij++;
281
 
               Jb_idx = *Ibridx++;
282
 
               Jb_sgn = *Ibsgn++;
283
 
               if (ij > kl) continue;
284
 
               ijkl = ioff[MAX0(ij,kl)] + MIN0(ij,kl);
285
 
               tval2 = tei[ijkl] * C[Ja_idx][Jb_idx] * 
286
 
                  (double) Ja_sgn * (double) Jb_sgn;
287
 
               if (ij == kl) tval2 *= 0.5;
288
 
               tval += tval2;
289
 
               }
290
 
            S[Ia_idx][Ib_idx] += tval;
291
 
            } /* end loop over Ib */
292
 
         } /* end loop over Ia excitations */
293
 
      } /* end loop over Ia */
294
 
}
295
 
 
296
 
 
297
 
 
298
 
 
299