annotate scripts/polynomial/ppint.m @ 29358:0a5b15007766 stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021.
author John W. Eaton <jwe@octave.org>
date Wed, 10 Feb 2021 09:52:15 -0500
parents bd51beb6205e
children 7854d5752dd2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
3 ## Copyright (C) 2008-2021 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11536
diff changeset
7 ##
9976
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
8 ## This file is part of Octave.
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11536
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
9976
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
13 ## (at your option) any later version.
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11536
diff changeset
14 ##
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
9976
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
18 ## GNU General Public License for more details.
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11536
diff changeset
19 ##
9976
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
17795
0a8c35ae5ce1 maint: Fix various problems with GPL copyright statements.
Rik <rik@octave.org>
parents: 17744
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
9976
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
25
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
26 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20165
diff changeset
27 ## @deftypefn {} {@var{ppi} =} ppint (@var{pp})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20165
diff changeset
28 ## @deftypefnx {} {@var{ppi} =} ppint (@var{pp}, @var{c})
11536
702dbd0c53f5 Add undocumented ppder, ppint, ppjumps functions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
29 ## Compute the integral of the piecewise polynomial struct @var{pp}.
20165
f1d0f506ee78 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
30 ##
9976
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
31 ## @var{c}, if given, is the constant of integration.
12575
d0b799dafede Grammarcheck files for 3.4.1 release.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
32 ## @seealso{mkpp, ppval, ppder}
9976
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
33 ## @end deftypefn
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
34
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
35 function ppi = ppint (pp, c)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20852
diff changeset
36
9976
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
37 if (nargin < 1 || nargin > 2)
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
38 print_usage ();
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
39 endif
13258
be74491c20e8 Correct typo in input validation of polynomial functions (Bug #33252)
Rik <octave@nomad.inbox5.com>
parents: 13141
diff changeset
40 if (! (isstruct (pp) && strcmp (pp.form, "pp")))
11472
1740012184f9 Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
41 error ("ppint: PP must be a structure");
9976
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
42 endif
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
43
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
44 [x, p, n, k, d] = unmkpp (pp);
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
45 p = reshape (p, [], k);
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11536
diff changeset
46
9976
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
47 ## Get piecewise antiderivatives
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
48 pi = p / diag (k:-1:1);
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
49 k += 1;
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
50 if (nargin == 1)
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 12575
diff changeset
51 pi(:, k) = 0;
9976
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
52 else
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 12575
diff changeset
53 pi(:, k) = repmat (c(:), n, 1);
9976
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
54 endif
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
55
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
56 ppi = mkpp (x, pi, d);
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
57
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 12575
diff changeset
58 tmp = -cumsum (ppjumps (ppi), length (d) + 1);
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
59 ppi.coefs(prod (d)+1 : end, k) = tmp(:);
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12608
diff changeset
60
9976
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
61 endfunction
702b998698ea implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
62
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
63
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 12575
diff changeset
64 %!shared x,y,pp,ppi
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
65 %! x = 0:8;
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
66 %! y = [ ones(size(x)); x+1 ];
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
67 %! pp = spline (x, y);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
68 %! ppi = ppint (pp);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
69 %!assert (ppval (ppi, x), [x; 0.5*x.^2 + x], 1e-14)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
70 %!assert (ppi.order, 5)