#NEWLINE# def test_diagonal( ) : #NEWLINE# #INDENT# np . random . seed ( 1234 ) #NEWLINE# n = 100 #NEWLINE# m = 4 #NEWLINE# vals = np . arange ( 1 , ( n + 1 ) , dtype = float ) #NEWLINE# A = scipy . sparse . diags ( [ vals ] , [ 0 ] , ( n , n ) ) #NEWLINE# B = scipy . sparse . eye ( n ) #NEWLINE# M = scipy . sparse . diags ( [ np . reciprocal ( vals ) ] , [ 0 ] , ( n , n ) ) #NEWLINE# X = np . random . rand ( n , m ) #NEWLINE# m_excluded = 3 #NEWLINE# Y = np . eye ( n , m_excluded ) #NEWLINE# ( eigs , vecs ) = lobpcg ( A , X , B , M = M , Y = Y , tol = 0.0001 , maxiter = 40 , largest = False ) #NEWLINE# assert_allclose ( eigs , np . arange ( ( 1 + m_excluded ) , ( ( 1 + m_excluded ) + n ) ) ) #NEWLINE# _check_eigen ( A , eigs , vecs , rtol = 0.001 , atol = 0.001 )