Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201894

R: Why is this outer-call so slow? How can I speed it up?

$
0
0

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?


Viewing all articles
Browse latest Browse all 201894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>