Let a, b
be two vectors of different length. I need to set up a matrix with elements exp(-1i*a*b)
, meaning for every pair of elements in a, b
, I want to multiply by the imaginary unit, and then take exponentials.
Okay, so I pull out the outer function and write
outer(a, b, FUN = function(x,y) exp(-1i*x*y))
but for large vectors a, b
, this is painfully slow. I'm actually surprised at how slow it is. All I'm doing is setting up the matrix - I haven't even used it in any calculations, and yet this is super slow.
Is there any alternative to speed this up?