Daniel@0: function D = distToFrom(n, Vto, Vfrom, Ito, Ifrom) Daniel@0: Cross = -2 * Vto' * Vfrom; Daniel@0: Tonorm = sum(Vto .^2, 1)'; Daniel@0: Fromnorm = sum(Vfrom .^2, 1); Daniel@0: Daniel@0: D = zeros(n); Daniel@0: D(Ito,Ifrom) = bsxfun(@plus, bsxfun(@plus, Cross, Tonorm), Fromnorm); Daniel@0: end