#include <iostream>
template <typename Monitor>
void report_status(Monitor& monitor)
{
if (monitor.converged())
{
std::cout << " Solver converged to " << monitor.tolerance() << " tolerance";
std::cout << " after " << monitor.iteration_count() << " iterations";
std::cout << " (" << monitor.residual_norm() << " final residual)" << std::endl;
}
else
{
std::cout << " Solver reached iteration limit " << monitor.iteration_limit() << " before converging";
std::cout << " to " << monitor.tolerance() << " tolerance ";
std::cout << " (" << monitor.residual_norm() << " final residual)" << std::endl;
}
}
int main(void)
{
typedef int IndexType;
typedef float ValueType;
typedef cusp::device_memory MemorySpace;
{
std::cout << "\nSolving with no preconditioner..." << std::endl;
monitor.print();
}
{
std::cout << "\nSolving with smoothed aggregation preconditioner..." << std::endl;
monitor.reset(b);
monitor.print();
std::cout << "\nPreconditioner statistics" << std::endl;
M.print();
}
return 0;
}