I'm working with a 39000+ data points and I'm computing the distance between a point and every single other one of them, resulting in a (39000+)^2 matrix that consumes 11GB (and I can't allocate this in the memory).
Great thing we have the dist
function that allows me to reduce this to a little bit less than 6GB. But now, I need to calculate the inverse distances powered by 2 and then regularize every row so that they sum up to 1. This is necessary because I will later multiply every row of the matrix by a vector and store this result. So, the big matrix is actually a temporary thing.
My question is, how can I extract rows of this dist
matrix?
A sample "dist" matrix obtained with dist(cbind(runif(5),runif(5))
1 2 3 4
2 0.47
3 0.63 0.72
4 0.79 0.62 0.37
5 0.53 0.15 0.62 0.48
What I'm looking for is to extract the entire first line, for instance:
0 0.47 0.63 0.79 0.53