MCPcopy Create free account
hub / github.com/chunleili/mgpbd / test_amg_python

Function test_amg_python

engine/solver/amg_python_easy.py:5–36  ·  view source on GitHub ↗
(matA,b)

Source from the content-addressed store, hash-verified

3import scipy
4
5def test_amg_python(matA,b):
6 import argparse
7 import sys,os
8 sys.path.append(os.getcwd())
9 parser = argparse.ArgumentParser()
10 from engine.common_args import add_common_args
11 add_common_args(parser)
12 args = parser.parse_args()
13 args.use_cuda = False
14 args.smoother_type = "jacobi"
15 args.tol_Axb=1e-6
16 args.maxiter=100
17 args.maxiter_Axb=100
18 print(args)
19
20 from engine.solver.amg_python import AmgPython
21
22 def get_A0_1():
23 A = csr_matrix(matA).astype(np.float32)
24 return A
25
26 def should_setup():
27 return True
28
29 amg = AmgPython(args, get_A0=get_A0_1, should_setup=should_setup)
30 x, r_Axb = amg.run(b)
31
32 print(f"AmgPython: {r_Axb[0]:.2e}->{r_Axb[-1]:.2e}")
33 print("niter:", len(r_Axb))
34 # print("x", x)
35 # assert r_Axb[-1] < args.tol_Axb * r_Axb[0]
36 return x, r_Axb
37
38
39

Callers 1

amg_python_easy.pyFile · 0.85

Calls 3

runMethod · 0.95
add_common_argsFunction · 0.90
AmgPythonClass · 0.90

Tested by

no test coverage detected