GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
defs/gmath.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

double * G_alloc_vector (size_t)
 Vector matrix memory allocation. More...
 
double ** G_alloc_matrix (int, int)
 Matrix memory allocation. More...
 
float * G_alloc_fvector (size_t)
 Floating point vector memory allocation. More...
 
float ** G_alloc_fmatrix (int, int)
 Floating point matrix memory allocation. More...
 
void G_free_vector (double *)
 Vector memory deallocation. More...
 
void G_free_matrix (double **)
 Matrix memory deallocation. More...
 
void G_free_fvector (float *)
 Vector memory deallocation. More...
 
void G_free_fmatrix (float **)
 Floating point matrix memory deallocation. More...
 
int * G_alloc_ivector (size_t)
 Vector matrix memory allocation. More...
 
int ** G_alloc_imatrix (int, int)
 Matrix memory allocation. More...
 
void G_free_ivector (int *)
 Vector memory deallocation. More...
 
void G_free_imatrix (int **)
 Matrix memory deallocation. More...
 
int fft (int, double *[2], int, int, int)
 Fast Fourier Transform for two-dimensional array. More...
 
int fft2 (int, double(*)[2], int, int, int)
 Fast Fourier Transform for two-dimensional array. More...
 
double G_math_rand_gauss (double)
 
long G_math_max_pow2 (long n)
 Finds least power of 2 >= n More...
 
long G_math_min_pow2 (long n)
 Finds largest power of 2 <= n More...
 
void G_math_srand (int)
 Seed the pseudo-random number generator. More...
 
int G_math_srand_auto (void)
 Seed the pseudo-random number generator from the time and PID. More...
 
float G_math_rand (void)
 
int del2g (double *[2], int, double)
 
int getg (double, double *[2], int)
 
int G_math_egvorder (double *, double **, long)
 
int G_math_complex_mult (double *v1[2], int size1, double *v2[2], int size2, double *v3[2], int size3)
 Multiply two complex vectors, point by point. More...
 
int G_ludcmp (double **, int, int *, double *)
 LU decomposition. More...
 
void G_lubksb (double **a, int n, int *indx, double b[])
 LU backward substitution. More...
 
int G_math_findzc (double conv[], int size, double zc[], double thresh, int num_orients)
 Finds locations and orientations of zero crossings. More...
 
int G_math_solv (double **, double *, int)
 Solve a general linear system A*x = b. More...
 
int G_math_solvps (double **, double *, int)
 Solve a symmetric positive definite linear system S*x = b. More...
 
void G_math_solvtd (double *, double *, double *, double *, int)
 Solve a tridiagonal linear system M*x = y. More...
 
int G_math_solvru (double **, double *, int)
 
int G_math_minv (double **, int)
 Invert (in place) a general real matrix A -> Inv(A). More...
 
int G_math_psinv (double **, int)
 Invert (in place) a symmetric real matrix, V -> Inv(V). More...
 
int G_math_ruinv (double **, int)
 Invert an upper right triangular matrix T -> Inv(T). More...
 
void G_math_eigval (double **, double *, int)
 Compute the eigenvalues of a real symmetric matrix A. More...
 
void G_math_eigen (double **, double *, int)
 Compute the eigenvalues and eigenvectors of a real symmetric matrix A. More...
 
double G_math_evmax (double **, double *, int)
 
int G_math_svdval (double *, double **, int, int)
 Compute the singular values of a real m by n matrix A. More...
 
int G_math_sv2val (double *, double **, int, int)
 Compute singular values when m >> n. More...
 
int G_math_svduv (double *, double **, double **, int, double **, int)
 
int G_math_sv2uv (double *, double **, double **, int, double **, int)
 Compute the singular value transformation when m >> n. More...
 
int G_math_svdu1v (double *, double **, int, double **, int)
 Compute the singular value transformation with A overloaded by the partial U-matrix. More...
 
G_math_spvectorG_math_alloc_spvector (int)
 Allocate memory for a sparse vector. More...
 
G_math_spvector ** G_math_alloc_spmatrix (int)
 Allocate memory for a sparse matrix. More...
 
void G_math_free_spmatrix (G_math_spvector **, int)
 Release the memory of the sparse matrix. More...
 
void G_math_free_spvector (G_math_spvector *)
 Release the memory of the sparse vector. More...
 
int G_math_add_spvector (G_math_spvector **, G_math_spvector *, int)
 Adds a sparse vector to a sparse matrix at position row. More...
 
G_math_spvector ** G_math_A_to_Asp (double **, int, double)
 Convert a quadratic matrix into a sparse matrix. More...
 
double ** G_math_Asp_to_A (G_math_spvector **, int)
 Convert a sparse matrix into a quadratic matrix. More...
 
double ** G_math_Asp_to_sband_matrix (G_math_spvector **, int, int)
 Convert a symmetric sparse matrix into a symmetric band matrix. More...
 
G_math_spvector ** G_math_sband_matrix_to_Asp (double **, int, int, double)
 Convert a symmetric band matrix into a sparse matrix. More...
 
void G_math_print_spmatrix (G_math_spvector **, int)
 print the sparse matrix Asp to stdout More...
 
void G_math_Ax_sparse (G_math_spvector **, double *, double *, int)
 Compute the matrix - vector product of sparse matrix **Asp and vector x. More...
 
double ** G_math_matrix_to_sband_matrix (double **, int, int)
 Convert a symmetrix matrix into a symmetric band matrix. More...
 
double ** G_math_sband_matrix_to_matrix (double **, int, int)
 Convert a symmetric band matrix into a symmetric matrix. More...
 
void G_math_Ax_sband (double **A, double *x, double *y, int rows, int bandwidth)
 Compute the matrix - vector product of symmetric band matrix A and vector x. More...
 
int G_math_solver_gauss (double **, double *, double *, int)
 The gauss elimination solver for quardatic matrices. More...
 
int G_math_solver_lu (double **, double *, double *, int)
 The LU solver for quardatic matrices. More...
 
int G_math_solver_cholesky (double **, double *, double *, int, int)
 The choleksy decomposition solver for quardatic, symmetric positiv definite matrices. More...
 
void G_math_solver_cholesky_sband (double **, double *, double *, int, int)
 Cholesky symmetric band matrix solver for linear equation systems of type Ax = b. More...
 
int G_math_solver_jacobi (double **, double *, double *, int, int, double, double)
 The iterative jacobi solver for quadratic matrices. More...
 
int G_math_solver_gs (double **, double *, double *, int, int, double, double)
 The iterative gauss seidel solver for quadratic matrices. More...
 
int G_math_solver_pcg (double **, double *, double *, int, int, double, int)
 The iterative preconditioned conjugate gradients solver for symmetric positive definite matrices. More...
 
int G_math_solver_cg (double **, double *, double *, int, int, double)
 The iterative conjugate gradients solver for symmetric positive definite matrices. More...
 
int G_math_solver_cg_sband (double **, double *, double *, int, int, int, double)
 The iterative conjugate gradients solver for symmetric positive definite band matrices. More...
 
int G_math_solver_bicgstab (double **, double *, double *, int, int, double)
 The iterative biconjugate gradients solver with stabilization for unsymmetric non-definite matrices. More...
 
int G_math_solver_sparse_jacobi (G_math_spvector **, double *, double *, int, int, double, double)
 The iterative jacobi solver for sparse matrices. More...
 
int G_math_solver_sparse_gs (G_math_spvector **, double *, double *, int, int, double, double)
 The iterative gauss seidel solver for sparse matrices. More...
 
int G_math_solver_sparse_pcg (G_math_spvector **, double *, double *, int, int, double, int)
 The iterative preconditioned conjugate gradients solver for sparse symmetric positive definite matrices. More...
 
int G_math_solver_sparse_cg (G_math_spvector **, double *, double *, int, int, double)
 The iterative conjugate gradients solver for sparse symmetric positive definite matrices. More...
 
int G_math_solver_sparse_bicgstab (G_math_spvector **, double *, double *, int, int, double)
 The iterative biconjugate gradients solver with stabilization for unsymmetric non-definite matrices. More...
 
void G_math_gauss_elimination (double **, double *, int)
 Gauss elimination. More...
 
void G_math_lu_decomposition (double **, double *, int)
 lu decomposition More...
 
int G_math_cholesky_decomposition (double **, int, int)
 cholesky decomposition for symmetric, positiv definite matrices with bandwidth optimization More...
 
void G_math_cholesky_sband_decomposition (double **, double **, int, int)
 Cholesky decomposition of a symmetric band matrix. More...
 
void G_math_backward_substitution (double **, double *, double *, int)
 backward substitution More...
 
void G_math_forward_substitution (double **, double *, double *, int)
 forward substitution More...
 
void G_math_cholesky_sband_substitution (double **, double *, double *, int, int)
 Forward and backward substitution of a lower tringular symmetric band matrix of A from system Ax = b. More...
 
void G_math_d_x_dot_y (double *, double *, double *, int)
 Compute the dot product of vector x and y. More...
 
void G_math_d_asum_norm (double *, double *, int)
 Compute the asum norm of vector x. More...
 
void G_math_d_euclid_norm (double *, double *, int)
 Compute the euclid norm of vector x. More...
 
void G_math_d_max_norm (double *, double *, int)
 Compute the maximum norm of vector x. More...
 
void G_math_d_ax_by (double *, double *, double *, double, double, int)
 Scales vectors x and y with the scalars a and b and adds them. More...
 
