#NEWLINE# def _update( s , _lambda , P ) : #NEWLINE# #INDENT# "\n    Update ``P`` such that for the updated `P'` `P' v = e_{s}`.\n    " #NEWLINE# k = min ( [ j for j in range ( s , len ( _lambda ) ) if ( _lambda [ j ] != 0 ) ] ) #NEWLINE# for r in range ( len ( P ) ) : #NEWLINE# #INDENT# if ( r != k ) : #NEWLINE# #INDENT# P [ r ] = [ ( P [ r ] [ j ] - ( ( P [ k ] [ j ] * _lambda [ r ] ) / _lambda [ k ] ) ) for j in range ( len ( P [ r ] ) ) ] #NEWLINE# #UNINDENT# #UNINDENT# P [ k ] = [ ( P [ k ] [ j ] / _lambda [ k ] ) for j in range ( len ( P [ k ] ) ) ] #NEWLINE# ( P [ k ] , P [ s ] ) = ( P [ s ] , P [ k ] ) #NEWLINE# return P