gauss.c: set a proper accuracy value: 1E-6
authorMarkus Brökers <mbroeker@largo.homelinux.org>
Mon, 30 Aug 2010 15:21:47 +0200
changeset 146 0ffa20c26b2d
parent 145 63a5269fb113
child 147 f9015072361f
gauss.c: set a proper accuracy value: 1E-6
gauss.c
--- 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++;