49 int rows,
int maxit,
double sor,
double error)
51 unsigned int i, j, center, finished = 0;
63 for (k = 0; k < maxit; k++) {
67 for (j = 0; j < (
unsigned int)rows; j++) {
71 for (i = 0; i < (
unsigned int)rows; i++) {
74 for (j = 0; j < Asp[i]->
cols; j++) {
76 if (Asp[i]->index[j] == i)
79 Enew[i] =
x[i] - sor * (E -
b[i]) / Asp[i]->values[center];
81 for (j = 0; j < (
unsigned int)rows; j++) {
82 err += (
x[j] - Enew[j]) * (
x[j] - Enew[j]);
88 G_message(
_(
"sparse Jacobi -- iteration %5i error %g\n"), k,
err);
123 int rows,
int maxit,
double sor,
double error)
125 unsigned int i, j, finished = 0;
139 for (k = 0; k < maxit; k++) {
143 for (j = 0; j < (
unsigned int)rows; j++) {
147 for (i = 0; i < (
unsigned int)rows; i++) {
150 for (j = 0; j < Asp[i]->
cols; j++) {
152 if (Asp[i]->index[j] == i)
155 Enew[i] =
x[i] - sor * (E -
b[i]) / Asp[i]->values[center];
157 for (j = 0; j < (
unsigned int)rows; j++) {
158 err += (
x[j] - Enew[j]) * (
x[j] - Enew[j]);
164 G_message(
_(
"sparse SOR -- iteration %5i error %g\n"), k,
err);
199 double sor,
double error)
209 for (j = 0; j < rows; j++) {
213 for (k = 0; k < maxit; k++) {
214 for (i = 0; i < rows; i++) {
216 for (j = 0; j < rows; j++) {
219 Enew[i] =
x[i] - sor * (E -
b[i]) / A[i][i];
222 for (j = 0; j < rows; j++) {
223 err += (
x[j] - Enew[j]) * (
x[j] - Enew[j]);
256 double sor,
double error)
266 for (j = 0; j < rows; j++) {
270 for (k = 0; k < maxit; k++) {
271 for (i = 0; i < rows; i++) {
273 for (j = 0; j < rows; j++) {
274 E += A[i][j] * Enew[j];
276 Enew[i] =
x[i] - sor * (E -
b[i]) / A[i][i];
279 for (j = 0; j < rows; j++) {
280 err += (
x[j] - Enew[j]) * (
x[j] - Enew[j]);
void G_free(void *)
Free allocated memory.
void G_message(const char *,...) __attribute__((format(printf
double * G_alloc_vector(size_t)
Vector matrix memory allocation.
#define assert(condition)
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.
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.
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.
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 row vector of the sparse matrix.
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)