#NEWLINE# def pinv_diagsvd( s , m , L ) : #NEWLINE# #INDENT# '\n    Construct the pseudo-inverse of the sigma matrix from singular values\n    ' #NEWLINE# t = s . dtype . char #NEWLINE# cond = { #NEWLINE# #INDENT# 0 : ( feps * 1000.0 ) , #NEWLINE# 1 : ( eps * 1000000.0 ) , #NEWLINE# #UNINDENT# } [ _array_precision [ t ] ] #NEWLINE# cutoff = ( s [ 0 ] * cond ) #NEWLINE# Si = np . zeros ( ( m , L ) , t ) #NEWLINE# for i in range ( len ( s ) ) : #NEWLINE# #INDENT# if ( s [ i ] > cutoff ) : #NEWLINE# #INDENT# Si [ ( cond , i ) ] = ( 1.0 / np . conj ( s [ i ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# return Si