Generalized Vector Matrix multiplication

Hi,
I ma trying to compute this multiplication of a vector with a matrix:
f=torch.tensor([[-1.],[1]])
r=torch.tensor([[11.,21],[21,22]])
f.matmul( r )

However I am getting this error:
size mismatch, m1: [2 x 1], m2: [2 x 2] at c:\programdata\miniconda3\conda-bld\pytorch-cpu_1524541161962\work\aten\src\th\generic/THTensorMath.c:2033

What works and produces the right result is:
f=torch.tensor([[-1.,0],[1,0]])
r=torch.tensor([[11.,21],[21,22]])
f.matmul( r )

I tried using mm() and mv() with similar results. Is there an alternative?
Is there an easy way to expand f adding 0?
Thanks,
Alberto

As a rule, matrix multiplication only works when the neighbouring dimensions coincide. so f.t() will be 1 x 2 and can be multiplied from the right with 2 x 2 r to give a 1 x 2.

Best regards

Thomas

Thanks Tom!
However that is not what I need to do. I need to do (note the extra 0’s in f):
f=torch.tensor([[-1.,0],[1,0]])
r=torch.tensor([[11.,21],[21,22]])
f.matmul( r )

Which would be equivalent to:
f=torch.tensor([[-1.],[1]])
r=torch.tensor([[11.,21],[21,22]])
r.matmul(f.t()).t()

However, this also will not work:
RuntimeError: size mismatch, m1: [2 x 2], m2: [1 x 2]

It seems I really need to fill up with 0’s.
Alberto

I found the solution:
all I need to do for this to work is:
f * r
This is what I really wanted to do.