|
75 | 75 | % |
76 | 76 | % Dot referencing ('.') is not supported. |
77 | 77 | % |
78 | | -% sum(mtVar <, nDimension>) is supported, to avoid importing the entire tensor |
79 | | -% into memory. |
| 78 | +% sum(mtVar <, nDimension, strOutType>) is supported, to avoid importing |
| 79 | +% the entire tensor into memory. |
80 | 80 | % |
81 | 81 | % Convenience functions: |
82 | 82 | % SliceFunction: Execute a function on the entire tensor, by slicing it along |
|
144 | 144 |
|
145 | 145 | % Author: Dylan Muir <[email protected]> |
146 | 146 | % Created: 19th November, 2010 |
| 147 | +% |
| 148 | +% Thanks to @marcsous (https://github.com/marcsous) for bug reports and |
| 149 | +% fixes. |
147 | 150 |
|
148 | 151 | classdef MappedTensor < handle |
149 | 152 | properties (SetAccess = private, GetAccess = private) |
@@ -1371,12 +1374,16 @@ function make_complex(mtVar) |
1371 | 1374 | % - Get the name of a temporary file |
1372 | 1375 | strFilename = tempname; |
1373 | 1376 |
|
1374 | | - % - Create the file |
1375 | | - hFile = fopen(strFilename, 'w+'); |
1376 | | - |
1377 | | - % - Allocate enough space |
1378 | | - fwrite(hFile, 0, 'uint8', nNumEntries-1); |
1379 | | - fclose(hFile); |
| 1377 | + % - Fast allocation on some platforms |
| 1378 | + bFailed = true; |
| 1379 | +% [bFailed, ~] = system(sprintf('fallocate -l %i %s', nNumEntries, strFilename)); |
| 1380 | + |
| 1381 | + % - Slow fallback -- use Matlab to write data directly |
| 1382 | + if (bFailed) |
| 1383 | + hFile = fopen(strFilename, 'w+'); |
| 1384 | + fwrite(hFile, 0, 'uint8', nNumEntries-1); |
| 1385 | + fclose(hFile); |
| 1386 | + end |
1380 | 1387 | end |
1381 | 1388 |
|
1382 | 1389 | function [nBytes, strStorageClass] = ClassSize(strClass) |
|
0 commit comments