Skip to content

Commit

Permalink
if _ArraySize_ has a single length, treat as a row vector
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Nov 16, 2019
1 parent f2bfb65 commit e46221a
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions jdatadecode.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,19 @@
for j=1:len
if(isfield(data,N_('_ArrayZipSize_')) && isfield(data,N_('_ArrayZipData_')))
zipmethod='zip';
dims=data(j).(N_('_ArrayZipSize_'))(:)';
if(length(dims)==1)
dims=[1 dims];
end
if(isfield(data,N_('_ArrayZipType_')))
zipmethod=data(j).(N_('_ArrayZipType_'));
end
if(~isempty(strmatch(zipmethod,{'zlib','gzip','lzma','lzip','lz4','lz4hc'})))
decompfun=str2func([zipmethod 'decode']);
if(needbase64)
ndata=reshape(typecast(decompfun(base64decode(data(j).(N_('_ArrayZipData_')))),data(j).(N_('_ArrayType_'))),data(j).(N_('_ArrayZipSize_'))(:)');
ndata=reshape(typecast(decompfun(base64decode(data(j).(N_('_ArrayZipData_')))),data(j).(N_('_ArrayType_'))),dims);
else
ndata=reshape(typecast(decompfun(data(j).(N_('_ArrayZipData_'))),data(j).(N_('_ArrayType_'))),data(j).(N_('_ArrayZipSize_'))(:)');
ndata=reshape(typecast(decompfun(data(j).(N_('_ArrayZipData_'))),data(j).(N_('_ArrayType_'))),dims);
end
else
error('compression method is not supported');
Expand All @@ -130,7 +134,11 @@
ndata=cast(data(j).(N_('_ArrayData_')),char(data(j).(N_('_ArrayType_'))));
end
if(isfield(data,N_('_ArrayZipSize_')))
ndata=reshape(ndata(:),fliplr(data(j).(N_('_ArrayZipSize_'))(:)'));
dims=data(j).(N_('_ArrayZipSize_'))(:)';
if(length(dims)==1)
dims=[1 dims];
end
ndata=reshape(ndata(:),fliplr(dims));
ndata=permute(ndata,ndims(ndata):-1:1);
end
iscpx=0;
Expand All @@ -142,6 +150,9 @@
if(isfield(data,N_('_ArrayIsSparse_')) && data(j).(N_('_ArrayIsSparse_')))
if(isfield(data,N_('_ArraySize_')))
dim=double(data(j).(N_('_ArraySize_'))(:)');
if(length(dim)==1)
dim=[1 dim];
end
if(iscpx)
ndata(end-1,:)=complex(ndata(end-1,:),ndata(end,:));
end
Expand Down Expand Up @@ -172,6 +183,9 @@
data(j).(N_('_ArraySize_'))=data(j).(N_('_ArraySize_'))(end:-1:1);
end
dims=data(j).(N_('_ArraySize_'))(:)';
if(length(dims)==1)
dims=[1 dims];
end
ndata=reshape(ndata(:),dims(:)');
if(format>1.9)
ndata=permute(ndata,ndims(ndata):-1:1);
Expand Down

0 comments on commit e46221a

Please sign in to comment.