如何在 Mathematica 中将列向量乘以行向量?
How to multiply Column vector by Row vector in Mathematica?
我想将列向量中的每个值乘以同一个向量但转置为行。输出应该是乘法 table 矩阵。 Like the third example in this picture.
I tried multiplying a column vector by its transposed form but Mathematica only gives me this which is not a Matrix.
布莱恩,
您需要使用 Dot
,而不是 Times
。参见 docs。
m = {{a}, {b}, {c}}
m.Transpose[m]
{{a^2, a b, a c}, {a b, b^2, b c}, {a c, b c, c^2}}
我想将列向量中的每个值乘以同一个向量但转置为行。输出应该是乘法 table 矩阵。 Like the third example in this picture.
I tried multiplying a column vector by its transposed form but Mathematica only gives me this which is not a Matrix.
布莱恩,
您需要使用 Dot
,而不是 Times
。参见 docs。
m = {{a}, {b}, {c}}
m.Transpose[m]
{{a^2, a b, a c}, {a b, b^2, b c}, {a c, b c, c^2}}