There are a few ways you can get an outer multiplication.
arr = np.array([1,2,4])
#Using Multiply outer
print(np.multiply.outer(arr, arr)) #As suggested by Warren
#Using broadcasting
print(arr[:,None] * arr[None,:]) #(3,1) * (1,3)
[[ 1 2 4]
[ 2 4 8]
[ 4 8 16]]
[[ 1 2 4]
[ 2 4 8]
[ 4 8 16]]
?
Note, the output is still a very large matrix for storing in memory. Depending on what you need it for, I would advise considering something like a generator function. Let me know how you are going to use this matrix and I could suggest more memory efficient methods.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…