42 return dv.
length () == 2 && (dv(0) == 1 || dv(1) == 1);
56 if (y > x[n-1] || y < x[0])
60 for (j = 0; j < n - 1; j++)
62 if (x[j] <= y && y <= x[j+1])
91 if (y > x[0] || y < x[n-1])
95 for (j = 0; j < n - 1; j++)
97 if (x[j+1] <= y && y <= x[j])
129 const T *v,
const T **y, T *vi)
141 for (
int i = 0; i < n; i++)
143 index[i] =
lookup (x[i], size[i], y[i][m]);
144 out = index[i] == -1;
151 coef[2*i+1] = (y[i][m] - x[i][j])/(x[i][j+1] - x[i][j]);
152 coef[2*i] = 1 - coef[2*i+1];
164 for (
int i = 0; i < (1 << n); i++)
170 for (
int j = 0; j < n; j++)
174 l += scale[j] * (index[j] + bit);
184 template <
class T,
class M>
190 M Vi =
M (Y[0].dims ());
195 for (
int i = 0; i < n; i++)
198 size[i] = V.dims ()(i);
204 const T *v = V.data ();
205 T *vi = Vi.fortran_vec ();
214 for (
int i = 1; i < n; i++)
222 for (
int i = 0; i < n; i++)
224 if (X[i].dims () != V.dims ())
226 error (
"interpn: incompatible size of argument number %d", i+1);
234 tmp(j) = X[i](
scale[i]*j);
241 for (
int i = 0; i < n; i++)
245 error (
"interpn: incompatible size of argument number %d", i+1);
270 DEFUN (__lin_interpn__, args, ,
272 @deftypefn {Built-in Function} {@var{vi} =} __lin_interpn__ (@var{x1}, @var{x2}, @dots{}, @var{xn}, @var{v}, @var{y1}, @var{y2}, @dots{}, @var{yn})\n\
273 Undocumented internal function.\n\
278 int nargin = args.
length ();
280 if (nargin < 2 || nargin % 2 == 0)
287 int n = (nargin-1)/2;
289 if (args(n).is_single_type ())
302 for (
int i = 0; i < n; i++)
305 Y[i] = args(n+i+1).float_array_value ();
313 if (Y[0].dims () != Y[i].dims ())
315 error (
"interpn: incompatible size of argument number %d", n+i+2);
320 retval = lin_interpn<float, FloatNDArray> (n, X,
V, Y);
327 const NDArray V = args(n).array_value ();
335 for (
int i = 0; i < n; i++)
338 Y[i] = args(n+i+1).array_value ();
346 if (Y[0].dims () != Y[i].dims ())
348 error (
"interpn: incompatible size of argument number %d", n+i+2);
353 retval = lin_interpn<double, NDArray> (n, X,
V, Y);