This is a static copy of a profile report

Home

aptknt (404 calls, 0.190 sec)
Generated 05-Nov-2014 07:53:25 using cpu time.
function in file /usr1/opt/matlab/7.13/toolbox/curvefit/splines/aptknt.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
spap2>spap21subfunction404
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
68
knots = augknt([tau(1) aveknt(...
4040.190 s100.0%
69
end
4040 s0%
65
if any(tau(k:n)==tau(1:n-k+1))
4040 s0%
64
else
4040 s0%
59
if k==1 % simply use midpoints...
4040 s0%
All other lines  0 s0%
Totals  0.190 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
avekntfunction4040.100 s52.6%
augkntfunction4040.080 s42.1%
Self time (built-ins, overhead, etc.)  0.010 s5.3%
Totals  0.190 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
[ Show coverage for parent directory ]
Total lines in function69
Non-code lines (comments, blank lines)53
Code lines (lines that can run)16
Code lines that did run9
Code lines that did not run7
Coverage (did run/can run)56.25 %
Function listing
   time   calls  line
1 function [knots,k] = aptknt(tau,k)
2 %APTKNT Acceptable knot sequence
3 %
4 % APTKNT(TAU,K) returns, for a given nondecreasing sequence TAU with
5 % TAU(i) < TAU(i+K-1), all i, a knot sequence, KNOTS, for which the
6 % Schoenberg-Whitney conditions
7 %
8 % KNOTS(i) < TAU(i) < KNOTS(i+K) , i=1:length(TAU)
9 %
10 % hold (with equality only for the first or last knot), ensuring that
11 % the space of splines of order
12 % K := min(K,length(TAU))
13 % with knot sequence KNOTS has a unique interpolant to arbitrary data
14 % at the data sites TAU; the K used is, optionally, returned.
15 %
16 % For example, for strictly increasing x , and given corresponding y ,
17 %
18 % sp = spapi(aptknt(x,k),x,y);
19 %
20 % gives a spline f of order min(k,length(x)) satisfying f(x(i)) = y(i),
21 % all i (and the same result is obtained by spapi(k,x,y) ).
22 % Be aware, though, of the fact that, for highly nonuniform x , the
23 % determination of this spline can be ill-conditioned, leading possibly
24 % to very strange behavior away from the interpolation points.
25 %
26 % At present, the knot sequence chosen here is the initial guess used for
27 % the iterative determination of the `optimal' knots in OPTKNT.
28 %
29 % See also AUGKNT, AVEKNT, NEWKNT, OPTKNT.
30
31 % Copyright 1987-2008 The MathWorks, Inc.
32 % $Revision: 1.1.6.3 $ $Date: 2011/05/09 00:40:21 $
33
34 % If tau(1) <= ... <= tau(n) with no more than k-2 consecutive equalities,
35 % and n>k , then the output xi = aveknt(tau,k) is strictly increasing and,
36 % for any a<tau(1), tau(n)<b, the output knots = augknt([a xi b],k) satisfies
37 % the above Schoenberg-Whitney conditions wrto tau .
38 %
39 % Indeed, then
40 % knots(1:k) = a < tau(1) <= ... <= tau(k),
41 % while, for i=1:n-k,
42 % knots(k+i) = xi(i) = (tau(i+1)+...+tau(i+k-1))/(k-1),
43 % hence (using the fact that at most k-1 consecutive tau's can be equal)
44 % tau(i) < knots(k+i) < tau(i+k) , i=1:n-k ,
45 % and, finally,
46 % tau(n-k+1) <= ... <= tau(n) < b = knots(n+[1:k]).
47 % Letting now a --> tau(1) and b --> tau(end) will not change any of these
48 % inequalities, except those involving the first and last data site may not
49 % be strict any more. But that is ok since these will be the endpoints of the
50 % corresponding basic interval, hence only right, respectively, left limits
51 % matter there.
52
404 53 n = length(tau);
404 54 if n<2, error(message('SPLINES:APTKNT:toofewTAU')), end
55
404 56 k = max(1,min(k,n)); dtau = diff(tau);
404 57 if any(dtau<0)
58 error(message('SPLINES:APTKNT:TAUdecreasing')), end
404 59 if k==1 % simply use midpoints between data sites
60 if ~all(dtau)
61 error(message('SPLINES:APTKNT:TAUnotstrictlyincreasing'))
62 end
63 knots = [tau(1) tau(1:n-1)+dtau/2 tau(n)];
404 64 else
404 65 if any(tau(k:n)==tau(1:n-k+1))
66 error(message('SPLINES:APTKNT:TAUmulttoolarge', sprintf( '%g', k - 1 )))
67 end
0.19 404 68 knots = augknt([tau(1) aveknt(tau,k) tau(end)],k);
404 69 end