Fork me on GitHub
 All Classes Files Functions Variables Groups Pages
cg.cu
#include <cusp/monitor.h>
#include <cusp/krylov/cg.h>
// where to perform the computation
typedef cusp::device_memory MemorySpace;
// which floating point type to use
typedef float ValueType;
int main(void)
{
// create an empty sparse matrix structure (HYB format)
// create a 2d Poisson problem on a 10x10 mesh
// allocate storage for solution (x) and right hand side (b)
// set stopping criteria:
// iteration_limit = 100
// relative_tolerance = 1e-3
// absolute_tolerance = 0
// verbose = true
cusp::monitor<ValueType> monitor(b, 100, 1e-3, 0, true);
// set preconditioner (identity)
// solve the linear system A * x = b with the Conjugate Gradient method
cusp::krylov::cg(A, x, b, monitor, M);
return 0;
}