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

« back to all changes in this revision

Viewing changes to src/lib/libciomr/ludcmp.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 "includes.h"
2
 
 
3
 
void ludcmp(a,n,indx,d)
4
 
   int n, *indx;
5
 
   double **a, *d;
6
 
 
7
 
   {
8
 
      int i,imax,j,k;
9
 
      double big,dum,sum,temp;
10
 
      double *vv;
11
 
 
12
 
      vv = (double *) init_array(n);
13
 
 
14
 
      *d = 1.0;
15
 
 
16
 
      for (i=0; i < n ; i++) {
17
 
         big=0.0;
18
 
         for (j=0; j < n; j++) {
19
 
            if ((temp=fabs(a[i][j])) > big) big=temp;
20
 
            }
21
 
         if (big == 0.0) {
22
 
            *d = 0.0;
23
 
            return;
24
 
            }
25
 
         vv[i] = 1.0/big;
26
 
         }
27
 
      for (j=0; j < n ; j++) {
28
 
         for (i=0; i < j ; i++) {
29
 
            sum = a[i][j];
30
 
            for (k=0; k < i ; k++) sum -= a[i][k]*a[k][j];
31
 
            a[i][j] = sum;
32
 
            }
33
 
         big = 0.0;
34
 
         for (i=j ; i < n ; i++) {
35
 
            sum=a[i][j];
36
 
            for (k=0; k < j ; k++) sum -= a[i][k]*a[k][j];
37
 
            a[i][j] = sum;
38
 
            if ((dum=vv[i]*fabs(sum)) >= big) {
39
 
               big = dum;
40
 
               imax = i;
41
 
               }
42
 
            }
43
 
         if (j != imax) {
44
 
            for (k=0; k < n; k++) {
45
 
               dum=a[imax][k];
46
 
               a[imax][k]=a[j][k];
47
 
               a[j][k]=dum;
48
 
               }
49
 
            *d = -(*d);
50
 
            vv[imax]=vv[j];
51
 
            }
52
 
         indx[j]=imax;
53
 
         if (a[j][j] == 0.0) a[j][j] = 1.0e-20;
54
 
         if (j != n-1) {
55
 
            dum = 1.0/a[j][j];
56
 
            for (i=j+1; i < n ; i++) a[i][j] *= dum;
57
 
            }
58
 
         }
59
 
      free(vv);
60
 
      }