30static int solver_pcg(
double **A,
G_math_spvector **Asp,
double *x,
double *
b,
37 double *
b,
int rows,
int maxit,
double err);
104 G_fatal_error(
"Preconditioning of band matrices is not implemented yet");
152 double a0 = 0, a1 = 0,
mygamma, tmp = 0;
170 M = create_diag_precond_matrix(A, Asp, rows,
prec);
189#pragma omp for schedule(static) private(i) reduction(+ : s)
190 for (i = 0; i < rows; i++) {
202#pragma omp parallel default(shared)
212#pragma omp for schedule(static) private(i) reduction(+ : s)
213 for (i = 0; i < rows; i++) {
245#pragma omp for schedule(static) private(i) reduction(+ : s)
246 for (i = 0; i < rows; i++) {
262 G_warning(
_(
"Unable to solve the linear equation system"));
270 G_message(
_(
"Sparse PCG -- iteration %i error %g\n"),
m, a0);
272 G_message(
_(
"PCG -- iteration %i error %g\n"),
m, a0);
386int solver_cg(
double **A,
G_math_spvector **Asp,
double *x,
double *
b,
int rows,
397 double a0 = 0, a1 = 0,
mygamma, tmp = 0;
426#pragma omp for schedule(static) private(i) reduction(+ : s)
427 for (i = 0; i < rows; i++) {
439#pragma omp parallel default(shared)
449#pragma omp for schedule(static) private(i) reduction(+ : s)
450 for (i = 0; i < rows; i++) {
479#pragma omp for schedule(static) private(i) reduction(+ : s)
480 for (i = 0; i < rows; i++) {
496 G_warning(
_(
"Unable to solve the linear equation system"));
504 G_message(
_(
"Sparse CG -- iteration %i error %g\n"),
m, a0);
506 G_message(
_(
"CG -- iteration %i error %g\n"),
m, a0);
601 double s1 = 0.0,
s2 = 0.0,
s3 = 0.0;
639#pragma omp parallel default(shared)
647#pragma omp for schedule(static) private(i) reduction(+ : s1, s2, s3)
648 for (i = 0; i < rows; i++) {
662 G_warning(
_(
"Unable to solve the linear equation system"));
678#pragma omp for schedule(static) private(i) reduction(+ : s1, s2)
679 for (i = 0; i < rows; i++) {
694#pragma omp for schedule(static) private(i) reduction(+ : s1)
695 for (i = 0; i < rows; i++) {
710 G_message(
_(
"Sparse BiCGStab -- iteration %i error %g\n"),
m,
751 unsigned int i,
j, cols = (
unsigned int)rows;
760#pragma omp parallel for schedule(static) private(i, j, sum) \
761 shared(A, Msp, rows, cols, prec)
762 for (i = 0; i < (
unsigned int)rows; i++) {
768 for (
j = 0;
j < cols;
j++)
769 sum += A[i][
j] * A[i][
j];
774 for (
j = 0;
j < cols;
j++)
775 sum +=
fabs(A[i][
j]);
776 spvect->values[0] = 1.0 / (sum);
780 spvect->values[0] = 1.0 / A[i][i];
791#pragma omp parallel for schedule(static) private(i, j, sum) \
792 shared(Asp, Msp, rows, cols, prec)
793 for (i = 0; i < (
unsigned int)rows; i++) {
799 for (
j = 0;
j < Asp[i]->
cols;
j++)
800 sum += Asp[i]->values[
j] * Asp[i]->values[
j];
805 for (
j = 0;
j < Asp[i]->
cols;
j++)
806 sum +=
fabs(Asp[i]->values[
j]);
807 spvect->values[0] = 1.0 / (sum);
811 for (
j = 0;
j < Asp[i]->
cols;
j++)
812 if (i == Asp[i]->index[
j])
void G_free(void *)
Free allocated memory.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_warning(const char *,...) __attribute__((format(printf
void G_message(const char *,...) __attribute__((format(printf
G_math_spvector * G_math_alloc_spvector(int)
Allocate memory for a sparse vector.
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.
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_free_spmatrix(G_math_spvector **, int)
Release the memory of the sparse matrix.
G_math_spvector ** G_math_alloc_spmatrix(int)
Allocate memory for a sparse matrix.
double * G_alloc_vector(size_t)
Vector matrix memory allocation.
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_Ax(double **, double *, double *, int, int)
Compute the matrix - vector product of matrix A and vector x.
void G_math_d_copy(double *, double *, int)
Copy the vector x to y.
#define G_MATH_ROWSCALE_ABSSUMNORM_PRECONDITION
#define G_MATH_ROWSCALE_EUKLIDNORM_PRECONDITION
#define G_MATH_DIAGONAL_PRECONDITION
#define assert(condition)
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.
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.
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.
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.
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.
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...
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.
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 matric...
The row vector of the sparse matrix.
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)