The following code runs forever on 10^5 square matrix A. It runs a few seconds on 10^3 square matrix. Is there any way to speed it up?
function [meanNV]=calcMeanNV_k(A,V,d)%A: input matrix (n x n)
%V: eigenvectors of k-th largest eigenvalues (n x 1)
%d: degrees of each node (n x 1)
%meanNV: mean of neighbors vectors (n x 1)
m=size(A,2);meanNV=zeros(113336); for i=1:m sumNode = 0; for j=1:m if A(i,j)==1 sumNode=sumNode+V(j); end end [meanNV(i)]=sumNode/d(i); end
Best Answer