GRASS Programmer's Manual  6.4.4(2014)-r
N_les.c File Reference
#include "grass/N_pde.h"
#include <stdlib.h>
Include dependency graph for N_les.c:

Go to the source code of this file.

Functions

N_spvectorN_alloc_spvector (int cols)
 Allocate memory for a sparse vector. More...
 
N_lesN_alloc_nquad_les (int cols, int rows, int type)
 Allocate memory for a (not) quadratic linear equation system which includes the Matrix A, vector x and vector b. More...
 
N_lesN_alloc_nquad_les_Ax (int cols, int rows, int type)
 Allocate memory for a (not) quadratic linear equation system which includes the Matrix A and vector x. More...
 
N_lesN_alloc_nquad_les_A (int cols, int rows, int type)
 Allocate memory for a (not) quadratic linear equation system which includes the Matrix A. More...
 
N_lesN_alloc_nquad_les_Ax_b (int cols, int rows, int type)
 Allocate memory for a (not) quadratic linear equation system which includes the Matrix A, vector x and vector b. More...
 
N_lesN_alloc_les (int rows, int type)
 Allocate memory for a quadratic linear equation system which includes the Matrix A, vector x and vector b. More...
 
N_lesN_alloc_les_Ax (int rows, int type)
 Allocate memory for a quadratic linear equation system which includes the Matrix A and vector x. More...
 
N_lesN_alloc_les_A (int rows, int type)
 Allocate memory for a quadratic linear equation system which includes the Matrix A. More...
 
N_lesN_alloc_les_Ax_b (int rows, int type)
 Allocate memory for a quadratic linear equation system which includes the Matrix A, vector x and vector b. More...
 
N_lesN_alloc_les_param (int cols, int rows, int type, int parts)
 Allocate memory for a quadratic or not quadratic linear equation system. More...
 
int N_add_spvector_to_les (N_les *les, N_spvector *spvector, int row)
 Adds a sparse vector to a sparse linear equation system at position row. More...
 
void N_print_les (N_les *les)
 prints the linear equation system to stdout More...
 
void N_free_spvector (N_spvector *spvector)
 Release the memory of the sparse vector. More...
 
void N_free_les (N_les *les)
 Release the memory of the linear equation system. More...
 

Function Documentation

