在处理涉及各种逆变换的矩阵等价问题时,我发现了一些我想澄清的意外行为。我已经使所有矩阵在这里等价,因为实际的转换与我遇到的问题并不真正相关。
a = np.matrix([ 1, 1], [-1, 4]])
x = inv(a)
y = inv(a)
z = inv(a)
(x == y & z).all()
Note: x = matrix([ 0.8, -0.2],
[ 0.2, 0.2]])
它返回以下错误消息:
TypeError: ufunc 'bitwise_and' not supported for the input types, and the
inputs could not be safely coerced to any supported types according to the
casting rule ''safe''
是否因为&运算符不能与浮点一起使用而引发此错误?以下方法似乎返回正确的答案,但我会很感激为给定的问题提供首选方法的输入。
(np.equal(x, y) & np.equal(y, z)).all()
True
np.equal([x,y,z], [y,z,x]).all()
True
扬帆大鱼
侃侃尔雅
相关分类