且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

NumPy如何将复数矩阵相乘?

更新时间:2023-02-10 15:42:27

计算 A * B 时,实际上是在相乘矩阵元素,给您所谓的哈达玛德积。这不是母乳。例如(17. + 0.j)*(60. + 0.j)= 1020. + 0.j ,它是输出中的第一个元素。对于矩阵乘法,请使用 np.dot 或仅使用 @ 运算符,即 A @ B

When you compute A*B it's actually multiplying the matrices elementwise, giving you what is called the hadamard product. It isn't matmul. For example (17.+0.j) * (60.+0.j) = 1020.+0.j, which is the first element in the output. For matrix multiplication use np.dot or simply the @ operator, ie, A@B.