This is a static copy of a profile reportHome
mkpp (25 calls, 0.000 sec)
Generated 05-Aug-2011 13:00:54 using cpu time.
function in file /usr/local/MATLAB/R2011a/toolbox/matlab/polyfun/mkpp.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Function Name | Function Type | Calls |
pwch | function | 25 |
Lines where the most time was spent
No measurable time spent in this functionLine Number | Code | Calls | Total Time | % Time | Time Plot |
71 | pp.dim = d; | 25 | 0 s | 0% |  |
70 | pp.order = k; | 25 | 0 s | 0% |  |
69 | pp.pieces = l; | 25 | 0 s | 0% |  |
68 | pp.coefs = reshape(coefs,dl,k)... | 25 | 0 s | 0% |  |
67 | pp.breaks = reshape(breaks,1,l... | 25 | 0 s | 0% |  |
All other lines | | | 0 s | 0% |  |
Totals | | | 0 s | 0% | |
Children (called functions)
No childrenCode Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
Total lines in function | 71 |
Non-code lines (comments, blank lines) | 60 |
Code lines (lines that can run) | 11 |
Code lines that did run | 9 |
Code lines that did not run | 2 |
Coverage (did run/can run) | 81.82 % |
Function listing
time calls line
1 function pp=mkpp(breaks,coefs,d)
2 %MKPP Make piecewise polynomial.
3 % PP = MKPP(BREAKS,COEFS) puts together a piecewise polynomial PP from its
4 % breaks and coefficients. BREAKS must be a vector of length L+1 with
5 % strictly increasing elements representing the start and end of each of L
6 % intervals. The matrix COEFS must be L-by-K, with the i-th row,
7 % COEFS(i,:), representing the local coefficients of the order K polynomial
8 % on the interval [BREAKS(i) ... BREAKS(i+1)], i.e., the polynomial
9 % COEFS(i,1)*(X-BREAKS(i))^(K-1) + COEFS(i,2)*(X-BREAKS(i))^(K-2) + ...
10 % COEFS(i,K-1)*(X-BREAKS(i)) + COEFS(i,K)
11 % Note: A K-th order polynomial uses K coefficients in its description:
12 % C(1)*X^(K-1) + C(2)*X^(K-2) + ... + C(K-1)*X + C(K)
13 % hence is of degree < K. For example, a cubic polynomial is usually
14 % written as a vector with 4 elements.
15 %
16 % PP = MKPP(BREAKS,COEFS,D) denotes that the piecewise polynomial PP has
17 % values of size D, with D either a scalar or an integer vector.
18 % BREAKS must be an increasing vector of length L+1.
19 % Whatever the size of COEFS may be, its last dimension is taken to be the
20 % polynomial order, K, hence the product of the remaining dimensions must
21 % equal prod(D)*L. If we take COEFS to be of size [prod(D),L,K], then
22 % COEFS(r,i,:) are the K coefficients of the r-th component of the i-th
23 % polynomial piece.
24 % Internally, COEFS is stored as a matrix, of size [prod(D)*L,K].
25 %
26 % Examples:
27 % These first two plots show the quadratic 1-(x/2-1)^2 = -x^2/4 + x
28 % shifted from the interval [-2 .. 2] to the interval [-8 .. -4], and the
29 % negative of that quadratic, namely the quadratic (x/2-1)^2-1 = x^2/4 - x,
30 % but shifted from [-2 .. 2] to the interval [-4 .. 0].
31 % subplot(2,2,1)
32 % cc = [-1/4 1 0];
33 % pp1 = mkpp([-8 -4],cc); xx1 = -8:0.1:-4;
34 % plot(xx1,ppval(pp1,xx1),'k-')
35 % subplot(2,2,2)
36 % pp2 = mkpp([-4 -0],-cc); xx2 = -4:0.1:0;
37 % plot(xx2,ppval(pp2,xx2),'k-')
38 % subplot(2,1,2)
39 % pp = mkpp([-8 -4 0 4 8],[cc; -cc; cc; -cc]);
40 % xx = -8:0.1:8;
41 % plot(xx,ppval(pp,xx),'k-')
42 % [breaks,coefs,l,k,d] = unmkpp(pp);
43 % dpp = mkpp(breaks,repmat(k-1:-1:1,d*l,1).*coefs(:,1:k-1),d);
44 % hold on, plot(xx,ppval(dpp,xx),'r-'), hold off
45 % This last plot shows a piecewise polynomial constructed by alternating the
46 % first two quadratic pieces over 4 intervals. To stress the piecewise
47 % polynomial character, also shown is its first derivative, as constructed
48 % from information about the piecewise polynomial obtained via UNMKPP.
49 %
50 % Class support for inputs BREAKS,COEFS:
51 % float: double, single
52 %
53 % See also UNMKPP, PPVAL, SPLINE.
54
55 % Carl de Boor 7-2-86
56 % Copyright 1984-2010 The MathWorks, Inc.
57 % $Revision: 5.17.4.5 $ $Date: 2010/11/22 02:46:40 $
58
25 59 if nargin==2, d = 1; else d = d(:).'; end
25 60 dlk=numel(coefs); l=length(breaks)-1; dl=prod(d)*l; k=fix(dlk/dl+100*eps);
25 61 if (k<=0)||(dl*k~=dlk)
62 error(message('MATLAB:mkpp:PPNumberMismatchCoeffs',...
63 int2str(l),int2str(d),int2str(dlk)))
64 end
65
25 66 pp.form = 'pp';
25 67 pp.breaks = reshape(breaks,1,l+1);
25 68 pp.coefs = reshape(coefs,dl,k);
25 69 pp.pieces = l;
25 70 pp.order = k;
25 71 pp.dim = d;