home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / fractal / kaos.lha / eigenlib / balbak.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-15  |  2.3 KB  |  77 lines

  1. balbak(nm,n,low,igh,scale,m,z)
  2.  
  3. int n,nm,m,*low,*igh;
  4. double *scale,**z;
  5. {
  6. int i,j,k,ii;
  7. double s;
  8.  
  9. /*    this subroutine is a translation of the algol procedure balbak,
  10.       num. math. 13, 293-304(1969) by parlett and reinsch.
  11.       handbook for auto. comp., vol.ii-linear algebra, 315-326(1971).
  12.  
  13.       this subroutine forms the eigenvectors of a real general
  14.       matrix by back transforming those of the corresponding
  15.       balanced matrix determined by  balanc.
  16.  
  17.       on input
  18.  
  19.          nm must be set to the row dimension of two-dimensional
  20.            array parameters as declared in the calling program
  21.            dimension statement.
  22.  
  23.          n is the order of the matrix.
  24.  
  25.          low and igh are integers determined by  balanc.
  26.  
  27.          scale contains information determining the permutations
  28.            and scaling factors used by  balanc.
  29.  
  30.          m is the number of columns of z to be back transformed.
  31.  
  32.          z contains the real and imaginary parts of the eigen-
  33.            vectors to be back transformed in its first m columns.
  34.  
  35.       on output
  36.  
  37.          z contains the real and imaginary parts of the
  38.            transformed eigenvectors in its first m columns.
  39.  
  40.  
  41.       this routine is a C-translation of the FORTRAN 77 source code
  42.       written by the mathematics and computer science division,
  43.       argonne national laboratory
  44.       last change :   september 1989.
  45.  
  46.       mark myers
  47.       Center for Applied Mathematics 
  48.       Cornell University    (607) 255-4195
  49.       ------------------------------------------------------------------  */
  50.  
  51.  if (m != 0)
  52.   { if (*igh != *low) 
  53.      {
  54.       for (i = *low;i <= *igh;i++) 
  55.         {s = scale[i];    /* left hand eigenvectors are back transformed */
  56.          for (j=1;j<=m;j++)    /* if the foregoing statement is replaced by   */
  57.             z[i][j] = z[i][j]*s;}    /* s=1.0d0/scale(i). */
  58.      }
  59.      for (ii=1;ii<=n;ii++)           /* for i=low-1 step -1 until 1,  */
  60.         {i = ii;                    /* igh+1 step 1 until n do       */
  61.          if (i >= *low & i <= *igh) 
  62.        continue;
  63.          if (i < *low) 
  64.         i = *low - ii;
  65.          k = scale[i];
  66.          if (k == i) 
  67.        continue;
  68.  
  69.          for (j=1;j<=m;j++) 
  70.            {s = z[i][j];
  71.             z[i][j] = z[k][j];
  72.             z[k][j] = s;}
  73.  
  74.         }              
  75.   }
  76. }
  77.