在python中获得两个一维数组的乘积

Mat*_*ijn 2 python numpy

在Matlab中非常简单,但我无法在Python中获得它.如何获得以下内容:

x=np.array([1,2,3])
y=np.array([4,5,6,7])

z=x.T*y
z= 
[[4,5,6,7],
[8,10,12,14],
[12,15,18,21]]
Run Code Online (Sandbox Code Playgroud)

如在

 x [4][5][6][7]
[1]
[2]
[3]
Run Code Online (Sandbox Code Playgroud)

Pau*_*aul 5

在科学蟒蛇,这将是一个外部产品 np.outer(x,y)

请参阅http://docs.scipy.org/doc/numpy/reference/generated/numpy.outer.html:

import numpy;
>>> x=numpy.array([1,2,3])
>>> y=numpy.array([4,5,6,7])
>>> numpy.outer(x,y)
array([[ 4,  5,  6,  7],
       [ 8, 10, 12, 14],
       [12, 15, 18, 21]])
Run Code Online (Sandbox Code Playgroud)