Mercurial > hg > octave-shane
changeset 6722:5b09d433171c
[project @ 2007-06-14 10:13:14 by dbateman]
author | dbateman |
---|---|
date | Thu, 14 Jun 2007 10:13:16 +0000 |
parents | 01036667884a |
children | 8bfb4ff637e1 |
files | scripts/ChangeLog scripts/general/interp3.m scripts/general/interpn.m |
diffstat | 3 files changed, 40 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -4,8 +4,9 @@ as permutation of results was incorrect. * general/interp1.m: Add demo on second derivative * general/interpn.m: Convert "y" to vectors for __splinen__ - call. Add 3D demo. - + call. Add 3D demo. Fix typos + * general/interp3.m: Fix typos. Correct permutation for use of + interpn. * polynomial/mkpp.m: Correction for matrices of 3 or more dimensions. 2007-06-13 John W. Eaton <jwe@octave.org>
--- a/scripts/general/interp3.m +++ b/scripts/general/interp3.m @@ -75,27 +75,58 @@ method = varargin {end}; nargs = nargs - 1; elseif (ischar (varargin {end - 1})) - if (! isnumeric (vargin {end}) || ! isscalar (vargin {end})) + if (! isnumeric (varargin {end}) || ! isscalar (varargin {end})) error ("extrapal is expected to be a numeric scalar"); endif + extrapval = varargin {end}; method = varargin {end - 1}; nargs = nargs - 2; endif if (nargs < 3 || (nargs == 4 && ! isvector (varargin {1}) && nargs == (ndims (varargin {1}) + 1))) - v = varargin {1}; if (ndims (v) != 3) error ("expect 3-dimensional array of values"); endif - vi = ipermute (interpn (permute(varargin, [1, 3, 2, 4]){:}), [2, 1, 3]); + x = varargin (2:4); + if (any (! cellfun (@isvector, x))) + for i = 2 : 3 + if (! size_equal (x{1}, x{i}) || ! size_equal (x{i}, v)) + error ("dimensional mismatch"); + endif + x{i} = permute (x{i}, [2, 1, 3]); + endfor + x{1} = permute (x{1}, [2, 1, 3]); + endif + v = permute (v, [2, 1, 3]); + vi = ipermute (interpn (v, x{:}, method, extrapval), [2, 1, 3]); elseif (nargs == 7 && nargs == (2 * ndims (varargin {ceil (nargs / 2)})) + 1) v = varargin {4}; if (ndims (v) != 3) error ("expect 3-dimensional array of values"); endif - vi = ipermute (interpn (permute(varargin, [2, 1, 3, 4, 6, 5, 7]){:}), - [2, 1, 3]); + x = varargin (1:3); + if (any (! cellfun (@isvector, x))) + for i = 2 : 3 + if (! size_equal (x{1}, x{i}) || ! size_equal (x{i}, v)) + error ("dimensional mismatch"); + endif + x{i} = permute (x{i}, [2, 1, 3]); + endfor + x{1} = permute (x{1}, [2, 1, 3]); + endif + y = varargin (5:7); + if (any (! cellfun (@isvector, y))) + for i = 2 : 3 + if (! size_equal (y{1}, y{i})) + error ("dimensional mismatch"); + endif + y{i} = permute (y{i}, [2, 1, 3]); + endfor + y{1} = permute (y{1}, [2, 1, 3]); + endif + v = permute (v, [2, 1, 3]); + vi = ipermute (interpn (x{:}, v, y{:}, method, extrapval), [2,1,3]); else error ("wrong number or incorrectly formatted input arguments"); endif
--- a/scripts/general/interpn.m +++ b/scripts/general/interpn.m @@ -76,7 +76,7 @@ method = varargin {end}; nargs = nargs - 1; elseif (ischar (varargin {end - 1})) - if (! isnumeric (vargin {end}) || ! isscalar (vargin {end})) + if (! isnumeric (varargin {end}) || ! isscalar (varargin {end})) error ("extrapal is expected to be a numeric scalar"); endif method = varargin {end - 1};