#NEWLINE# def test_sing_val_update( self ) : #NEWLINE# #INDENT# sigmas = np . array ( [ 4.0 , 3.0 , 2.0 , 0 ] ) #NEWLINE# m_vec = np . array ( [ 3.12 , 5.7 , ( - 4.8 ) , ( - 2.2 ) ] ) #NEWLINE# M = np . hstack ( ( np . vstack ( ( np . diag ( sigmas [ 0 : ( - 1 ) ] ) , np . zeros ( ( 1 , ( len ( m_vec ) - 1 ) ) ) ) ) , m_vec [ : , np . newaxis ] ) ) #NEWLINE# SM = svd ( M , full_matrices = False , compute_uv = False , overwrite_a = False , check_finite = False ) #NEWLINE# it_len = len ( sigmas ) #NEWLINE# sgm = np . concatenate ( ( sigmas [ : : ( - 1 ) ] , ( ( sigmas [ 0 ] + ( it_len * np . sqrt ( np . sum ( np . power ( m_vec , 2 ) ) ) ) ) , ) ) ) #NEWLINE# mvc = np . concatenate ( ( m_vec [ : : ( - 1 ) ] , ( 0 , ) ) ) #NEWLINE# lasd4 = get_lapack_funcs ( 'lasd4' , ( sigmas , ) ) #NEWLINE# roots = [ ] #NEWLINE# for i in range ( 0 , it_len ) : #NEWLINE# #INDENT# res = lasd4 ( i , sgm , mvc ) #NEWLINE# roots . append ( res [ 1 ] ) #NEWLINE# assert_ ( ( res [ 3 ] <= 0 ) , ( 'LAPACK root finding dlasd4 failed to find                                     the singular value %i' % i ) ) #NEWLINE# #UNINDENT# roots = np . array ( roots ) [ : : ( - 1 ) ] #NEWLINE# assert_ ( ( ( not np . any ( np . isnan ( res ) ) ) , 'There are NaN roots' ) ) #NEWLINE# assert_allclose ( SM , roots , atol = ( 100 * np . finfo ( np . float64 ) . eps ) , rtol = ( 100 * np . finfo ( np . float64 ) . eps ) )