#NEWLINE# def matvec( self , f ) : #NEWLINE# #INDENT# dx = ( ( - f ) / b . alpha ) #NEWLINE# n = len ( self . dx ) #NEWLINE# if ( n == 0 ) : #NEWLINE# #INDENT# return dx #NEWLINE# #UNINDENT# df_f = np . empty ( n , dtype = f . dtype ) #NEWLINE# for k in xrange ( n ) : #NEWLINE# #INDENT# df_f [ k ] = vdot ( self . df [ k ] , f ) #NEWLINE# #UNINDENT# b = np . empty ( ( n , n ) , dtype = f . dtype ) #NEWLINE# for i in xrange ( n ) : #NEWLINE# #INDENT# for j in xrange ( n ) : #NEWLINE# #INDENT# b [ ( i , j ) ] = vdot ( self . df [ i ] , self . dx [ j ] ) #NEWLINE# if ( ( i == j ) and ( self . w0 != 0 ) ) : #NEWLINE# #INDENT# b [ ( i , j ) ] -= ( ( vdot ( self . df [ i ] , self . df [ i ] ) * ( self . w0 ** 2 ) ) * self . alpha ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# gamma = solve ( b , df_f ) #NEWLINE# for m in xrange ( n ) : #NEWLINE# #INDENT# dx += ( gamma [ m ] * ( self . df [ m ] + ( self . dx [ m ] / self . alpha ) ) ) #NEWLINE# #UNINDENT# return dx