void G_math_d_copy (double *, double *, int)
 Copy the vector x to y. More...
 
void G_math_f_x_dot_y (float *, float *, float *, int)
 Compute the dot product of vector x and y. More...
 
void G_math_f_asum_norm (float *, float *, int)
 Compute the asum norm of vector x. More...
 
void G_math_f_euclid_norm (float *, float *, int)
 Compute the euclid norm of vector x. More...
 
void G_math_f_max_norm (float *, float *, int)
 Compute the maximum norm of vector x. More...
 
void G_math_f_ax_by (float *, float *, float *, float, float, int)
 Scales vectors x and y with the scalars a and b and adds them. More...
 
void G_math_f_copy (float *, float *, int)
 Copy the vector x to y. More...
 
void G_math_i_x_dot_y (int *, int *, double *, int)
 Compute the dot product of vector x and y. More...
 
void G_math_i_asum_norm (int *, double *, int)
 Compute the asum norm of vector x. More...
 
void G_math_i_euclid_norm (int *, double *, int)
 Compute the euclid norm of vector x. More...
 
void G_math_i_max_norm (int *, int *, int)
 Compute the maximum norm of vector x. More...
 
void G_math_i_ax_by (int *, int *, int *, int, int, int)
 Scales vectors x and y with the scalars a and b and adds them. More...
 
void G_math_i_copy (int *, int *, int)
 Copy the vector x to y. More...
 
double G_math_ddot (double *, double *, int)
 Compute the dot product of vector x and y using the ATLAS routine cblas_ddot. More...
 
float G_math_sdot (float *, float *, int)
 Compute the dot product of vector x and y using the ATLAS routine cblas_sdot. More...
 
float G_math_sdsdot (float *, float *, float, int)
 Compute the dot product of vector x and y using the ATLAS routine cblas_sdsdot. More...
 
double G_math_dnrm2 (double *, int)
 Compute the euclidean norm of vector x using the ATLAS routine cblas_dnrm2. More...
 
double G_math_dasum (double *, int)
 Compute the absolute sum norm of vector x using the ATLAS routine cblas_dasum. More...
 
double G_math_idamax (double *, int)
 Compute the maximum norm of vector x using the ATLAS routine cblas_idamax. More...
 
float G_math_snrm2 (float *, int)
 Compute the euclidean norm of vector x using the ATLAS routine cblas_dnrm2. More...
 
float G_math_sasum (float *, int)
 Compute the absolute sum norm of vector x using the ATLAS routine cblas_dasum. More...
 
float G_math_isamax (float *, int)
 Compute the maximum norm of vector x using the ATLAS routine cblas_idamax. More...
 
void G_math_dscal (double *, double, int)
 Scale vector x with scalar a using the ATLAS routine cblas_dscal. More...
 
void G_math_sscal (float *, float, int)
 Scale vector x with scalar a using the ATLAS routine cblas_dscal. More...
 
void G_math_dcopy (double *, double *, int)
 Copy vector x to vector y. More...
 
void G_math_scopy (float *, float *, int)
 Copy vector x to vector y. More...
 
void G_math_daxpy (double *, double *, double, int)
 Scale vector x with scalar a and add it to y. More...
 
void G_math_saxpy (float *, float *, float, int)
 Scale vector x with scalar a and add it to y. More...
 
void G_math_d_Ax (double **, double *, double *, int, int)
 Compute the matrix - vector product of matrix A and vector x. More...
 
void G_math_f_Ax (float **, float *, float *, int, int)
 Compute the matrix - vector product of matrix A and vector x. More...
 
void G_math_d_x_dyad_y (double *, double *, double **, int, int)
 Compute the dyadic product of two vectors. The result is stored in the matrix A. More...
 
void G_math_f_x_dyad_y (float *, float *, float **, int, int)
 Compute the dyadic product of two vectors. The result is stored in the matrix A. More...
 
void G_math_d_aAx_by (double **, double *, double *, double, double, double *, int, int)
 Compute the scaled matrix - vector product of matrix double **A and vector x and y. More...
 
void G_math_f_aAx_by (float **, float *, float *, float, float, float *, int, int)
 Compute the scaled matrix - vector product of matrix A and vectors x and y. More...
 
int G_math_d_A_T (double **A, int rows)
 Compute the transposition of matrix A. Matrix A will be overwritten. More...
 
int G_math_f_A_T (float **A, int rows)
 Compute the transposition of matrix A. Matrix A will be overwritten. More...
 
void G_math_d_aA_B (double **, double **, double, double **, int, int)
 Add two matrices and scale matrix A with the scalar a. More...
 
void G_math_f_aA_B (float **, float **, float, float **, int, int)
 Add two matrices and scale matrix A with the scalar a. More...
 
void G_math_d_AB (double **, double **, double **, int, int, int)
 Matrix multiplication. More...
 
void G_math_f_AB (float **, float **, float **, int, int, int)
 Matrix multiplication. More...
 

Function Documentation

◆ del2g()

int del2g ( double *  img[2],
int  size,
double  w 
)
Parameters
img
size
w
Returns
int

Definition at line 46 of file del2g.c.

References _, fft(), FORWARD, g, G_malloc, G_math_complex_mult(), G_message(), getg(), and INVERSE.

◆ fft()

int fft ( int  i_sign,
double *  DATA[2],
int  NN,
int  dimc,
int  dimr 
)

Fast Fourier Transform for two-dimensional array.

Fast Fourier Transform for two-dimensional array.
<bNote: If passing real data to fft() forward transform (especially when using fft() in a loop), explicitly (re-)initialize the imaginary part to zero (DATA[1][i] = 0.0). Returns 0.

Parameters
[in]i_signDirection of transform -1 is normal, +1 is inverse
[in,out]DATAPointer to complex linear array in row major order containing data and result
[in]NNValue of DATA dimension (dimc * dimr)
[in]dimcValue of image column dimension (max power of 2)
[in]dimrValue of image row dimension (max power of 2)
Returns
int always returns 0

Definition at line 127 of file fft.c.

Referenced by del2g().

◆ fft2()

int fft2 ( int  i_sign,
double(*)  data[2],
int  NN,
int  dimc,
int  dimr 
)

Fast Fourier Transform for two-dimensional array.

Fast Fourier Transform for two-dimensional array.
<bNote: If passing real data to fft() forward transform (especially when using fft() in a loop), explicitly (re-)initialize the imaginary part to zero (DATA[1][i] = 0.0). Returns 0.

Parameters
[in]i_signDirection of transform -1 is normal, +1 is inverse
[in,out]dataPointer to complex linear array in row major order containing data and result
[in]NNValue of DATA dimension (dimc * dimr)
[in]dimcValue of image column dimension (max power of 2)
[in]dimrValue of image row dimension (max power of 2)
Returns
int always returns 0

Definition at line 70 of file fft.c.

◆ G_alloc_fmatrix()

float ** G_alloc_fmatrix ( int  rows,
int  cols 
)

Floating point matrix memory allocation.

Allocate a matrix of rows by cols floats initialized to zero.

Parameters
[in]rowsnumber of rows in matrix
[in]colsnumber of columns in matrix
Returns
float **

Definition at line 104 of file dalloc.c.

References G_calloc.

◆ G_alloc_fvector()

float * G_alloc_fvector ( size_t  n)

Floating point vector memory allocation.

Allocate a vector (array) of n floats initialized to zero.

Parameters
[in]nsize of vector to allocate
Returns
float *

Definition at line 85 of file dalloc.c.

References G_calloc.

◆ G_alloc_imatrix()

int ** G_alloc_imatrix ( int  rows,
int  cols 
)

Matrix memory allocation.

Allocate a matrix of rows by cols integers initialized to zero.

Parameters
[in]rowsnumber of rows in matrix
[in]colsnumber of columns in matrix
Returns
int **

Definition at line 58 of file ialloc.c.

References G_calloc.

◆ G_alloc_ivector()

int * G_alloc_ivector ( size_t  n)

Vector matrix memory allocation.

Allocate a vector (array) of n integers initialized to zero.

Parameters
[in]nsize of vector to allocate
Returns
integer *

Definition at line 41 of file ialloc.c.

References G_calloc.

◆ G_alloc_matrix()

double ** G_alloc_matrix ( int  rows,
int  cols 
)

Matrix memory allocation.

Allocate a matrix of rows by cols doubles initialized to zero.

Parameters
[in]rowsnumber of rows in matrix
[in]colsnumber of columns in matrix
Returns
double **

Definition at line 60 of file dalloc.c.

References G_calloc.

◆ G_alloc_vector()

double * G_alloc_vector ( size_t  n)

Vector matrix memory allocation.

Allocate a vector (array) of n doubles initialized to zero.

Parameters
[in]nsize of vector to allocate
Returns
double *

Definition at line 41 of file dalloc.c.

References G_calloc.

Referenced by G_math_solver_sparse_gs(), and G_math_solver_sparse_jacobi().

◆ G_free_fmatrix()

void G_free_fmatrix ( float **  m)

Floating point matrix memory deallocation.

Deallocate a matrix of floats.

Parameters
[in,out]mmatrix to free
Returns
void

Definition at line 190 of file dalloc.c.

References G_free(), and NULL.

◆ G_free_fvector()

void G_free_fvector ( float *  v)

Vector memory deallocation.

Deallocate a vector (array) of floats.

Parameters
[in,out]vvector to free
Returns
void

