   function [CSR] = coo2csr(A) 
%% function [CSR] = coo2csr(A) 
%% conversion from coo to csr format - 
%% CSR= srtuct with:  n, m, rr, jj, ptr
[m n] = size(A);
ptr(1) = 1;
jj = [];  rr = [];
for j = 1:m
    [i0 j0 r0] = find(A(j,:));
    rr = [rr, r0];
    jj = [jj, j0];
    ptr(j+1)= ptr(j) + length(j0);
end
rr = rr(:); jj=jj(:); ptr= ptr(:);
CSR=struct('n',n,'m',m,'rr',rr,'jj',jj,'ptr',ptr);
