首页 > 解决方案 > 为什么我在 python 错误中收到“all”函数?

问题描述

为什么我在all函数中收到函数错误?

import numpy as np
A = np.matrix([[.6+1j,.5], [.6,.5]])
def isNormalcomplex(A):
    if (all(A@A.T.conj() == A.T.conj()@A)):
        print("The matrix is normal")
    else:
        print("The matrix is Non-normal")
isNormalcomplex(A)

ValueError:具有多个元素的数组的真值不明确。使用 a.any() 或 a.all()

标签: pythonfunctiontranspose

解决方案


推荐阅读