This is a static copy of a profile reportHome
ppual (1 call, 0.020 sec)
Generated 05-Nov-2014 07:52:41 using cpu time.
function in file /usr1/opt/matlab/7.13/toolbox/curvefit/splines/ppual.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Function Name | Function Type | Calls |
spval | function | 1 |
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
101 | offset = repmat(reshape(sub2in... | 1 | 0.010 s | 50.0% |  |
38 | if iscell(x) % evaluation on ... | 1 | 0.010 s | 50.0% |  |
118 | end | 1 | 0 s | 0% |  |
117 | v = reshape(v,d,n); | 1 | 0 s | 0% |  |
116 | end | 2 | 0 s | 0% |  |
All other lines | | | 0 s | 0% |  |
Totals | | | 0.020 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
sub2ind | function | 2 | 0 s | 0% |  |
num2cell | function | 2 | 0 s | 0% |  |
repmat | function | 11 | 0 s | 0% |  |
ppual>get_index | subfunction | 2 | 0 s | 0% |  |
ppbrk | function | 1 | 0 s | 0% |  |
Self time (built-ins, overhead, etc.) | | | 0.020 s | 100.0% |  |
Totals | | | 0.020 s | 100% | |
Code Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
Total lines in function | 122 |
Non-code lines (comments, blank lines) | 57 |
Code lines (lines that can run) | 65 |
Code lines that did run | 40 |
Code lines that did not run | 25 |
Coverage (did run/can run) | 61.54 % |
Function listing
time calls line
1 function v = ppual(pp,x,left)
2 %PPUAL Evaluate function in ppform.
3 %
4 % This is the function used by FNVAL when a spline in ppform is to be
5 % evaluated.
6 %
7 % V = PPUAL(PP,X) returns the value, at the entries of X, of the
8 % function f whose ppform is in PP.
9 % V = PPUAL(PP,X,'l<anything>') takes f to be left-continuous.
10 % If f is m-variate and the third input argument is actually an m-cell,
11 % LEFT say, then, continuity from the left is enforced in the i-th
12 % variable if LEFT{i}(1) = 'l'.
13 %
14 % Roughly speaking, V is obtained by replacing each entry of X by the value
15 % of f there. The details, as laid out in the help for FNVAL, depend on
16 % whether or not f is scalar-valued and whether or not f is univariate.
17 %
18 % See also FNVAL, SPVAL, RSVAL, STVAL, PPVAL.
19
20 % Copyright 1987-2010 The MathWorks, Inc.
21 % $Revision: 1.1.6.4 $
22
1 23 if ~isstruct(pp), pp = fn2fm(pp); end
24
1 25 if iscell(pp.breaks) % we are dealing with a multivariate spline
26
1 27 [breaks,coefs,l,k,d] = ppbrk(pp); m = length(breaks);
1 28 sizec = [d,l.*k]; % size(coefs)
29
1 30 if nargin>2 % set up LEFT appropriately
31 if ~iscell(left)
32 temp = left; left = cell(1,m); [left{:}] = deal(temp);
33 end
1 34 else
1 35 left = cell(1,m);
1 36 end
37
0.01 1 38 if iscell(x) % evaluation on a mesh
39
40 if length(x)~=m
41 error(message('SPLINES:PPUAL:needgrid', num2str( m )))
42 end
43
44 v = coefs; sizev = sizec;
45 nsizev = zeros(1,m);
46 for i=m:-1:1
47 nsizev(i) = length(x{i}(:)); dd = prod(sizev(1:m));
48 v = reshape(ppual1(...
49 ppmak(breaks{i},reshape(v,dd*l(i),k(i)),dd), x{i}, left{i} ),...
50 [sizev(1:m),nsizev(i)]);
51 sizev(m+1) = nsizev(i);
52 if m>1
53 v = permute(v,[1,m+1,2:m]); sizev(2:m+1) = sizev([m+1,2:m]);
54 end
55 end
56 if d>1
57 v = reshape(v,[d,nsizev]);
58 else
59 v = reshape(v,nsizev);
60 end
61
1 62 else % evaluation at scattered points
63
64 % locate the scattered data in the break sequences:
1 65 [mx,n] = size(x);
1 66 if mx~=m, error(message('SPLINES:PPUAL:wrongx', num2str( m ))), end
67
1 68 ix = zeros(m,n);
1 69 for i=1:m
2 70 [ox,iindex] = sort(x(i,:));
2 71 ix(i,iindex) = get_index(breaks{i}(2:end-1),ox,left{i});
2 72 end
73
74 % ... and now set up lockstep polynomial evaluation
75 % %%First, select the relevant portion of the coefficients array.
76 % This has the additional pain that now there are k(i) coefficients
77 % for the i-th univariate interval.
78 % The coefficients sit in the (m+1)-dimensional array COEFS, with
79 % the (i+1)st dimension containing the coefficients in the i-th
80 % dimension, and organized to have first the highest coefficients
81 % for each interval, then the next-highest, etc (i.e., as if coming
82 % from an array of size [l(i),k(i)]).
83 % ix(:,j) is the index vector for the lower corner of j-th point
84 % The goal is to extract, for the j-th point, the requisite coefficients
85 % from the equivalent one-dimensional array for COEFS, computing a
86 % base index from ix(:,j), and adding to this the same set of offsets
87 % computed from the l(i) and k(i).
88
1 89 temp = l(1)*(0:k(1)-1)';
1 90 for i=2:m
1 91 lt = length(temp(:,1));
1 92 temp = [repmat(temp,k(i),1), ...
93 reshape(repmat(l(i)*(0:k(i)-1),lt,1),k(i)*lt,1)];
1 94 end
95 % also take care of the possibility that the function in PP is
96 % vector-valued:
1 97 lt = length(temp(:,1));
1 98 temp=[reshape(repmat((0:d-1).',1,lt),d*lt,1) temp(repmat(1:lt,d,1),:)];
99
1 100 temp = num2cell(1+temp,1);
0.01 1 101 offset = repmat(reshape(sub2ind(sizec,temp{:}),d*prod(k),1),1,n);
102
1 103 temp = num2cell([ones(n,1) ix.'],1);
1 104 base = repmat(sub2ind(sizec,temp{:}).',d*prod(k),1)-1;
1 105 v = reshape(coefs(base+offset),[d,k,n]);
106
107 % ... then do a version of local polynomial evaluation
1 108 for i=m:-1:1
2 109 s = reshape(x(i,:) - breaks{i}(ix(i,:)),[1,1,n]);
2 110 otherk = d*prod(k(1:i-1));
2 111 v = reshape(v,[otherk,k(i),n]);
2 112 for j=2:k(i)
5 113 v(:,1,:) = v(:,1,:).*repmat(s,[otherk,1,1])+v(:,j,:);
5 114 end
2 115 v(:,2:k(i),:) = [];
2 116 end
1 117 v = reshape(v,d,n);
1 118 end
119 else
120 if nargin<3, left = []; end
121 v = ppual1(pp,x,left);
122 end
Other subfunctions in this file are not included in this listing.