#NEWLINE# def _check_svds( A , k , U , s , VH ) : #NEWLINE# #INDENT# ( n , m ) = A . shape #NEWLINE# assert_equal ( U . shape , ( n , k ) ) #NEWLINE# assert_equal ( s . shape , ( k , ) ) #NEWLINE# assert_equal ( VH . shape , ( k , m ) ) #NEWLINE# A_rebuilt = ( U * s ) . dot ( VH ) #NEWLINE# assert_equal ( A_rebuilt . shape , A . shape ) #NEWLINE# assert_allclose ( A_rebuilt , A ) #NEWLINE# UH_U = np . dot ( U . T . conj ( ) , U ) #NEWLINE# assert_equal ( UH_U . shape , ( k , k ) ) #NEWLINE# assert_allclose ( UH_U , np . identity ( k ) , atol = 1e-12 ) #NEWLINE# VH_V = np . dot ( VH , VH . T . conj ( ) ) #NEWLINE# assert_equal ( VH_V . shape , ( k , k ) ) #NEWLINE# assert_allclose ( VH_V , np . identity ( k ) , atol = 1e-12 )