~ubuntu-branches/ubuntu/quantal/psicode/quantal

« back to all changes in this revision

Viewing changes to src/lib/libdpd/buf4_mat_irrep_shift13.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 <libqt/qt.h>
5
 
#include "dpd.h"
6
 
 
7
 
int dpd_buf4_mat_irrep_shift13(dpdbuf4 *Buf, int buf_block)
8
 
{
9
 
  int h, i, nirreps, all_buf_irrep;
10
 
  int *count;
11
 
  long int *dataoff;
12
 
  int rowtot, coltot;
13
 
  double *data;
14
 
 
15
 
#ifdef DPD_TIMER
16
 
  timer_on("shift");
17
 
#endif
18
 
 
19
 
  all_buf_irrep = Buf->file.my_irrep;
20
 
 
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);
25
 
    }
26
 
  else Buf->shift.shift_type = 13;
27
 
  
28
 
  Buf->shift.shift_type = 13;
29
 
 
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];
35
 
 
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];
40
 
    }
41
 
 
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 *)));
48
 
 
49
 
  /* Calculate the data offset */
50
 
  dataoff = init_long_int_array(nirreps);
51
 
  dataoff[0] = 0;
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]);
56
 
                     
57
 
 
58
 
  /* The row counter for each sub-block */
59
 
  count = init_int_array(nirreps);
60
 
 
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];
64
 
          i++,count[h]++) {
65
 
          Buf->shift.matrix[buf_block][h][count[h]] =
66
 
                    &(data[dataoff[h]+((long) (Buf->shift.coltot[buf_block][h]))*((long) i)]);
67
 
        }
68
 
    }
69
 
 
70
 
  free(count); free(dataoff);
71
 
 
72
 
#ifdef DPD_TIMER
73
 
  timer_off("shift");
74
 
#endif
75
 
 
76
 
  return 0;
77
 
}