1 function [varargout]=read_array_sp(f,num1,num2)
\r
2 % a=read_array_sp(f,num1,num2)
\r
3 % [i,j,aij]=read_array_sp(f,num1,num2)
\r
4 % [i,j,k,aijk]=read_array_sp(f,num1,num2)
\r
5 % read array produced by matching call write_array_m
\r
6 % as sparse, with correct indexing
\r
10 if exist('num1','var'),
\r
11 if ~exist('num2','var'),
\r
14 f=[file_name(f,num1,num2),'.txt'];
\r
28 fprintf(1,'matrix size %i:%i %i:%i %i:%i from file %s length %i\n',its,ite,jts,jte,kts,kte,f,l)
\r
30 error(sprintf('incorrect file length, should be %i',s))
\r
33 d=reshape(b(7:s),[m,n,o]);
\r
34 if(its>0 & jts > 0 & kts == 1 & kte == 1),
\r
35 a=sparse(ite,jte,m*n);
\r
36 a(its:ite,jts:jte)=d;
\r
39 error('incompatible dimensions for output as a sparse matrix')
\r
51 idx=1+ii+m*jj+m*n*kk;
\r
66 error('dimension 3 must be 1 for ouput as a 2d matrix')
\r
74 error('bad number of output arguments')
\r