GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
solvers_direct.c File Reference
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include "grass/gis.h"
#include "grass/glocale.h"
#include "grass/gmath.h"
Include dependency graph for solvers_direct.c:

Go to the source code of this file.

Macros

#define TINY   1.0e-20
 
#define COMP_PIVOT   100
 

Functions

int G_math_solver_gauss (double **A, double *x, double *b, int rows)
 The gauss elimination solver for quardatic matrices. More...
 
int G_math_solver_lu (double **A, double *x, double *b, int rows)
 The LU solver for quardatic matrices. More...
 
int G_math_solver_cholesky (double **A, double *x, double *b, int bandwith, int rows)
 The choleksy decomposition solver for quardatic, symmetric positiv definite matrices. More...
 
void G_math_gauss_elimination (double **A, double *b, int rows)
 Gauss elimination. More...
 
void G_math_lu_decomposition (double **A, double *b, int rows)
 lu decomposition More...
 
int G_math_cholesky_decomposition (double **A, int rows, int bandwith)
 cholesky decomposition for symmetric, positiv definite matrices with bandwith optimization More...
 
void G_math_backward_solving (double **A, double *x, double *b, int rows)
 backward solving More...
 
void G_math_forward_solving (double **A, double *x, double *b, int rows)
 forward solving More...
 
int G_math_pivot_create (double **A, double *b, int rows, int start)
 Optimize the structure of the linear equation system with a common pivoting strategy. More...
 

Macro Definition Documentation

#define COMP_PIVOT   100

Definition at line 28 of file solvers_direct.c.

#define TINY   1.0e-20

Definition at line 27 of file solvers_direct.c.

Referenced by G_math_pivot_create().

Function Documentation

void G_math_backward_solving ( double **  A,
double *  x,
double *  b,
int  rows 
)

backward solving

Parameters
Adouble **
xdouble *
bdouble *
rowsint
Returns
void

Definition at line 296 of file solvers_direct.c.

Referenced by G_math_solver_cholesky(), G_math_solver_gauss(), and G_math_solver_lu().

int G_math_cholesky_decomposition ( double **  A,
int  rows,
int  bandwith 
)

cholesky decomposition for symmetric, positiv definite matrices with bandwith optimization

The provided matrix will be overwritten with the lower and upper triangle matrix A = LL^T

Parameters
Adouble **
rowsint
bandwithint – the bandwith of the matrix (0 > bandwith <= cols)
Returns
void

Definition at line 227 of file solvers_direct.c.

References G_warning().

Referenced by G_math_solver_cholesky().

void G_math_forward_solving ( double **  A,
double *  x,
double *  b,
int  rows 
)

forward solving

Parameters
Adouble **
xdouble *
bdouble *
rowsint
Returns
void

Definition at line 320 of file solvers_direct.c.

Referenced by G_math_solver_cholesky(), and G_math_solver_lu().

void G_math_gauss_elimination ( double **  A,
double *  b,
int  rows 
)

Gauss elimination.

To run this solver efficiently, no pivoting is supported. The matrix will be overwritten with the decomposite form

Parameters
Adouble **
bdouble *
rowsint
Returns
void

Definition at line 155 of file solvers_direct.c.

Referenced by G_math_solver_gauss().

void G_math_lu_decomposition ( double **  A,
double *  b,
int  rows 
)

lu decomposition

To run this solver efficiently, no pivoting is supported. The matrix will be overwritten with the decomposite form

Parameters
Adouble **
bdouble * – this vector is needed if its part of the linear equation system, otherwise set it to NULL
rowsint
Returns
void

Definition at line 192 of file solvers_direct.c.

Referenced by G_math_solver_lu().

int G_math_pivot_create ( double **  A,
double *  b,
int  rows,
int  start 
)

Optimize the structure of the linear equation system with a common pivoting strategy.

Create a optimized linear equation system for direct solvers: gauss and lu decomposition.

The rows are permuted based on the pivot elements.

This algorithm will modify the provided linear equation system and should only be used with the gauss elimination and lu decomposition solver.

Parameters
Adouble ** - a quadratic matrix
bdouble * - the right hand vector, if not available set it to NULL
rowsint
startint – the row
Returns
int - the number of swapped rows

Definition at line 357 of file solvers_direct.c.

References G_alloc_vector(), G_debug(), G_free_vector(), G_math_d_copy(), G_warning(), max, NULL, num, dialogs::s, and TINY.

int G_math_solver_cholesky ( double **  A,
double *  x,
double *  b,
int  bandwith,
int  rows 
)

The choleksy decomposition solver for quardatic, symmetric positiv definite matrices.

This solver does not support sparse matrices The matrix A will be overwritten. The result is written to the vector x

Parameters
Adouble **
xdouble *
bdouble * rows int
Returns
int – 1 success

Definition at line 126 of file solvers_direct.c.

References G_math_backward_solving(), G_math_cholesky_decomposition(), G_math_forward_solving(), G_message(), and G_warning().

int G_math_solver_gauss ( double **  A,
double *  x,
double *  b,
int  rows 
)

The gauss elimination solver for quardatic matrices.

This solver does not support sparse matrices The matrix A will be overwritten. The result is written to the vector x

Parameters
Adouble **
xdouble *
bdouble * rows int
Returns
int – 1 success

Definition at line 43 of file solvers_direct.c.

References G_math_backward_solving(), G_math_gauss_elimination(), and G_message().

int G_math_solver_lu ( double **  A,
double *  x,
double *  b,
int  rows 
)

The LU solver for quardatic matrices.

This solver does not support sparse matrices The matrix A will be overwritten. The result is written to the vector x in the G_math_les structure

Parameters
Adouble **
xdouble *
bdouble * rows int
Returns
int – 1 success

Definition at line 67 of file solvers_direct.c.

References G_alloc_vector(), G_free(), G_math_backward_solving(), G_math_forward_solving(), G_math_lu_decomposition(), and G_message().