@@ -364,8 +364,7 @@ function delete(mtVar)
364364 end
365365
366366 % - Get equivalent subscripted indexes
367- vnTensorSize = size(mtVar );
368- [cIndices{1 : nNumDims }] = ind2sub(vnTensorSize , S.subs{1 });
367+ [cIndices{1 : nNumDims }] = ind2sub(vnReferencedTensorSize , S.subs{1 });
369368
370369 % - Permute indices and convert back to linear indexing
371370 vnInvOrder(mtVar .vnDimensionOrder(1 : nNumTotalDims )) = 1 : nNumTotalDims ;
@@ -432,7 +431,10 @@ function delete(mtVar)
432431
433432 % - Reshape return data to concatenate trailing dimensions (just as
434433 % matlab does)
435- if (nNumDims < nNumTotalDims )
434+ if (nNumDims == 1 )
435+ tfData = reshape(tfData , [], 1 );
436+
437+ elseif (nNumDims < nNumTotalDims )
436438 cnSize = num2cell(size(tfData ));
437439 tfData = reshape(tfData , cnSize{1 : nNumDims - 1 }, []);
438440 end
@@ -448,7 +450,6 @@ function delete(mtVar)
448450 % - Test real/complex nature of input and current tensor
449451 if (~isreal(tfData ))
450452 % - The input data is complex
451-
452453 if (~mtVar .bIsComplex )
453454 make_complex(mtVar );
454455 end
@@ -1559,13 +1560,8 @@ function isvalidsubscript(oRefs)
15591560
15601561 % - Catch "read whole tensor" condition
15611562 if (all(cellfun(@iscolon , sSubs .subs )))
1562- nNumStackElems = prod(vnTensorSize );
1563- vnFileChunkIndices = [1 1 nNumStackElems ];
1564- tData = 1 : nNumStackElems ; % Use a pre-allocated vector to save memory
1565-
15661563 % - Read data
1567- tData = hShimFunc(' read_chunks' , hDataFile , vnFileChunkIndices , ...
1568- tData , tData , vnTensorSize , ...
1564+ tData = hShimFunc(' read_all' , hDataFile , vnTensorSize , ...
15691565 strClass , nHeaderBytes , double(bBigEndian ));
15701566
15711567 % - Reshape stack and return
@@ -1592,13 +1588,8 @@ function mt_write_data(hShimFunc, hDataFile, sSubs, vnTensorSize, strClass, nHea
15921588
15931589 % - Catch "read whole tensor" condition
15941590 if (all(cellfun(@iscolon , sSubs .subs )))
1595- nNumStackElems = prod(vnTensorSize );
1596- vnFileChunkIndices = [1 1 nNumStackElems ];
1597- vnLinearIndices = 1 : nNumStackElems ;
1598-
15991591 % - Write data and return
1600- hShimFunc(' write_chunks' , hDataFile , vnFileChunkIndices , ...
1601- vnLinearIndices , vnTensorSize , ...
1592+ hShimFunc(' write_all' , hDataFile , vnTensorSize , ...
16021593 strClass , nHeaderBytes , cast(tData , strClass ), double(bBigEndian ));
16031594 return ;
16041595 end
@@ -1734,9 +1725,14 @@ function mt_write_data_chunks(hDataFile, mnFileChunkIndices, vnUniqueDataIndices
17341725 % - Find colon references
17351726 vbIsColon = cellfun(@iscolon , cRefs );
17361727
1728+ % - Catch "reference whole stack" condition
17371729 if (all(vbIsColon ))
17381730 vnLinearIndices = 1 : prod(vnLims );
1739- vnDimRefSizes = vnLims ;
1731+ if (numel(cRefs ) == 1 )
1732+ vnDimRefSizes = [vnLims 1 ];
1733+ else
1734+ vnDimRefSizes = vnLims ;
1735+ end
17401736 return ;
17411737 end
17421738
@@ -1782,6 +1778,11 @@ function mt_write_data_chunks(hDataFile, mnFileChunkIndices, vnUniqueDataIndices
17821778 vnLinearIndices(1 : nThisWindowLength ) = hRepSumFunc(vnLinearIndices(1 : nCurrWindowLength ), (cRefs{nDimension }-1 ) * vnDimOffsets(nDimension ));
17831779 end
17841780 end
1781+
1782+ if (numel(vnDimRefSizes ) == 1 ) % && ~any(vbIsColon)
1783+ vnDimRefSizes = size(cRefs{1 });
1784+ end
1785+
17851786end
17861787
17871788% SplitFileChunks - FUNCTION Split a set of indices into contiguous chunks
0 commit comments