diff options
author | Anton Khirnov <anton@khirnov.net> | 2019-03-18 10:33:46 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2019-03-18 10:33:46 +0100 |
commit | 457d8274fde5d20dc5694576b99c5541e55b4f40 (patch) | |
tree | ca1df761a0340bcc1bd5324895d8067d3b8528e6 /bicgstab.h | |
parent | 53e7613a1111702bb62708d1e5aff8b18fa9c9cb (diff) |
ell_grid_solve: use BiCGSTAB to speed up exact solves
Diffstat (limited to 'bicgstab.h')
-rw-r--r-- | bicgstab.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/bicgstab.h b/bicgstab.h new file mode 100644 index 0000000..f25cb28 --- /dev/null +++ b/bicgstab.h @@ -0,0 +1,47 @@ +/* + * BiCGStab iterative linear system solver + * Copyright (C) 2016 Anton Khirnov <anton@khirnov.net> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef MG2D_BICGSTAB_H +#define MG2D_BICGSTAB_H + +typedef struct BiCGStabContext BiCGStabContext; + +/** + * Allocate and initialize the solver for the NxN system. + */ +int mg2di_bicgstab_context_alloc(BiCGStabContext **ctx, size_t N, unsigned int maxiter); + +/** + * Free the solver and all its internal state. + */ +void mg2di_bicgstab_context_free(BiCGStabContext **ctx); + +/** + * Initialise the solver with the given preconditioner matrix. This function + * may be any number of times on a given solver context. + */ +int mg2di_bicgstab_init(BiCGStabContext *ctx, const double *k, const double *x0); + +/** + * Solve the linear system + * mat ยท x = rhs + * The result is written into x. + */ +int mg2di_bicgstab_solve(BiCGStabContext *ctx, const double *mat, const double *rhs, double *x); + +#endif /* MG2D_BICGSTAB_H */ |