This is a static copy of a profile report

Home

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

Parents (calling functions)

Function NameFunction TypeCalls
spap2function404
fnbrkfunction3
spvalfunction1
sp2ppfunction1
sp2pp>sp2pp1subfunction2
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
25
if ~isstruct(sp)
4110.020 s50.0%
45
for jp=1:lp
30.010 s25.0%
39
if nargin>1 % we have to ha...
4110.010 s25.0%
120
end
4080 s0%
119
end
4080 s0%
All other lines  0 s0%
Totals  0.040 s100% 
Children (called functions)
No children
Code Analyzer results
Line numberMessage
48IF might not be aligned with its matching END (line 50).
68IF might not be aligned with its matching END (line 74).
Coverage results
[ Show coverage for parent directory ]
Total lines in function120
Non-code lines (comments, blank lines)27
Code lines (lines that can run)93
Code lines that did run31
Code lines that did not run62
Coverage (did run/can run)33.33 %
Function listing
   time   calls  line
1 function varargout = spbrk(sp,varargin)
2 %SPBRK Part(s) of a B-form or a BBform.
3 %
4 % [KNOTS,COEFS,N,K,D] = SPBRK(SP) breaks the B-form in SP into its parts and
5 % returns as many of them as are specified by the output arguments.
6 %
7 % OUT1 = SPBRK(SP,PART) returns the part specified by the string PART which
8 % may be (the beginning character(s) of) one of the following strings:
9 % 'knots' or 't', 'coefs', 'number', 'order', 'dimension', 'interval',
10 % 'breaks'.
11 %
12 % If PART is the 1-by-2 matrix [A,B], the restriction/extension of the spline
13 % in SP to the interval with endpoints A and B is returned, in the same form.
14 %
15 % [OUT1,...,OUTo] = SPBRK(SP, PART1,...,PARTi) returns in OUTj the part
16 % specified by the string PARTj, j=1:o, provided o<=i.
17 %
18 % SPBRK(SP) returns nothing, but prints out all the parts.
19 %
20 % See also PPBRK, FNBRK, RSBRK, RPBRK.
21
22 % Copyright 1987-2010 The MathWorks, Inc.
23 % $Revision: 1.1.6.4 $
24
0.02 411 25 if ~isstruct(sp)
26 if sp(1)~=11&&sp(1)~=12
27 error(message('SPLINES:SPBRK:fnotBform'))
28 else
29 di=sp(2);ni=sp(3);
30 ci=reshape(sp(3+(1:di*ni)),di,ni);
31 kk=sp(4+di*ni);ki=sp(4+di*ni+(1:kk+ni));
32 sp = spmak(ki,ci);
33 end
34 end
35
411 36 if length(sp.form)~=2||sp.form(1)~='B'
37 error(message('SPLINES:SPBRK:snotBform'))
38 end
0.01 411 39 if nargin>1 % we have to hand back one or more parts
3 40 lp = max(1,nargout); % SPBRK(SP,PART) may be part of an expression
3 41 if lp>length(varargin)
42 error(message('SPLINES:SPBRK:moreoutthanin'))
43 end
3 44 varargout = cell(1,lp);
0.01 3 45 for jp=1:lp
4 46 part = varargin{jp};
4 47 if ischar(part)
4 48 if isempty(part)
49 error(message('SPLINES:SPBRK:partemptystr'))
50 end
4 51 switch part(1)
4 52 case 'f', out1 = [sp.form,'form'];
4 53 case 'd', out1 = sp.dim;
2 54 case 'n', out1 = sp.number;
2 55 case {'k','t'}, out1 = sp.knots;
2 56 case 'o', out1 = sp.order;
2 57 case 'c', out1 = sp.coefs;
2 58 case 'v', out1 = length(sp.order);
1 59 case 'i', % this must be treated differently in multivariate case
1 60 if iscell(sp.knots)
1 61 for i=length(sp.knots):-1:1 % loop backward to avoid redef.
2 62 out1{i} = sp.knots{i}([1 end]);
2 63 end
64 else
65 out1 = sp.knots([1 end]);
66 end
67 case 'b', % this must be treated differently in multivariate case
68 if iscell(sp.knots)
69 for i=length(sp.knots):-1:1 % loop backward to avoid redef.
70 out1{i} = knt2brk(sp.knots{i});
71 end
72 else
73 out1 = knt2brk(sp.knots);
74 end
75 otherwise
76 error(message('SPLINES:SPBRK:wrongpart', part))
77 end
78 elseif isempty(part)
79 out1 = sp;
80 else
81 if iscell(part) % we must be dealing with a tensor-product spline
82 c = sp.coefs; knots = sp.knots; m = length(knots);
83 sizec = size(c);
84 if length(sizec)~=m+1 % trouble because of trailing singleton dims
85 sizec = [sp.dim,sp.number]; c = reshape(c,sizec);
86 end
87 for i=m:-1:1
88 dd = prod(sizec(1:m));
89 spi = spcut(spmak(knots{i},reshape(c,dd,sp.number(i))), part{i});
90 knots{i} = spi.knots; sizec(m+1) = spi.number;
91 c = reshape(spi.coefs,sizec);
92 if m>1
93 c = permute(c,[1,m+1,2:m]);
94 sizec(2:m+1) = sizec([m+1,2:m]);
95 end
96 end
97 out1 = spmak(knots,c,sizec);
98
99 else % we must be dealing with a univariate spline
100 out1 = spcut(sp,part);
101 end
102 end
4 103 varargout{jp} = out1;
4 104 end
408 105 else
408 106 if nargout==0
107 if iscell(sp.knots) % we have a multivariate spline and, at present,
108 % I can't think of anything clever to do; so...
109 disp(sp)
110 else
111 disp('knots(1:n+k)'),disp(sp.knots),
112 disp('coefficients(d,n)'),disp(sp.coefs),
113 disp('number n of coefficients'),disp(sp.number),
114 disp('order k'),disp(sp.order),
115 disp('dimension d of target'),disp(sp.dim),
116 end
408 117 else
408 118 varargout = {sp.knots,sp.coefs, sp.number, sp.order, sp.dim};
408 119 end
408 120 end

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