Hi Jeremy, The algorithms used by interp2d require a rectangular grid. Doing interpolation without that grid would require an entirely different algorithm, so that would be a separate project. The algorithms can be generalized to higher-dimensional interpolation, but it becomes exponentially more complicated as the number of dimensions increases. For linear interpolation this probably wouldn't be too bad, but other interpolation schemes would be quite a pain to code in a higher number of dimensions. I believe it would be possible to make an interpolation routine that automatically generalizes to any number of dimensions (I think Mathematica does this, for example), but that would require pretty much rewriting the entire code base. :) David On 01/10/2014 07:27 PM, jeremy theler wrote: > Hi all, > > I consider the addition of these routines to GSL as a major breakthrough. > Now I have three questions about generalization: > > 1. can these 2D interpolation routines be extended to scattered (i.e. non- > rectangular) data? > > 2. can these 2D interpolation routines be extended to n dimensions? > > 3. both > > > Thank you for your hard work! > > -- > jeremy > > > On Friday 10 January 2014 09:37:04 Patrick Alken wrote: >>> Sure, that would be a reasonable option, but I'd like to do a bit of >>> research (i.e. ask a few more people for opinions) to see what solution >>> will be the least confusing. After all, if there is a change to be made, >>> this is the time to do it, not later after the code is incorporated into >>> GSL. I think backward compatibility will not be too much of a problem >>> because people will have to make other changes anyway to transition from >>> the interp2d_* functions to the corresponding gsl_* functions. >> I think 2 additional functions could be added to help solve this issue >> and hide the indexing >> from the user: >> >> interp2d_grid_set(double zarr[], size_t i, size_t j, double z) >> { >> /* set point (i,j) of grid 'zarr' to value 'z' */ >> } >> >> and >> >> interp2d_grid_fill(double zarr[], int (*grid_func)(double x, double y, >> void *params)) >> { >> /* fill entire grid 'zarr' using callback function 'grid_func'; this >> would be useful >> * in cases where the user has a continuous/analytic function which >> is expensive to call, but >> * they'd like to make a grid and then interpolate from it >> */ >> }