Mercurial > hg > octave-nkf
annotate scripts/deprecated/bicubic.m @ 20815:a260a6acb70f
fix test failures introduced by a22d8a2eb0e5
* scripts/ode/private/integrate_adaptive.m: fix stepping backwards, fix
invocation of OutputFcn, fix text of some error messages
* scripts/ode/private/integrate_const.m: remove use of option OutputSave
* scripts/ode/private/integrate_n_steps.m: remove use of option OutputSave
author | Carlo de Falco <carlo.defalco@polimi.it> |
---|---|
date | Sun, 11 Oct 2015 23:09:01 +0200 |
parents | 4197fc428c7d |
children |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19842
diff
changeset
|
1 ## Copyright (C) 2005-2015 Hoxide Ma |
5837 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
5837 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
5837 | 18 |
19 ## -*- texinfo -*- | |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
20 ## @deftypefn {Function File} {@var{zi} =} bicubic (@var{x}, @var{y}, @var{z}, @var{xi}, @var{yi}, @var{extrapval}) |
5837 | 21 ## |
19842
ebd27d8c63fd
update default branch to release as 4.0
John W. Eaton <jwe@octave.org>
parents:
18804
diff
changeset
|
22 ## @code{bicubic} is deprecated and will be removed in Octave version 4.4. |
18804
7485f8a8e431
bicubic.m: Deprecate function for 4.2 release.
Rik <rik@octave.org>
parents:
18754
diff
changeset
|
23 ## Use @code{interp2 (@dots{}, "spline")} for the equivalent functionality. |
7485f8a8e431
bicubic.m: Deprecate function for 4.2 release.
Rik <rik@octave.org>
parents:
18754
diff
changeset
|
24 ## |
6653 | 25 ## Return a matrix @var{zi} corresponding to the bicubic |
5838 | 26 ## interpolations at @var{xi} and @var{yi} of the data supplied |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
27 ## as @var{x}, @var{y} and @var{z}. Points outside the grid are set |
8828 | 28 ## to @var{extrapval}. |
5837 | 29 ## |
6702 | 30 ## See @url{http://wiki.woodpecker.org.cn/moin/Octave/Bicubic} |
31 ## for further information. | |
5838 | 32 ## @seealso{interp2} |
5837 | 33 ## @end deftypefn |
34 | |
35 ## Bicubic interpolation method. | |
36 ## Author: Hoxide Ma <hoxide_dirac@yahoo.com.cn> | |
37 | |
19842
ebd27d8c63fd
update default branch to release as 4.0
John W. Eaton <jwe@octave.org>
parents:
18804
diff
changeset
|
38 ## Deprecated in version 4.0 |
18804
7485f8a8e431
bicubic.m: Deprecate function for 4.2 release.
Rik <rik@octave.org>
parents:
18754
diff
changeset
|
39 |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
40 function zi = bicubic (x, y, z, xi, yi, extrapval, spline_alpha) |
5837 | 41 |
18804
7485f8a8e431
bicubic.m: Deprecate function for 4.2 release.
Rik <rik@octave.org>
parents:
18754
diff
changeset
|
42 persistent warned = false; |
7485f8a8e431
bicubic.m: Deprecate function for 4.2 release.
Rik <rik@octave.org>
parents:
18754
diff
changeset
|
43 if (! warned) |
7485f8a8e431
bicubic.m: Deprecate function for 4.2 release.
Rik <rik@octave.org>
parents:
18754
diff
changeset
|
44 warned = true; |
7485f8a8e431
bicubic.m: Deprecate function for 4.2 release.
Rik <rik@octave.org>
parents:
18754
diff
changeset
|
45 warning ("Octave:deprecated-function", |
7485f8a8e431
bicubic.m: Deprecate function for 4.2 release.
Rik <rik@octave.org>
parents:
18754
diff
changeset
|
46 "bicubic is obsolete and will be removed from a future version of Octave, please use interp2 instead"); |
7485f8a8e431
bicubic.m: Deprecate function for 4.2 release.
Rik <rik@octave.org>
parents:
18754
diff
changeset
|
47 endif |
7485f8a8e431
bicubic.m: Deprecate function for 4.2 release.
Rik <rik@octave.org>
parents:
18754
diff
changeset
|
48 |
6702 | 49 if (nargin < 1 || nargin > 7) |
5837 | 50 print_usage (); |
51 endif | |
52 | |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14598
diff
changeset
|
53 if (nargin == 7 && isscalar (spline_alpha)) |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
54 a = spline_alpha; |
5837 | 55 else |
56 a = 0.5; | |
57 endif | |
58 | |
6702 | 59 if (nargin < 6) |
60 extrapval = NaN; | |
61 endif | |
62 | |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
63 if (isa (x, "single") || isa (y, "single") || isa (z, "single") |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
64 || isa (xi, "single") || isa (yi, "single")) |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
65 myeps = eps ("single"); |
7795
df9519e9990c
Handle single precision eps values
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
66 else |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
67 myeps = eps (); |
7795
df9519e9990c
Handle single precision eps values
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
68 endif |
df9519e9990c
Handle single precision eps values
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
69 |
5838 | 70 if (nargin <= 2) |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
71 ## bicubic (z) or bicubic (z, 2) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
72 if (nargin == 1) |
5837 | 73 n = 1; |
74 else | |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
75 n = y; |
5837 | 76 endif |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
77 z = x; |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
78 x = []; |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
79 [rz, cz] = size (z); |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
80 s = linspace (1, cz, (cz-1) * pow2 (n) + 1); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
81 t = linspace (1, rz, (rz-1) * pow2 (n) + 1); |
5837 | 82 elseif (nargin == 3) |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
83 if (! isvector (x) || ! isvector (y)) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
84 error ("bicubic: XI and YI must be vector"); |
5837 | 85 endif |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
86 s = y; |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
87 t = z; |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
88 z = x; |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
89 [rz, cz] = size (z); |
5837 | 90 elseif (nargin == 5 || nargin == 6) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
91 [rz, cz] = size (z) ; |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
92 if (isvector (x) && isvector (y)) |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
93 if (rz != length (y) || cz != length (x)) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
94 error ("bicubic: length of X and Y must match the size of Z"); |
5837 | 95 endif |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
96 elseif (size_equal (x, y) && size_equal (x, z)) |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
97 x = x(1,:); |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
98 y = y(:,1); |
5837 | 99 else |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
100 error ("bicubic: X, Y and Z must be equal size matrices of same size"); |
5837 | 101 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
102 |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
103 if (all (diff (x) < 0)) |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
104 flipx = true; |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
105 x = fliplr (x); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
106 elseif (all (diff (x) > 0)) |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
107 flipx = false; |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
108 else |
15202
f3b5cadfd6d5
fix missing semicolons in various .m files
John W. Eaton <jwe@octave.org>
parents:
14868
diff
changeset
|
109 error ("bicubic:nonmonotonic", "bicubic: X values must be monotonic"); |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
110 endif |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
111 if (all (diff (y) < 0)) |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
112 flipy = true; |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
113 y = flipud (y); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
114 elseif (all (diff (y) > 0)) |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
115 flipy = false; |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
116 else |
15202
f3b5cadfd6d5
fix missing semicolons in various .m files
John W. Eaton <jwe@octave.org>
parents:
14868
diff
changeset
|
117 error ("bicubic:nonmonotonic", "bicubic: Y values must be monotonic"); |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
118 endif |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
119 |
8506 | 120 ## Mark values outside the lookup table. |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
121 xfirst_ind = find (xi < x(1)); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
122 xlast_ind = find (xi > x(cz)); |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
123 yfirst_ind = find (yi < y(1)); |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
124 ylast_ind = find (yi > y(rz)); |
8506 | 125 ## Set value outside the table preliminary to min max index. |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
126 xi(xfirst_ind) = x(1); |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
127 xi(xlast_ind) = x(cz); |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
128 yi(yfirst_ind) = y(1); |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
129 yi(ylast_ind) = y(rz); |
5837 | 130 |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
131 x = reshape (x, 1, cz); |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
132 x(cz) *= 1 + sign (x(cz)) * myeps; |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
133 if (x(cz) == 0) |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
134 x(cz) = myeps; |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
135 endif; |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
136 xi = reshape (xi, 1, length (xi)); |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
137 [m, i] = sort ([x, xi]); |
5838 | 138 o = cumsum (i <= cz); |
139 xidx = o(find (i > cz)); | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
140 |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
141 y = reshape (y, rz, 1); |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
142 y(rz) *= 1 + sign (y(rz)) * myeps; |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
143 if (y(rz) == 0) |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
144 y(rz) = myeps; |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
145 endif; |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
146 yi = reshape (yi, length (yi), 1); |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
147 [m, i] = sort ([y; yi]); |
5838 | 148 o = cumsum (i <= rz); |
8507 | 149 yidx = o([find(i > rz)]); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
150 |
8506 | 151 ## Set s and t used follow codes. |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
152 s = xidx + ((xi .- x(xidx)) ./ (x(xidx+1) .- x(xidx))); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
153 t = yidx + ((yi - y(yidx)) ./ (y(yidx+1) - y(yidx))); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
154 |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
155 if (flipx) |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
156 s = fliplr (s); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
157 endif |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
158 if (flipy) |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
159 t = flipud (t); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
160 endif |
5837 | 161 else |
162 print_usage (); | |
163 endif | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
164 |
5837 | 165 if (rz < 3 || cz < 3) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
166 error ("bicubic: Z at least a 3 by 3 matrices"); |
5837 | 167 endif |
168 | |
5838 | 169 inds = floor (s); |
170 d = find (s == cz); | |
171 s = s - floor (s); | |
5837 | 172 inds(d) = cz-1; |
173 s(d) = 1.0; | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
174 |
5837 | 175 d = []; |
5838 | 176 indt = floor (t); |
177 d = find (t == rz); | |
178 t = t - floor (t); | |
5837 | 179 indt(d) = rz-1; |
180 t(d) = 1.0; | |
181 d = []; | |
182 | |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
183 p = zeros (size (z) + 2); |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
184 p(2:rz+1,2:cz+1) = z; |
8507 | 185 p(1,:) = (6*(1-a))*p(2,:) - 3*p(3,:) + (6*a-2)*p(4,:); |
186 p(rz+2,:) = (6*(1-a))*p(rz+1,:) - 3*p(rz,:) + (6*a-2)*p(rz-1,:); | |
187 p(:,1) = (6*(1-a))*p(:,2) - 3*p(:,3) + (6*a-2)*p(:,4); | |
188 p(:,cz+2) = (6*(1-a))*p(:,cz+1) - 3*p(:,cz) + (6*a-2)*p(:,cz-1); | |
5837 | 189 |
8506 | 190 ## Calculte the C1(t) C2(t) C3(t) C4(t) and C1(s) C2(s) C3(s) C4(s). |
8507 | 191 t2 = t.*t; |
192 t3 = t2.*t; | |
5837 | 193 |
8507 | 194 ct0 = -a .* t3 + (2 * a) .* t2 - a .* t ; # -a G0 |
5837 | 195 ct1 = (2-a) .* t3 + (-3+a) .* t2 + 1 ; # F0 - a G1 |
196 ct2 = (a-2) .* t3 + (-2 *a + 3) .* t2 + a .* t ; # F1 + a G0 | |
197 ct3 = a .* t3 - a .* t2; # a G1 | |
8507 | 198 t = []; t2 = []; t3 = []; |
5837 | 199 |
8507 | 200 s2 = s.*s; |
201 s3 = s2.*s; | |
5837 | 202 |
8507 | 203 cs0 = -a .* s3 + (2 * a) .* s2 - a .*s ; # -a G0 |
5837 | 204 cs1 = (2-a) .* s3 + (-3 + a) .* s2 + 1 ; # F0 - a G1 |
205 cs2 = (a-2) .* s3 + (-2 *a + 3) .* s2 + a .*s ; # F1 + a G0 | |
206 cs3 = a .* s3 - a .* s2; # a G1 | |
8507 | 207 s = []; s2 = []; s3 = []; |
5837 | 208 |
209 cs0 = cs0([1,1,1,1],:); | |
210 cs1 = cs1([1,1,1,1],:); | |
211 cs2 = cs2([1,1,1,1],:); | |
212 cs3 = cs3([1,1,1,1],:); | |
213 | |
5838 | 214 lent = length (ct0); |
10859
09144fbb0e36
Fix bug #30400 when bicubic called with small numbers of arguments.
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
215 lens = columns (cs0); |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
216 zi = zeros (lent, lens); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
217 |
5837 | 218 for i = 1:lent |
219 it = indt(i); | |
220 int = [it, it+1, it+2, it+3]; | |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
221 zi(i,:) = ([ct0(i),ct1(i),ct2(i),ct3(i)] |
10549 | 222 * (p(int,inds) .* cs0 + p(int,inds+1) .* cs1 |
223 + p(int,inds+2) .* cs2 + p(int,inds+3) .* cs3)); | |
5837 | 224 endfor |
225 | |
8506 | 226 ## Set points outside the table to extrapval. |
5837 | 227 if (! (isempty (xfirst_ind) && isempty (xlast_ind))) |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
228 zi(:, [xfirst_ind, xlast_ind]) = extrapval; |
5837 | 229 endif |
230 if (! (isempty (yfirst_ind) && isempty (ylast_ind))) | |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
231 zi([yfirst_ind; ylast_ind], :) = extrapval; |
5837 | 232 endif |
233 | |
234 endfunction | |
235 | |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
236 |
5837 | 237 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
238 %! clf; |
14247
c4fa5e0b6193
test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
239 %! colormap ("default"); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
240 %! A = [13,-1,12;5,4,3;1,6,2]; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
241 %! x = [0,1,4]+10; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
242 %! y = [-10,-9,-8]; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
243 %! xi = linspace (min (x), max (x), 17); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
244 %! yi = linspace (min (y), max (y), 26)'; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
245 %! mesh (xi, yi, bicubic (x,y,A,xi,yi)); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
246 %! [x,y] = meshgrid (x,y); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
247 %! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
248 |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
249 %!test |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
250 %! x = linspace (1, -1, 10); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
251 %! [xx, yy] = meshgrid (x); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
252 %! z = cos (6 * xx) + sin (6 * yy); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
253 %! x = linspace (1, -1, 30); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
254 %! [xx2, yy2] = meshgrid (x); |
18754
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
255 %! z1 = interp2 (xx, yy, z, xx2, yy2, "spline"); |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14598
diff
changeset
|
256 %! z2 = interp2 (fliplr (xx), flipud (yy), fliplr (flipud(z)), |
18754
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
257 %! fliplr (xx2), flipud (yy2), "spline"); |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
258 %! z2 = fliplr (flipud (z2)); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
259 %! assert (z1, z2, 100 * eps ()) |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
260 |