This is a static copy of a profile reportHome
tformarray>CombinedGrid (1721 calls, 2.223 sec)
Generated 05-Nov-2014 07:52:39 using cpu time.
subfunction in file /usr1/opt/matlab/7.13/toolbox/images/images/tformarray.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
340 | x = repmat( x, [ D(1:i-1) ... | 3442 | 0.941 s | 42.3% |  |
328 | G = zeros([D N]); | 1721 | 0.371 s | 16.7% |  |
341 | G(colons{:},i) = x; | 3442 | 0.320 s | 14.4% |  |
331 | colons = repmat({':'},[1 N]); | 1721 | 0.320 s | 14.4% |  |
339 | x = reshape( x, [ones(1,i-1) D... | 3442 | 0.070 s | 3.2% |  |
All other lines | | | 0.200 s | 9.0% |  |
Totals | | | 2.223 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
repmat | function | 5163 | 1.132 s | 50.9% |  |
Self time (built-ins, overhead, etc.) | | | 1.092 s | 49.1% |  |
Totals | | | 2.223 s | 100% | |
Code Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
Total lines in function | 50 |
Non-code lines (comments, blank lines) | 30 |
Code lines (lines that can run) | 20 |
Code lines that did run | 17 |
Code lines that did not run | 3 |
Coverage (did run/can run) | 85.00 % |
Function listing
time calls line
294 function G = CombinedGrid(varargin)
295
296 % If N >= 2, G = COMBINEDGRID(x1,x2,...,xN) is a memory-efficient
297 % equivalent to:
298 %
299 % G = cell(N,1);
300 % [G{:}] = ndgrid(x1,x2,...,xN);
301 % G = cat(N + 1, G{:});
302 %
303 % (where x{i} = varargin{i} and D(i) is the number of
304 % elements in x{}).
305 %
306 % If N == 1, COMBINEDGRID returns x1 as a column vector. (The code
307 % with NDGRID replicates x1 across N columns, returning an N-by-N
308 % matrix -- which is inappropriate for our application.)
309 %
310 % N == 0 is not allowed.
311
0.01 1721 312 N = length(varargin);
0.01 1721 313 if N == 0
314 error(message('images:tformarray:combinegridCalledNoArgs'));
315 end
316
0.01 1721 317 D = zeros(1, N);
1721 318 for i=1:N
3442 319 D(1,i) = numel(varargin{i});
3442 320 end
321
0.01 1721 322 if N == 1
323 % Special handling required to avoid calling RESHAPE
324 % with a single-element size vector.
325 G = varargin{1}(:);
1721 326 else
327 % Pre-allocate the output array.
0.37 1721 328 G = zeros([D N]);
329
330 % Prepare to generate a comma-separated list of N colons.
0.32 1721 331 colons = repmat({':'},[1 N]);
332
0.05 1721 333 for i=1:N
334 % Extract the i-th vector, reshape it to run along the
335 % i-th dimension (adding singleton dimensions as needed),
336 % replicate it across all the other dimensions, and
337 % copy it to G(:,:,...,:,i) -- with N colons.
0.03 3442 338 x = varargin{i}(:);
0.07 3442 339 x = reshape( x, [ones(1,i-1) D(i) ones(1,N-i)] );
0.94 3442 340 x = repmat( x, [ D(1:i-1) 1 D(i+1:N) ] );
0.32 3442 341 G(colons{:},i) = x;
0.03 3442 342 end
1721 343 end
Other subfunctions in this file are not included in this listing.