Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // while we're less than or equal to the number of iterations
- for(itt=0; itt<=itt_max; itt++)
- {
- // reset error
- error=0.0;
- // rows
- for(i=0; i< n; i++)
- {
- sum = 0.0;
- // columns of the rows
- for(j=0; j< n; j++)
- {
- // multiply an entry
- sum += a[i][j] * t[j];
- }
- t1[i] = sum + b[i];
- errori = fabs(t1[i]-t[i]);
- if(errori > error) {
- error=errori;
- }
- }
- // answer into temporary array
- ttemp = t1;
- // old x vector into t1 (why?)
- t1 = t;
- // new x vector is the answer from the last multiplication
- t = ttemp;
- // print, do it all over again
- printf("%5d %14.6e\n", itt, error);
- }
Add Comment
Please, Sign In to add comment