GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
solvers_krylov.c File Reference
#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 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_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_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 92 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_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.