% compute yCSR = A*x with A in CSR format function yCSR = SpMV_CSR(valACSR,colindexACSR,rowbeginACSR,x); yCSR = zeros(length(rowbeginACSR)-1,1); % allocate space for answer for i = 1:length(rowbeginACSR)-1, tmp = 0; for j=rowbeginACSR(i):rowbeginACSR(i+1)-1, tmp = tmp + valACSR(j)*x(colindexACSR(j)); end yCSR(i) = tmp; end