/usr/include/rheolef/matrix_solver.h is in librheolef-dev 5.93-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | #ifndef _RHEO_MATRIX_SOLVER_H
#define _RHEO_MATRIX_SOLVER_H
/// This file is part of Rheolef.
///
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
///
/// Rheolef 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 2 of the License, or
/// (at your option) any later version.
///
/// Rheolef 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 Rheolef; if not, write to the Free Software
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
///
/// =========================================================================
/*Class:matrix_solver
NAME: @code{cg_solver}, @code{ldlt_solver} - wrappers for algoritms
@clindex cg_solver
@clindex ldlt_solver
@clindex iterative_stokes_solver
DESCRIPTION:
@noindent
These class offers an uniform invocation
for linear system solver, and thus are suitable for
upper-lever template algorithm developments.
These classes call a matrix inversion method and
can contains some parameters.
@noindent
These classes are used by @code{iterative_stokes_solver}.
@code{cg_solver}, @code{ldlt_solver} are examples of
base classes @code{iterative_matrix_solver}
and
@code{direct_matrix_solver}, respectively.
EXAMPLE:
@example
cg_solver my_algo(100, 1.e-14, cout);
my_algo (a1,m_a1,x1,b1);
my_algo (a2,m_a2,x2,b2);
@end example
SEE ALSO:
class "iterative_solver"
DATE: 24 sept 1997
METHODS: @matrixsolver
End:
*/
#include "rheolef/gen_solver.h"
#include "rheolef/cg.h"
namespace rheolef {
//<matrixsolver:
// iterative conjugate gradient solver
template<
class MatrixPreconditionner,
class Matrix,
class InputVector,
class OutputVector,
class Real>
class cg_solver
: public iterative_solver<Real>
{
public:
// allocator:
cg_solver(int n_iter_max_init, Real epsilon_init,
std::ostream* p_clog_init = 0, std::ostream* p_cres_init = 0);
// solve method:
int operator()(
const Matrix& a,
const MatrixPreconditionner& ma,
OutputVector& x,
const InputVector& b)
const;
};
//>matrixsolver:
template<
class MatrixPreconditionner,
class Matrix,
class InputVector,
class OutputVector,
class Real>
inline
cg_solver<MatrixPreconditionner,Matrix,InputVector,OutputVector,Real>::cg_solver(
int n_iter_max_init,
Real epsilon_init,
std::ostream* p_clog_init,
std::ostream* p_cres_init)
: iterative_solver<Real>(
n_iter_max_init,
epsilon_init,
p_cres_init,
p_clog_init )
{
}
template<
class MatrixPreconditionner,
class Matrix,
class InputVector,
class OutputVector,
class Real>
inline
int
cg_solver<MatrixPreconditionner,Matrix,InputVector,OutputVector,Real>::operator()(
const Matrix& A,
const MatrixPreconditionner& M_A,
OutputVector& x,
const InputVector& b)
const
{
int n_iter = iterative_solver<Real>::_n_iter_max ;
Real residu = iterative_solver<Real>::_epsilon ;
int status = cg( A, x, b, M_A, n_iter, residu ) ;
bilan(status, n_iter, residu) ;
return status ;
}
//<matrixsolver:
// Direct matrix solver : Choleski factorization
template<
class MatrixFactorized,
class Matrix,
class InputVector,
class OutputVector>
class ldlt_solver
: public direct_solver
{
public:
// allocator:
ldlt_solver();
// solve method:
int operator()(
const Matrix& a,
const MatrixFactorized& m,
OutputVector& x,
const InputVector& b)
const;
};
//>matrixsolver:
template<
class MatrixFactorized,
class Matrix,
class InputVector,
class OutputVector>
inline
ldlt_solver<MatrixFactorized,Matrix,InputVector,OutputVector>::ldlt_solver()
: direct_solver()
{
}
template<
class MatrixFactorized,
class Matrix,
class InputVector,
class OutputVector>
inline
int
ldlt_solver<MatrixFactorized,Matrix,InputVector,OutputVector>::operator()(
const Matrix& A,
const MatrixFactorized& m,
OutputVector& x,
const InputVector& b )
const
{
m.solve( b, x ) ;
return 0 ;
}
}// namespace rheolef
#endif // _RHEO_MATRIX_SOLVER_H
|