#NEWLINE# def __iter__( self ) : #NEWLINE# #INDENT# f = self . f #NEWLINE# x0 = self . x0 #NEWLINE# norm = self . norm #NEWLINE# J = self . J #NEWLINE# fx = self . ctx . matrix ( f ( * x0 ) ) #NEWLINE# fxnorm = norm ( fx ) #NEWLINE# cancel = False #NEWLINE# while ( not cancel ) : #NEWLINE# #INDENT# fxn = ( - fx ) #NEWLINE# Jx = J ( * x0 ) #NEWLINE# s = self . ctx . lu_solve ( Jx , fxn ) #NEWLINE# if self . verbose : #NEWLINE# #INDENT# print_ ( 'Jx:' ) #NEWLINE# print_ ( Jx ) #NEWLINE# print_ ( 's:' , s ) #NEWLINE# #UNINDENT# l = self . ctx . one #NEWLINE# x1 = ( x0 + s ) #NEWLINE# while True : #NEWLINE# #INDENT# if ( x1 == fx ) : #NEWLINE# #INDENT# if self . verbose : #NEWLINE# #INDENT# print_ ( "canceled, won't get more excact" ) #NEWLINE# #UNINDENT# cancel = True #NEWLINE# break #NEWLINE# #UNINDENT# fx = self . ctx . matrix ( f ( * x1 ) ) #NEWLINE# newnorm = norm ( fx ) #NEWLINE# if ( newnorm < fxnorm ) : #NEWLINE# #INDENT# fxnorm = newnorm #NEWLINE# x0 = x1 #NEWLINE# break #NEWLINE# #UNINDENT# l /= 2 #NEWLINE# x1 = ( x0 + ( l * s ) ) #NEWLINE# #UNINDENT# ( yield ( x0 , fxnorm ) )