Faster than pdist for cityblock on integers?
Ältere Kommentare anzeigen
Hi folks, I have very large matrices in the order of 100k+ rows and even more columns containing only 3 possible integer values 0, 1, 2, most frequent of which is 0. I have to calculate pairwise distance matrix using cityblock metric. Is there any faster, more efficient or less memory occupant way of calculating the pairwise distance matrix for such case that perhaps exploits the fact there are only 3 integer values involved and cityblock distance, than simply running d=pdist(a,'cityblock'); ?
The following can be used as benchmark:
a=randi(3,5e3,1e4)-1;
tic;d=pdist(a,'cityblock');toc
Which takes 30s on my average home PC
I am aware of the GPU speedup (15x in this case) by:
tic;d=pdist(gpuArray(a),'cityblock');toc
but this is only available for relatively small matrices I can completely fit in GPU.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!