[Note, I wrote out this question, then found an answer. I thought maybe someone else would like to know it, so I’m posting the answer just in case. I’m not sure if this is the “done thing”].
Suppose I want the signed distance matrix of a vector, i.e. the distance’s aren’t always positive, but can be negative. You can’t use
dist()
because it returns absolute values.
Here’s another approach, which is much faster and needs less memory:
yields:
but you possibly want: