S - NxN sparse matrix.A - Mx1 vector.
The non zero values of S are the indexes of A.
I want to calculate a vector x such that in the i'th entry of x:
for each non zero value j in the i'th row of S , take A[j] and calculate the sum of all this j's and put it in the i'th entry of x.
in pseudo it should look like this:
for i = 1:N
for j = 1:N
if( s[i][j] != 0)
x[i] += s[ A[i,j] ]
how can i do it in matlab in the most efficient way?