25#include "fasp_functs.h"
72 const INT MIN_ITER = 0;
78 REAL r_norm, r_normb, gamma, t;
83 REAL * c = NULL, *s = NULL, *rs = NULL;
84 REAL * norms = NULL, *r = NULL, *w = NULL;
86 REAL **p = NULL, **hh = NULL;
88 INT Restart =
MIN(restart, MaxIt);
89 INT Restart1 = Restart + 1;
90 LONG worksize = (Restart + 4) * (Restart + n) + 1 - n;
96 if (PrtLvl >
PRINT_NONE) printf(
"\nCalling GMRes solver (CSR) ...\n");
99 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
100 printf(
"### DEBUG: maxit = %d, tol = %.4le\n", MaxIt, tol);
104 while ((work == NULL) && (Restart > 5)) {
105 Restart = Restart - 5;
106 Restart1 = Restart + 1;
107 worksize = (Restart + 4) * (Restart + n) + 1 - n;
112 printf(
"### ERROR: No enough memory! [%s:%d]\n", __FILE__, __LINE__);
116 if (PrtLvl >
PRINT_MIN && Restart < restart) {
117 printf(
"### WARNING: GMRES restart number set to %d!\n", Restart);
130 for (i = 0; i < Restart1; i++) p[i] = s + Restart + i * n;
132 for (i = 0; i < Restart1; i++) hh[i] = p[Restart] + n + i * Restart;
143 relres = r_norm / absres0;
152 relres = r_normb / absres0;
157 relres = absres0 / normu;
160 printf(
"### ERROR: Unknown stopping type! [%s]\n", __FUNCTION__);
165 if (relres < tol || absres0 < abstol)
goto FINISHED;
168 fasp_itinfo(PrtLvl, StopType, 0, relres, absres0, 0.0);
174 while (iter < MaxIt && relres > tol) {
184 while (i < Restart && iter < MaxIt) {
193 pc->
fct(p[i - 1], r, pc->
data);
198 for (j = 0; j < i; j++) {
210 for (j = 1; j < i; ++j) {
211 t = hh[j - 1][i - 1];
212 hh[j - 1][i - 1] = s[j - 1] * hh[j][i - 1] + c[j - 1] * t;
213 hh[j][i - 1] = -s[j - 1] * t + c[j - 1] * hh[j][i - 1];
215 t = hh[i][i - 1] * hh[i][i - 1];
216 t += hh[i - 1][i - 1] * hh[i - 1][i - 1];
219 c[i - 1] = hh[i - 1][i - 1] / gamma;
220 s[i - 1] = hh[i][i - 1] / gamma;
221 rs[i] = -s[i - 1] * rs[i - 1];
222 rs[i - 1] = c[i - 1] * rs[i - 1];
223 hh[i - 1][i - 1] = s[i - 1] * hh[i][i - 1] + c[i - 1] * hh[i - 1][i - 1];
225 absres = r_norm = fabs(rs[i]);
227 relres = absres / absres0;
229 norms[iter] = relres;
232 fasp_itinfo(PrtLvl, StopType, iter, relres, absres,
233 norms[iter] / norms[iter - 1]);
236 if (relres < tol && iter >= MIN_ITER)
break;
241 rs[i - 1] = rs[i - 1] / hh[i - 1][i - 1];
242 for (k = i - 2; k >= 0; k--) {
244 for (j = k + 1; j < i; j++) t -= hh[k][j] * rs[j];
246 rs[k] = t / hh[k][k];
264 if (relres < tol && iter >= MIN_ITER) {
266 REAL computed_relres = relres;
276 relres = absres / absres0;
284 relres = absres / absres0;
289 relres = absres / normu;
293 norms[iter] = relres;
303 ITS_COMPRES(computed_relres);
310 for (j = i; j > 0; j--) {
311 rs[j - 1] = -s[j - 1] * rs[j];
312 rs[j] = c[j - 1] * rs[j];
326 if (PrtLvl >
PRINT_NONE) ITS_FINAL(iter, MaxIt, relres);
341 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
377 const REAL tol,
const REAL abstol,
const INT MaxIt,
382 const INT MIN_ITER = 0;
388 REAL r_norm, r_normb, gamma, t;
393 REAL * c = NULL, *s = NULL, *rs = NULL;
394 REAL * norms = NULL, *r = NULL, *w = NULL;
396 REAL **p = NULL, **hh = NULL;
398 INT Restart =
MIN(restart, MaxIt);
399 INT Restart1 = Restart + 1;
400 LONG worksize = (Restart + 4) * (Restart + n) + 1 - n;
406 if (PrtLvl >
PRINT_NONE) printf(
"\nCalling GMRes solver (BSR) ...\n");
409 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
410 printf(
"### DEBUG: maxit = %d, tol = %.4le\n", MaxIt, tol);
414 while ((work == NULL) && (Restart > 5)) {
415 Restart = Restart - 5;
416 Restart1 = Restart + 1;
417 worksize = (Restart + 4) * (Restart + n) + 1 - n;
422 printf(
"### ERROR: No enough memory! [%s:%d]\n", __FILE__, __LINE__);
426 if (PrtLvl >
PRINT_MIN && Restart < restart) {
427 printf(
"### WARNING: GMRES restart number set to %d!\n", Restart);
440 for (i = 0; i < Restart1; i++) p[i] = s + Restart + i * n;
442 for (i = 0; i < Restart1; i++) hh[i] = p[Restart] + n + i * Restart;
453 relres = r_norm / absres0;
462 relres = r_normb / absres0;
467 relres = absres0 / normu;
470 printf(
"### ERROR: Unknown stopping type! [%s]\n", __FUNCTION__);
475 if (relres < tol || absres0 < abstol)
goto FINISHED;
478 fasp_itinfo(PrtLvl, StopType, 0, relres, absres0, 0.0);
484 while (iter < MaxIt && relres > tol) {
494 while (i < Restart && iter < MaxIt) {
503 pc->
fct(p[i - 1], r, pc->
data);
508 for (j = 0; j < i; j++) {
520 for (j = 1; j < i; ++j) {
521 t = hh[j - 1][i - 1];
522 hh[j - 1][i - 1] = s[j - 1] * hh[j][i - 1] + c[j - 1] * t;
523 hh[j][i - 1] = -s[j - 1] * t + c[j - 1] * hh[j][i - 1];
525 t = hh[i][i - 1] * hh[i][i - 1];
526 t += hh[i - 1][i - 1] * hh[i - 1][i - 1];
529 c[i - 1] = hh[i - 1][i - 1] / gamma;
530 s[i - 1] = hh[i][i - 1] / gamma;
531 rs[i] = -s[i - 1] * rs[i - 1];
532 rs[i - 1] = c[i - 1] * rs[i - 1];
533 hh[i - 1][i - 1] = s[i - 1] * hh[i][i - 1] + c[i - 1] * hh[i - 1][i - 1];
535 absres = r_norm = fabs(rs[i]);
537 relres = absres / absres0;
539 norms[iter] = relres;
542 fasp_itinfo(PrtLvl, StopType, iter, relres, absres,
543 norms[iter] / norms[iter - 1]);
546 if (relres < tol && iter >= MIN_ITER)
break;
551 rs[i - 1] = rs[i - 1] / hh[i - 1][i - 1];
552 for (k = i - 2; k >= 0; k--) {
554 for (j = k + 1; j < i; j++) t -= hh[k][j] * rs[j];
556 rs[k] = t / hh[k][k];
574 if (relres < tol && iter >= MIN_ITER) {
576 REAL computed_relres = relres;
586 relres = absres / absres0;
594 relres = absres / absres0;
599 relres = absres / normu;
603 norms[iter] = relres;
613 ITS_COMPRES(computed_relres);
620 for (j = i; j > 0; j--) {
621 rs[j - 1] = -s[j - 1] * rs[j];
622 rs[j] = c[j - 1] * rs[j];
637 if (PrtLvl >
PRINT_NONE) ITS_FINAL(iter, MaxIt, relres);
652 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
688 const REAL tol,
const REAL abstol,
const INT MaxIt,
693 const INT MIN_ITER = 0;
699 REAL r_norm, r_normb, gamma, t;
704 REAL * c = NULL, *s = NULL, *rs = NULL;
705 REAL * norms = NULL, *r = NULL, *w = NULL;
707 REAL **p = NULL, **hh = NULL;
709 INT Restart =
MIN(restart, MaxIt);
710 INT Restart1 = Restart + 1;
711 LONG worksize = (Restart + 4) * (Restart + n) + 1 - n;
717 if (PrtLvl >
PRINT_NONE) printf(
"\nCalling GMRes solver (BLC) ...\n");
720 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
721 printf(
"### DEBUG: maxit = %d, tol = %.4le\n", MaxIt, tol);
725 while ((work == NULL) && (Restart > 5)) {
726 Restart = Restart - 5;
727 Restart1 = Restart + 1;
728 worksize = (Restart + 4) * (Restart + n) + 1 - n;
733 printf(
"### ERROR: No enough memory! [%s:%d]\n", __FILE__, __LINE__);
737 if (PrtLvl >
PRINT_MIN && Restart < restart) {
738 printf(
"### WARNING: GMRES restart number set to %d!\n", Restart);
751 for (i = 0; i < Restart1; i++) p[i] = s + Restart + i * n;
753 for (i = 0; i < Restart1; i++) hh[i] = p[Restart] + n + i * Restart;
764 relres = r_norm / absres0;
773 relres = r_normb / absres0;
778 relres = absres0 / normu;
781 printf(
"### ERROR: Unknown stopping type! [%s]\n", __FUNCTION__);
786 if (relres < tol || absres0 < abstol)
goto FINISHED;
789 fasp_itinfo(PrtLvl, StopType, 0, relres, absres0, 0.0);
795 while (iter < MaxIt && relres > tol) {
805 while (i < Restart && iter < MaxIt) {
814 pc->
fct(p[i - 1], r, pc->
data);
819 for (j = 0; j < i; j++) {
831 for (j = 1; j < i; ++j) {
832 t = hh[j - 1][i - 1];
833 hh[j - 1][i - 1] = s[j - 1] * hh[j][i - 1] + c[j - 1] * t;
834 hh[j][i - 1] = -s[j - 1] * t + c[j - 1] * hh[j][i - 1];
836 t = hh[i][i - 1] * hh[i][i - 1];
837 t += hh[i - 1][i - 1] * hh[i - 1][i - 1];
840 c[i - 1] = hh[i - 1][i - 1] / gamma;
841 s[i - 1] = hh[i][i - 1] / gamma;
842 rs[i] = -s[i - 1] * rs[i - 1];
843 rs[i - 1] = c[i - 1] * rs[i - 1];
844 hh[i - 1][i - 1] = s[i - 1] * hh[i][i - 1] + c[i - 1] * hh[i - 1][i - 1];
846 absres = r_norm = fabs(rs[i]);
848 relres = absres / absres0;
850 norms[iter] = relres;
853 fasp_itinfo(PrtLvl, StopType, iter, relres, absres,
854 norms[iter] / norms[iter - 1]);
857 if (relres < tol && iter >= MIN_ITER)
break;
862 rs[i - 1] = rs[i - 1] / hh[i - 1][i - 1];
863 for (k = i - 2; k >= 0; k--) {
865 for (j = k + 1; j < i; j++) t -= hh[k][j] * rs[j];
867 rs[k] = t / hh[k][k];
885 if (relres < tol && iter >= MIN_ITER) {
887 REAL computed_relres = relres;
897 relres = absres / absres0;
905 relres = absres / absres0;
910 relres = absres / normu;
914 norms[iter] = relres;
924 ITS_COMPRES(computed_relres);
931 for (j = i; j > 0; j--) {
932 rs[j - 1] = -s[j - 1] * rs[j];
933 rs[j] = c[j - 1] * rs[j];
948 if (PrtLvl >
PRINT_NONE) ITS_FINAL(iter, MaxIt, relres);
963 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
999 const REAL tol,
const REAL abstol,
const INT MaxIt,
1004 const INT MIN_ITER = 0;
1010 REAL r_norm, r_normb, gamma, t;
1015 REAL * c = NULL, *s = NULL, *rs = NULL;
1016 REAL * norms = NULL, *r = NULL, *w = NULL;
1018 REAL **p = NULL, **hh = NULL;
1020 INT Restart =
MIN(restart, MaxIt);
1021 INT Restart1 = Restart + 1;
1022 LONG worksize = (Restart + 4) * (Restart + n) + 1 - n;
1028 if (PrtLvl >
PRINT_NONE) printf(
"\nCalling GMRes solver (STR) ...\n");
1031 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
1032 printf(
"### DEBUG: maxit = %d, tol = %.4le\n", MaxIt, tol);
1036 while ((work == NULL) && (Restart > 5)) {
1037 Restart = Restart - 5;
1038 Restart1 = Restart + 1;
1039 worksize = (Restart + 4) * (Restart + n) + 1 - n;
1044 printf(
"### ERROR: No enough memory! [%s:%d]\n", __FILE__, __LINE__);
1048 if (PrtLvl >
PRINT_MIN && Restart < restart) {
1049 printf(
"### WARNING: GMRES restart number set to %d!\n", Restart);
1062 for (i = 0; i < Restart1; i++) p[i] = s + Restart + i * n;
1064 for (i = 0; i < Restart1; i++) hh[i] = p[Restart] + n + i * Restart;
1075 relres = r_norm / absres0;
1084 relres = r_normb / absres0;
1089 relres = absres0 / normu;
1092 printf(
"### ERROR: Unknown stopping type! [%s]\n", __FUNCTION__);
1097 if (relres < tol || absres0 < abstol)
goto FINISHED;
1100 fasp_itinfo(PrtLvl, StopType, 0, relres, absres0, 0.0);
1106 while (iter < MaxIt && relres > tol) {
1116 while (i < Restart && iter < MaxIt) {
1125 pc->
fct(p[i - 1], r, pc->
data);
1130 for (j = 0; j < i; j++) {
1142 for (j = 1; j < i; ++j) {
1143 t = hh[j - 1][i - 1];
1144 hh[j - 1][i - 1] = s[j - 1] * hh[j][i - 1] + c[j - 1] * t;
1145 hh[j][i - 1] = -s[j - 1] * t + c[j - 1] * hh[j][i - 1];
1147 t = hh[i][i - 1] * hh[i][i - 1];
1148 t += hh[i - 1][i - 1] * hh[i - 1][i - 1];
1151 c[i - 1] = hh[i - 1][i - 1] / gamma;
1152 s[i - 1] = hh[i][i - 1] / gamma;
1153 rs[i] = -s[i - 1] * rs[i - 1];
1154 rs[i - 1] = c[i - 1] * rs[i - 1];
1155 hh[i - 1][i - 1] = s[i - 1] * hh[i][i - 1] + c[i - 1] * hh[i - 1][i - 1];
1157 absres = r_norm = fabs(rs[i]);
1159 relres = absres / absres0;
1161 norms[iter] = relres;
1164 fasp_itinfo(PrtLvl, StopType, iter, relres, absres,
1165 norms[iter] / norms[iter - 1]);
1168 if (relres < tol && iter >= MIN_ITER)
break;
1173 rs[i - 1] = rs[i - 1] / hh[i - 1][i - 1];
1174 for (k = i - 2; k >= 0; k--) {
1176 for (j = k + 1; j < i; j++) t -= hh[k][j] * rs[j];
1178 rs[k] = t / hh[k][k];
1196 if (relres < tol && iter >= MIN_ITER) {
1198 REAL computed_relres = relres;
1208 relres = absres / absres0;
1216 relres = absres / absres0;
1221 relres = absres / normu;
1225 norms[iter] = relres;
1235 ITS_COMPRES(computed_relres);
1236 ITS_REALRES(relres);
1242 for (j = i; j > 0; j--) {
1243 rs[j - 1] = -s[j - 1] * rs[j];
1244 rs[j] = c[j - 1] * rs[j];
1259 if (PrtLvl >
PRINT_NONE) ITS_FINAL(iter, MaxIt, relres);
1274 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
1310 const REAL tol,
const REAL abstol,
const INT MaxIt,
1314 const INT min_iter = 0;
1321 REAL r_norm, b_norm, den_norm;
1322 REAL epsilon, gamma, t;
1325 REAL * c = NULL, *s = NULL, *rs = NULL;
1326 REAL * norms = NULL, *r = NULL, *w = NULL;
1328 REAL **p = NULL, **hh = NULL;
1330 INT Restart = restart;
1331 INT Restart1 = Restart + 1;
1332 LONG worksize = (Restart + 4) * (Restart + n) + 1 - n;
1335 if (PrtLvl >
PRINT_NONE) printf(
"\nCalling GMRes solver (MatFree) ...\n");
1338 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
1339 printf(
"### DEBUG: maxit = %d, tol = %.4le\n", MaxIt, tol);
1346 while ((work == NULL) && (Restart > 5)) {
1347 Restart = Restart - 5;
1348 worksize = (Restart + 4) * (Restart + n) + 1 - n;
1350 Restart1 = Restart + 1;
1354 printf(
"### ERROR: No enough memory! [%s:%d]\n", __FILE__, __LINE__);
1358 if (PrtLvl >
PRINT_MIN && Restart < restart) {
1359 printf(
"### WARNING: GMRES restart number set to %d!\n", Restart);
1372 for (i = 0; i < Restart1; i++) p[i] = s + Restart + i * n;
1374 for (i = 0; i < Restart1; i++) hh[i] = p[Restart] + n + i * Restart;
1386 ITS_PUTNORM(
"right-hand side", b_norm);
1387 ITS_PUTNORM(
"residual", r_norm);
1396 epsilon = tol * den_norm;
1399 while (iter < MaxIt) {
1402 if (r_norm == 0.0) {
1414 if (r_norm <= epsilon && iter >= min_iter) {
1419 if (r_norm <= epsilon) {
1432 while (i < Restart && iter < MaxIt) {
1441 pc->
fct(p[i - 1], r, pc->
data);
1446 for (j = 0; j < i; j++) {
1458 for (j = 1; j < i; ++j) {
1459 t = hh[j - 1][i - 1];
1460 hh[j - 1][i - 1] = s[j - 1] * hh[j][i - 1] + c[j - 1] * t;
1461 hh[j][i - 1] = -s[j - 1] * t + c[j - 1] * hh[j][i - 1];
1463 t = hh[i][i - 1] * hh[i][i - 1];
1464 t += hh[i - 1][i - 1] * hh[i - 1][i - 1];
1466 if (gamma == 0.0) gamma = epsmac;
1467 c[i - 1] = hh[i - 1][i - 1] / gamma;
1468 s[i - 1] = hh[i][i - 1] / gamma;
1469 rs[i] = -s[i - 1] * rs[i - 1];
1470 rs[i - 1] = c[i - 1] * rs[i - 1];
1471 hh[i - 1][i - 1] = s[i - 1] * hh[i][i - 1] + c[i - 1] * hh[i - 1][i - 1];
1472 r_norm = fabs(rs[i]);
1474 norms[iter] = r_norm;
1477 fasp_itinfo(PrtLvl, StopType, iter, norms[iter] / b_norm, norms[iter],
1478 norms[iter] / norms[iter - 1]);
1480 fasp_itinfo(PrtLvl, StopType, iter, norms[iter], norms[iter],
1481 norms[iter] / norms[iter - 1]);
1485 if (r_norm <= epsilon && iter >= min_iter) {
1491 rs[i - 1] = rs[i - 1] / hh[i - 1][i - 1];
1492 for (k = i - 2; k >= 0; k--) {
1494 for (j = k + 1; j < i; j++) t -= hh[k][j] * rs[j];
1497 rs[k] = t / hh[k][k];
1512 if (r_norm <= epsilon && iter >= min_iter) {
1517 if (r_norm <= epsilon) {
1527 for (j = i; j > 0; j--) {
1528 rs[j - 1] = -s[j - 1] * rs[j];
1529 rs[j] = c[j - 1] * rs[j];
1542 if (PrtLvl >
PRINT_NONE) ITS_FINAL(iter, MaxIt, r_norm);
1557 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
1567static double estimate_spectral_radius (
const double **A,
int n,
size_t k = 20)
1569 double *x = (
double *)malloc(n*
sizeof(
double));
1570 double *y = (
double *)malloc(n*
sizeof(
double));
1571 double *z = (
double *)malloc(n*
sizeof(
double));
1583 for(
size_t i = 0; i < k; i++)
1587 for(i1= 0; i1 <n; i1++) x[i1] *= t;
1591 for(i1= 0; i1 <n; i1++) {
1593 for(j1= 0; j1 <n; j1++) t += A[i1][j1] * x[j1];
1596 for(i1= 0; i1 <n; i1++) z[i1] = x[i1];
1597 for(i1= 0; i1 <n; i1++) x[i1] = y[i1];
1598 for(i1= 0; i1 <n; i1++) y[i1] = z[i1];
1612static double spectral_radius (
dCSRmat *A,
1613 const SHORT restart)
1616 const INT MIN_ITER = 0;
1620 INT Restart1 = restart + 1;
1623 REAL r_norm, den_norm;
1624 REAL epsilon, gamma, t;
1626 REAL *c = NULL, *s = NULL, *rs = NULL;
1627 REAL *norms = NULL, *r = NULL, *w = NULL;
1628 REAL **p = NULL, **hh = NULL;
1638 r = work; w = r + n; rs = w + n; c = rs + Restart1; s = c + restart;
1640 for (i = 0; i < Restart1; i ++) p[i] = s + restart + i*n;
1641 for (i = 0; i < Restart1; i ++) hh[i] = p[restart] + n + i*restart;
1651 for (j = 0; j < n; j ++) p[0][j] *= t;
1653 int maxiter =
MIN(n, restart) ;
1654 for ( j = 0; j < maxiter; j++ ) {
1655 fasp_blas_bdbsr_mxv(A, p[j], p[j+1]);
1657 for( i = 0; i <= j; i++ ) {
1663 if ( hh[j+1][j] < 1e-10)
break;
1665 for (k = 0; k < n; k ++) p[j+1][k] *= t;
1670 for (i = 1; i < j; i ++) H[i] = H[i-1] + j;
1673 for(
size_t row = 0; row < j; row++ )
1674 for(
size_t col = 0; col < j; col++ )
1675 H[row][col] = hh[row][col];
1677 double spectral_radius = estimate_spectral_radius( H, j, 20);
1689 return spectral_radius;
void fasp_darray_cp(const INT n, const REAL *x, REAL *y)
Copy an array to the other y=x.
void fasp_mem_free(void *mem)
Free up previous allocated memory body and set pointer to NULL.
void * fasp_mem_calloc(const unsigned int size, const unsigned int type)
Allocate, initiate, and check memory.
void fasp_itinfo(const INT ptrlvl, const INT stop_type, const INT iter, const REAL relres, const REAL absres, const REAL factor)
Print out iteration information for iterative solvers.
void fasp_chkerr(const SHORT status, const char *fctname)
Check error status and print out error messages before quit.
void fasp_dvec_rand(const INT n, dvector *x)
Generate fake random REAL vector in the range from 0 to 1.
REAL fasp_blas_darray_dotprod(const INT n, const REAL *x, const REAL *y)
Inner product of two arraies x and y.
REAL fasp_blas_darray_norminf(const INT n, const REAL *x)
Linf norm of array x.
void fasp_blas_darray_axpby(const INT n, const REAL a, const REAL *x, const REAL b, REAL *y)
y = a*x + b*y
REAL fasp_blas_darray_norm2(const INT n, const REAL *x)
L2 norm of array x.
void fasp_blas_darray_ax(const INT n, const REAL a, REAL *x)
x = a*x
void fasp_blas_darray_axpy(const INT n, const REAL a, const REAL *x, REAL *y)
y = a*x + y
void fasp_blas_dblc_mxv(const dBLCmat *A, const REAL *x, REAL *y)
Matrix-vector multiplication y = A*x.
void fasp_blas_dblc_aAxpy(const REAL alpha, const dBLCmat *A, const REAL *x, REAL *y)
Matrix-vector multiplication y = alpha*A*x + y.
void fasp_blas_dbsr_aAxpy(const REAL alpha, const dBSRmat *A, const REAL *x, REAL *y)
Compute y := alpha*A*x + y.
void fasp_blas_dbsr_mxv(const dBSRmat *A, const REAL *x, REAL *y)
Compute y := A*x.
void fasp_blas_dcsr_mxv(const dCSRmat *A, const REAL *x, REAL *y)
Matrix-vector multiplication y = A*x.
void fasp_blas_dcsr_aAxpy(const REAL alpha, const dCSRmat *A, const REAL *x, REAL *y)
Matrix-vector multiplication y = alpha*A*x + y.
void fasp_blas_dstr_aAxpy(const REAL alpha, const dSTRmat *A, const REAL *x, REAL *y)
Matrix-vector multiplication y = alpha*A*x + y.
void fasp_blas_dstr_mxv(const dSTRmat *A, const REAL *x, REAL *y)
Matrix-vector multiplication y = A*x.
INT fasp_solver_dbsr_pgmres(dBSRmat *A, dvector *b, dvector *x, precond *pc, const REAL tol, const REAL abstol, const INT MaxIt, const SHORT restart, const SHORT StopType, const SHORT PrtLvl)
Preconditioned GMRES method for solving Au=b.
INT fasp_solver_dcsr_pgmres(dCSRmat *A, dvector *b, dvector *x, precond *pc, const REAL tol, const REAL abstol, const INT MaxIt, const SHORT restart, const SHORT StopType, const SHORT PrtLvl)
Right preconditioned GMRES method for solving Au=b.
INT fasp_solver_dstr_pgmres(dSTRmat *A, dvector *b, dvector *x, precond *pc, const REAL tol, const REAL abstol, const INT MaxIt, const SHORT restart, const SHORT StopType, const SHORT PrtLvl)
Preconditioned GMRES method for solving Au=b.
INT fasp_solver_dblc_pgmres(dBLCmat *A, dvector *b, dvector *x, precond *pc, const REAL tol, const REAL abstol, const INT MaxIt, const SHORT restart, const SHORT StopType, const SHORT PrtLvl)
Preconditioned GMRES method for solving Au=b.
INT fasp_solver_pgmres(mxv_matfree *mf, dvector *b, dvector *x, precond *pc, const REAL tol, const REAL abstol, const INT MaxIt, const SHORT restart, const SHORT StopType, const SHORT PrtLvl)
Solve "Ax=b" using PGMRES (right preconditioned) iterative method.
Main header file for the FASP project.
#define SHORT
FASP integer and floating point numbers.
#define MAX(a, b)
Definition of max, min, abs.
#define ERROR_SOLVER_MAXIT
#define STOP_REL_RES
Definition of iterative solver stopping criteria types.
#define BIGREAL
Some global constants.
#define PRINT_NONE
Print level for all subroutines – not including DEBUG output.
Block REAL CSR matrix format.
Block sparse row storage matrix of REAL type.
Sparse matrix of REAL type in CSR format.
INT row
row number of matrix A, m
Structure matrix of REAL type.
Vector with n entries of REAL type.
REAL * val
actual vector entries
Matrix-vector multiplication, replace the actual matrix.
void * data
data for MxV, can be a Matrix or something else
void(* fct)(const void *, const REAL *, REAL *)
action for MxV, void function pointer
Preconditioner data and action.
void * data
data for preconditioner, void pointer
void(* fct)(REAL *, REAL *, void *)
action for preconditioner, void function pointer