Definition at line 149 of file dalloc.c.

References G_free(), and NULL.

◆ G_free_imatrix()

int G_free_imatrix ( int **  m)

Matrix memory deallocation.

Deallocate a matrix of integers.

Parameters
[in,out]mmatrix to free
Returns
void

Definition at line 99 of file ialloc.c.

References G_free(), and NULL.

◆ G_free_ivector()

void G_free_ivector ( int *  v)

Vector memory deallocation.

Deallocate a vector (array) of integers.

Parameters
[in,out]vvector to free
Returns
void

Definition at line 81 of file ialloc.c.

References G_free(), and NULL.

◆ G_free_matrix()

void G_free_matrix ( double **  m)

Matrix memory deallocation.

Deallocate a matrix of doubles.

Parameters
[in,out]mmatrix to free
Returns
void

Definition at line 169 of file dalloc.c.

References G_free(), and NULL.

Referenced by N_free_les().

◆ G_free_vector()

void G_free_vector ( double *  v)

Vector memory deallocation.

Deallocate a vector (array) of doubles.

Parameters
[in,out]vvector to free
Returns
void

Definition at line 129 of file dalloc.c.

References G_free(), and NULL.

◆ G_lubksb()

void G_lubksb ( double **  a,
int  n,
int *  indx,
double  b[] 
)

LU backward substitution.

Parameters
adouble **
nint
indxint *
bdouble []
Returns
void

Definition at line 104 of file lu.c.

◆ G_ludcmp()

int G_ludcmp ( double **  a,
int  n,
int *  indx,
double *  d 
)

LU decomposition.

Parameters
adouble **
nint
indxint *
ddouble *
Returns
0 on singular matrix, 1 on success

Definition at line 18 of file lu.c.

◆ G_math_A_to_Asp()

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 253 of file sparse_matrix.c.

◆ G_math_add_spvector()

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

Adds a sparse vector to a sparse matrix at position row.

Return 1 for success and -1 for failure

Parameters
AspG_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.

◆ G_math_alloc_spmatrix()

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_calloc, and G_debug().

◆ G_math_alloc_spvector()

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 G_math_spvector::cols, G_calloc, G_debug(), G_math_spvector::index, and G_math_spvector::values.

Referenced by N_assemble_les_2d_param(), and N_assemble_les_3d_param().

◆ G_math_Asp_to_A()

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.

◆ G_math_Asp_to_sband_matrix()

double** G_math_Asp_to_sband_matrix ( G_math_spvector **  Asp,
int  rows,
int  bandwidth 
)

Convert a symmetric sparse matrix into a symmetric band matrix.

Symmetric matrix with bandwidth of 3

5 2 1 0
2 5 2 1
1 2 5 2
0 1 2 5

will be converted into the band matrix

5 2 1
5 2 1
5 2 0
5 0 0
Parameters
Asp(G_math_spvector **)
rows(int)
bandwidth(int)
Returns
(double **) the resulting ymmetric band matrix [rows][bandwidth]

Definition at line 221 of file sparse_matrix.c.

◆ G_math_Ax_sband()

void G_math_Ax_sband ( double **  A,
double *  x,
double *  y,
int  rows,
int  bandwidth 
)

Compute the matrix - vector product of symmetric band matrix A and vector x.

This function is multi-threaded with OpenMP and can be called within a parallel OpenMP region.

y = A * x

Parameters
A(double **)
x(double) *)
y(double * )
rows(int)
bandwidth(int)
Returns
(void)

Definition at line 123 of file symmetric_band_matrix.c.

◆ G_math_Ax_sparse()

void G_math_Ax_sparse ( G_math_spvector **  Asp,
double *  x,
double *  y,
int  rows 
)

Compute the matrix - vector product of sparse matrix **Asp and vector x.

This function is multi-threaded with OpenMP and can be called within a parallel OpenMP region.

y = A * x

Parameters
Asp(G_math_spvector **)
x(double) *)
y(double * )
rows(int)
Returns
(void)

Definition at line 363 of file sparse_matrix.c.

Referenced by N_les_integrate_dirichlet_2d(), and N_les_integrate_dirichlet_3d().

◆ G_math_backward_substitution()

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

backward substitution

Parameters
Adouble **
xdouble *
bdouble *
rowsint
Returns
void

Definition at line 289 of file solvers_direct.c.

◆ G_math_cholesky_decomposition()

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

cholesky decomposition for symmetric, positiv definite matrices with bandwidth optimization

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

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

Definition at line 220 of file solvers_direct.c.

◆ G_math_cholesky_sband_decomposition()

void G_math_cholesky_sband_decomposition ( double **  A,
double **  T,
int  rows,
int  bandwidth 
)

Cholesky decomposition of a symmetric band matrix.

Parameters
A(double**) the input symmetric band matrix
T(double**) the resulting lower tringular symmetric band matrix
rows(int) number of rows
bandwidth(int) the bandwidth of the symmetric band matrix

Definition at line 18 of file solvers_direct_cholesky_band.c.

◆ G_math_cholesky_sband_substitution()

void G_math_cholesky_sband_substitution ( double **  T,
double *  x,
double *  b,
int  rows,
int  bandwidth 
)

Forward and backward substitution of a lower tringular symmetric band matrix of A from system Ax = b.

Parameters
T(double**) the lower triangle symmetric band matrix
x(double*) the resulting vector
b(double*) the right hand side of Ax = b
rows(int) number of rows
bandwidth(int) the bandwidth of the symmetric band matrix

Definition at line 87 of file solvers_direct_cholesky_band.c.

◆ G_math_complex_mult()

int G_math_complex_mult ( double *  v1[2],
int  size1,
double *  v2[2],
int  size2,
double *  v3[2],
int  size3 
)

Multiply two complex vectors, point by point.

Vectors are in the form: real, imaginary (each a floating number). A vector can be of any size. Computes v3 = v1 * v2. v3 should as big as the biggest of v1 and v2.

Parameters
v1
size1
v2
size2
v3
size3
Returns
int

Definition at line 23 of file mult.c.

Referenced by del2g().

◆ G_math_d_A_T()

int G_math_d_A_T ( double **  A,
int  rows 
)

Compute the transposition of matrix A. Matrix A will be overwritten.

This function is multi-threaded with OpenMP and can be called within a parallel OpenMP region.

Returns 0.

Parameters
A(double **)
rows(int)
Returns
int

Definition at line 339 of file blas_level_2.c.

◆ G_math_d_aA_B()

void G_math_d_aA_B ( double **  A,
double **  B,
double  a,
double **  C,
int  rows,
int  cols 
)

Add two matrices and scale matrix A with the scalar a.

\[ {\bf C} = a {\bf A} + {\bf B} \]

In case B == NULL, matrix A will be scaled by scalar a.
In case a == 1.0, a simple matrix addition is performed.
In case a == -1.0 matrix A is subtracted from matrix B.
The result is written into matrix C.

This function is multi-threaded with OpenMP and can be called within a parallel OpenMP region.

Parameters
A(double **)
B(double **) if NULL, matrix A is scaled by scalar a only
a(double)
C(double **)
rows(int)
cols(int)
Returns
(void)

Definition at line 50 of file blas_level_3.c.

◆ G_math_d_aAx_by()

void G_math_d_aAx_by ( double **  A,
double *  x,
double *  y,
double  a,
double  b,
double *  z,
int  rows,
int  cols 
)

Compute the scaled matrix - vector product of matrix double **A and vector x and y.

z = a * A * x + b * y

This function is multi-threaded with OpenMP and can be called within a parallel OpenMP region.

Parameters
A(double **)
x(double *)
y(double *)
a(double)
b(double)
z(double *)
rows(int)
cols(int)
Returns
(void)

Definition at line 179 of file blas_level_2.c.

◆ G_math_d_AB()

void G_math_d_AB ( double **  A,
double **  B,
double **  C,
int  rows_A,
int  cols_A,
int  cols_B 
)

Matrix multiplication.

\[ {\bf C} = {\bf A}{\bf B} \]

The result is written into matrix C.

A must be of size rows_A * cols_A B must be of size rows_B * cols_B with rows_B == cols_A C must be of size rows_A * cols_B

This function is multi-threaded with OpenMP and can be called within a parallel OpenMP region.

Parameters
A(double **)
B(double **)
C(double **)
rows_A(int)
cols_A(int)
cols_B(int)
Returns
(void)

Definition at line 174 of file blas_level_3.c.

◆ G_math_d_asum_norm()

void G_math_d_asum_norm ( double *  x,
double *  value,
int  rows 
)

Compute the asum norm of vector x.

\[ a = ||{\bf x}||_1 \]

The functions creates its own parallel OpenMP region. It can be called within a parallel OpenMP region if nested parallelism is supported by the compiler.

Parameters
x(double *)– the vector
value(double *) – the return value
rows(int)
Returns
(void)

Definition at line 112 of file blas_level_1.c.

Referenced by G_math_dasum().

◆ G_math_d_Ax()

void G_math_d_Ax ( double **  A,
double *  x,
double *  y,
int  rows,
int  cols 
)

Compute the matrix - vector product of matrix A and vector x.

This function is multi-threaded with OpenMP and can be called within a parallel OpenMP region.

y = A * x

Parameters
A(double ** )
x(double *)
y(double *)
rows(int)
cols(int)
Returns
(void)

Definition at line 47 of file blas_level_2.c.

