IterativeSolvers.hpp
Go to the documentation of this file.
1 /*
2  * STRUMPACK -- STRUctured Matrices PACKage, Copyright (c) 2014, The
3  * Regents of the University of California, through Lawrence Berkeley
4  * National Laboratory (subject to receipt of any required approvals
5  * from the U.S. Dept. of Energy). All rights reserved.
6  *
7  * If you have questions about your rights to use or distribute this
8  * software, please contact Berkeley Lab's Technology Transfer
9  * Department at TTD@lbl.gov.
10  *
11  * NOTICE. This software is owned by the U.S. Department of Energy. As
12  * such, the U.S. Government has been granted for itself and others
13  * acting on its behalf a paid-up, nonexclusive, irrevocable,
14  * worldwide license in the Software to reproduce, prepare derivative
15  * works, and perform publicly and display publicly. Beginning five
16  * (5) years after the date permission to assert copyright is obtained
17  * from the U.S. Department of Energy, and subject to any subsequent
18  * five (5) year renewals, the U.S. Government is granted for itself
19  * and others acting on its behalf a paid-up, nonexclusive,
20  * irrevocable, worldwide license in the Software to reproduce,
21  * prepare derivative works, distribute copies to the public, perform
22  * publicly and display publicly, and to permit others to do so.
23  *
24  * Developers: Pieter Ghysels, Francois-Henry Rouet, Xiaoye S. Li.
25  * (Lawrence Berkeley National Lab, Computational Research
26  * Division).
27  *
28  */
33 #ifndef STRUMPACK_ITERATIVE_SOLVERS_HPP
34 #define STRUMPACK_ITERATIVE_SOLVERS_HPP
35 
36 #include <functional>
37 
38 #include "StrumpackOptions.hpp" // for GramSchmidtType
40 #include "dense/DenseMatrix.hpp"
41 
42 namespace strumpack {
43 
44  namespace iterative {
45 
46  template<typename T> using SPMV = std::function<void(const T*, T*)>;
47  template<typename T> using PREC = std::function<void(T*)>;
48 
49  /*
50  * This is left preconditioned restarted GMRes.
51  *
52  * Input vectors x and b have stride 1, length n
53  */
54  template<typename scalar_t,
55  typename real_t = typename RealType<scalar_t>::value_type>
56  real_t GMRes
57  (const SPMV<scalar_t>& A, const PREC<scalar_t>& M, std::size_t n,
58  scalar_t* x, const scalar_t* b, real_t rtol, real_t atol,
59  int& totit, int maxit, int restart, GramSchmidtType GStype,
60  bool non_zero_guess, bool verbose);
61 
62 
66  template<typename scalar_t,
67  typename real_t = typename RealType<scalar_t>::value_type>
68  real_t BiCGStab
69  (const SPMV<scalar_t>& A, const PREC<scalar_t>& M, std::size_t n,
70  scalar_t* x, const scalar_t* b, real_t rtol, real_t atol,
71  int& totit, int maxit, bool non_zero_guess, bool verbose);
72 
94  template<typename scalar_t,typename integer_t,
95  typename real_t = typename RealType<scalar_t>::value_type>
97  (const CompressedSparseMatrix<scalar_t,integer_t>& A,
98  const std::function<void(DenseMatrix<scalar_t>&)>& M,
99  DenseMatrix<scalar_t>& x, const DenseMatrix<scalar_t>& b,
100  real_t rtol, real_t atol, int& totit, int maxit,
101  bool non_zero_guess, bool verbose);
102 
103 
124  template<typename scalar_t,
125  typename real_t = typename RealType<scalar_t>::value_type>
127  (const DenseMatrix<scalar_t>& A,
128  const std::function<void(DenseMatrix<scalar_t>&)>& M,
129  DenseMatrix<scalar_t>& x, const DenseMatrix<scalar_t>& b,
130  real_t rtol, real_t atol, int& totit, int maxit,
131  bool non_zero_guess, bool verbose);
132 
133 
134  } // end namespace iterative
135 } // end namespace strumpack
136 
137 #endif // STRUMPACK_ITERATIVE_SOLVERS_HPP
strumpack::iterative::BiCGStab
real_t BiCGStab(const SPMV< scalar_t > &A, const PREC< scalar_t > &M, std::size_t n, scalar_t *x, const scalar_t *b, real_t rtol, real_t atol, int &totit, int maxit, bool non_zero_guess, bool verbose)
strumpack::iterative::IterativeRefinement
void IterativeRefinement(const CompressedSparseMatrix< scalar_t, integer_t > &A, const std::function< void(DenseMatrix< scalar_t > &)> &M, DenseMatrix< scalar_t > &x, const DenseMatrix< scalar_t > &b, real_t rtol, real_t atol, int &totit, int maxit, bool non_zero_guess, bool verbose)
strumpack::GramSchmidtType
GramSchmidtType
Definition: StrumpackOptions.hpp:135
DenseMatrix.hpp
Contains the DenseMatrix and DenseMatrixWrapper classes, simple wrappers around BLAS/LAPACK style den...
strumpack
Definition: StrumpackOptions.hpp:42
CompressedSparseMatrix.hpp
Contains the CompressedSparseMatrix class, a base class for compressed sparse storage.
StrumpackOptions.hpp
Holds options for the sparse solver.