home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / C-SSP.ARJ / YENBOB.C < prev    next >
Encoding:
Text File  |  1984-08-16  |  1.2 KB  |  55 lines

  1.    yenbob(a,icola,icol)
  2.  
  3.       /*purpose...finds the solution of a system of N equations */
  4.       /*in N unknowns.                                          */
  5.  
  6.       int icol,icola;
  7.       float a[];
  8.  
  9.     {
  10.       int i,icol1,index1,index2,index3,index4,j,k;
  11.  
  12.  
  13.       icol1 = icol + 1;
  14.       for(k = 0; k <= icol-1; k++)
  15.       {
  16.        index1 = k + (k * icola);
  17.        a[index1] = 1./a[index1];
  18.  
  19.        for(j = 0; j <= icol1-1; j++)
  20.        {
  21.         if((j-k) != 0)
  22.         {
  23.         index2 = j + (k * icola);
  24.         a[index2] = a[index2] * a[index1];
  25.         }
  26.        }
  27.  
  28.        for(i = 0; i <= icol-1; i++)
  29.        {
  30.         if((i - k) != 0)
  31.         {
  32.          index3 = k + (i * icola);
  33.          for(j = 0; j <= icol1-1; j++)
  34.          {
  35.           if((j - k) != 0)
  36.           {
  37.            index2 = j + (i * icola);
  38.            index4 = j + (k * icola);
  39.            a[index2] = a[index2] - (a[index4] * a[index3]);
  40.           }
  41.          }
  42.         }
  43.        }
  44.        for(i = 0; i <= icol-1; i++)
  45.        {
  46.         if((i - k) != 0)
  47.         {
  48.          index2 = k + (i * icola);
  49.          a[index2] = -a[index2] * a[index1];
  50.         }
  51.        }
  52.       }
  53.     }
  54.  
  55.