title: Is `outer` fast enough for my double summation?
body: <p>I'm trying to evaluate the following double sums in r:</p>
  
  <p><a href="https://i.stack.imgur.com/IOJXa.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IOJXa.gif" alt="enter image description here"></a></p>
  
  <p>I know <code>outer</code> is a quick way to do it. I've tried the following</p>
  
  <pre><code>sum(f(outer(X,X,function(x,y) (x-y)/c)))
  </code></pre>
  
  <p>and while it seems to work, I'm not sure just how fast it is compare to some alternatives? Does it make a difference in terms of speed to do <code>outer</code> first then my function or vice versa? is there a better way to do it?</p>