gauss.c
author Markus Bröker <mbroeker@largo.dyndns.tv>
Sat, 13 Dec 2008 17:58:02 +0100
changeset 9 c3fecc82ade6
parent 8 96d16dfe787a
child 27 81a574d60c15
permissions -rw-r--r--
standard tags for git projects committer: Markus Bröker <mbroeker@largo.homelinux.org>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     1
/**
9
c3fecc82ade6 standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 8
diff changeset
     2
 * test/demos/gauss.c
c3fecc82ade6 standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 8
diff changeset
     3
 * Copyright (C) 2008 Markus Broeker
3
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     4
 */
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     5
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     6
#define VERSION 0.8
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     7
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     8
#ifndef VERBOSE
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     9
#define VERBOSE 1
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    10
#endif
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    11
#ifndef ZEROASSUMPTION
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    12
#define ZEROASSUMPTION 1E-3     /* 0.001 = 0.0 */
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    13
#endif
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    14
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    15
#include <stdio.h>
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    16
#include <stdlib.h>
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    17
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    18
void ausgabe (float **A, int MAXX, int MAXY)
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    19
{
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    20
    int n, k;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    21
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    22
    for (k = 0; k < MAXY; k++) {
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    23
        for (n = 0; n < MAXX - 1; n++) {
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    24
            if ((A[k][n] < ZEROASSUMPTION) && (A[k][n] > -ZEROASSUMPTION))
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    25
                A[k][n] = 0.0;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    26
            printf ("%8.2f ", A[k][n]);
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    27
        }
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    28
        printf ("=%8.2f\n", A[k][n]);
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    29
    }
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    30
}
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    31
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    32
void gauss (float **A, int MAXX, int MAXY)
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    33
{
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    34
    int i, j, k, n;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    35
    float h;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    36
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    37
    i = 0;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    38
    for (j = 0; j < MAXY; j++) {
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    39
        for (k = j + 1; k < MAXY; k++) {
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    40
            if (A[k][i] != 0)
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    41
                h = A[j][i] / A[k][i];
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    42
            else
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    43
                continue;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    44
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    45
            for (n = 0; n < MAXX; n++) {
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    46
                A[k][n] *= -h;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    47
                A[k][n] += A[j][n];
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    48
            }
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    49
        }
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    50
        i++;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    51
    }
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    52
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    53
#ifdef PUPILS
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    54
    printf ("\n");
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    55
    ausgabe (A, MAXX, MAXY);
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    56
    printf ("\n");
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    57
#endif
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    58
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    59
    i--;                        /* i = (MAXX-1)-1; */
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    60
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    61
    for (j = MAXY - 1; j > -1; j--) {
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    62
        for (k = j - 1; k > -1; k--) {
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    63
            h = A[j][i] / A[k][i];
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    64
            for (n = MAXX - 1; n > k - 1; n--) {
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    65
                A[k][n] *= -h;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    66
                A[k][n] += (A[j][n]);
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    67
                if (A[j][i] == 0.0) {
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    68
                    printf ("Divison by Zero\n");
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    69
                    exit (-1);
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    70
                }
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    71
                A[j][n] /= (A[j][i]);
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    72
            }
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    73
        }
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    74
        i--;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    75
    }
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    76
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    77
    if ((h = A[0][0]) == 0.0) {
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    78
        printf ("Division by Zero\n");
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    79
        exit (-1);
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    80
    }
8
96d16dfe787a We use return EXIT_SUCCESS instead of return 0
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 3
diff changeset
    81
    /*
96d16dfe787a We use return EXIT_SUCCESS instead of return 0
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 3
diff changeset
    82
     * h=A[0][0];
96d16dfe787a We use return EXIT_SUCCESS instead of return 0
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 3
diff changeset
    83
     */
3
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    84
    A[0][0] /= h;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    85
    A[0][MAXX - 1] /= h;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    86
}
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    87
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    88
int main (int argc, char **argv)
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    89
{
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    90
    int i, k;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    91
    int MAXX, MAXY;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    92
    float value;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    93
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    94
    float **A;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    95
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    96
    if (argc != 2) {
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    97
        printf ("Benutzung: %s UNBEKANNTE\n", argv[0]);
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    98
        printf ("Berechnet ein lineares Gleichungssystem mit n UNBEKANNTEN und n Zeilen ( nxn ).\n");
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    99
        printf ("Praktische Beispiele stehen in der README Datei.\n");
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   100
        return EXIT_SUCCESS;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   101
    }
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   102
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   103
    MAXY = atoi (argv[1]);
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   104
    MAXX = MAXY + 1;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   105
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   106
    if ((A = calloc (MAXY, sizeof (float *))) == NULL) {
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   107
        printf ("Nicht genug Speicher verfuegbar\n");
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   108
        return EXIT_SUCCESS;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   109
    }
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   110
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   111
    for (i = 0; i < MAXY; i++) {
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   112
        if ((A[i] = calloc (MAXX, sizeof (float))) == NULL) {
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   113
            printf ("Nicht genug Speicher verfuegbar\n");
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   114
            for (k = 0; k < i; k++)
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   115
                free (A[k]);
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   116
            free (A);
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   117
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   118
            return EXIT_SUCCESS;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   119
        }
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   120
    }
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   121
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   122
    for (k = 0; k < MAXY; k++) {
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   123
        printf ("Spalte %d: ", k);
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   124
        for (i = 0; i < MAXX; i++) {
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   125
            if (scanf ("%f", &value) < 1) {
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   126
                printf ("READ ERROR\n");
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   127
                return EXIT_FAILURE;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   128
            }
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   129
            A[k][i] = value;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   130
        }
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   131
    }
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   132
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   133
    if (VERBOSE) {
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   134
        printf ("\n");
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   135
        ausgabe (A, MAXX, MAXY);
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   136
    }
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   137
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   138
    gauss (A, MAXX, MAXY);
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   139
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   140
    printf ("\nLoesung des GL-Systems( %d x %d )\n\n", MAXX - 1, MAXY);
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   141
    for (i = 0; i < MAXY; i++)
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   142
        printf ("a[%2d] = %8.2f\n", i, A[i][MAXX - 1]);
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   143
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   144
    for (i = 0; i < MAXY; i++)
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   145
        if (A[i] != NULL)
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   146
            free (A[i]);
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   147
    if (A != NULL)
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   148
        free (A);
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   149
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   150
    return EXIT_SUCCESS;
820ed7fb9314 database, gauss, lotto, mem2swap, prog_limit moved to demos
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   151
}