gauss.c
changeset 146 0ffa20c26b2d
parent 77 49e0babccb23
--- a/gauss.c
+++ b/gauss.c
@@ -8,8 +8,8 @@
 #ifndef VERBOSE
 #define VERBOSE 1
 #endif
-#ifndef ZEROASSUMPTION
-#define ZEROASSUMPTION 1E-3     /* 0.001 = 0.0 */
+#ifndef ACCURACY
+#define ACCURACY 1E-6           /* 0.000001 = 0.0 */
 #endif
 
 #include <stdio.h>
@@ -21,8 +21,6 @@
 
     for (k = 0; k < MAXY; k++) {
         for (n = 0; n < MAXX - 1; n++) {
-            if ((A[k][n] < ZEROASSUMPTION) && (A[k][n] > -ZEROASSUMPTION))
-                A[k][n] = 0.0;
             printf ("%8.2f ", A[k][n]);
         }
         printf ("=%8.2f\n", A[k][n]);
@@ -46,6 +44,8 @@
             for (n = 0; n < MAXX; n++) {
                 A[k][n] *= -h;
                 A[k][n] += A[j][n];
+                if ((A[k][n] < ACCURACY) && (A[k][n] > -ACCURACY))
+                    A[k][n] = ACCURACY;
             }
         }
         i++;