26 #if defined (HAVE_CONFIG_H)
45 return dv.
ndims () == 2 && (dv(0) == 1 || dv(1) == 1);
59 if (y >
x[
n-1] || y <
x[0])
62 #if defined (EXHAUSTIF)
63 for (j = 0; j <
n - 1; j++)
65 if (
x[j] <= y && y <=
x[j+1])
94 if (y >
x[0] || y <
x[
n-1])
97 #if defined (EXHAUSTIF)
98 for (j = 0; j <
n - 1; j++)
100 if (
x[j+1] <= y && y <=
x[j])
128 template <
typename T>
132 const T *v,
const T **y, T *vi)
144 for (
int i = 0; i <
n; i++)
146 index[i] =
lookup (
x[i], size[i], y[i][
m]);
147 out = index[i] == -1;
154 coef[2*i+1] = (y[i][
m] -
x[i][j])/(
x[i][j+1] -
x[i][j]);
155 coef[2*i] = 1 - coef[2*i+1];
166 for (
int i = 0; i < (1 <<
n); i++)
172 for (
int j = 0; j <
n; j++)
176 l +=
scale[j] * (index[j] + bit);
186 template <
typename T,
typename M>
192 M Vi =
M (Y[0].dims ());
197 for (
int i = 0; i <
n; i++)
200 size[i] =
V.dims ()(i);
206 const T *v =
V.data ();
207 T *vi = Vi.fortran_vec ();
216 for (
int i = 1; i <
n; i++)
224 for (
int i = 0; i <
n; i++)
226 if (X[i].dims () !=
V.dims ())
227 error (
"interpn: incompatible size of argument number %d", i+1);
232 tmp(j) = X[i](
scale[i]*j);
238 for (
int i = 0; i <
n; i++)
240 if (!
isvector (X[i]) && X[i].numel () != size[i])
241 error (
"interpn: incompatible size of argument number %d", i+1);
264 DEFUN (__lin_interpn__, args, ,
270 int nargin = args.length ();
272 if (nargin < 2 || nargin % 2 == 0)
278 int n = (nargin-1)/2;
280 if (args(
n).is_single_type ())
287 for (
int i = 0; i <
n; i++)
289 X[i] = args(i).float_array_value ();
290 Y[i] = args(
n+i+1).float_array_value ();
292 if (Y[0].dims () != Y[i].dims ())
293 error (
"interpn: incompatible size of argument number %d",
n+i+2);
296 retval = lin_interpn<float, FloatNDArray> (
n, X,
V, Y);
303 const NDArray V = args(
n).array_value ();
305 for (
int i = 0; i <
n; i++)
307 X[i] = args(i).array_value ();
308 Y[i] = args(
n+i+1).array_value ();
310 if (Y[0].dims () != Y[i].dims ())
311 error (
"interpn: incompatible size of argument number %d",
n+i+2);
314 retval = lin_interpn<double, NDArray> (
n, X,
V, Y);
octave_idx_type lookup(const T *x, octave_idx_type n, T y)
bool isvector(const T &array)
void lin_interpn(int n, const octave_idx_type *size, const octave_idx_type *scale, octave_idx_type Ni, T extrapval, const T **x, const T *v, const T **y, T *vi)
Vector representing the dimensions (size) of an Array.
octave_idx_type ndims(void) const
Number of dimensions.
OCTINTERP_API void print_usage(void)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
void scale(Matrix &m, double x, double y, double z)
F77_RET_T const F77_INT const F77_INT const F77_INT const F77_DBLE const F77_DBLE F77_INT & M
F77_RET_T const F77_INT const F77_INT const F77_INT const F77_DBLE const F77_DBLE F77_INT F77_DBLE * V
F77_RET_T const F77_DBLE * x
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
octave_value::octave_value(const Array< char > &chm, char type) return retval