spectrum.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:Matrix-Analysis 作者: kingofspace0wzz 项目源码 文件源码
def isSimple(A):
    '''
    ask is matrix A is a simple matrix
    '''
    # check if A is a squre matrix
    if A.shape[1] != A.shape[0]:
        return False

    eigenValues, eigenVectors = la.eig(A)

    while eigenValues.shape[0] != 0:

        #dictValues.update({eigenValues[0]: 1})

        index = np.argwhere(abs(eigenValues - eigenValues[0]) < 0.00001)

        algebraicMulti = len(index)

        geometricMulti = eigenVectors[:, index].shape[1]

        if algebraicMulti != geometricMulti:
            return False

        #dictValues.update({eigenValues[0]: len})
        eigenValues = np.delete(eigenValues, index)

    # stack another spaces of eigenvalue and eigenvector

    return True


# compute the spectrum decomposition of matrix A
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号