annotate scripts/general/private/__splinen__.m @ 19833:9fc020886ae9

maint: Clean up m-files to follow Octave coding conventions. Try to trim long lines to < 80 chars. Use '##' for single line comments. Use '(...)' around tests for if/elseif/switch/while. Abut cell indexing operator '{' next to variable. Abut array indexing operator '(' next to variable. Use space between negation operator '!' and following expression. Use two newlines between endfunction and start of %!test or %!demo code. Remove unnecessary parens grouping between short-circuit operators. Remove stray extra spaces (typos) between variables and assignment operators. Remove stray extra spaces from ends of lines.
author Rik <rik@octave.org>
date Mon, 23 Feb 2015 14:54:39 -0800
parents 4197fc428c7d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19658
diff changeset
1 ## Copyright (C) 2007-2015 David Bateman
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
2 ##
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
3 ## This file is part of Octave.
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
4 ##
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6967
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6967
diff changeset
8 ## your option) any later version.
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
9 ##
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
13 ## General Public License for more details.
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
14 ##
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6967
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6967
diff changeset
17 ## <http://www.gnu.org/licenses/>.
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
18
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6721
diff changeset
19 ## Undocumented internal function.
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6721
diff changeset
20
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
21 ## -*- texinfo -*-
7650
eb7bdde776f2 Texinfo fixes
John W. Eaton <jwe@octave.org>
parents: 7423
diff changeset
22 ## @deftypefn {Function File} {@var{yi} =} __splinen__ (@var{x}, @var{y}, @var{xi})
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8506
diff changeset
23 ## Undocumented internal function.
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
24 ## @end deftypefn
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
25
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
26 ## FIXME: Allow arbitrary grids..
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
27
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
28 function yi = __splinen__ (x, y, xi, extrapval, f)
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 7650
diff changeset
29 ## ND isvector function.
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 7650
diff changeset
30 isvec = @(x) numel (x) == length (x);
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
31 if (! iscell (x) || length (x) < ndims (y) || any (! cellfun (isvec, x))
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
32 || ! iscell (xi) || length (xi) < ndims (y)
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
33 || any (! cellfun (isvec, xi)))
17176
abf384f5d243 maint: Remove unneeded input validation from internal fcns in private/ directories.
Rik <rik@octave.org>
parents: 14868
diff changeset
34 error ("__splinen__: %s: non-gridded data or dimensions inconsistent", f);
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
35 endif
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
36 yi = y;
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
37 for i = length (x):-1:1
9768
31900e17b5f5 improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
38 yi = permute (spline (x{i}, yi, xi{i}(:)), [length(x),1:length(x)-1]);
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
39 endfor
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
40
11191
01ddaedd6ad5 Reverse changeset b1f4bdc276b6. Use all lower case for "uniformoutput" option.
Rik <octave@nomad.inbox5.com>
parents: 11149
diff changeset
41 [xi{:}] = ndgrid (cellfun (@(x) x(:), xi, "uniformoutput", false){:});
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
42 if (! isempty (extrapval))
19658
5a59c0e1203d Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
43 idx = zeros (size (xi{1}));
5a59c0e1203d Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
44 for i = 1 : length (x)
5a59c0e1203d Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
45 idx |= xi{i} < min (x{i}(:)) | xi{i} > max (x{i}(:));
5a59c0e1203d Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
46 endfor
5a59c0e1203d Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
47 yi(idx) = extrapval;
5a59c0e1203d Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
48 endif
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents:
diff changeset
49 endfunction
17338
1c89599167a6 maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents: 17176
diff changeset
50