Back to index

extremetuxracer  0.5beta
Defines | Functions
gaus.h File Reference
#include <math.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define EPS   1.0e-10

Functions

static unsigned short order (double *matrix, int n, int pivot)
static void elim (double *matrix, int n, int pivot)
static void backsb (double *matrix, int n, double *soln)
static int gauss (double *matrix, int n, double *soln)

Define Documentation

#define EPS   1.0e-10

Definition at line 27 of file gaus.h.


Function Documentation

static void backsb ( double *  matrix,
int  n,
double *  soln 
) [static]

Definition at line 119 of file gaus.h.

{
    int row, col;


    for (row = n-1; row >=0; row--)
    {
       for (col = n-1; col >= row+1; col--)
       {
           *(matrix+row*(n+1)+(n)) = *(matrix+row*(n+1)+n) - 
              (*(soln+col))*(*(matrix+row*(n+1)+col));
       }
       *(soln+row) = (*(matrix+row*(n+1)+n))/(*(matrix+row*(n+1)+row));
    }

}

Here is the caller graph for this function:

static void elim ( double *  matrix,
int  n,
int  pivot 
) [static]

Definition at line 101 of file gaus.h.

{
    int row, col;
    double factor;

    for (row = pivot+1; row < n; row++)
    {
       factor = (*(matrix+row*(n+1)+pivot))/(*(matrix+pivot*(n+1)+pivot));
       *(matrix+row*(n+1)+pivot)=0.0;
       for (col=pivot+1l; col<n+1; col++)
       {
           *(matrix+row*(n+1)+col) = *(matrix+row*(n+1)+col) - 
              (*(matrix+pivot*(n+1)+col))*factor;
       }
    }
}

Here is the caller graph for this function:

static int gauss ( double *  matrix,
int  n,
double *  soln 
) [static]

Definition at line 43 of file gaus.h.

{
    int pivot=0;
    unsigned short error=0;


    while ((pivot<(n-1)) && (!error))
    {
       if(!(error = order(matrix,n,pivot)))
       {
           elim(matrix,n,pivot);
           pivot++;
       }
    }

    if (error)
    {
       return 1;
    }
    else
    {
       backsb(matrix, n, soln);
    }
       
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static unsigned short order ( double *  matrix,
int  n,
int  pivot 
) [static]

Definition at line 71 of file gaus.h.

{
    int row, rmax, k;
    double temp;
    unsigned short error=0;

    rmax = pivot;

    for (row=pivot+1; row<n; row++)
    {
       if (fabs(*(matrix+row*(n+1)+pivot)) > fabs(*(matrix+rmax*(n+1)+pivot)))
           rmax = row;
    }

    if (fabs(*(matrix+rmax*(n+1)+pivot)) < EPS )
       error = 1;
    else if (rmax != pivot)
    {
       for (k=0; k<(n+1); k++)
       {
           temp = *(matrix+rmax*(n+1)+k);
           *(matrix+rmax*(n+1)+k) = *(matrix+pivot*(n+1)+k);
           *(matrix+pivot*(n+1)+k) = temp;
       }
    }

    return error;

}

Here is the caller graph for this function: