Why is set function on a numpy array returning slightly different values?
问题 I had to check whether a matrix had eigenvalue with multiplicity>1 or not. Using numpy's eig function I got an array and converted it into set,which should remove the repeated eigenvalue and comparing the length of the list and the set,we can infer whether whether there are repeated eigenvalues or not.The code is given below- from numpy.linalg import eig A=[[3,1,1],[2,4,2],[-1,-1,1]] if len(eig(A)[0])!=len(set(eig(A)[0])): print "Multiple eigenvalues found!" else: print "All distinct" I got