Referenced by N_les_integrate_dirichlet_2d(), and N_les_integrate_dirichlet_3d().

◆ G_math_d_ax_by()

void G_math_d_ax_by ( double *  x,
double *  y,
double *  z,
double  a,
double  b,
int  rows 
)

Scales vectors x and y with the scalars a and b and adds them.

\[ {\bf z} = a{\bf x} + b{\bf y} \]

This function is multi-threaded with OpenMP and can be called within a parallel OpenMP region.

Parameters
x(double *)
y(double *)
z(double *)
a(double)
b(double)
rows(int)
Returns
(void)

Definition at line 173 of file blas_level_1.c.

◆ G_math_d_copy()

void G_math_d_copy ( double *  x,
double *  y,
int  rows 
)

Copy the vector x to y.

\[ {\bf y} = {\bf x} \]

This function is not multi-threaded

Parameters
x(double *)
y(double *)
rows(int)

Definition at line 237 of file blas_level_1.c.

Referenced by G_math_dcopy().

◆ G_math_d_euclid_norm()

void G_math_d_euclid_norm ( double *  x,
double *  value,
int  rows 
)

Compute the euclid norm of vector x.

\[ a = ||{\bf x}||_2 \]

The functions creates its own parallel OpenMP region. It can be called within a parallel OpenMP region if nested parallelism is supported by the compiler.

Parameters
x(double *) – the vector
value(double *) – the return value
rows(int)
Returns
(void)

Definition at line 80 of file blas_level_1.c.

Referenced by G_math_dnrm2().

◆ G_math_d_max_norm()

void G_math_d_max_norm ( double *  x,
double *  value,
int  rows 
)

Compute the maximum norm of vector x.

\[ a = ||{\bf x}||_\infty \]

This function is not multi-threaded

Parameters
x(double *)– the vector
value(double *) – the return value
rows(int)
Returns
(void)

Definition at line 142 of file blas_level_1.c.

References max.

Referenced by G_math_idamax().

◆ G_math_d_x_dot_y()

void G_math_d_x_dot_y ( double *  x,
double *  y,
double *  value,
int  rows 
)

Compute the dot product of vector x and y.

\[ a = {\bf x}^T {\bf y} \]

The functions creates its own parallel OpenMP region. It can be called within a parallel OpenMP region if nested parallelism is supported by the compiler.

Parameters
x(double *)
y(double *)
value(double *) – the return value
rows(int)
Returns
(void)

Definition at line 48 of file blas_level_1.c.

Referenced by G_math_ddot().

◆ G_math_d_x_dyad_y()

void G_math_d_x_dyad_y ( double *  x,
double *  y,
double **  A,
int  rows,
int  cols 
)

Compute the dyadic product of two vectors. The result is stored in the matrix A.

This function is multi-threaded with OpenMP and can be called within a parallel OpenMP region.

A = x * y^T

Parameters
x(double *)
y(double *)
A(float **) – matrix of size rows*cols
rows(int) – length of vector x
cols(int) – lengt of vector y
Returns
(void)

Definition at line 115 of file blas_level_2.c.

◆ G_math_dasum()

double G_math_dasum ( double *  x,
int  rows 
)

Compute the absolute sum norm of vector x using the ATLAS routine cblas_dasum.

If grass was not compiled with ATLAS support it will call G_math_d_asum_norm, the OpenMP multi threaded grass implementatiom

Parameters
x(double *)
rows(int)
Returns
(double)

Definition at line 122 of file ATLAS_wrapper_blas_level_1.c.

References G_math_d_asum_norm().

◆ G_math_daxpy()

void G_math_daxpy ( double *  x,
double *  y,
double  a,
int  rows 
)

Scale vector x with scalar a and add it to y.

\[ {\bf z} = a{\bf x} + {\bf y} \]

If grass was not compiled with ATLAS support it will call G_math_d_ax_by, the grass implementatiom

Parameters
x(double *)
y(double *)
a(double)
rows(int)
Returns
(void)

Definition at line 225 of file ATLAS_wrapper_blas_level_1.c.

◆ G_math_dcopy()

void G_math_dcopy ( double *  x,
double *  y,
int  rows 
)

Copy vector x to vector y.

If grass was not compiled with ATLAS support it will call G_math_d_copy

Parameters
x(double *)
y(double *)
rows(int)
Returns
(void)

Definition at line 196 of file ATLAS_wrapper_blas_level_1.c.

References G_math_d_copy().

◆ G_math_ddot()

double G_math_ddot ( double *  x,
double *  y,
int  rows 
)

Compute the dot product of vector x and y using the ATLAS routine cblas_ddot.

If grass was not compiled with ATLAS support it will call G_math_f_x_dot_y, the OpenMP multi threaded grass implementatiom

Parameters
x(float *)
y(float *)
rows(int)
Returns
(double)

Definition at line 44 of file ATLAS_wrapper_blas_level_1.c.

References G_math_d_x_dot_y().

◆ G_math_dnrm2()

double G_math_dnrm2 ( double *  x,
int  rows 
)

Compute the euclidean norm of vector x using the ATLAS routine cblas_dnrm2.

If grass was not compiled with ATLAS support it will call G_math_d_euclid_norm, the OpenMP multi threaded grass implementatiom

Parameters
x(double *)
rows(int)
Returns
(double)

Definition at line 97 of file ATLAS_wrapper_blas_level_1.c.

References G_math_d_euclid_norm().

◆ G_math_dscal()

void G_math_dscal ( double *  x,
double  a,
int  rows 
)

Scale vector x with scalar a using the ATLAS routine cblas_dscal.

If grass was not compiled with ATLAS support it will call G_math_d_ax_by, the OpenMP multi threaded grass implementatiom

Parameters
x(double *)
a(double)
rows(int)
Returns
(void)

Definition at line 173 of file ATLAS_wrapper_blas_level_1.c.

◆ G_math_egvorder()

int G_math_egvorder ( double *  ,
double **  ,
long   
)

Definition at line 9 of file eigen_tools.c.

◆ G_math_eigen()

void G_math_eigen ( double **  a,
double *  ev,
int  n 
)

Compute the eigenvalues and eigenvectors of a real symmetric matrix A.

The input and output matrices are related by

A = E*D*E~ where D is the diagonal matrix of eigenvalues
D[i,j] = ev[i] if i=j and 0 otherwise.

The columns of E are the eigenvectors.

Parameters
a= pointer to store for symmetric n by n input matrix A. The computation overloads this with an orthogonal matrix of eigenvectors E.
ev= pointer to the array of the output eigenvalues
n= dimension parameter (dim(a)= n*n, dim(ev)= n)

Definition at line 310 of file ccmath_grass_wrapper.c.

◆ G_math_eigval()

void G_math_eigval ( double **  a,
double *  ev,
int  n 
)

Compute the eigenvalues of a real symmetric matrix A.

Parameters
a= pointer to array of symmetric n by n input matrix A. The computation alters these values.
ev= pointer to array of the output eigenvalues
n= dimension parameter (dim(a)= n*n, dim(ev)= n)

Definition at line 289 of file ccmath_grass_wrapper.c.

◆ G_math_evmax()

double G_math_evmax ( double **  ,
double *  ,
int   
)

Definition at line 326 of file ccmath_grass_wrapper.c.

◆ G_math_f_A_T()

int G_math_f_A_T ( float **  A,
int  rows 
)

Compute the transposition of matrix A. Matrix A will be overwritten.

This function is multi-threaded with OpenMP and can be called within a parallel OpenMP region.

Returns 0.

Parameters
A(float **)
rows(int)
Returns
int

Definition at line 372 of file blas_level_2.c.

◆ G_math_f_aA_B()

void G_math_f_aA_B ( float **  A,
float **  B,
float  a,
float **  C,
int  rows,
int  cols 
)

Add two matrices and scale matrix A with the scalar a.

\[ {\bf C} = a {\bf A} + {\bf B} \]

In case B == NULL, matrix A will be scaled by scalar a.
In case a == 1.0, a simple matrix addition is performed.
In case a == -1.0 matrix A is subtracted from matrix B.
The result is written into matrix C.

This function is multi-threaded with OpenMP and can be called within a parallel OpenMP region.

Parameters
A(float **)
B(float **) if NULL, matrix A is scaled by scalar a only
a(float)
C(float **)
rows(int)
cols(int)
Returns
(void)

Definition at line 113 of file blas_level_3.c.

◆ G_math_f_aAx_by()

void G_math_f_aAx_by ( float **  A,
float *  x,
float *  y,
float  a,
float  b,
float *  z,
int  rows,
int  cols 
)

Compute the scaled matrix - vector product of matrix A and vectors x and y.

z = a * A * x + b * y

This function is multi-threaded with OpenMP and can be called within a parallel OpenMP region.

Parameters
A(float **)
x(float *)
y(float *)
a(float)
b(float)
z(float *)
rows(int)
cols(int)
Returns
(void)

Definition at line 261 of file blas_level_2.c.

◆ G_math_f_AB()

void G_math_f_AB ( float **  A,
float **  B,
float **  C,
int  rows_A,
int  cols_A,
int  cols_B 
)

Matrix multiplication.

\[ {\bf C} = {\bf A}{\bf B} \]

The result is written into matrix C.

A must be of size rows_A * cols_A B must be of size rows_B * cols_B with rows_B == cols_A C must be of size rows_A * cols_B

This function is multi-threaded with OpenMP and can be called within a parallel OpenMP region.

