% Matrix vector multiplication, written to the file <br/> % dual for loop. It has been running for a long time and needs to be improved, <br/> clear <br/> CLC <br/> N = 150000; % matrix dimension <br/> A = sprand (N, N, 0.0001 ); % generate a sparse matrix <br/> fid1 = fopen ('matrix. gmt', 'w'); % matrix file to be written <br/> fid2 = fopen ('matrix _ B. gmt', 'w'); % Vector file <br/> disp ('1') <br/> Len = nnz (); % Number of non-zero elements in the sparse matrix <br/> disp ('2') <br/> fprintf (fid1, '% d/N', N, N, len); % number of rows, columns, and non-zero elements <br/> disp ('3') <br/> for j = 1: n <br/> for I = 1: n <br/> If a (I, j )~ = 0 <br/> fprintf (fid1, '% d % F/N', I, j, a (I, j )); % file written in triple format <br/> end <br/> disp ('4') <br/> fprintf (fid2, '% d/N', n); <br/> B = sprand (n, 1, 0.9); % generates a sparse vector <br/> disp ('6 ') <br/> for I = 1: n <br/> fprintf (fid2, '% d/N', B (I, 1 )); % write vector <br/> end <br/> disp ('5') <br/> S = a * B; <br/> full_s = Full (s ); % convert the result into a matrix <br/> Save s.txt full_s-ASCII % Save the result of matrix vector multiplication <br/> fclose (fid1); <br/> fclose (fid2 );