I want to calculate the cumulative cosine distance between sets of vectors.
The natural representation of many vectors is the matrix ... but how do I outline the following?
function d = cosdist(P1,P2) ds = zeros(size(P1,2),1); for k=1:size(P1,2) %
Of course I can write
fz = @(v1,v2) transpose(v1)*v2/(norm(v1)*norm(v2)); ds = cellfun(fz,P1,P2);
... as long as I rebuild my matrices as arrays of vector cells. Is there a better / fully digital way?
Also, will there be cellfun, arrayfun, etc. Use vector instructions and / or multithreading?
The note is probably redundant in the current company, but for column vectors v1'*v2 == dot(v1,v2) and significantly faster in Matlab.
source share