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

« back to all changes in this revision

Viewing changes to src/lib/libciomr/lubksb.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck
  • Date: 2006-09-10 14:01:33 UTC
  • Revision ID: james.westby@ubuntu.com-20060910140133-ib2j86trekykfsfv
Tags: upstream-3.2.3
ImportĀ upstreamĀ versionĀ 3.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/* $Log: lubksb.c,v $
 
3
/* Revision 1.1.1.1  2000/02/04 22:53:20  evaleev
 
4
/* Started PSI 3 repository
 
5
/*
 
6
/* Revision 2.1  1991/06/15 18:29:26  seidl
 
7
/* *** empty log message ***
 
8
/* */
 
9
 
 
10
static char *rcsid = "$Id: lubksb.c,v 1.1.1.1 2000/02/04 22:53:20 evaleev Exp $";
 
11
 
 
12
#include "includes.h"
 
13
 
 
14
void lubksb(a,n,indx,b)
 
15
   double **a, *b;
 
16
   int n, *indx;
 
17
 
 
18
   {
 
19
      int i,ii,ip,j;
 
20
      int t=0;
 
21
      double sum;
 
22
 
 
23
      for (i=0; i < n ; i++) {
 
24
         ip = indx[i];
 
25
         sum = b[ip];
 
26
         b[ip]=b[i];
 
27
         if(t) {
 
28
            for (j=ii; j <= i-1 ; j++) sum -= a[i][j]*b[j];
 
29
            }
 
30
         else if(sum) {
 
31
            ii=i;
 
32
            t++;
 
33
            }
 
34
         b[i]=sum;
 
35
         }
 
36
      for (i=n-1; i >= 0 ; i--) {
 
37
         sum = b[i];
 
38
         for (j=i+1; j < n ; j++) sum -= a[i][j]*b[j];
 
39
         b[i] = sum/a[i][i];
 
40
         }
 
41
      }