3
#include <libiwl/iwl.h>
4
#include <libdpd/dpd.h>
6
void idx_error(char *message, int p, int q, int r, int s, int pq, int rs,
7
int pq_sym, int rs_sym, FILE *outfile);
8
void idx_permute_multipass(dpdfile4 *File, int this_bucket, int **bucket_map,
9
int **bucket_offset, int p, int q, int r, int s,
10
int perm_pr, int perm_qs, int perm_prqs,
11
double value, FILE *outfile)
13
int p_sym, q_sym, r_sym, s_sym;
14
int pq_sym, rs_sym, rq_sym, ps_sym, qp_sym, sp_sym, sr_sym, qr_sym;
15
int pq, rs, rq, ps, qp, sr, qr, sp;
20
Params = File->params;
21
perm_pq = Params->perm_pq;
22
perm_rs = Params->perm_rs;
24
/* Get the orbital symmetries */
25
p_sym = Params->psym[p]; q_sym = Params->qsym[q];
26
r_sym = Params->rsym[r]; s_sym = Params->ssym[s];
28
/* Go through the allowed permutations --- NB these are Dirac permutations */
30
if(bucket_map[p][q] == this_bucket) {
32
/* Get the left and right symmetry blocks */
36
/* Get the row and column indices and assign the value */
37
pq = Params->rowidx[p][q];
38
rs = Params->colidx[r][s];
39
if((pq >= Params->rowtot[pq_sym]) || (rs >= Params->coltot[rs_sym]))
40
idx_error("MP Params_make: pq, rs", p,q,r,s,pq,rs,pq_sym,rs_sym,outfile);
42
offset = bucket_offset[this_bucket][pq_sym];
43
File->matrix[pq_sym][pq-offset][rs] = value;
47
if(bucket_map[r][q] == this_bucket) {
50
rq = Params->rowidx[r][q];
51
ps = Params->colidx[p][s];
52
if((rq >= Params->rowtot[rq_sym]) || (ps >= Params->coltot[ps_sym]))
53
idx_error("MP Params_make: rq, ps", p,q,r,s,rq,ps,rq_sym,ps_sym,outfile);
55
offset = bucket_offset[this_bucket][rq_sym];
56
File->matrix[rq_sym][rq-offset][ps] = value;
61
if(bucket_map[p][s] == this_bucket) {
64
ps = Params->rowidx[p][s];
65
rq = Params->colidx[r][q];
66
if((ps >= Params->rowtot[ps_sym]) || (rq >= Params->coltot[rq_sym]))
67
idx_error("MP Params_make: ps, rq", p,q,r,s,ps,rq,ps_sym,rq_sym,outfile);
69
offset = bucket_offset[this_bucket][ps_sym];
70
File->matrix[ps_sym][ps-offset][rq] = value;
74
if(perm_pr && perm_qs) {
75
if(bucket_map[r][s] == this_bucket) {
78
rs = Params->rowidx[r][s];
79
pq = Params->colidx[p][q];
80
if((rs >= Params->rowtot[rs_sym]) || (pq >= Params->coltot[pq_sym]))
81
idx_error("MP Params_make: rs, pq", p,q,r,s,rs,pq,rs_sym,pq_sym,outfile);
83
offset = bucket_offset[this_bucket][rs_sym];
84
File->matrix[rs_sym][rs-offset][pq] = value;
89
if(bucket_map[q][p] == this_bucket) {
92
qp = Params->rowidx[q][p];
93
sr = Params->colidx[s][r];
94
if((qp >= Params->rowtot[qp_sym]) || (sr >= Params->coltot[sr_sym]))
95
idx_error("MP Params_make: qp, sr", p,q,r,s,qp,sr,qp_sym,sr_sym,outfile);
97
offset = bucket_offset[this_bucket][qp_sym];
98
File->matrix[qp_sym][qp-offset][sr] = value;
102
if(bucket_map[q][r] == this_bucket) {
103
qr_sym = q_sym^r_sym;
104
sp_sym = s_sym^p_sym;
105
qr = Params->rowidx[q][r];
106
sp = Params->colidx[s][p];
107
if((qr >= Params->rowtot[qr_sym])||(sp >= Params->coltot[sp_sym]))
108
idx_error("MP Params_make: qr, sp", p,q,r,s,qr,sp,qr_sym,sp_sym,
111
offset = bucket_offset[this_bucket][qr_sym];
112
File->matrix[qr_sym][qr-offset][sp] = value;
117
if(bucket_map[s][p] == this_bucket) {
118
sp_sym = s_sym^p_sym;
119
qr_sym = q_sym^r_sym;
120
sp = Params->rowidx[s][p];
121
qr = Params->colidx[q][r];
122
if((sp >= Params->rowtot[sp_sym])||(qr >= Params->coltot[qr_sym]))
123
idx_error("MP Params_make: sp, qr", p,q,r,s,sp,qr,sp_sym,qr_sym,
126
offset = bucket_offset[this_bucket][sp_sym];
127
File->matrix[sp_sym][sp-offset][qr] = value;
131
if(perm_pr && perm_qs) {
132
if(bucket_map[s][r] == this_bucket) {
133
sr_sym = s_sym^r_sym;
134
qp_sym = q_sym^p_sym;
135
sr = Params->rowidx[s][r];
136
qp = Params->colidx[q][p];
137
if((sr >= Params->rowtot[sr_sym])||(qp >= Params->coltot[qp_sym]))
138
idx_error("MP Params_make: sr, qp", p,q,r,s,sr,qp,sr_sym,qp_sym,
141
offset = bucket_offset[this_bucket][sr_sym];
142
File->matrix[sr_sym][sr-offset][qp] = value;