Parameters
A(float **)
B(float **)
C(float **)
rows_A(int)
cols_A(int)
cols_B(int)
Returns
(void)

Definition at line 215 of file blas_level_3.c.

◆ G_math_f_asum_norm()

void G_math_f_asum_norm ( float *  x,
float *  value,
int  rows 
)

Compute the asum norm of vector x.

\[ a = ||{\bf x}||_1 \]

The functions creates its own parallel OpenMP region. It can be called within a parallel OpenMP region if nested parallelism is supported by the compiler.

Parameters
x(float *)– the vector
value(float *) – the return value
rows(int)
Returns
(void)

Definition at line 328 of file blas_level_1.c.

References count.

Referenced by G_math_sasum().

◆ G_math_f_Ax()

void G_math_f_Ax ( float **  A,
float *  x,
float *  y,
int  rows,
int  cols 
)

Compute the matrix - vector product of matrix A and vector x.

This function is multi-threaded with OpenMP and can be called within a parallel OpenMP region.

y = A * x

Parameters
A(float ** )
x(float *)
y(float *)
rows(int)
cols(int)
Returns
(void)

Definition at line 81 of file blas_level_2.c.

◆ G_math_f_ax_by()

void G_math_f_ax_by ( float *  x,
float *  y,
float *  z,
float  a,
float  b,
int  rows 
)

Scales vectors x and y with the scalars a and b and adds them.

\[ {\bf z} = a{\bf x} + b{\bf y} \]

This function is multi-threaded with OpenMP and can be called within a parallel OpenMP region.

Parameters
x(float *)
y(float *)
z(float *)
a(float)
b(float)
rows(int)
Returns
(void)

Definition at line 392 of file blas_level_1.c.

◆ G_math_f_copy()

void G_math_f_copy ( float *  x,
float *  y,
int  rows 
)

Copy the vector x to y.

\[ {\bf y} = {\bf x} \]

This function is not multi-threaded

Parameters
x(float *)
y(float *)
rows(int)

Definition at line 455 of file blas_level_1.c.

Referenced by G_math_scopy().

◆ G_math_f_euclid_norm()

void G_math_f_euclid_norm ( float *  x,
float *  value,
int  rows 
)

Compute the euclid norm of vector x.

\[ a = ||{\bf x}||_2 \]

The functions creates its own parallel OpenMP region. It can be called within a parallel OpenMP region if nested parallelism is supported by the compiler.

Parameters
x(double *) – the vector
value(float *) – the return value
rows(int)
Returns
(void)

Definition at line 296 of file blas_level_1.c.

Referenced by G_math_snrm2().

◆ G_math_f_max_norm()

void G_math_f_max_norm ( float *  x,
float *  value,
int  rows 
)

Compute the maximum norm of vector x.

\[ a = ||{\bf x}||_\infty \]

This function is not multi-threaded

Parameters
x(float *)– the vector
value(float *) – the return value
rows(int)
Returns
(void)

Definition at line 361 of file blas_level_1.c.

References max.

Referenced by G_math_isamax().

◆ G_math_f_x_dot_y()

void G_math_f_x_dot_y ( float *  x,
float *  y,
float *  value,
int  rows 
)

Compute the dot product of vector x and y.

\[ a = {\bf x}^T {\bf y} \]

The functions creates its own parallel OpenMP region. It can be called within a parallel OpenMP region if nested parallelism is supported by the compiler.

Parameters
x(float *)
y(float *)
value(float *) – the return value
rows(int)
Returns
(void)

Definition at line 264 of file blas_level_1.c.

Referenced by G_math_sdot().

◆ G_math_f_x_dyad_y()

void G_math_f_x_dyad_y ( float *  x,
float *  y,
float **  A,
int  rows,
int  cols 
)

Compute the dyadic product of two vectors. The result is stored in the matrix A.

This function is multi-threaded with OpenMP and can be called within a parallel OpenMP region.

A = x * y^T

