This is a static copy of a profile reportHome
circshift (1216653 calls, 252.830 sec)
Generated 05-Nov-2014 07:53:54 using cpu time.
function in file /usr1/opt/matlab/7.13/toolbox/matlab/elmat/circshift.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Function Name | Function Type | Calls |
ml_shift | function | 1216653 |
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
34 | [p, sizeA, numDimsA] = ParseIn... | 1216653 | 90.455 s | 35.8% |  |
46 | idx{k} = mod((0:m-1)-p(k), m)+... | 2433306 | 67.944 s | 26.9% |  |
44 | for k = 1:numDimsA | 1216653 | 16.172 s | 6.4% |  |
41 | idx = cell(1, numDimsA); | 1216653 | 13.859 s | 5.5% |  |
50 | b = a(idx{:}); | 1216653 | 12.527 s | 5.0% |  |
All other lines | | | 51.872 s | 20.5% |  |
Totals | | | 252.830 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
circshift>ParseInputs | subfunction | 1216653 | 73.402 s | 29.0% |  |
Self time (built-ins, overhead, etc.) | | | 179.428 s | 71.0% |  |
Totals | | | 252.830 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) | 36 |
Code lines (lines that can run) | 14 |
Code lines that did run | 9 |
Code lines that did not run | 5 |
Coverage (did run/can run) | 64.29 % |
Function listing
time calls line
1 function b = circshift(a,p)
2 %CIRCSHIFT Shift array circularly.
3 % B = CIRCSHIFT(A,SHIFTSIZE) circularly shifts the values in the array A
4 % by SHIFTSIZE elements. SHIFTSIZE is a vector of integer scalars where
5 % the N-th element specifies the shift amount for the N-th dimension of
6 % array A. If an element in SHIFTSIZE is positive, the values of A are
7 % shifted down (or to the right). If it is negative, the values of A
8 % are shifted up (or to the left).
9 %
10 % Examples:
11 % A = [ 1 2 3;4 5 6; 7 8 9];
12 % B = circshift(A,1) % circularly shifts first dimension values down by 1.
13 % B = 7 8 9
14 % 1 2 3
15 % 4 5 6
16 % B = circshift(A,[1 -1]) % circularly shifts first dimension values
17 % % down by 1 and second dimension left by 1.
18 % B = 8 9 7
19 % 2 3 1
20 % 5 6 4
21 %
22 % See also FFTSHIFT, SHIFTDIM, PERMUTE.
23
24 % Copyright 1984-2011 The MathWorks, Inc.
25 % $Revision: 1.11.4.6 $ $Date: 2011/05/17 02:22:56 $
26
27 % Error out if there are not exactly two input arguments
6.90 1216653 28 if nargin < 2
29 error(message('MATLAB:circshift:NoInputs'))
30 end
31
32 % Parse the inputs to reveal the variables necessary for the calculations
5.93 1216653 33 try
90.46 1216653 34 [p, sizeA, numDimsA] = ParseInputs(a,p);
35 catch ME
36 rethrow(ME)
37 end
38
39 % Calculate the indices that will convert the input matrix to the desired output
40 % Initialize the cell array of indices
13.86 1216653 41 idx = cell(1, numDimsA);
42
43 % Loop through each dimension of the input matrix to calculate shifted indices
16.17 1216653 44 for k = 1:numDimsA
11.57 2433306 45 m = sizeA(k);
67.94 2433306 46 idx{k} = mod((0:m-1)-p(k), m)+1;
11.78 2433306 47 end
48
49 % Perform the actual conversion by indexing into the input matrix
12.53 1216653 50 b = a(idx{:});
Other subfunctions in this file are not included in this listing.