Guest User

Untitled

a guest
Jul 15th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.93 KB | None | 0 0
  1.     // while we're less than or equal to the number of iterations
  2.     for(itt=0; itt<=itt_max; itt++)
  3.     {
  4.         // reset error
  5.         error=0.0;
  6.        
  7.         // rows
  8.         for(i=0; i< n; i++)
  9.         {
  10.             sum = 0.0;
  11.            
  12.             // columns of the rows
  13.             for(j=0; j< n; j++)
  14.             {
  15.                 // multiply an entry
  16.                 sum += a[i][j] * t[j];
  17.             }
  18.            
  19.             t1[i] = sum + b[i];
  20.             errori = fabs(t1[i]-t[i]);
  21.             if(errori > error) {
  22.                 error=errori;
  23.             }
  24.         }
  25.        
  26.         // answer into temporary array
  27.         ttemp = t1;
  28.        
  29.         // old x vector into t1 (why?)
  30.         t1 = t;
  31.        
  32.         // new x vector is the answer from the last multiplication
  33.         t = ttemp;
  34.        
  35.         // print, do it all over again
  36.         printf("%5d %14.6e\n", itt, error);
  37.     }
Add Comment
Please, Sign In to add comment