21 #include <grass/glocale.h>
22 #include <grass/N_pde.h>
26 static int test_solvers(
void);
27 static N_les *create_normal_les(
int rows);
28 static N_les *create_sparse_les(
int rows);
37 G_message(_(
"\n++ Running solver unit tests ++"));
39 sum += test_solvers();
42 G_warning(_(
"\n-- Solver unit tests failure --"));
44 G_message(_(
"\n-- Solver unit tests finished successfully --"));
52 N_les *create_normal_les(
int rows)
60 for (i = 0; i < size; i++) {
62 for (j = 0; j < size; j++) {
63 les->
A[i][j] = (double)(1.0 / (((
double)i + 1.0) +
64 ((
double)j + 1.0) - 1.0));
76 N_les *create_sparse_les(
int rows)
85 for (i = 0; i < rows; i++) {
89 for (j = 0; j < rows; j++) {
91 (double)(1.0 / (((
double)i + 1.0) + ((
double)j + 1.0) - 1.0));
92 spvector->
index[j] = j;
93 val += spvector->
values[j];
108 int test_solvers(
void)
113 G_message(
"\t * testing jacobi solver\n");
153 G_message(
"\t * testing pcg solver with N_DIAGONAL_PRECONDITION\n");
167 (
"\t * testing pcg solver with N_ROWSCALE_EUKLIDNORM_PRECONDITION\n");
181 (
"\t * testing pcg solver with N_ROWSCALE_ABSSUMNORM_PRECONDITION\n");
195 G_message(
"\t * testing bicgstab solver\n");
208 G_message(
"\t * testing gauss elimination solver\n");
217 G_message(
"\t * testing lu decomposition solver\n");