1 function a=ijsparse(d,x,r,v)
\r
2 % convert matrix from ij to column sparse format
\r
4 % d vector [number of rows; number of columns; number of nonzeros]
\r
9 % a matlab sparse matrix
\r
11 % row indices for column j are r(x(j):x(j+1)-1)
\r
12 % values for column j are v(x(j):x(j+1)-1)
\r
20 if ~isvector(x),error('x must be vector'),end
\r
21 if ~isvector(r),error('r must be vector'),end
\r
22 if ~isvector(v),error('v must be vector'),end
\r
23 if length(x)~=n+1,error('bad length of x'),end
\r
24 if length(r)~=s,error('bad length of r'),end
\r
25 if length(v)~=s,error('bad length of v'),end
\r
26 if any(x~=round(x)) | any(x<1) | any(x>s+1) | x(n+1)-1~=s,
\r
27 error('bad values of x')
\r
29 if any(r~=round(r)) | any(r<1) | any(r>m),
\r
30 error('bad values of r')
\r
33 % create column index
\r