Mercurial > octave
annotate scripts/geometry/griddatan.m @ 28211:289882040316
griddatan.m: Rewrite docstring and redo input validation.
* griddatan.m: Rewrite docstring. Redo input validation to make it more strict
and error messages more specific. Add BIST tests for new input validation.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 12 Apr 2020 18:14:05 -0700 |
parents | bb929d5a34cb |
children | bb50407f9c60 |
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 ## |
27919
1891570abac8
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27918
diff
changeset
|
3 ## Copyright (C) 2007-2020 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27845
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/>. |
6823 | 7 ## |
8 ## This file is part of Octave. | |
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 |
6823 | 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 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
6823 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
6823 | 19 ## |
20 ## You should have received a copy of the GNU General Public License | |
7016 | 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 ######################################################################## |
6823 | 25 |
26 ## -*- texinfo -*- | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
27 ## @deftypefn {} {@var{yi} =} griddatan (@var{x}, @var{y}, @var{xi}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
28 ## @deftypefnx {} {@var{yi} =} griddatan (@var{x}, @var{y}, @var{xi}, @var{method}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
29 ## @deftypefnx {} {@var{yi} =} griddatan (@var{x}, @var{y}, @var{xi}, @var{method}, @var{options}) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
30 ## |
28211
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
31 ## Interpolate irregular source data @var{x}, @var{y} at points specified by |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
32 ## @var{xi}. |
20158
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
33 ## |
28211
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
34 ## The input @var{x} is an MxN matrix representing M points in an N-dimensional |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
35 ## space. The input @var{y} is a single-valued column vector (Mx1) |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
36 ## representing a function evaluated at the points @var{x}, i.e., |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
37 ## @code{@var{y} = fcn (@var{x})}. The input @var{xi} is a list of points |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
38 ## for which the function output @var{yi} should be approximated through |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
39 ## interpolation. @var{xi} must have the same number of columns (@var{N}) |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
40 ## as @var{x} so that the dimensionality matches. |
6823 | 41 ## |
28211
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
42 ## The optional input interpolation @var{method} can be @qcode{"nearest"} or |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
43 ## @qcode{"linear"}. When the method is @qcode{"nearest"}, the output @var{yi} |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
44 ## will be the closest point in the original data @var{x} to the query point |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
45 ## @var{xi}. When the method is @qcode{"linear"}, the output @var{yi} will |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
46 ## be a linear interpolation between the two closest points in the original |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
47 ## source data. If @var{method} is omitted or empty, it defaults to |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
48 ## @qcode{"linear"}. |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
49 ## |
14370
fbdee844550c
griddatan.m: Restore ability to pass options to underlying Qhull
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
50 ## The optional argument @var{options} is passed directly to Qhull when |
fbdee844550c
griddatan.m: Restore ability to pass options to underlying Qhull
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
51 ## computing the Delaunay triangulation used for interpolation. See |
fbdee844550c
griddatan.m: Restore ability to pass options to underlying Qhull
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
52 ## @code{delaunayn} for information on the defaults and how to pass different |
fbdee844550c
griddatan.m: Restore ability to pass options to underlying Qhull
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
53 ## values. |
28211
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
54 ## |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
55 ## Example |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
56 ## |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
57 ## @example |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
58 ## @group |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
59 ## ## Evaluate sombrero() function at irregular data points |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
60 ## x = 16*gallery ("uniformdata", [200,1], 1) - 8; |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
61 ## y = 16*gallery ("uniformdata", [200,1], 11) - 8; |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
62 ## z = sin (sqrt (x.^2 + y.^2)) ./ sqrt (x.^2 + y.^2); |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
63 ## ## Create a regular grid and interpolate data |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
64 ## [xi, yi] = ndgrid (linspace (-8, 8, 50)); |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
65 ## zi = griddatan ([x, y], z, [xi(:), yi(:)]); |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
66 ## zi = reshape (zi, size (xi)); |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
67 ## ## Plot results |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
68 ## clf (); |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
69 ## plot3 (x, y, z, "or"); |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
70 ## hold on |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
71 ## surf (xi, yi, zi); |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
72 ## legend ("Original Data", "Interpolated Data"); |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
73 ## @end group |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
74 ## @end example |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
75 ## |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
76 ## Programming Notes: If the input is complex the real and imaginary parts |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
77 ## are interpolated separately. For 2-D and 3-D data additional interpolation |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
78 ## methods are available by using the @code{griddata} function. |
14370
fbdee844550c
griddatan.m: Restore ability to pass options to underlying Qhull
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
79 ## @seealso{griddata, griddata3, delaunayn} |
6823 | 80 ## @end deftypefn |
81 | |
14370
fbdee844550c
griddatan.m: Restore ability to pass options to underlying Qhull
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
82 function yi = griddatan (x, y, xi, method = "linear", varargin) |
6826 | 83 |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
84 if (nargin < 3) |
6826 | 85 print_usage (); |
6823 | 86 endif |
87 | |
6826 | 88 [m, n] = size (x); |
89 [mi, ni] = size (xi); | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
90 |
28211
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
91 if (m < n + 1) |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
92 error ("griddatan: number of points in X (rows of X) must be greater than dimensionality of data + 1 (columns of X + 1)"); |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
93 endif |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
94 if (! iscolumn (y) || rows (y) != m) |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
95 error ("griddatan: Y must be a column vector with the same number of points (rows) as X"); |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
96 endif |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
97 if (n != ni) |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
98 error ("griddatan: dimension of query data XI (columns) must match X"); |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
99 endif |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
100 |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
101 if (nargin > 3) |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
102 if (isempty (method)) |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
103 method = "linear"; |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
104 elseif (! ischar (method)) |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
105 error ("griddatan: METHOD must be a string"); |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
106 endif |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
107 |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
108 method = tolower (method); |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
109 if (strcmp (method, "linear") || strcmp (method, "nearest")) |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
110 ## Do nothing, these are implemented methods |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
111 elseif (any (strcmp (method, {"cubic", "v4"}))) |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
112 error ('griddatan: "%s" METHOD is available for 2-D inputs by using "griddata"', method); |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
113 |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
114 elseif (strcmp (method, "natural")) |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
115 ## FIXME: Remove when griddata.m supports "natural" method. |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
116 error ('griddatan: "natural" interpolation METHOD not yet implemented'); |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
117 |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
118 else |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
119 error ('griddatan: unknown interpolation METHOD: "%s"', method); |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
120 endif |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
121 |
6823 | 122 endif |
123 | |
124 ## triangulate data | |
14370
fbdee844550c
griddatan.m: Restore ability to pass options to underlying Qhull
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
125 tri = delaunayn (x, varargin{:}); |
6823 | 126 |
10548
479536c5bb10
Replace lowercase nan with NaN for visual cue in scripts
Rik <code@nomad.inbox5.com>
parents:
8920
diff
changeset
|
127 yi = NaN (mi, 1); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
128 |
28211
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
129 if (strcmp (method, "linear")) |
6823 | 130 ## search for every point the enclosing triangle |
6826 | 131 [tri_list, bary_list] = tsearchn (x, tri, xi); |
6823 | 132 |
133 ## only keep the points within triangles. | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
134 valid = ! isnan (tri_list); |
27244
3f354ef16400
griddatan.m: Allow a single query point as input (bug #45542, bug #56515).
Rik <rik@octave.org>
parents:
27239
diff
changeset
|
135 tri_list = tri_list(valid); |
3f354ef16400
griddatan.m: Allow a single query point as input (bug #45542, bug #56515).
Rik <rik@octave.org>
parents:
27239
diff
changeset
|
136 bary_list = bary_list(valid, :); |
6826 | 137 nr_t = rows (tri_list); |
6823 | 138 |
139 ## Use barycentric coordinate of point to calculate yi | |
27244
3f354ef16400
griddatan.m: Allow a single query point as input (bug #45542, bug #56515).
Rik <rik@octave.org>
parents:
27239
diff
changeset
|
140 if (isscalar (tri_list)) |
3f354ef16400
griddatan.m: Allow a single query point as input (bug #45542, bug #56515).
Rik <rik@octave.org>
parents:
27239
diff
changeset
|
141 ## Special case required by orientation rules for vector/vector index. |
3f354ef16400
griddatan.m: Allow a single query point as input (bug #45542, bug #56515).
Rik <rik@octave.org>
parents:
27239
diff
changeset
|
142 yi(valid) = sum (y(tri(tri_list,:)).' .* bary_list, 2); |
3f354ef16400
griddatan.m: Allow a single query point as input (bug #45542, bug #56515).
Rik <rik@octave.org>
parents:
27239
diff
changeset
|
143 else |
3f354ef16400
griddatan.m: Allow a single query point as input (bug #45542, bug #56515).
Rik <rik@octave.org>
parents:
27239
diff
changeset
|
144 yi(valid) = sum (y(tri(tri_list,:)) .* bary_list, 2); |
27239
bee80e27dcc5
griddatan.m: Fix 4-D interpolation (bug #45542, bug #56515).
Juho Iipponen <juho.iipponen@helsinki.fi>
parents:
26376
diff
changeset
|
145 endif |
6823 | 146 |
28211
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
147 else |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
148 ## search index of nearest point |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
149 idx = dsearchn (x, tri, xi); |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
150 valid = ! isnan (idx); |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
151 yi(valid) = y(idx(valid)); |
28210
bb929d5a34cb
griddata.m: Added support for "v4" biharmonic spline interpolation method (bug #33539).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
28027
diff
changeset
|
152 |
6823 | 153 endif |
154 | |
155 endfunction | |
156 | |
157 | |
8153
ec0a13863eb7
Only run tests that depend on HDF5 and QHull if Octave was actually
Soren Hauberg <hauberg@gmail.com>
parents:
7017
diff
changeset
|
158 %!testif HAVE_QHULL |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
159 %! [xx,yy] = meshgrid (linspace (-1,1,32)); |
6823 | 160 %! xi = [xx(:), yy(:)]; |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
161 %! x = 2*rand (100,2) - 1; |
6823 | 162 %! x = [x;1,1;1,-1;-1,-1;-1,1]; |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
163 %! y = sin (2 * sum (x.^2,2)); |
28211
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
164 %! zz = griddatan (x,y,xi, "linear"); |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
165 %! zz2 = griddata (x(:,1),x(:,2),y,xi(:,1),xi(:,2), "linear"); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
166 %! assert (zz, zz2, 1e-10); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
167 |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
168 %!testif HAVE_QHULL |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
169 %! [xx,yy] = meshgrid (linspace (-1,1,32)); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
170 %! xi = [xx(:), yy(:)]; |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
171 %! x = 2*rand (100,2) - 1; |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
172 %! x = [x;1,1;1,-1;-1,-1;-1,1]; |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
173 %! y = sin (2*sum (x.^2,2)); |
28211
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
174 %! zz = griddatan (x,y,xi, "nearest"); |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
175 %! zz2 = griddata (x(:,1),x(:,2),y,xi(:,1),xi(:,2), "nearest"); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
176 %! assert (zz, zz2, 1e-10); |
27244
3f354ef16400
griddatan.m: Allow a single query point as input (bug #45542, bug #56515).
Rik <rik@octave.org>
parents:
27239
diff
changeset
|
177 |
28011
b31a118729ed
update bug status for tests
John W. Eaton <jwe@octave.org>
parents:
27978
diff
changeset
|
178 %!testif HAVE_QHULL <*56515> |
27244
3f354ef16400
griddatan.m: Allow a single query point as input (bug #45542, bug #56515).
Rik <rik@octave.org>
parents:
27239
diff
changeset
|
179 %! x = [ 0, 0; 1, 1; 0, 1; 1, 0 ]; |
3f354ef16400
griddatan.m: Allow a single query point as input (bug #45542, bug #56515).
Rik <rik@octave.org>
parents:
27239
diff
changeset
|
180 %! y = [ 1; 2; 3; 4 ]; |
3f354ef16400
griddatan.m: Allow a single query point as input (bug #45542, bug #56515).
Rik <rik@octave.org>
parents:
27239
diff
changeset
|
181 %! xi = [ .5, .5 ]; |
3f354ef16400
griddatan.m: Allow a single query point as input (bug #45542, bug #56515).
Rik <rik@octave.org>
parents:
27239
diff
changeset
|
182 %! yi = griddatan (x, y, xi); |
28210
bb929d5a34cb
griddata.m: Added support for "v4" biharmonic spline interpolation method (bug #33539).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
28027
diff
changeset
|
183 |
bb929d5a34cb
griddata.m: Added support for "v4" biharmonic spline interpolation method (bug #33539).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
28027
diff
changeset
|
184 ## Test input validation |
bb929d5a34cb
griddata.m: Added support for "v4" biharmonic spline interpolation method (bug #33539).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
28027
diff
changeset
|
185 %!error griddatan () |
bb929d5a34cb
griddata.m: Added support for "v4" biharmonic spline interpolation method (bug #33539).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
28027
diff
changeset
|
186 %!error griddatan (1) |
bb929d5a34cb
griddata.m: Added support for "v4" biharmonic spline interpolation method (bug #33539).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
28027
diff
changeset
|
187 %!error griddatan (1,2) |
28211
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
188 %!error <number of points in X> griddatan (1,2,3) |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
189 %!error <Y must be a column vector> griddatan ([1;2],[3,4], 1) |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
190 %!error <Y must .* same number of points .* as X> griddatan ([1;2],[3;4;5], 1) |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
191 %!error <dimension of .* XI .* must match X> griddatan ([1;2],[3;4], [1, 2]) |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
192 %!error <METHOD must be a string> griddatan ([1;2],[3;4], 1, 5) |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
193 %!error <"v4" METHOD is available for 2-D> griddatan ([1;2],[3;4], 1, "v4") |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
194 %!error <"cubic" METHOD is available> griddatan ([1;2],[3;4], 1, "cubic") |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
195 %!error <"natural" .* not yet implemented> griddatan ([1;2],[3;4], 1, "natural") |
289882040316
griddatan.m: Rewrite docstring and redo input validation.
Rik <rik@octave.org>
parents:
28210
diff
changeset
|
196 %!error <unknown .* METHOD: "foobar"> griddatan ([1;2],[3;4], 1, "foobar") |