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

« back to all changes in this revision

Viewing changes to src/lib/libdpd/buf4_init.c

  • 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
 
#include <stdio.h>
2
 
#include <stdlib.h>
3
 
#include <libciomr/libciomr.h>
4
 
#include "dpd.h"
5
 
#define EXTERN
6
 
#include "dpd.gbl"
7
 
 
8
 
/* dpd_buf4_init(): Initializes a dpd four-index buffer for reading or writing
9
 
**   data.
10
 
**
11
 
** Arguments:
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.
25
 
*/
26
 
 
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)
29
 
{
30
 
  int h, nirreps, nump, nrows, p, Gp, Gr, offset;
31
 
 
32
 
  Buf->dpdnum = dpd_default;
33
 
  Buf->params = &(dpd_list[dpd_default].params4[pqnum][rsnum]);
34
 
 
35
 
  Buf->anti = anti;
36
 
 
37
 
  dpd_file4_init(&(Buf->file), inputfile, irrep, file_pqnum, file_rsnum, label);
38
 
 
39
 
  Buf->matrix = (double ***) malloc(Buf->params->nirreps*sizeof(double **));
40
 
 
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 ***));
47
 
 
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];
62
 
      }
63
 
    }
64
 
  }
65
 
 
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
70
 
  quantities.  */
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];
76
 
    }
77
 
  }
78
 
 
79
 
  return 0;
80
 
}