[Scipy-tickets] [SciPy] #350: Monitoring function for iterative solvers

SciPy scipy-tickets@scipy....
Thu Apr 12 01:59:27 CDT 2007


#350: Monitoring function for iterative solvers
--------------------------+-------------------------------------------------
 Reporter:  nils          |        Owner:  somebody
     Type:  enhancement   |       Status:  new     
 Priority:  normal        |    Milestone:          
Component:  scipy.linalg  |      Version:  devel   
 Severity:  normal        |   Resolution:          
 Keywords:                |  
--------------------------+-------------------------------------------------
Comment (by nils):

 IIRC it doesn't work for GMRES

 [http://article.gmane.org/gmane.comp.python.scientific.devel/5616/match=callback]


 {{{
 from scipy import *
 from pylab import semilogy, show, xlabel, ylabel, legend, spy, figure,
 imshow, savefig

 global data

 def callback(x):
     res = b-dot(A,x)
     print "||A.x - b|| = " + str(linalg.norm(res))
     data.append(linalg.norm(res))

 n = 50
 A = random.rand(n,n)+diag(2*ones(n))
 A = 0.5*(A+A.T)
 b = random.rand(n)

 figure(1)
 imshow(A)

 figure(2)
 print 'GMRES'
 data = []
 x0 = zeros(n,float)
 x,info = linalg.gmres(A,b,x0,tol=1.e-5,callback=callback)
 print info
 semilogy(arange(0,len(data)),data)
 print data
 print
 }}}

-- 
Ticket URL: <http://projects.scipy.org/scipy/scipy/ticket/350#comment:2>
SciPy <http://www.scipy.org/>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list