This is a static copy of a profile report

Home

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

Parents (calling functions)

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

Line NumberCodeCallsTotal Time% TimeTime Plot
74
[knots,coefs,k,sizec] = chckkn...
4060.090 s40.9%
72
[knots,coefs,k,sizec] = chckkn...
2020.030 s13.6%
82
spline.dim = sizeval;
6080.020 s9.1%
80
spline.number = sizec(2:end);
6080.010 s4.5%
77
spline.form = 'B-';
6080.010 s4.5%
All other lines  0.060 s27.3%
Totals  0.220 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
spmak>chckkntsubfunction6080.090 s40.9%
Self time (built-ins, overhead, etc.)  0.130 s59.1%
Totals  0.220 s100% 
Code Analyzer results
Line numberMessage
Coverage results
[ Show coverage for parent directory ]
Total lines in function82
Non-code lines (comments, blank lines)48
Code lines (lines that can run)34
Code lines that did run23
Code lines that did not run11
Coverage (did run/can run)67.65 %
Function listing
   time   calls  line
1 function spline = spmak(knots,coefs,sizec)
2 %SPMAK Put together a spline in B-form.
3 %
4 % SPMAK(KNOTS,COEFS) puts together a spline from the knots and
5 % coefficients. Let SIZEC be size(COEFS). Then the spline is taken to be
6 % SIZEC(1:end-1)-valued, hence there are altogether n = SIZEC(end)
7 % coefficients.
8 % The order of the spline is inferred as k := length(KNOTS) - n .
9 % Knot multiplicity is held to <= k , with the coefficients
10 % corresponding to a B-spline with trivial support ignored.
11 %
12 % SPMAK will prompt you for KNOTS and COEFS.
13 %
14 % If KNOTS is a cell array of length m , then COEFS must be at least
15 % m-dimensional, i.e., length(SIZEC) must be at least m. If COEFS is
16 % m-dimensional, then the spline is taken to be scalar-valued; otherwise,
17 % it is taken to be SIZEC(1:end-m)-valued.
18 %
19 % SPMAK(KNOTS,COEFS,SIZEC) uses SIZEC to specify the intended array
20 % dimensions of COEFS, and may be needed for proper interpretation
21 % of COEFS in case one or more of its trailing dimensions is a singleton
22 % and thus COEFS appears to be of lower dimension.
23 %
24 % For example, if the intent is to construct a 2-vector-valued bivariate
25 % polynomial on the rectangle [-1 .. 1] x [0 .. 1], linear in the first
26 % variable and constant in the second, say
27 % coefs = zeros([2 2 1]); coefs(:,:,1) = [1 0;0 1];
28 % then the straightforward
29 % sp = spmak({[-1 -1 1 1],[0 1]},coefs);
30 % will fail, producing a scalar-valued function of (illegal) order [2 0],
31 % as will
32 % sp = spmak({[-1 -1 1 1],[0 1]},coefs,size(coefs));
33 % while proper use of that third argument, as in
34 % sp = spmak({[-1 -1 1 1],[0 1]},coefs,[2 2 1]);
35 % will succeed.
36 %
37 % See also SPBRK, RSMAK, PPMAK, RPMAK, STMAK, FNBRK.
38
39 % Copyright 1987-2010 The MathWorks, Inc.
40 % $Revision: 1.1.6.4 $
41
0.01 608 42 if nargin==0;
43 knots = input('Give the vector of knots >');
44 coefs = input('Give the array of B-spline coefficients >');
45 end
46
0.01 608 47 if nargin>2
202 48 if numel(coefs)~=prod(sizec)
49 error(message('SPLINES:SPMAK:coefsdontmatchsize'))
50 end
406 51 else
406 52 if isempty(coefs)
53 error(message('SPLINES:SPMAK:emptycoefs'))
54 end
0.01 406 55 sizec = size(coefs);
406 56 end
57
0.01 608 58 m = 1; if iscell(knots), m = length(knots); end
608 59 if length(sizec)<m
60 error(message('SPLINES:SPMAK:coefsdontmatchknots', sprintf( '%g', m ), sprintf( '%g', m )))
61 end
608 62 if length(sizec)==m, % coefficients of a scalar-valued function
63 sizec = [1 sizec];
64 end
65
66 % convert ND-valued coefficients into vector-valued ones, retaining the
67 % original size in SIZEVAL, to be stored eventually in SP.DIM .
608 68 sizeval = sizec(1:end-m); sizec = [prod(sizeval), sizec(end-m+(1:m))];
608 69 coefs = reshape(coefs, sizec);
70
0.01 608 71 if iscell(knots), % we are putting together a tensor-product spline
0.03 202 72 [knots,coefs,k,sizec] = chckknt(knots,coefs,sizec);
406 73 else % we are putting together a univariate spline
0.09 406 74 [knots,coefs,k,sizec] = chckknt({knots},coefs,sizec); knots = knots{1};
406 75 end
76
0.01 608 77 spline.form = 'B-';
608 78 spline.knots = knots;
608 79 spline.coefs = coefs;
0.01 608 80 spline.number = sizec(2:end);
608 81 spline.order = k;
0.02 608 82 spline.dim = sizeval;

Other subfunctions in this file are not included in this listing.