b = np.ones(n * n, "d") e = np.ones(n * n, "d") c = np.ones(n * n, "d") for loop in xrange(n * n): b[loop] = loop c[loop] = loop y = np.ones(n * n, "d") S.matvec(b, y) b = y # ----------------------------------------------------------------------------- t1 = time.clock() x = np.empty(n * n, "d") info, iter, relres = gmres(S, b, x, 1e-12, 200, None, 100) print "info=%d, iter=%d, relres=%e" % (info, iter, relres) print "Solve time using SSS matrix: %8.2f s" % (time.clock() - t1) print "norm(x) = %g" % np.linalg.norm(x) r = np.empty(n * n, "d") S.matvec(x, r) r = b - r print "norm(b - A*x) = %g" % np.linalg.norm(r) # ----------------------------------------------------------------------------- t1 = time.clock()
b = np.ones(n*n, 'd') e = np.ones(n*n, 'd') c = np.ones(n*n, 'd') for loop in xrange(n*n): b[loop]= loop c[loop] = loop y = np.ones(n*n, 'd') S.matvec(b,y) b = y # ----------------------------------------------------------------------------- t1 = time.clock() x = np.empty(n*n, 'd') info, iter, relres = gmres(S, b, x, 1e-12, 200, None, 100) print 'info=%d, iter=%d, relres=%e' % (info, iter, relres) print 'Solve time using SSS matrix: %8.2f s' % (time.clock() - t1) print 'norm(x) = %g' % np.linalg.norm(x) r = np.empty(n*n, 'd') S.matvec(x, r) r = b - r print 'norm(b - A*x) = %g' % np.linalg.norm(r) # ----------------------------------------------------------------------------- t1 = time.clock()
def gmres(*args, **kwargs): return krylov.gmres(*args, **kwargs)