gauss.c
changeset 146 0ffa20c26b2d
parent 77 49e0babccb23
equal deleted inserted replaced
145:63a5269fb113 146:0ffa20c26b2d
     6 #define VERSION 0.8
     6 #define VERSION 0.8
     7 
     7 
     8 #ifndef VERBOSE
     8 #ifndef VERBOSE
     9 #define VERBOSE 1
     9 #define VERBOSE 1
    10 #endif
    10 #endif
    11 #ifndef ZEROASSUMPTION
    11 #ifndef ACCURACY
    12 #define ZEROASSUMPTION 1E-3     /* 0.001 = 0.0 */
    12 #define ACCURACY 1E-6           /* 0.000001 = 0.0 */
    13 #endif
    13 #endif
    14 
    14 
    15 #include <stdio.h>
    15 #include <stdio.h>
    16 #include <stdlib.h>
    16 #include <stdlib.h>
    17 
    17 
    19 {
    19 {
    20     int n, k;
    20     int n, k;
    21 
    21 
    22     for (k = 0; k < MAXY; k++) {
    22     for (k = 0; k < MAXY; k++) {
    23         for (n = 0; n < MAXX - 1; n++) {
    23         for (n = 0; n < MAXX - 1; n++) {
    24             if ((A[k][n] < ZEROASSUMPTION) && (A[k][n] > -ZEROASSUMPTION))
       
    25                 A[k][n] = 0.0;
       
    26             printf ("%8.2f ", A[k][n]);
    24             printf ("%8.2f ", A[k][n]);
    27         }
    25         }
    28         printf ("=%8.2f\n", A[k][n]);
    26         printf ("=%8.2f\n", A[k][n]);
    29     }
    27     }
    30 }
    28 }
    44                 continue;
    42                 continue;
    45 
    43 
    46             for (n = 0; n < MAXX; n++) {
    44             for (n = 0; n < MAXX; n++) {
    47                 A[k][n] *= -h;
    45                 A[k][n] *= -h;
    48                 A[k][n] += A[j][n];
    46                 A[k][n] += A[j][n];
       
    47                 if ((A[k][n] < ACCURACY) && (A[k][n] > -ACCURACY))
       
    48                     A[k][n] = ACCURACY;
    49             }
    49             }
    50         }
    50         }
    51         i++;
    51         i++;
    52     }
    52     }
    53 
    53