This is a static copy of a profile reportHome
mpower>integerMpower (Calls: 1, Time: 0.002 s)
Generated 16-Jul-2020 17:08:32 using performance time.
subfunction in file /Applications/MATLAB_R2020a.app/toolbox/matlab/ops/mpower.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Function Name | Function Type | Calls |
mpower | function | 1 |
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
66 | if rem(p,2) == 1 %if odd | 10 | 0.000 s | 23.7% | |
65 | while p > 0 | 1 | 0.000 s | 15.1% | |
78 | end | 10 | 0.000 s | 12.5% | |
67 | if first | 6 | 0.000 s | 12.4% | |
75 | if p ~= 0 | 10 | 0.000 s | 10.0% | |
All other lines | | | 0.001 s | 26.4% | |
Totals | | | 0.002 s | 100% | |
Children (called functions)
No childrenCode Analyzer results
No Code Analyzer messages.Coverage results
Show coverage for parent directory
Total lines in function | 28 |
Non-code lines (comments, blank lines) | 4 |
Code lines (lines that can run) | 24 |
Code lines that did run | 22 |
Code lines that did not run | 2 |
Coverage (did run/can run) | 91.67 % |
Function listing
time | Calls | line |
---|
| | 55 | function Z = integerMpower(X,y)
|
< 0.001 | 1 | 56 | if y == 0
|
| | 57 | Z = eye(size(X),'like',X([])); %always real
|
< 0.001 | 1 | 58 | else
|
| | 59 | % X and y can be sparse
|
| | 60 | % Z = X^y for integer y. Use repeated squaring.
|
| | 61 | % For example: A^13 = A^1 * A^4 * A^8
|
< 0.001 | 1 | 62 | p = abs(y);
|
< 0.001 | 1 | 63 | D = X;
|
< 0.001 | 1 | 64 | first = true;
|
< 0.001 | 1 | 65 | while p > 0
|
< 0.001 | 10 | 66 | if rem(p,2) == 1 %if odd
|
< 0.001 | 6 | 67 | if first
|
< 0.001 | 1 | 68 | Z = D; % hit first time. D*I
|
< 0.001 | 1 | 69 | first = false;
|
< 0.001 | 5 | 70 | else
|
< 0.001 | 5 | 71 | Z = D*Z;
|
< 0.001 | 6 | 72 | end
|
< 0.001 | 10 | 73 | end
|
< 0.001 | 10 | 74 | p = fix(p/2);
|
< 0.001 | 10 | 75 | if p ~= 0
|
< 0.001 | 9 | 76 | D = D*D;
|
< 0.001 | 10 | 77 | end
|
< 0.001 | 10 | 78 | end
|
< 0.001 | 1 | 79 | if y < 0
|
| | 80 | Z = inv(Z);
|
< 0.001 | 1 | 81 | end
|
< 0.001 | 1 | 82 | end
|
Other subfunctions in this file are not included in this listing.