3
#include <libciomr/libciomr.h>
7
int dpd_buf4_mat_irrep_shift13(dpdbuf4 *Buf, int buf_block)
9
int h, i, nirreps, all_buf_irrep;
19
all_buf_irrep = Buf->file.my_irrep;
21
if(Buf->shift.shift_type) {
22
fprintf(stderr, "\n\tShift is already on! %d\n",
23
Buf->shift.shift_type);
24
exit(PSI_RETURN_FAILURE);
26
else Buf->shift.shift_type = 13;
28
Buf->shift.shift_type = 13;
30
nirreps = Buf->params->nirreps;
31
rowtot = Buf->params->rowtot[buf_block];
32
coltot = Buf->params->coltot[buf_block^all_buf_irrep];
33
if (rowtot == 0 || coltot == 0) data = 0;
34
else data = Buf->matrix[buf_block][0];
36
/* Calculate row and column dimensions of each new sub-block */
37
for(h=0; h < nirreps; h++) {
38
Buf->shift.rowtot[buf_block][h] = Buf->params->ppi[h];
39
Buf->shift.coltot[buf_block][h] = coltot * Buf->params->qpi[h^buf_block];
42
/* Malloc the pointers to the rows for the shifted access matrix */
43
Buf->shift.matrix[buf_block] = (double ***) malloc(nirreps * sizeof(double **));
44
for(h=0; h < nirreps; h++)
45
Buf->shift.matrix[buf_block][h] =
46
((!Buf->shift.rowtot[buf_block][h]) ? NULL :
47
(double **) malloc(Buf->shift.rowtot[buf_block][h] * sizeof(double *)));
49
/* Calculate the data offset */
50
dataoff = init_long_int_array(nirreps);
52
for(h=1; h < nirreps; h++)
53
dataoff[h] = dataoff[h-1] +
54
((long) Buf->shift.rowtot[buf_block][h-1]) *
55
((long) Buf->shift.coltot[buf_block][h-1]);
58
/* The row counter for each sub-block */
59
count = init_int_array(nirreps);
61
/* Loop over irreps of isolated index */
62
for(h=0; h < Buf->params->nirreps; h++) {
63
for(i=0; (i < Buf->shift.rowtot[buf_block][h]) && Buf->shift.coltot[buf_block][h];
65
Buf->shift.matrix[buf_block][h][count[h]] =
66
&(data[dataoff[h]+((long) (Buf->shift.coltot[buf_block][h]))*((long) i)]);
70
free(count); free(dataoff);