int N_add_spvector_to_les ( N_les les,
N_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
lesN_les *
spvectorN_spvector *
rowint
Returns
int

Definition at line 263 of file N_les.c.

References N_les::Asp, G_debug(), N_SPARSE_LES, NULL, N_les::rows, and N_les::type.

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

N_les* N_alloc_les ( int  rows,
int  type 
)

Allocate memory for a quadratic linear equation system which includes the Matrix A, vector x and vector b.

This function calls N_alloc_les_param

Parameters
rowsint
typeint
Returns
N_les *

Definition at line 120 of file N_les.c.

References N_alloc_les_param().

N_les* N_alloc_les_A ( int  rows,
int  type 
)

Allocate memory for a quadratic linear equation system which includes the Matrix A.

This function calls N_alloc_les_param

Parameters
rowsint
typeint
Returns
N_les *

Definition at line 150 of file N_les.c.

References N_alloc_les_param().

Referenced by N_create_diag_precond_matrix().

N_les* N_alloc_les_Ax ( int  rows,
int  type 
)

Allocate memory for a quadratic linear equation system which includes the Matrix A and vector x.

This function calls N_alloc_les_param

Parameters
rowsint
typeint
Returns
N_les *

Definition at line 135 of file N_les.c.

References N_alloc_les_param().

N_les* N_alloc_les_Ax_b ( int  rows,
int  type 
)

Allocate memory for a quadratic linear equation system which includes the Matrix A, vector x and vector b.

This function calls N_alloc_les_param

Parameters
rowsint
typeint
Returns
N_les *

Definition at line 165 of file N_les.c.

References N_alloc_les_param().

Referenced by N_assemble_les_2d_param(), and N_assemble_les_3d_param().

N_les* N_alloc_les_param ( int  cols,
int  rows,
int  type,
int  parts 
)

Allocate memory for a quadratic or not quadratic linear equation system.

The type of the linear equation system must be N_NORMAL_LES for a regular quadratic matrix or N_SPARSE_LES for a sparse matrix

In case of N_NORMAL_LES

A quadratic matrix of size rows*rows*sizeof(double) will allocated

In case of N_SPARSE_LES

a vector of size row will be allocated, ready to hold additional allocated sparse vectors. each sparse vector may have a different size.

Parameter parts defines which parts of the les should be allocated. The number of columns and rows defines if the matrix is quadratic.

Parameters
colsint
rowsint
typeint
partsint – 2 = A, x and b; 1 = A and x; 0 = A allocated
Returns
N_les *

Definition at line 198 of file N_les.c.

References N_les::A, N_les::Asp, N_les::b, N_les::cols, dialogs::cols, G_debug(), N_NORMAL_LES, N_SPARSE_LES, NULL, N_les::quad, N_les::rows, N_les::type, and N_les::x.

Referenced by N_alloc_les(), N_alloc_les_A(), N_alloc_les_Ax(), N_alloc_les_Ax_b(), N_alloc_nquad_les(), N_alloc_nquad_les_A(), N_alloc_nquad_les_Ax(), and N_alloc_nquad_les_Ax_b().

N_les* N_alloc_nquad_les ( int  cols,
int  rows,
int  type 
)

Allocate memory for a (not) quadratic linear equation system which includes the Matrix A, vector x and vector b.

This function calls N_alloc_les_param

Parameters
colsint
rowsint
typeint
Returns
N_les *

Definition at line 55 of file N_les.c.

References N_alloc_les_param().

N_les* N_alloc_nquad_les_A ( int  cols,
int  rows,
int  type 
)

Allocate memory for a (not) quadratic linear equation system which includes the Matrix A.

This function calls N_alloc_les_param

Parameters
colsint
rowsint
typeint
Returns
N_les *

Definition at line 87 of file N_les.c.

References N_alloc_les_param().

N_les* N_alloc_nquad_les_Ax ( int  cols,
int  rows,
int  type 
)

Allocate memory for a (not) quadratic linear equation system which includes the Matrix A and vector x.

This function calls N_alloc_les_param

Parameters
colsint
rowsint
typeint
Returns
N_les *

Definition at line 71 of file N_les.c.

References N_alloc_les_param().

N_les* N_alloc_nquad_les_Ax_b ( int  cols,
int  rows,
int  type 
)

Allocate memory for a (not) quadratic linear equation system which includes the Matrix A, vector x and vector b.

This function calls N_alloc_les_param

Parameters
colsint
rowsint
typeint
Returns
N_les *

Definition at line 103 of file N_les.c.

References N_alloc_les_param().

N_spvector* N_alloc_spvector ( int  cols)

Allocate memory for a sparse vector.

Parameters
colsint
Returns
N_spvector *

Definition at line 29 of file N_les.c.

References N_spvector::cols, dialogs::cols, G_debug(), N_spvector::index, and N_spvector::values.

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

void N_free_les ( N_les les)

Release the memory of the linear equation system.

Parameters
lesN_les *
Returns
void

Definition at line 387 of file N_les.c.

References N_les::A, N_les::Asp, N_les::b, free(), G_debug(), G_free(), N_free_spvector(), N_SPARSE_LES, N_les::rows, N_les::type, and N_les::x.

void N_free_spvector ( N_spvector spvector)

Release the memory of the sparse vector.

Parameters
spvectorN_spvector *
Returns
void

Definition at line 363 of file N_les.c.

References G_free(), N_spvector::index, NULL, and N_spvector::values.

Referenced by N_free_les().

void N_print_les ( N_les les)

prints the linear equation system to stdout

Format: A*x = b

Example

2 1 1 1 * 2 = 0.1
1 2 0 0 * 3 = 0.2
1 0 2 0 * 3 = 0.2
1 0 0 2 * 2 = 0.1
Parameters
lesN_les *
Returns
void

Definition at line 312 of file N_les.c.

References N_les::A, N_les::Asp, N_les::b, N_spvector::cols, N_les::cols, N_spvector::index, N_SPARSE_LES, N_les::rows, N_les::type, N_spvector::values, and N_les::x.