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

Go to the source code of this file.

Functions

int G_math_add_spvector (G_math_spvector **Asp, G_math_spvector *spvector, int row)
 Adds a sparse vector to a sparse linear equation system at position row. More...
 
G_math_spvector ** G_math_alloc_spmatrix (int rows)
 Allocate memory for a sparse matrix. More...
 
G_math_spvector * G_math_alloc_spvector (int cols)
 Allocate memory for a sparse vector. More...
 
void G_math_free_spvector (G_math_spvector *spvector)
 Release the memory of the sparse vector. More...
 
void G_math_free_spmatrix (G_math_spvector **spmatrix, int rows)
 Release the memory of the sparse matrix. More...
 
void G_math_print_spmatrix (G_math_spvector **Asp, int rows)
 print the sparse matrix Asp to stdout More...
 
double ** G_math_Asp_to_A (G_math_spvector **Asp, int rows)
 Convert a sparse matrix into a quadratic matrix. More...
 
G_math_spvector ** G_math_A_to_Asp (double **A, int rows, double epsilon)
 Convert a quadratic matrix into a sparse matrix. More...
 

Function Documentation

G_math_spvector** G_math_A_to_Asp ( double **  A,
int  rows,
double  epsilon 
)

Convert a quadratic matrix into a sparse matrix.

This function is multi-threaded with OpenMP. It creates its own parallel OpenMP region.

Parameters
A(double **)
rows(int)
epsilon(double) – non-zero values are greater then epsilon
Returns
(G_math_spvector **)

Definition at line 207 of file sparse_matrix.c.

References count, G_math_add_spvector(), G_math_alloc_spmatrix(), G_math_alloc_spvector(), and NULL.

int G_math_add_spvector ( G_math_spvector **  Asp,
G_math_spvector *  spvector,
int  row 
)

Adds a sparse vector to a sparse linear equation system at position row.

Return 1 for success and -1 for failure

Parameters
spmatrixG_math_spvector **
spvectorG_math_spvector *
rowint
Returns
int 1 success, -1 failure

Definition at line 35 of file sparse_matrix.c.

References G_debug(), and NULL.

Referenced by G_math_A_to_Asp(), N_assemble_les_2d_param(), and N_assemble_les_3d_param().

G_math_spvector** G_math_alloc_spmatrix ( int  rows)

Allocate memory for a sparse matrix.

Parameters
rowsint
Returns
G_math_spvector **

Definition at line 58 of file sparse_matrix.c.

References G_debug().

Referenced by G_math_A_to_Asp(), and N_alloc_les_param().

G_math_spvector* G_math_alloc_spvector ( int  cols)

Allocate memory for a sparse vector.

Parameters
colsint
Returns
G_math_spvector *

Definition at line 76 of file sparse_matrix.c.

References dialogs::cols, and G_debug().

Referenced by G_math_A_to_Asp(), N_assemble_les_2d_param(), and N_assemble_les_3d_param().

double** G_math_Asp_to_A ( G_math_spvector **  Asp,
int  rows 
)

Convert a sparse matrix into a quadratic matrix.

This function is multi-threaded with OpenMP. It creates its own parallel OpenMP region.

Parameters
Asp(G_math_spvector **)
rows(int)
Returns
(double **)

Definition at line 179 of file sparse_matrix.c.

References G_alloc_matrix(), and NULL.

void G_math_free_spmatrix ( G_math_spvector **  spmatrix,
int  rows 
)

Release the memory of the sparse matrix.

Parameters
spvectorG_math_spvector **
rowsint
Returns
void

Definition at line 121 of file sparse_matrix.c.

References G_free(), G_math_free_spvector(), and NULL.

Referenced by N_free_les().

void G_math_free_spvector ( G_math_spvector *  spvector)

Release the memory of the sparse vector.

Parameters
spvectorG_math_spvector *
Returns
void

Definition at line 98 of file sparse_matrix.c.

References G_free(), and NULL.

Referenced by G_math_free_spmatrix().

void G_math_print_spmatrix ( G_math_spvector **  Asp,
int  rows 
)

print the sparse matrix Asp to stdout

Parameters
Asp(G_math_spvector **)
rows(int)
Returns
void

Definition at line 146 of file sparse_matrix.c.