Python计算两行数据内积的方法:首先使用【mat()】方法;然后将每组数据分别放到方法里转换为矩阵;再使两矩阵相乘;最后进行转换即可。

>>> a=mat([[1],[2],[3]]);
>>> b=mat([[0],[2],[3]]);
>>> a
matrix([[1],
[2],
[3]])
>>> b
matrix([[0],
[2],
[3]])
>>> a.T*b
matrix([[13]])上面为两个列向量的内积计算,注意列向量的构建a=mat([[1],[2],[3]]);
下面为两个行向量的内积计算,注意行向量的构建a=mat([[1,2,3]]);
>>> a=mat([[1,2,3]]); >>> b=mat([[0,2,3]]); >>> a4 matrix([[1, 2, 3]]) >>> b6 matrix([[0, 2, 3]]) >>> a*b.T matrix([[13]]) >>>









