File tree Expand file tree Collapse file tree 2 files changed +8
-15
lines changed
Expand file tree Collapse file tree 2 files changed +8
-15
lines changed Original file line number Diff line number Diff line change 11try :
22 from julia .api import Julia
33 from julia import Main
4+
5+ julia = Julia ()
6+ Main .eval ("using IterativeSolvers" )
47except :
58 print ("Installing Julia is Required" )
6-
7- def start ():
8- julia = Julia ()
9- Main .using ("IterativeSolvers" )
109
1110def cg (A ,b ,** kwargs ):
1211 '''
Original file line number Diff line number Diff line change 1010A = np .random .rand (n ,n )
1111A = A * A .T
1212b = np .random .rand (n )
13- IterativeSolvers .start ()
1413
1514start = time .time ()
1615x = IterativeSolvers .cg (A ,b )
17- print ("Iterative Solvers CG Computational Time: %.3f " % (time .time ()- start ))
16+ print ("Iterative Solvers CG Computational Time: %.7f " % (time .time ()- start ))
1817print ("Iterative Solvers CG Solution: " ,x )
1918
2019start = time .time ()
2120x = linalg .cg (A ,b )
22- print ("Scipy CG Computational Time: %.3f " % (time .time ()- start ))
21+ print ("Scipy CG Computational Time: %.7f " % (time .time ()- start ))
2322print ("Scipy CG Solution: " ,x )
2423
2524start = time .time ()
26- x = IterativeSolvers .cg (A ,b )
27- print ("Iterative Solvers CG Computational Time: %.3f" % (time .time ()- start ))
28- print ("Iterative Solvers CG Solution: " ,x )
29- # N= 10
30-
31- # N = 100
32-
33- # N = 1000
25+ x = IterativeSolvers .gmres (A + 2 ,b )
26+ print ("Iterative Solvers CG Computational Time: %.7f" % (time .time ()- start ))
27+ print ("Iterative Solvers CG Solution: " ,x )
You can’t perform that action at this time.
0 commit comments