Parameters
x(float *)
y(float *)
A(float **= – matrix of size rows*cols
rows(int) – length of vector x
cols(int) – lengt of vector y
Returns
(void)

Definition at line 145 of file blas_level_2.c.

◆ G_math_findzc()

int G_math_findzc ( double  conv[],
int  size,
double  zc[],
double  thresh,
int  num_orients 
)

Finds locations and orientations of zero crossings.

Finds the locations and orientations of zero crossings in the input array conv, which is the result of the convolution of the Marr-Hildreth operator with the image. The output array is zc, which is non-zero only at zero crossing pixels. At those pixels, the value is 1 + (orientation), where orientation is a value from 0 to num_orients.

Parameters
[in]convinput
[in]sizesize of largest matrix column or row
[out]zcoutput
[in]threshmagnitude threshold
[in]num_orients
Returns
int always returns 0

Definition at line 56 of file findzc.c.

References M_PI, M_PI_2, and TINY.

◆ G_math_forward_substitution()

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

forward substitution

Parameters
Adouble **
xdouble *
bdouble *
rowsint
Returns
void

Definition at line 313 of file solvers_direct.c.

◆ G_math_free_spmatrix()

void G_math_free_spmatrix ( G_math_spvector **  Asp,
int  rows 
)

Release the memory of the sparse matrix.

Parameters
AspG_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().

◆ G_math_free_spvector()

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(), G_math_spvector::index, NULL, and G_math_spvector::values.

Referenced by G_math_free_spmatrix().

◆ G_math_gauss_elimination()

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 156 of file solvers_direct.c.

◆ G_math_i_asum_norm()

void G_math_i_asum_norm ( int *  x,
double *  value,
int  rows 
)

Compute the asum norm of vector x.

\[ a = ||{\bf x}||_1 \]

The functions creates its own parallel OpenMP region. It can be called within a parallel OpenMP region if nested parallelism is supported by the compiler.

Parameters
x(int *)– the vector
value(double *) – the return value
rows(int)
Returns
(void)

Definition at line 546 of file blas_level_1.c.

◆ G_math_i_ax_by()

void G_math_i_ax_by ( int *  x,
int *  y,
int *  z,
int  a,
int  b,
int  rows 
)

Scales vectors x and y with the scalars a and b and adds them.

\[ {\bf z} = a{\bf x} + b{\bf y} \]

This function is multi-threaded with OpenMP and can be called within a parallel OpenMP region.

Parameters
x(int *)
y(int *)
z(int *)
a(int)
b(int)
rows(int)
Returns
(void)

Definition at line 607 of file blas_level_1.c.

◆ G_math_i_copy()

void G_math_i_copy ( int *  x,
int *  y,
int  rows 
)

Copy the vector x to y.

\[ {\bf y} = {\bf x} \]

This function is not multi-threaded

Parameters
x(int *)
y(int *)
rows(int)

Definition at line 670 of file blas_level_1.c.

◆ G_math_i_euclid_norm()

void G_math_i_euclid_norm ( int *  x,
double *  value,
int  rows 
)

Compute the euclid norm of vector x.

\[ a = ||{\bf x}||_2 \]

The functions creates its own parallel OpenMP region. It can be called within a parallel OpenMP region if nested parallelism is supported by the compiler.

Parameters
x(int *) – the vector
value(double *) – the return value
rows(int)
Returns
(void)

Definition at line 514 of file blas_level_1.c.

◆ G_math_i_max_norm()

void G_math_i_max_norm ( int *  x,
int *  value,
int  rows 
)

Compute the maximum norm of vector x.

\[ a = ||{\bf x}||_\infty \]

This function is not multi-threaded

Parameters
x(int *)– the vector
value(int *) – the return value
rows(int)
Returns
(void)

Definition at line 576 of file blas_level_1.c.

References max.

◆ G_math_i_x_dot_y()

void G_math_i_x_dot_y ( int *  x,
int *  y,
double *  value,
int  rows 
)

Compute the dot product of vector x and y.

\[ a = {\bf x}^T {\bf y} \]

The functions creates its own parallel OpenMP region. It can be called within a parallel OpenMP region if nested parallelism is supported by the compiler.

Parameters
x(int *)
y(int *)
value(double *) – the return value
rows(int)
Returns
(void)

Definition at line 482 of file blas_level_1.c.

◆ G_math_idamax()

double G_math_idamax ( double *  x,
int  rows 
)

Compute the maximum norm of vector x using the ATLAS routine cblas_idamax.

If grass was not compiled with ATLAS support it will call G_math_d_max_norm, the OpenMP multi threaded grass implementatiom

Parameters
x(double *)
rows(int)
Returns
(double)

Definition at line 147 of file ATLAS_wrapper_blas_level_1.c.

References G_math_d_max_norm().

◆ G_math_isamax()

float G_math_isamax ( float *  x,
int  rows 
)

Compute the maximum norm of vector x using the ATLAS routine cblas_idamax.

If grass was not compiled with ATLAS support it will call G_math_f_max_norm, the OpenMP multi threaded grass implementatiom

Parameters
x(float *)
rows(int)
Returns
(float)

Definition at line 331 of file ATLAS_wrapper_blas_level_1.c.

References G_math_f_max_norm().

◆ G_math_lu_decomposition()

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 189 of file solvers_direct.c.

◆ G_math_matrix_to_sband_matrix()

double** G_math_matrix_to_sband_matrix ( double **  A,
int  rows,
int  bandwidth 
)

Convert a symmetrix matrix into a symmetric band matrix.

Symmetric matrix with bandwidth of 3

5 2 1 0
2 5 2 1
1 2 5 2
0 1 2 5

will be converted into the symmetric band matrix

5 2 1
5 2 1
5 2 0
5 0 0
Parameters
A(double**) the symmetric matrix
rows(int)
bandwidth(int)
Returns
B (double**) new created symmetric band matrix

Definition at line 34 of file symmetric_band_matrix.c.

◆ G_math_max_pow2()

long G_math_max_pow2 ( long  n)

Finds least power of 2 >= n

Finds least power of 2 >= n.

Parameters
[in]n
Returns
long

Definition at line 16 of file max_pow2.c.

◆ G_math_min_pow2()

long G_math_min_pow2 ( long  n)

Finds largest power of 2 <= n

Finds largest power of 2 <= n.

Parameters
[in]n
Returns
long

Definition at line 44 of file max_pow2.c.

◆ G_math_minv()

int G_math_minv ( double **  a,
int  n 
)

Invert (in place) a general real matrix A -> Inv(A).

Parameters
a= array containing the input matrix A. This is converted to the inverse matrix.
n= dimension of the system (i.e. A is n x n )
Returns
: 0 -> normal exit, 1 -> singular input matrix

Definition at line 242 of file ccmath_grass_wrapper.c.

◆ G_math_print_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.

References G_math_spvector::cols.

◆ G_math_psinv()

int G_math_psinv ( double **  a,
int  n 
)

Invert (in place) a symmetric real matrix, V -> Inv(V).

The input matrix V is symmetric (V[i,j] = V[j,i]).

Parameters
a= array containing a symmetric input matrix. This is converted to the inverse matrix.
n= dimension of the system (dim(v)=n*n)
Returns
: 0 -> normal exit 1 -> input matrix not positive definite

Definition at line 256 of file ccmath_grass_wrapper.c.

◆ G_math_rand()

float G_math_rand ( void  )

Definition at line 17 of file rand1.c.

References G_drand48().

Referenced by G_math_rand_gauss().

◆ G_math_rand_gauss()

double G_math_rand_gauss ( double  )

Definition at line 17 of file gauss.c.

References G_math_rand(), and x.

◆ G_math_ruinv()

int G_math_ruinv ( double **  a,
int  n 
)

Invert an upper right triangular matrix T -> Inv(T).

Parameters
a= pointer to array of upper right triangular matrix, This is replaced by the inverse matrix.
n= dimension (dim(a)=n*n)
Returns
value: status flag, with 0 -> matrix inverted -1 -> matrix singular

Definition at line 269 of file ccmath_grass_wrapper.c.

◆ G_math_sasum()

float G_math_sasum ( float *  x,
int  rows 
)

Compute the absolute sum norm of vector x using the ATLAS routine cblas_dasum.

If grass was not compiled with ATLAS support it will call G_math_f_asum_norm, the OpenMP multi threaded grass implementatiom

Parameters
x(float *)
rows(int)
Returns
(float)

Definition at line 306 of file ATLAS_wrapper_blas_level_1.c.

References G_math_f_asum_norm().

◆ G_math_saxpy()

void G_math_saxpy ( float *  x,
float *  y,
float  a,
int  rows 
)

Scale vector x with scalar a and add it to y.

\[ {\bf z} = a{\bf x} + {\bf y} \]

If grass was not compiled with ATLAS support it will call G_math_f_ax_by, the grass implementatiom

Parameters
x(float *)
y(float *)
a(float)
rows(int)
Returns
(void)

Definition at line 410 of file ATLAS_wrapper_blas_level_1.c.

◆ G_math_sband_matrix_to_Asp()

G_math_spvector** G_math_sband_matrix_to_Asp ( double **  A,
int  rows,
int  bandwidth,
double  epsilon 
)

Convert a symmetric band matrix into a sparse matrix.

WARNING: This function is experimental, do not use. Only the upper triangle matrix of the band strcuture is copied.

Parameters
A(double **) the symmetric band matrix
rows(int)
bandwidth(int)
epsilon(double) – non-zero values are greater then epsilon
Returns
(G_math_spvector **)

Definition at line 304 of file sparse_matrix.c.

◆ G_math_sband_matrix_to_matrix()

double** G_math_sband_matrix_to_matrix ( double **  A,
int  rows,
int  bandwidth 
)

Convert a symmetric band matrix into a symmetric matrix.

Such a symmetric band matrix with banwidth 3

5 2 1
5 2 1
5 2 0
5 0 0

Will be converted into this symmetric matrix

5 2 1 0
2 5 2 1
1 2 5 2
0 1 2 5
Parameters
A(double**) the symmetric band matrix
rows(int)
bandwidth(int)
Returns
B (double**) new created symmetric matrix

Definition at line 80 of file symmetric_band_matrix.c.

◆ G_math_scopy()

void G_math_scopy ( float *  x,
float *  y,
int  rows 
)

Copy vector x to vector y.

If grass was not compiled with ATLAS support it will call G_math_f_copy, the grass implementatiom

Parameters
x(float *)
y(float *)
rows(int)
Returns
(void)

Definition at line 381 of file ATLAS_wrapper_blas_level_1.c.

References G_math_f_copy().

◆ G_math_sdot()

float G_math_sdot ( float *  x,
float *  y,
int  rows 
)

Compute the dot product of vector x and y using the ATLAS routine cblas_sdot.

If grass was not compiled with ATLAS support it will call G_math_f_x_dot_y, the OpenMP multi threaded grass implementatiom

Parameters
x(float *)
y(float *)
rows(int)
Returns
(float)

Definition at line 256 of file ATLAS_wrapper_blas_level_1.c.

References G_math_f_x_dot_y().

◆ G_math_sdsdot()

float G_math_sdsdot ( float *  x,
float *  y,
float  a,
int  rows 
)

Compute the dot product of vector x and y using the ATLAS routine cblas_sdsdot.

If grass was not compiled with ATLAS support it will call G_math_f_x_dot_y, the OpenMP multi threaded grass implementatiom

Parameters
x(float *)
y(float *)
a(float)
rows(int)
Returns
(float)

Definition at line 72 of file ATLAS_wrapper_blas_level_1.c.

◆ G_math_snrm2()

float G_math_snrm2 ( float *  x,
int  rows 
)

Compute the euclidean norm of vector x using the ATLAS routine cblas_dnrm2.

If grass was not compiled with ATLAS support it will call G_math_f_euclid_norm, the OpenMP multi threaded grass implementatiom

Parameters
x(float *)
rows(int)
Returns
(float)

Definition at line 281 of file ATLAS_wrapper_blas_level_1.c.

References G_math_f_euclid_norm().

◆ G_math_solv()

int G_math_solv ( double **  a,
double *  b,
int  n 
)

Solve a general linear system A*x = b.

Documentation and ccmath library version 2.2.1 by Daniel A. Atkinson

                         Chapter 1

                       LINEAR ALGEBRA

                          Summary

        The matrix algebra library contains functions that
        perform the standard computations of linear algebra.
        General areas covered are:

                  o Solution of Linear Systems
                  o Matrix Inversion
                  o Eigensystem Analysis
                  o Matrix Utility Operations
                  o Singular Value Decomposition

        The operations covered here are fundamental to many
        areas of mathematics and statistics. Thus, functions
        in this library segment are called by other library
        functions. Both real and complex valued matrices
        are covered by functions in the first four of these
        categories.

Notes on Contents

Functions in this library segment provide the basic operations of

numerical linear algebra and some useful utility functions for operations on vectors and matrices. The following list describes the functions available for operations with real-valued matrices.

o Solving and Inverting Linear Systems:

solv ---—— solve a general system of real linear equations. solvps -—— solve a real symmetric linear system. solvru -—— solve a real right upper triangular linear system. solvtd -—— solve a tridiagonal real linear system.

minv ---—— invert a general real square matrix. psinv --—— invert a real symmetric matrix. ruinv --—— invert a right upper triangular matrix.

 The solution of a general linear system and efficient algorithms for

solving special systems with symmetric and tridiagonal matrices are provided by these functions. The general solution function employs a LU factorization with partial pivoting and it is very robust. It will work efficiently on any problem that is not ill-conditioned. The symmetric matrix solution is based on a modified Cholesky factorization. It is best used on positive definite matrices that do not require pivoting for numeric stability. Tridiagonal solvers require order-N operations (N = dimension). Thus, they are highly recommended for this important class of sparse systems. Two matrix inversion routines are provided. The general inversion function is again LU based. It is suitable for use on any stable (ie. well-conditioned) problem. The Cholesky based symmetric matrix inversion is efficient and safe for use on matrices known to be positive definite, such as the variance matrices encountered in statistical computations. Both the solver and the inverse functions are designed to enhance data locality. They are very effective on modern microprocessors.

o Eigensystem Analysis:

eigen —— extract all eigen values and vectors of a real symmetric matrix. eigval –— extract the eigen values of a real symmetric matrix. evmax —— compute the eigen value of maximum absolute magnitude and its corresponding vector for a symmetric matrix.

 Eigensystem functions operate on real symmetric matrices. Two forms of

the general eigen routine are provided because the computation of eigen values only is much faster when vectors are not required. The basic algorithms use a Householder reduction to tridiagonal form followed by QR iterations with shifts to enhance convergence. This has become the accepted standard for symmetric eigensystem computation. The evmax function uses an efficient iterative power method algorithm to extract the eigen value of maximum absolute size and the corresponding eigenvector.

o Singular Value Decomposition:

svdval –— compute the singular values of a m by n real matrix. sv2val –— compute the singular values of a real matrix efficiently for m >> n. svduv —— compute the singular values and the transformation matrices u and v for a real m by n matrix. sv2uv —— compute the singular values and transformation matrices efficiently for m >> n. svdu1v –— compute the singular values and transformation matrices u1 and v, where u1 overloads the input with the first n column vectors of u. sv2u1v –— compute the singular values and the transformation matrices u1 and v efficiently for m >> n.

 Singular value decomposition is extremely useful when dealing with linear

systems that may be singular. Singular values with values near zero are flags of a potential rank deficiency in the system matrix. They can be used to identify the presence of an ill-conditioned problem and, in some cases, to deal with the potential instability. They are applied to the linear least squares problem in this library. Singular values also define some important matrix norm parameters such as the 2-norm and the condition value. A complete decomposition provides both singular values and an orthogonal decomposition of vector spaces related to the matrix identifying the range and null-space. Fortunately, a highly stable algorithm based on Householder reduction to bidiagonal form and QR rotations can be used to implement the decomposition. The library provides two forms with one more efficient when the dimensions satisfy m > (3/2)n.

General Technical Comments

Efficient computation with matrices on modern processors must be

adapted to the storage scheme employed for matrix elements. The functions of this library segment do not employ the multidimensional array intrinsic of the C language. Access to elements employs the simple row-major scheme described here.

Matrices are modeled by the library functions as arrays with elements

stored in row order. Thus, the element in the jth row and kth column of the n by n matrix M, stored in the array mat[], is addressed by

      M[j,k] = mat[n*j+k]  , with   0 =< j,k <= n-1 .

(Remember that C employs zero as the starting index.) The storage order has important implications for data locality.

The algorithms employed here all have excellent numerical stability, and

the default double precision arithmetic of C enhances this. Thus, any problems encountered in using the matrix algebra functions will almost certainly be due to an ill-conditioned matrix. (The Hilbert matrices,

            H[i,j] = 1/(1+i+j)  for i,j < n

form a good example of such ill-conditioned systems.) We remind the reader that the appropriate response to such ill-conditioning is to seek an alternative approach to the problem. The option of increasing precision has already been exploited. Modification of the linear algebra algorithm code is not normally effective in an ill-conditioned problem.


FUNCTION SYNOPSES

Linear System Solutions:

Parameters
a= array containing system matrix A in row order (altered to L-U factored form by computation)
b= array containing system vector b at entry and solution vector x at exit
n= dimension of system
Returns
0 -> normal exit; -1 -> singular input

Definition at line 184 of file ccmath_grass_wrapper.c.

◆ G_math_solver_bicgstab()

int G_math_solver_bicgstab ( double **  A,
double *  x,
double *  b,
int  rows,
int  maxit,
double  err 
)

The iterative biconjugate gradients solver with stabilization for unsymmetric non-definite matrices.

This iterative solver works with regular quadratic matrices.

This solver solves the linear equation system: A x = b

The parameter maxit specifies the maximum number of iterations. If the maximum is reached, the solver will abort the calculation and writes the current result into the vector x. The parameter err defines the error break criteria for the solver.

Parameters
A(double **) – the matrix
x(double *) – the value vector
b(double *) – the right hand side
rows(int)
maxit(int) – the maximum number of iterations
err(double) – defines the error break criteria
Returns
(int) – 1 - success, 2 - not finished but success, 0 - matrix singular, -1 - could not solve the les

Definition at line 535 of file solvers_krylov.c.

◆ G_math_solver_cg()

int G_math_solver_cg ( double **  A,
double *  x,
double *  b,
int  rows,
int  maxit,
double  err 
)

The iterative conjugate gradients solver for symmetric positive definite matrices.

This iterative solver works with symmetric positive definite regular quadratic matrices.

This solver solves the linear equation system: A x = b

The parameter maxit specifies the maximum number of iterations. If the maximum is reached, the solver will abort the calculation and writes the current result into the vector x. The parameter err defines the error break criteria for the solver.

Parameters
A(double **) – the matrix
x(double *) – the value vector
b(double *) – the right hand side
rows(int)
maxit(int) – the maximum number of iterations
err(double) – defines the error break criteria
Returns
(int) – 1 - success, 2 - not finished but success, 0 - matrix singular, -1 - could not solve the les

Definition at line 309 of file solvers_krylov.c.

◆ G_math_solver_cg_sband()

int G_math_solver_cg_sband ( double **  A,
double *  x,
double *  b,
int  rows,
int  bandwidth,
int  maxit,
double  err 
)

The iterative conjugate gradients solver for symmetric positive definite band matrices.

This iterative solver works with symmetric positive definite band matrices.

This solver solves the linear equation system: A x = b

The parameter maxit specifies the maximum number of iterations. If the maximum is reached, the solver will abort the calculation and writes the current result into the vector x. The parameter err defines the error break criteria for the solver.

Parameters
A(double **) – the symmetric positive definite band matrix
x(double *) – the value vector
b(double *) – the right hand side
rows(int)
bandwidth(int) – the bandwidth of matrix A
maxit(int) – the maximum number of iterations
err(double) – defines the error break criteria
Returns
(int) – 1 - success, 2 - not finished but success, 0 - matrix singular, -1 - could not solve the les

Definition at line 337 of file solvers_krylov.c.

◆ G_math_solver_cholesky()

int G_math_solver_cholesky ( double **  A,
double *  x,
double *  b,
int  bandwidth,
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 *
bandwidthint – the bandwidth of the band matrix, if unsure set to rows
rowsint
Returns
int – 1 success

Definition at line 127 of file solvers_direct.c.

◆ G_math_solver_cholesky_sband()

void G_math_solver_cholesky_sband ( double **  A,
double *  x,
double *  b,
int  rows,
int  bandwidth 
)

Cholesky symmetric band matrix solver for linear equation systems of type Ax = b.

Parameters
A(double**) the input symmetric band matrix
x(double*) the resulting vector, result is written in here
b(double*) the right hand side of Ax = b
rows(int) number of rows
bandwidth(int) the bandwidth of the symmetric band matrix

Definition at line 61 of file solvers_direct_cholesky_band.c.

◆ G_math_solver_gauss()

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 *
rowsint
Returns
int – 1 success

Definition at line 43 of file solvers_direct.c.

◆ G_math_solver_gs()

int G_math_solver_gs ( double **  A,
double *  x,
double *  b,
int  rows,
int  maxit,
double  sor,
double  error 
)

The iterative gauss seidel solver for quadratic matrices.

The Jacobi solver solves the linear equation system Ax = b The result is written to the vector x.

The parameter maxit specifies the maximum number of iterations. If the maximum is reached, the solver will abort the calculation and writes the current result into the vector x. The parameter err defines the error break criteria for the solver.

Parameters
Adouble ** – the dense matrix
xdouble * – the vector of unknowns
bdouble * – the right side vector
rowsint – number of rows
maxitint – the maximum number of iterations
sordouble – defines the successive overrelaxion parameter [0:2]
errordouble – defines the error break criteria
Returns
int – 1=success, -1=could not solve the les

Definition at line 247 of file solvers_classic_iter.c.

◆ G_math_solver_jacobi()

int G_math_solver_jacobi ( double **  A,
double *  x,
double *  b,
int  rows,
int  maxit,
double  sor,
double  error 
)

The iterative jacobi solver for quadratic matrices.

The Jacobi solver solves the linear equation system Ax = b The result is written to the vector x.

The parameter maxit specifies the maximum number of iterations. If the maximum is reached, the solver will abort the calculation and writes the current result into the vector x. The parameter err defines the error break criteria for the solver.

Parameters
Adouble ** – the dense matrix
xdouble * – the vector of unknowns
bdouble * – the right side vector
rowsint – number of rows
maxitint – the maximum number of iterations
sordouble – defines the successive overrelaxion parameter [0:1]
errordouble – defines the error break criteria
Returns
int – 1=success, -1=could not solve the les

Definition at line 190 of file solvers_classic_iter.c.

◆ G_math_solver_lu()

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 *
rowsint
Returns
int – 1 success

Definition at line 67 of file solvers_direct.c.

◆ G_math_solver_pcg()

int G_math_solver_pcg ( double **  A,
double *  x,
double *  b,
int  rows,
int  maxit,
double  err,
int  prec 
)

The iterative preconditioned conjugate gradients solver for symmetric positive definite matrices.

This iterative solver works with symmetric positive definite regular quadratic matrices.

This solver solves the linear equation system: A x = b

The parameter maxit specifies the maximum number of iterations. If the maximum is reached, the solver will abort the calculation and writes the current result into the vector x. The parameter err defines the error break criteria for the solver.

Parameters
A(double **) – the matrix
x(double *) – the value vector
b(double *) – the right hand side
rows(int)
maxit(int) – the maximum number of iterations
err(double) – defines the error break criteria
prec(int) – the preconditioner which should be used 1,2 or 3
Returns
(int) – 1 - success, 2 - not finished but success, 0 - matrix singular, -1 - could not solve the les

Definition at line 60 of file solvers_krylov.c.

◆ G_math_solver_sparse_bicgstab()

int G_math_solver_sparse_bicgstab ( G_math_spvector **  Asp,
double *  x,
double *  b,
int  rows,
int  maxit,
double  err 
)

The iterative biconjugate gradients solver with stabilization for unsymmetric non-definite matrices.

This iterative solver works with sparse matrices.

This solver solves the linear equation system: A x = b

The parameter maxit specifies the maximum number of iterations. If the maximum is reached, the solver will abort the calculation and writes the current result into the vector x. The parameter err defines the error break criteria for the solver.

Parameters
Asp(G_math_spvector **) – the sparse matrix
x(double *) – the value vector
b(double *) – the right hand side
rows(int)
maxit(int) – the maximum number of iterations
err(double) – defines the error break criteria
Returns
(int) – 1 - success, 2 - not finished but success, 0 - matrix singular, -1 - could not solve the les

Definition at line 562 of file solvers_krylov.c.

◆ G_math_solver_sparse_cg()

int G_math_solver_sparse_cg ( G_math_spvector **  Asp,
double *  x,
double *  b,
int  rows,
int  maxit,
double  err 
)

The iterative conjugate gradients solver for sparse symmetric positive definite matrices.

This iterative solver works with symmetric positive definite sparse matrices.

This solver solves the linear equation system: A x = b

The parameter maxit specifies the maximum number of iterations. If the maximum is reached, the solver will abort the calculation and writes the current result into the vector x. The parameter err defines the error break criteria for the solver.

Parameters
Asp(G_math_spvector **) – the sparse matrix
x(double *) – the value vector
b(double *) – the right hand side
rows(int)
maxit(int) – the maximum number of iterations
err(double) – defines the error break criteria
Returns
(int) – 1 - success, 2 - not finished but success, 0 - matrix singular, -1 - could not solve the les

Definition at line 364 of file solvers_krylov.c.

◆ G_math_solver_sparse_gs()

int G_math_solver_sparse_gs ( G_math_spvector **  Asp,
double *  x,
double *  b,
int  rows,
int  maxit,
double  sor,
double  error 
)

The iterative gauss seidel solver for sparse matrices.

The Jacobi solver solves the linear equation system Ax = b The result is written to the vector x.

The parameter maxit specifies the maximum number of iterations. If the maximum is reached, the solver will abort the calculation and writes the current result into the vector x. The parameter err defines the error break criteria for the solver.

Parameters
AspG_math_spvector ** – the sparse matrix
xdouble * – the vector of unknowns
bdouble * – the right side vector
rowsint – number of rows
maxitint – the maximum number of iterations
sordouble – defines the successive overrelaxion parameter [0:2]
errordouble – defines the error break criteria
Returns
int – 1=success, -1=could not solve the les

Definition at line 118 of file solvers_classic_iter.c.

References _, G_math_spvector::cols, err(), G_alloc_vector(), G_free(), G_message(), G_math_spvector::index, and G_math_spvector::values.

◆ G_math_solver_sparse_jacobi()

int G_math_solver_sparse_jacobi ( G_math_spvector **  Asp,
double *  x,
double *  b,
int  rows,
int  maxit,
double  sor,
double  error 
)

The iterative jacobi solver for sparse matrices.

The Jacobi solver solves the linear equation system Ax = b The result is written to the vector x.

The parameter maxit specifies the maximum number of iterations. If the maximum is reached, the solver will abort the calculation and writes the current result into the vector x. The parameter err defines the error break criteria for the solver.

Parameters
AspG_math_spvector ** – the sparse matrix
xdouble * – the vector of unknowns
bdouble * – the right side vector
rowsint – number of rows
maxitint – the maximum number of iterations
sordouble – defines the successive overrelaxion parameter [0:1]
errordouble – defines the error break criteria
Returns
int – 1=success, -1=could not solve the les

Definition at line 48 of file solvers_classic_iter.c.

References _, G_math_spvector::cols, err(), G_alloc_vector(), G_free(), G_message(), G_math_spvector::index, and G_math_spvector::values.

◆ G_math_solver_sparse_pcg()

int G_math_solver_sparse_pcg ( G_math_spvector **  Asp,
double *  x,
double *  b,
int  rows,
int  maxit,
double  err,
int  prec 
)

The iterative preconditioned conjugate gradients solver for sparse symmetric positive definite matrices.

This iterative solver works with symmetric positive definite sparse matrices.

This solver solves the linear equation system: A x = b

The parameter maxit specifies the maximum number of iterations. If the maximum is reached, the solver will abort the calculation and writes the current result into the vector x. The parameter err defines the error break criteria for the solver.

Parameters
Asp(G_math_spvector **) – the sparse matrix
x(double *) – the value vector
b(double *) – the right hand side
rows(int)
maxit(int) – the maximum number of iterations
err(double) – defines the error break criteria
prec(int) – the preconditioner which should be used 1,2 or 3
Returns
(int) – 1 - success, 2 - not finished but success, 0 - matrix singular, -1 - could not solve the les

Definition at line 122 of file solvers_krylov.c.

◆ G_math_solvps()

int G_math_solvps ( double **  a,
double *  b,
int  n 
)

Solve a symmetric positive definite linear system S*x = b.

Parameters
a= array containing system matrix S (altered to Cholesky upper right factor by computation)
b= array containing system vector b as input and solution vector x as output
n= dimension of system
Returns
: 0 -> normal exit; -1 -> input matrix not positive definite

Definition at line 198 of file ccmath_grass_wrapper.c.

◆ G_math_solvru()

int G_math_solvru ( double **  ,
double *  ,
int   
)

Definition at line 229 of file ccmath_grass_wrapper.c.

◆ G_math_solvtd()

void G_math_solvtd ( double *  a,
double *  b,
double *  c,
double *  x,
int  m 
)

Solve a tridiagonal linear system M*x = y.

Parameters
a= array containing m+1 diagonal elements of M
b= array of m elements below the main diagonal of M
c= array of m elements above the main diagonal
x= array containing the system vector y initially, and the solution vector at exit (m+1 elements)
m= dimension parameter ( M is (m+1)x(m+1) )

Definition at line 214 of file ccmath_grass_wrapper.c.

◆ G_math_srand()

void G_math_srand ( int  seed)

Seed the pseudo-random number generator.

Parameters
seedval32-bit integer used to seed the PRNG

Definition at line 28 of file rand1.c.

References G_srand48().

◆ G_math_srand_auto()

int G_math_srand_auto ( void  )

Seed the pseudo-random number generator from the time and PID.

Returns
generated seed value passed to G_srand48()

Definition at line 39 of file rand1.c.

References G_srand48_auto().

◆ G_math_sscal()

void G_math_sscal ( float *  x,
float  a,
int  rows 
)

Scale vector x with scalar a using the ATLAS routine cblas_dscal.

If grass was not compiled with ATLAS support it will call G_math_f_ax_by, the OpenMP multi threaded grass implementatiom

Parameters
x(float *)
a(float)
rows(int)
Returns
(float)

Definition at line 357 of file ATLAS_wrapper_blas_level_1.c.

◆ G_math_sv2uv()

int G_math_sv2uv ( double *  d,
double **  a,
double **  u,
int  m,
double **  v,
int  n 
)

Compute the singular value transformation when m >> n.

Parameters
d= pointer to double array of dimension n (output = singular values of A)
a= pointer to store of the m by n input matrix A (A is altered by the computation)
u= pointer to store for m by m orthogonal matrix U
v= pointer to store for n by n orthogonal matrix V
m= number of rows in A
n= number of columns in A (m>=n required)
Returns
value: status flag with: 0 -> success -1 -> input error m < n

Definition at line 457 of file ccmath_grass_wrapper.c.

◆ G_math_sv2val()

int G_math_sv2val ( double *  d,
double **  a,
int  m,
int  n 
)

Compute singular values when m >> n.

Parameters
d= pointer to double array of dimension n (output = singular values of A)
a= pointer to store of the m by n input matrix A (A is altered by the computation)
m= number of rows in A
n= number of columns in A (m>=n required)
Returns
value: status flag with: 0 -> success -1 -> input error m < n

Definition at line 423 of file ccmath_grass_wrapper.c.

◆ G_math_svdu1v()

int G_math_svdu1v ( double *  d,
double **  a,
int  m,
double **  v,
int  n 
)

Compute the singular value transformation with A overloaded by the partial U-matrix.

Parameters
d= pointer to double array of dimension n (output = singular values of A)
a= pointer to store of the m by n input matrix A (At output a is overloaded by the matrix U1 whose n columns are orthogonal vectors equal to the first n columns of U.)
v= pointer to store for n by n orthogonal matrix V
m= number of rows in A
n= number of columns in A (m>=n required)
Returns
value: status flag with: 0 -> success -1 -> input error m < n

Definition at line 476 of file ccmath_grass_wrapper.c.

◆ G_math_svduv()

int G_math_svduv ( double *  ,
double **  ,
double **  ,
int  ,
double **  ,
int   
)

Definition at line 440 of file ccmath_grass_wrapper.c.

◆ G_math_svdval()

int G_math_svdval ( double *  d,
double **  a,
int  m,
int  n 
)

Compute the singular values of a real m by n matrix A.

Parameters
d= pointer to double array of dimension n (output = singular values of A)
a= pointer to store of the m by n input matrix A (A is altered by the computation)
m= number of rows in A
n= number of columns in A (m>=n required)
Returns
value: status flag with: 0 -> success -1 -> input error m < n

Definition at line 407 of file ccmath_grass_wrapper.c.

◆ getg()

int getg ( double  ,
double *  [2],
int   
)

Definition at line 16 of file getg.c.

Referenced by del2g().