~ubuntu-branches/ubuntu/karmic/psicode/karmic

« back to all changes in this revision

Viewing changes to src/bin/ccenergy/AO_contribute.cc

  • 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
/*! \file
 
2
    \ingroup CCENERGY
 
3
    \brief Enter brief description of file here 
 
4
*/
 
5
 
 
6
/*! \defgroup CCENERGY ccenergy: Compute the Coupled-Cluster Energy */
 
7
 
 
8
#include <cstdio>
 
9
#include <cstdlib>
 
10
#include <cmath>
 
11
#include <libciomr/libciomr.h>
 
12
#include <libiwl/iwl.h>
 
13
#include <libqt/qt.h>
 
14
#include <libdpd/dpd.h>
 
15
 
 
16
namespace psi { namespace ccenergy {
 
17
 
 
18
int AO_contribute(struct iwlbuf *InBuf, dpdbuf4 *tau1_AO, dpdbuf4 *tau2_AO)
 
19
{
 
20
  int idx, p, q, r, s;
 
21
  double value;
 
22
  Value *valptr;
 
23
  Label *lblptr;
 
24
  int Gp, Gq, Gr, Gs, Gpr, Gps, Gqr, Gqs, Grp, Gsp, Grq, Gsq;
 
25
  int pr, ps, qr, qs, rp, rq, sp, sq, pq, rs;
 
26
  int count=0;
 
27
 
 
28
  lblptr = InBuf->labels;
 
29
  valptr = InBuf->values;
 
30
 
 
31
  for(idx=4*InBuf->idx; InBuf->idx < InBuf->inbuf; InBuf->idx++) {
 
32
    p = abs((int) lblptr[idx++]);
 
33
    q = (int) lblptr[idx++];
 
34
    r = (int) lblptr[idx++];
 
35
    s = (int) lblptr[idx++];
 
36
 
 
37
    value = (double) valptr[InBuf->idx];
 
38
    /*
 
39
    if(fabs(value) > 1e-8)
 
40
        fprintf(stdout, "%d %d %d %d %20.14f\n", p, q, r, s, value);
 
41
    */
 
42
    count++;
 
43
 
 
44
    Gp = tau1_AO->params->psym[p]; 
 
45
    Gq = tau1_AO->params->psym[q]; 
 
46
    Gr = tau1_AO->params->psym[r]; 
 
47
    Gs = tau1_AO->params->psym[s];
 
48
 
 
49
    Gpr = Grp = Gp^Gr;
 
50
    Gps = Gsp = Gp^Gs;
 
51
    Gqr = Grq = Gq^Gr;
 
52
    Gqs = Gsq = Gq^Gs;
 
53
 
 
54
    pq = tau1_AO->params->rowidx[p][q];  
 
55
    rs = tau1_AO->params->rowidx[r][s];
 
56
 
 
57
    pr = tau1_AO->params->rowidx[p][r];
 
58
    rp = tau1_AO->params->rowidx[r][p];
 
59
    ps = tau1_AO->params->rowidx[p][s];
 
60
    sp = tau1_AO->params->rowidx[s][p];
 
61
    qr = tau1_AO->params->rowidx[q][r];
 
62
    rq = tau1_AO->params->rowidx[r][q];
 
63
    qs = tau1_AO->params->rowidx[q][s];
 
64
    sq = tau1_AO->params->rowidx[s][q];
 
65
 
 
66
    /* (pq|rs) */
 
67
    if(tau1_AO->params->coltot[Gpr])
 
68
      C_DAXPY(tau1_AO->params->coltot[Gpr], value, tau1_AO->matrix[Gpr][qs], 1,
 
69
              tau2_AO->matrix[Gpr][pr], 1);
 
70
 
 
71
    if(p!=q && r!=s && pq != rs) {
 
72
 
 
73
      /* (pq|sr) */
 
74
      if(tau1_AO->params->coltot[Gps])
 
75
        C_DAXPY(tau1_AO->params->coltot[Gps], value, tau1_AO->matrix[Gps][qr], 1,
 
76
                tau2_AO->matrix[Gps][ps], 1);
 
77
 
 
78
      /* (qp|rs) */
 
79
      if(tau1_AO->params->coltot[Gqr])
 
80
        C_DAXPY(tau1_AO->params->coltot[Gqr], value, tau1_AO->matrix[Gqr][ps], 1,
 
81
                tau2_AO->matrix[Gqr][qr], 1);
 
82
 
 
83
      /* (qp|sr) */
 
84
      if(tau1_AO->params->coltot[Gqs])
 
85
        C_DAXPY(tau1_AO->params->coltot[Gqs], value, tau1_AO->matrix[Gqs][pr], 1,
 
86
                tau2_AO->matrix[Gqs][qs], 1);
 
87
 
 
88
      /* (rs|pq) */
 
89
      if(tau1_AO->params->coltot[Grp])
 
90
        C_DAXPY(tau1_AO->params->coltot[Grp], value, tau1_AO->matrix[Grp][sq], 1,
 
91
                tau2_AO->matrix[Grp][rp], 1);
 
92
 
 
93
      /* (sr|pq) */
 
94
      if(tau1_AO->params->coltot[Gsp])
 
95
        C_DAXPY(tau1_AO->params->coltot[Gsp], value, tau1_AO->matrix[Gsp][rq], 1, 
 
96
                tau2_AO->matrix[Gsp][sp], 1);
 
97
 
 
98
      /* (rs|qp) */
 
99
      if(tau1_AO->params->coltot[Grq])
 
100
        C_DAXPY(tau1_AO->params->coltot[Grq], value, tau1_AO->matrix[Grq][sp], 1,
 
101
                tau2_AO->matrix[Grq][rq], 1);
 
102
 
 
103
      /* (sr|qp) */
 
104
      if(tau1_AO->params->coltot[Gsq])
 
105
        C_DAXPY(tau1_AO->params->coltot[Gsq], value, tau1_AO->matrix[Gsq][rp], 1,
 
106
                tau2_AO->matrix[Gsq][sq],1 );
 
107
 
 
108
    }
 
109
    else if(p!=q && r!=s && pq==rs) {
 
110
 
 
111
      /* (pq|sr) */
 
112
      if(tau1_AO->params->coltot[Gps])
 
113
        C_DAXPY(tau1_AO->params->coltot[Gps], value, tau1_AO->matrix[Gps][qr], 1,
 
114
                tau2_AO->matrix[Gps][ps], 1);
 
115
 
 
116
      /* (qp|rs) */
 
117
      if(tau1_AO->params->coltot[Gqr])
 
118
        C_DAXPY(tau1_AO->params->coltot[Gqr], value, tau1_AO->matrix[Gqr][ps], 1,
 
119
                tau2_AO->matrix[Gqr][qr], 1);
 
120
 
 
121
      /* (qp|sr) */
 
122
      if(tau1_AO->params->coltot[Gqs])
 
123
        C_DAXPY(tau1_AO->params->coltot[Gqs], value, tau1_AO->matrix[Gqs][pr], 1,
 
124
                tau2_AO->matrix[Gqs][qs], 1);
 
125
 
 
126
    }
 
127
    else if(p!=q && r==s) {
 
128
 
 
129
      /* (qp|rs) */
 
130
      if(tau1_AO->params->coltot[Gqr])
 
131
        C_DAXPY(tau1_AO->params->coltot[Gqr], value, tau1_AO->matrix[Gqr][ps], 1,
 
132
                tau2_AO->matrix[Gqr][qr], 1);
 
133
 
 
134
      /* (rs|pq) */
 
135
      if(tau1_AO->params->coltot[Grp])
 
136
        C_DAXPY(tau1_AO->params->coltot[Grp], value, tau1_AO->matrix[Grp][sq], 1,
 
137
                tau2_AO->matrix[Grp][rp], 1);
 
138
 
 
139
      /* (rs|qp) */
 
140
      if(tau1_AO->params->coltot[Grq])
 
141
        C_DAXPY(tau1_AO->params->coltot[Grq], value, tau1_AO->matrix[Grq][sp], 1,
 
142
                tau2_AO->matrix[Grq][rq], 1);
 
143
 
 
144
    }
 
145
 
 
146
    else if(p==q && r!=s) {
 
147
 
 
148
      /* (pq|sr) */
 
149
      if(tau1_AO->params->coltot[Gps])
 
150
        C_DAXPY(tau1_AO->params->coltot[Gps], value, tau1_AO->matrix[Gps][qr], 1,
 
151
                tau2_AO->matrix[Gps][ps], 1);
 
152
 
 
153
      /* (rs|pq) */
 
154
      if(tau1_AO->params->coltot[Grp])
 
155
        C_DAXPY(tau1_AO->params->coltot[Grp], value, tau1_AO->matrix[Grp][sq], 1,
 
156
                tau2_AO->matrix[Grp][rp], 1);
 
157
 
 
158
      /* (sr|pq) */
 
159
      if(tau1_AO->params->coltot[Gsp])
 
160
        C_DAXPY(tau1_AO->params->coltot[Gsp], value, tau1_AO->matrix[Gsp][rq], 1, 
 
161
                tau2_AO->matrix[Gsp][sp], 1);
 
162
 
 
163
    }
 
164
 
 
165
    else if(p==q && r==s && pq != rs) {
 
166
 
 
167
      /* (rs|pq) */
 
168
      if(tau1_AO->params->coltot[Grp])
 
169
        C_DAXPY(tau1_AO->params->coltot[Grp], value, tau1_AO->matrix[Grp][sq], 1,
 
170
                tau2_AO->matrix[Grp][rp], 1);
 
171
 
 
172
    }
 
173
  }
 
174
 
 
175
  return count;
 
176
}
 
177
 
 
178
}} // namespace psi::ccenergy