23 #include <cusp/detail/config.h>
24 #include <cusp/array1d.h>
25 #include <cusp/blas.h>
26 #include <cusp/array2d.h>
27 #include <cusp/print.h>
53 template <
typename ValueType>
57 typedef typename norm_type<ValueType>::type
Real;
73 template <
typename MV>
78 bool verbose =
true) :
87 for (
int i = 0; i <
numRHS; i++)
88 b_norm[i] = cusp::blas::nrm2(b.column(i));
100 template <
typename MV>
107 cusp::array1d<ValueType, cusp::host_memory> resid(
numRHS);
108 std::cout <<
"Successfully converged after " <<
iteration_count() <<
" iterations to tolerance " <<
tolerance(0) << std::endl;
109 std::cout <<
"with max residual norm ";
111 for (
int i = 0; i <
numRHS; i++) {
112 resid[i] = cusp::blas::nrm2(r.column(i));
113 if (resid[i] > norm_max) norm_max = resid[i];
115 std::cout << norm_max << std::endl;
125 cusp::array1d<ValueType, cusp::host_memory> resid(
numRHS);
126 std::cout <<
"Failed to converge after " <<
iteration_count() <<
" iterations." << std::endl;
127 std::cout <<
"with max residual norm ";
129 for (
int i = 0; i <
numRHS; i++) {
130 resid[i] = cusp::blas::nrm2(r.column(i));
131 if (resid[i] > norm_max) norm_max = resid[i];
133 std::cout << norm_max << std::endl;
150 template <
typename MV>
153 for (
int i = 0; i <
numRHS; i++){
155 if (cusp::blas::nrm2(r.column(i)) >
tolerance(i)){
194 cusp::array1d<ValueType, cusp::host_memory>
b_norm;
bool converged(MV &r) const
default_block_monitor(const MV &b, size_t iteration_limit=500, Real absolute_tolerance=1e-6, Real relative_tolerance=1e-6, bool verbose=true)
bool finished(const MV &r)
norm_type< ValueType >::type Real
size_t iteration_count() const
size_t iteration_limit() const
Real tolerance(int i) const
cusp::array1d< ValueType, cusp::host_memory > b_norm
Real absolute_tolerance() const
Real relative_tolerance() const