GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-b4e4cb0fe9
solvers_krylov.c File Reference
#include <assert.h>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/gmath.h>
#include <grass/glocale.h>
Include dependency graph for solvers_krylov.c:

Go to the source code of this file.

Functions

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. More...
 
int G_math_solver_pcg_sband (double **A, double *x, double *b, int rows, int bandwidth, int maxit, double err, int prec)
 The iterative preconditioned conjugate gradients solver for symmetric positive definite band matrices. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 

Function Documentation

◆ 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 550 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 319 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 350 of file solvers_krylov.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 65 of file solvers_krylov.c.

◆ G_math_solver_pcg_sband()

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

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

WARNING: The preconditioning of symmetric band matrices is not implemented yet

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 positive definite band matrix
x(double *) – the value vector
b(double *) – the right hand side
rows(int)
bandwidth(int) – bandwidth of matrix A
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 101 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 580 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 380 of file solvers_krylov.c.

◆ 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 133 of file solvers_krylov.c.