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