How to multiply torch[N,1] and torch[1,N]?
I'd like to calculate a matrix (shape[N,N]) by multiplying 2 torch vectors A(shape[N,1]) and B=A'(shape[1,N]).
When I use torch.matmul or torch.mm, I got errors or A'A(shape[1,1]).
If A is denoted as
A = [a_1, a_2, ..., a_N]', I want to calculate a matrix C whose (i,j)element is
for i in range(N):
     for j in range(N):
       C(i,j) = a_i * a_j

I'd like to calculate this quickly. Do you have any ideas?
thank you for your help!

If I understood you correctly you can do something like this :
A = torch.randint(0,5,(5,))
C = (A.view(1, -1) * A.view(-1, 1)).to(torch.float)

it produces :
tensor([[ 1.,  4.,  3.,  3.,  0.],
        [ 4., 16., 12., 12.,  0.],
        [ 3., 12.,  9.,  9.,  0.],
        [ 3., 12.,  9.,  9.,  0.],
        [ 0.,  0.,  0.,  0.,  0.]])

which is equivalent to writting :
 D = torch.zeros((5,5))
for i in range(5):
  for j in range(5):
    D[i][j] = A[i] * A[j]

which results in :
tensor([[ 1.,  4.,  3.,  3.,  0.],
        [ 4., 16., 12., 12.,  0.],
        [ 3., 12.,  9.,  9.,  0.],
        [ 3., 12.,  9.,  9.,  0.],
        [ 0.,  0.,  0.,  0.,  0.]])

