Changeset 8025 for trunk/anuga_core/source/anuga/utilities/cg_solve.py
 Timestamp:
 Sep 23, 2010, 12:21:55 PM (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/anuga_core/source/anuga/utilities/cg_solve.py
r7848 r8025 8 8 9 9 10 def conjugate_gradient(A,b,x0=None,imax=10000,tol=1.0e8, iprint=None):10 def conjugate_gradient(A,b,x0=None,imax=10000,tol=1.0e8,atol=1.0e14,iprint=None): 11 11 """ 12 12 Try to solve linear equation Ax = b using … … 27 27 for i in range(b.shape[1]): 28 28 x0[:,i] = _conjugate_gradient(A, b[:,i], x0[:,i], 29 imax, tol, iprint)29 imax, tol, atol, iprint) 30 30 else: 31 x0 = _conjugate_gradient(A, b, x0, imax, tol, iprint)31 x0 = _conjugate_gradient(A, b, x0, imax, tol, atol, iprint) 32 32 33 33 return x0 34 34 35 def _conjugate_gradient(A,b,x0=None,imax=10000,tol=1.0e8,iprint=None): 35 def _conjugate_gradient(A, b, x0, 36 imax=10000, tol=1.0e8, atol=1.0e14, iprint=None): 36 37 """ 37 38 Try to solve linear equation Ax = b using … … 73 74 74 75 #FIXME Let the iterations stop if starting with a small residual 75 while (i<imax and rTr>tol**2*rTr0 ):76 while (i<imax and rTr>tol**2*rTr0 and rTr>atol**2 ): 76 77 q = A*d 77 78 alpha = rTr/num.dot(d,q)
Note: See TracChangeset
for help on using the changeset viewer.