回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我有两个sympy矩阵,<code>U</code>和{<cd2>}:</p>
<pre><code>>> U
<< Matrix([
[1.0, 0, 0, 0],
[ 0, 1.0, 0, 0],
[ 0, 0, 1.0, 0],
[ 0, 0, 0, 1.0]])
>> B
<< Matrix([
[sqrt(2)/2, 0.5*sqrt(2)*I, 0, 0],
[ 0, 0, 0.5*sqrt(2)*I, sqrt(2)/2],
[ 0, 0, 0.5*sqrt(2)*I, -sqrt(2)/2],
[sqrt(2)/2, -0.5*sqrt(2)*I, 0, 0]])
</code></pre>
<p>对它们应用点积会生成一个列表,而不是4x4矩阵:</p>
^{pr2}$
<p>相比之下,numpy似乎做了正确的事情:</p>
<pre><code>>> numpy.dot(sympy.matrix2numpy(U),sympy.matrix2numpy(B))
<< array([[0.5*sqrt(2), 0.5*sqrt(2)*I, 0, 0],
[0, 0, 0.5*sqrt(2)*I, 0.5*sqrt(2)],
[0, 0, 0.5*sqrt(2)*I, -0.5*sqrt(2)],
[0.5*sqrt(2), -0.5*sqrt(2)*I, 0, 0]], dtype=object)
</code></pre>
<p>我做错什么了?这是预期的行为吗?在</p>