I would like to create a M-mode, n-dimensional tensor A from a vector x of length n such that
A_[i_1, i_2, ... , i_M] = x[i_1] * x[i_2] * ... * x[i_M].
The code that I have so far is
A=np.multiply.outer(x,x)
for i in range(M-2):
A=np.multiply.outer(A,x)
I'm rather new to coding in Python so I'm not sure if there is a more compact/convenient way of computing this tensor.