【发布时间】:2020-08-28 19:56:11
【问题描述】:
我正在尝试将 numpy 数组除以 numpy float64 类型标量。以下是我的代码。
pose_q = np.array(pose_q)
expectecd_q = np.array(expectecd_q)
pose_q = np.squeeze(pose_q)
expectecd_q = np.squeeze(expectecd_q)
q1 = expectecd_q / np.linalg.norm(expectecd_q)
q2 = pose_q / np.linalg.norm(pose_q)
d = abs(np.sum(np.multiply(q1, q2)))
但是我收到以下指向 expectecd_q / np.linalg.norm(expectecd_q) 的错误
TypeError: ufunc 'true_divide' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
【问题讨论】:
-
pose_q的 dtype 是什么? -
请打印出
expectecd_q.dtype -
@Miguelpose_q 的类型是
-
@Ehsan expected_q 的类型是
-
@Mr.RandyTom 我想你在打印
type(expected_q),我的意思是expected_q.dtype。
标签: python numpy division calculation divide