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

« back to all changes in this revision

Viewing changes to src/lib/libdpd/trace42_13.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 <libqt/qt.h>
3
 
#include "dpd.h"
4
 
 
5
 
/* dpd_trace42_13(): Take a "trace" of the specified indices of a buf4 and put the
6
 
** result into a file2.
7
 
** 
8
 
** In this version of the trace42 functions, the summation indices are 1 and 3:
9
 
**
10
 
**         B(q,s) = alpha * \Sum_{p==r} A(pq,rs) + beta * B(q,s)
11
 
** 
12
 
** Arguments:
13
 
**   dpdbuf4 *A: Pointer to the input four-index buffer.
14
 
**   dpdfile2 *B: Pointer to the target two-index file.
15
 
**   int transb: Boolean to indicate whether B should be transposed to match the 
16
 
**               target index ordering of A.
17
 
**   double alpha: Prefactor for A.
18
 
**   double beta: Prefactor for B.
19
 
*/
20
 
 
21
 
int dpd_trace42_13(dpdbuf4 *A, dpdfile2 *B, int transb, double alpha, double beta)
22
 
{
23
 
  int h, Gp, Gq, Gr, Gs;
24
 
  int p, q, r, s;
25
 
  int P, Q, R, S;
26
 
  int pq, rs;
27
 
  int nirreps;
28
 
 
29
 
  nirreps = A->params->nirreps;
30
 
 
31
 
  dpd_file2_scm(B, beta);
32
 
  dpd_file2_mat_init(B);
33
 
  dpd_file2_mat_rd(B);
34
 
 
35
 
#ifdef DPD_TIMER
36
 
  timer_on("trace42");
37
 
#endif
38
 
 
39
 
  /* Read all of A into core */
40
 
  for(h=0; h < nirreps; h++) {
41
 
    dpd_buf4_mat_irrep_init(A, h);
42
 
    dpd_buf4_mat_irrep_rd(A, h);
43
 
  }
44
 
 
45
 
  for(h=0; h < nirreps; h++) {
46
 
 
47
 
    for(Gp=0; Gp < nirreps; Gp++) {
48
 
      Gq = Gp ^ h;
49
 
      Gr = Gp;
50
 
      Gs = Gq;
51
 
 
52
 
      /* Loop over target indices */
53
 
      for(q=0; q < A->params->qpi[Gq]; q++) {
54
 
        Q = A->params->qoff[Gq] + q;
55
 
 
56
 
        for(s=0; s < A->params->spi[Gs]; s++) {
57
 
          S = A->params->soff[Gs] + s;
58
 
 
59
 
          /* Loop over elements for which P==R */
60
 
          for(p=0; p < A->params->ppi[Gp]; p++) {
61
 
            P = A->params->poff[Gp] + p;
62
 
            R = P;
63
 
 
64
 
            pq = A->params->rowidx[P][Q];
65
 
            rs = A->params->colidx[R][S];
66
 
 
67
 
            if(!transb)  B->matrix[Gq][q][s] += alpha * A->matrix[h][pq][rs];
68
 
            else  B->matrix[Gq][s][q] += alpha * A->matrix[h][pq][rs];
69
 
 
70
 
          }
71
 
        }
72
 
      }
73
 
 
74
 
    }
75
 
 
76
 
  }
77
 
 
78
 
  for(h=0; h < nirreps; h++) {
79
 
    dpd_buf4_mat_irrep_close(A, h);
80
 
  }
81
 
 
82
 
#ifdef DPD_TIMER
83
 
  timer_off("trace42");
84
 
#endif
85
 
 
86
 
  /* Close the two-index quantities */
87
 
  dpd_file2_mat_wrt(B);
88
 
  dpd_file2_mat_close(B);
89
 
 
90
 
  return 0;
91
 
}