1 % KNTBRKDEGREG: Construct an open knot vector by giving the sequence of
2 % knots, the degree and the regularity.
4 % knots = kntbrkdegreg (breaks, degree)
5 % knots = kntbrkdegreg (breaks, degree, regularity)
9 % breaks: sequence of knots.
10 % degree: polynomial degree of the splines associated to the knot vector.
11 % regularity: splines regularity.
17 % If REGULARITY has as many entries as BREAKS, or as the number of interior
18 % knots, a different regularity will be assigned to each knot. If
19 % REGULARITY is not present, it will be taken equal to DEGREE-1.
21 % Copyright (C) 2010 Carlo de Falco, Rafael Vazquez
23 % This program is free software: you can redistribute it and/or modify
24 % it under the terms of the GNU General Public License as published by
25 % the Free Software Foundation, either version 2 of the License, or
26 % (at your option) any later version.
28 % This program is distributed in the hope that it will be useful,
29 % but WITHOUT ANY WARRANTY; without even the implied warranty of
30 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 % GNU General Public License for more details.
33 % You should have received a copy of the GNU General Public License
34 % along with this program. If not, see <http://www.gnu.org/licenses/>.
36 function knots = kntbrkdegreg (breaks, degree, reg)
43 if (numel(breaks)~=numel(degree) || numel(breaks)~=numel(reg))
44 error('kntbrkdegreg: degree and regularity must have the same length as the number of knot vectors')
47 degree = num2cell (degree);
53 knots = cellfun (@do_kntbrkdegreg, breaks, degree, reg, 'uniformoutput', false);
60 knots = do_kntbrkdegreg (breaks, degree, reg);
65 function knots = do_kntbrkdegreg (breaks, degree, reg)
67 if (numel (breaks) < 2)
68 error ('kntbrkdegreg: the knots sequence should contain at least two points')
72 mults = [-1, (degree (ones (1, numel (breaks) - 2)) - reg), -1];
73 elseif (numel (reg) == numel (breaks))
75 elseif (numel (reg) == numel (breaks) - 2)
76 mults = [-1 degree-reg -1];
78 error('kntbrkdegreg: the length of mult should be equal to one or the number of knots')
82 warning ('kntbrkdegreg: for some knots the regularity is lower than -1')
83 elseif (any (reg > degree-1))
84 error('kntbrkdegreg: the regularity should be lower than the degree')
87 knots = kntbrkdegmult (breaks, degree, mults);
92 %! breaks = [0 1 2 3 4];
94 %! knots = kntbrkdegreg (breaks, degree);
95 %! assert (knots, [0 0 0 0 1 2 3 4 4 4 4])
98 %! breaks = [0 1 2 3 4];
101 %! knots = kntbrkdegreg (breaks, degree, reg);
102 %! assert (knots, [0 0 0 0 1 1 2 2 3 3 4 4 4 4])
105 %! breaks = [0 1 2 3 4];
108 %! knots = kntbrkdegreg (breaks, degree, reg);
109 %! assert (knots, [0 0 0 0 1 1 1 2 2 3 4 4 4 4])
112 %! breaks = {[0 1 2 3 4] [0 1 2 3]};
114 %! reg = {[0 1 2] 0};
115 %! knots = kntbrkdegreg (breaks, degree, reg);
116 %! assert (knots, {[0 0 0 0 1 1 1 2 2 3 4 4 4 4] [0 0 0 1 1 2 2 3 3 3]})