3
#include <libciomr/libciomr.h>
8
/* dpd_buf4_init(): Initializes a dpd four-index buffer for reading or writing
12
** dpdbuf4 *Buf: A pointer to the dpdbuf to be initialized.
13
** int inputfile: The PSI unit number for the data on disk.
14
** int pqnum: The index combination for the bra indices for the
15
** data as it will be used in memory.
16
** int rsnum: The index combination for the ket indices for the
17
** data as it will be used in memory.
18
** int file_pqnum: The index combination for the bra indices for the
19
** data as it will be stored on disk.
20
** int file_rsnum: The index combination for the ket indices for the
21
** data as it will be stored on disk.
22
** int anti: Boolean flag which indicates whether the data needs to
23
** be antisymmetrized as it is read from disk.
24
** char *label: The string labelling the PSIO TOC entry on disk.
27
int dpd_buf4_init(dpdbuf4 *Buf, int inputfile, int irrep, int pqnum, int rsnum,
28
int file_pqnum, int file_rsnum, int anti, char *label)
30
int h, nirreps, nump, nrows, p, Gp, Gr, offset;
32
Buf->dpdnum = dpd_default;
33
Buf->params = &(dpd_list[dpd_default].params4[pqnum][rsnum]);
37
dpd_file4_init(&(Buf->file), inputfile, irrep, file_pqnum, file_rsnum, label);
39
Buf->matrix = (double ***) malloc(Buf->params->nirreps*sizeof(double **));
41
/* Set up shifted matrix info */
42
nirreps = Buf->params->nirreps;
43
Buf->shift.shift_type = 0;
44
Buf->shift.rowtot = init_int_matrix(nirreps, nirreps);
45
Buf->shift.coltot = init_int_matrix(nirreps, nirreps);
46
Buf->shift.matrix = (double ****) malloc(nirreps * sizeof(double ***));
48
/* row_offset lookup array */
49
/* For a (pq,rs) buffer (assuming p and q are NOT packed), on which
50
row of the irrep submatrix h does a given value of the orbital
51
index, p, first appear? This should work for non-totally
52
symmetric quantities. */
53
for(h=0,nump=0; h < nirreps; h++) nump += Buf->params->ppi[h];
54
Buf->row_offset = init_int_matrix(nirreps, nump);
55
for(h=0; h < nirreps; h++) {
56
for(p=0; p < nump; p++) Buf->row_offset[h][p] = -1;
57
for(Gp=0,nrows=0; Gp < nirreps; Gp++) {
58
for(p=0; p < Buf->params->ppi[Gp]; p++) {
59
if(Buf->params->qpi[Gp^h])
60
Buf->row_offset[h][Buf->params->poff[Gp]+p] = nrows;
61
nrows += Buf->params->qpi[Gp^h];
66
/* col_offset lookup array */
67
/* For a (pq,rs) buffer (assuming r and s are NOT packed), in which
68
column of the irrep submatrix h does a given irrep of the orbital
69
index, r, first appear? This should work for non-totally-symmetric
71
Buf->col_offset = init_int_matrix(nirreps, nirreps);
72
for(h=0; h < nirreps; h++) {
73
for(Gr=0,offset=0; Gr < nirreps; Gr++) {
74
Buf->col_offset[h][Gr] = offset;
75
offset += Buf->params->rpi[Gr] * Buf->params->spi[Gr^h^Buf->file.my_irrep];