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

« back to all changes in this revision

Viewing changes to src/bin/ccsort/idx_permute_multipass.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 CCSORT
 
3
    \brief Enter brief description of file here 
 
4
*/
 
5
#include <cstdio>
 
6
#include <cstdlib>
 
7
#include <libiwl/iwl.h>
 
8
#include <libdpd/dpd.h>
 
9
 
 
10
namespace psi { namespace ccsort {
 
11
 
 
12
void idx_error(const char *message, int p, int q, int r, int s, int pq, int rs,
 
13
               int pq_sym, int rs_sym, FILE *outfile);
 
14
void idx_permute_multipass(dpdfile4 *File, int this_bucket, int **bucket_map, 
 
15
                           int **bucket_offset, int p, int q, int r, int s, 
 
16
                           int perm_pr, int perm_qs, int perm_prqs,
 
17
                           double value, FILE *outfile)
 
18
{
 
19
  int p_sym, q_sym, r_sym, s_sym;
 
20
  int pq_sym, rs_sym, rq_sym, ps_sym, qp_sym, sp_sym, sr_sym, qr_sym;
 
21
  int pq, rs, rq, ps, qp, sr, qr, sp;
 
22
  int perm_pq, perm_rs;
 
23
  dpdparams4 *Params;
 
24
  int offset;
 
25
 
 
26
  Params = File->params;
 
27
  perm_pq = Params->perm_pq;
 
28
  perm_rs = Params->perm_rs;
 
29
  
 
30
  /* Get the orbital symmetries */
 
31
  p_sym = Params->psym[p]; q_sym = Params->qsym[q];
 
32
  r_sym = Params->rsym[r]; s_sym = Params->ssym[s];
 
33
 
 
34
  /* Go through the allowed permutations --- NB these are Dirac permutations */
 
35
 
 
36
  if(bucket_map[p][q] == this_bucket) {
 
37
 
 
38
    /* Get the left and right symmetry blocks */
 
39
    pq_sym = p_sym^q_sym;
 
40
    rs_sym = r_sym^s_sym;
 
41
 
 
42
    /* Get the row and column indices and assign the value */
 
43
    pq = Params->rowidx[p][q];
 
44
    rs = Params->colidx[r][s];
 
45
    if((pq >= Params->rowtot[pq_sym]) || (rs >= Params->coltot[rs_sym]))
 
46
      idx_error("MP Params_make: pq, rs", p,q,r,s,pq,rs,pq_sym,rs_sym,outfile);
 
47
 
 
48
    offset = bucket_offset[this_bucket][pq_sym];
 
49
    File->matrix[pq_sym][pq-offset][rs] = value;
 
50
  }
 
51
 
 
52
  if(perm_pr) {
 
53
    if(bucket_map[r][q] == this_bucket) {
 
54
      rq_sym = r_sym^q_sym;
 
55
      ps_sym = p_sym^s_sym;
 
56
      rq = Params->rowidx[r][q];
 
57
      ps = Params->colidx[p][s];
 
58
      if((rq >= Params->rowtot[rq_sym]) || (ps >= Params->coltot[ps_sym]))
 
59
        idx_error("MP Params_make: rq, ps", p,q,r,s,rq,ps,rq_sym,ps_sym,outfile);
 
60
 
 
61
      offset = bucket_offset[this_bucket][rq_sym];
 
62
      File->matrix[rq_sym][rq-offset][ps] = value;
 
63
    }
 
64
  }
 
65
 
 
66
  if(perm_qs) {
 
67
    if(bucket_map[p][s] == this_bucket) {
 
68
      ps_sym = p_sym^s_sym;
 
69
      rq_sym = r_sym^q_sym;
 
70
      ps = Params->rowidx[p][s];
 
71
      rq = Params->colidx[r][q];
 
72
      if((ps >= Params->rowtot[ps_sym]) || (rq >= Params->coltot[rq_sym]))
 
73
        idx_error("MP Params_make: ps, rq", p,q,r,s,ps,rq,ps_sym,rq_sym,outfile);
 
74
 
 
75
      offset = bucket_offset[this_bucket][ps_sym];
 
76
      File->matrix[ps_sym][ps-offset][rq] = value;
 
77
    }
 
78
  }
 
79
 
 
80
  if(perm_pr && perm_qs) {
 
81
    if(bucket_map[r][s] == this_bucket) {
 
82
      rs_sym = r_sym^s_sym;
 
83
      pq_sym = p_sym^q_sym;
 
84
      rs = Params->rowidx[r][s];
 
85
      pq = Params->colidx[p][q];
 
86
      if((rs >= Params->rowtot[rs_sym]) || (pq >= Params->coltot[pq_sym]))
 
87
        idx_error("MP Params_make: rs, pq", p,q,r,s,rs,pq,rs_sym,pq_sym,outfile);
 
88
 
 
89
      offset = bucket_offset[this_bucket][rs_sym];
 
90
      File->matrix[rs_sym][rs-offset][pq] = value;
 
91
    }
 
92
  }
 
93
 
 
94
  if(perm_prqs) {
 
95
    if(bucket_map[q][p] == this_bucket) {
 
96
      qp_sym = q_sym^p_sym;
 
97
      sr_sym = s_sym^r_sym;
 
98
      qp = Params->rowidx[q][p];
 
99
      sr = Params->colidx[s][r];
 
100
      if((qp >= Params->rowtot[qp_sym]) || (sr >= Params->coltot[sr_sym]))
 
101
        idx_error("MP Params_make: qp, sr", p,q,r,s,qp,sr,qp_sym,sr_sym,outfile);
 
102
 
 
103
      offset = bucket_offset[this_bucket][qp_sym];
 
104
      File->matrix[qp_sym][qp-offset][sr] = value;
 
105
    }
 
106
 
 
107
    if(perm_pr) {
 
108
      if(bucket_map[q][r] == this_bucket) {
 
109
        qr_sym = q_sym^r_sym;
 
110
        sp_sym = s_sym^p_sym;
 
111
        qr = Params->rowidx[q][r];
 
112
        sp = Params->colidx[s][p];
 
113
        if((qr >= Params->rowtot[qr_sym])||(sp >= Params->coltot[sp_sym]))
 
114
          idx_error("MP Params_make: qr, sp", p,q,r,s,qr,sp,qr_sym,sp_sym,
 
115
                    outfile);
 
116
 
 
117
        offset = bucket_offset[this_bucket][qr_sym];
 
118
        File->matrix[qr_sym][qr-offset][sp] = value;
 
119
      }
 
120
    }
 
121
 
 
122
    if(perm_qs) {
 
123
      if(bucket_map[s][p] == this_bucket) {
 
124
        sp_sym = s_sym^p_sym;
 
125
        qr_sym = q_sym^r_sym;
 
126
        sp = Params->rowidx[s][p];
 
127
        qr = Params->colidx[q][r];
 
128
        if((sp >= Params->rowtot[sp_sym])||(qr >= Params->coltot[qr_sym]))
 
129
          idx_error("MP Params_make: sp, qr", p,q,r,s,sp,qr,sp_sym,qr_sym,
 
130
                    outfile);
 
131
 
 
132
        offset = bucket_offset[this_bucket][sp_sym];
 
133
        File->matrix[sp_sym][sp-offset][qr] = value;
 
134
      }
 
135
    }
 
136
      
 
137
    if(perm_pr && perm_qs) {
 
138
      if(bucket_map[s][r] == this_bucket) {
 
139
        sr_sym = s_sym^r_sym;
 
140
        qp_sym = q_sym^p_sym;
 
141
        sr = Params->rowidx[s][r];
 
142
        qp = Params->colidx[q][p];
 
143
        if((sr >= Params->rowtot[sr_sym])||(qp >= Params->coltot[qp_sym]))
 
144
          idx_error("MP Params_make: sr, qp", p,q,r,s,sr,qp,sr_sym,qp_sym,
 
145
                    outfile);
 
146
 
 
147
        offset = bucket_offset[this_bucket][sr_sym];
 
148
        File->matrix[sr_sym][sr-offset][qp] = value;
 
149
      }
 
150
    }
 
151
  }
 
152
}
 
153
 
 
154
}} // namespace psi::ccsort