status = 1 hpddm.schwarzDestroy(ctypes.byref(A)) else: S = ctypes.POINTER(hpddm.Subdomain)() hpddm.subdomainNumfact(ctypes.byref(S), Mat) hpddm.subdomainSolve(S, f, sol) nrmb = numpy.linalg.norm(f, axis = 0) tmp = numpy.empty_like(f) hpddm.csrmv(Mat, sol, tmp) tmp -= f nrmAx = numpy.linalg.norm(tmp, axis = 0) if mu == 0: nrmb = [ nrmb ] nrmAx = [ nrmAx ] mu = 1 for nu in xrange(mu): if nu == 0: print(' --- error = ', end = '') else: print(' ', end = '') print('{:e} / {:e}'.format(nrmAx[nu], nrmb[nu]), end = '') if mu > 1: print(' (rhs #{:d})'.format(nu + 1), end = '') print('') if nrmAx[nu] / nrmb[nu] > (1.0e-6 if ctypes.sizeof(hpddm.underlying) == ctypes.sizeof(ctypes.c_double) else 1.0e-2): status = 1 hpddm.subdomainDestroy(ctypes.byref(S)) hpddm.matrixCSRDestroy(ctypes.byref(Mat)) hpddm.matrixCSRDestroy(ctypes.byref(MatNeumann)) sys.exit(status)
status = 1 hpddm.schwarzDestroy(ctypes.byref(A)) else: S = ctypes.POINTER(hpddm.Subdomain)() hpddm.subdomainNumfact(ctypes.byref(S), Mat) hpddm.subdomainSolve(S, f, sol) nrmb = numpy.linalg.norm(f, axis = 0) tmp = numpy.empty_like(f) hpddm.csrmv(Mat, sol, tmp) tmp -= f nrmAx = numpy.linalg.norm(tmp, axis = 0) if mu == 0: nrmb = [ nrmb ] nrmAx = [ nrmAx ] mu = 1 for nu in xrange(mu): if nu == 0: print(' --- residual = ', end = '') else: print(' ', end = '') print('{:e} / {:e}'.format(nrmAx[nu], nrmb[nu]), end = '') if mu > 1: print(' (rhs #{:d})'.format(nu + 1), end = '') print('') if nrmAx[nu] / nrmb[nu] > (1.0e-6 if ctypes.sizeof(hpddm.underlying) == ctypes.sizeof(ctypes.c_double) else 1.0e-2): status = 1 hpddm.subdomainDestroy(ctypes.byref(S)) hpddm.matrixCSRDestroy(ctypes.byref(Mat)) hpddm.matrixCSRDestroy(ctypes.byref(MatNeumann)) sys.exit(status)