Skip to content
Prev 43310 / 398506 Next

distance between two matrices

On Wed, 28 Jan 2004, "H?sing, Johannes" wrote:

            
Unfortunately apply() is a wrapper for a for() loop, so will not help much 
(if at all).
You can improve this a bit: see predict.qda.
A 140K x 2 array takes up 1.6Mb, and R needs 10x that to run at all.

Several people have mentioned knn1 as a C-level equivalent of the loops
(and I timed it as probably fast enough).  Roger Bivand mentioned
quadtrees, and that is one of a class of possible solutions if you need
extra speed.  Which member of that class is suitable depends on the
spatial distribution of A and B (viewing the rows as 2D points), but it is
hard to do very much better for only around a 1000 reference points.