C interface for Interpolation. More...

Vector Interpolation

Vector (1D) interpolation.

Parameters
[out]d_YIInterpolated function values
[in]nNumber of elements in inputs d_Y
[in]d_YFunction values
[in]batch_YNumber of tiles of d_Y
[in]niNumber of elements in d_XI
[in]d_XIGrid values to interpolate at
[in]batch_XINumber of tiles of d_XI
[in]methodinterpolation type ('N' nearest, 'L' linear, 'C' cubic)
[in]offgridValue for interpolations off the grid (i.e. out-of-bounds)
afError af_approx1_S (float *d_YI, unsigned n, const float *d_Y, unsigned batch_Y, unsigned ni, const float *d_XI, unsigned batch_XI, char method, float offgrid)
 
afError af_approx1_D (double *d_YI, unsigned n, const double *d_Y, unsigned batch_Y, unsigned ni, const double *d_XI, unsigned batch_XI, char method, float offgrid)
 
afError af_approx1_C (cfloat *d_YI, unsigned n, const cfloat *d_Y, unsigned batch_Y, unsigned ni, const float *d_XI, unsigned batch_XI, char method, float offgrid)
 
afError af_approx1_Z (cdouble *d_YI, unsigned n, const cdouble *d_Y, unsigned batch_Y, unsigned ni, const double *d_XI, unsigned batch_XI, char method, float offgrid)
 

Matrix Interpolation

Matrix (2D) interpolation.

Parameters
[out]d_ZIInterpolated function values
[in]nxNumber of rows in d_Z
[in]nyNumber of columns in d_Z
[in]d_ZFunction values
[in]batch_ZNumber of tiles of d_Z
[in]niNumber of elements in d_XI, d_YI
[in]d_XIX Grid or Vector values to interpolate at
[in]batch_XINumber of tiles of d_XI
[in]d_YIY Grid or Vector values to interpolate at
[in]batch_YINumber of tiles of d_YI
[in]methodinterpolation type ('N' nearest, 'L' linear, 'C' cubic)
[in]offgridValue for interpolations off the grid (i.e. out-of-bounds)
afError af_approx2_S (float *d_ZI, unsigned nx, unsigned ny, const float *d_Z, unsigned batch_Z, unsigned ni, const float *d_XI, unsigned batch_XI, const float *d_YI, unsigned batch_YI, char method, float offgrid)
 
afError af_approx2_D (double *d_ZI, unsigned nx, unsigned ny, const double *d_Z, unsigned batch_Z, unsigned ni, const double *d_XI, unsigned batch_XI, const double *d_YI, unsigned batch_YI, char method, float offgrid)
 
afError af_approx2_C (cfloat *d_ZI, unsigned nx, unsigned ny, const cfloat *d_Z, unsigned batch_Z, unsigned ni, const float *d_XI, unsigned batch_XI, const float *d_YI, unsigned batch_YI, char method, float offgrid)
 
afError af_approx2_Z (cdouble *d_ZI, unsigned nx, unsigned ny, const cdouble *d_Z, unsigned batch_Z, unsigned ni, const double *d_XI, unsigned batch_XI, const double *d_YI, unsigned batch_YI, char method, float offgrid)
 

Detailed Description

C interface for Interpolation.

approx1 and approx2 perform interpolation on data in one and two dimensions, respectively. These methods have three options for the type of interpolation to perform—nearest neighbor, linear interpolation, and cubic interpolation.

1D Example:

// Pass the values to arrayfire
float h_Y[] = {0,1,2,3,4,5,6};
array Y = array(7,h_Y);
// Interpolate for the following
float h_Xi[] = {1.2, 1.4, 1.6, 4, 700};
array Xi = array(5,h_Xi);
// Perform interpolation
array Yi = approx1(Y, // Original sample data
Xi, // locations for interpolation
'L'); // linear interpolation
print(Yi);
// Yi =
// 1.2000
// 1.4000
// 1.6000
// 4.0000
// nan

2D Example:

float h_data[] = { 0.00, // (0,0)
0.10, // (1,0)
0.20, // (2,0)
0.01, // (0,1)
0.11, // (1,1)
0.21 // (2,1)
};
// Interpolate for the following
float h_Xirange[] = {1.2, 1.4, 1.6};
float h_Yirange[] = {0.3, 0.4, 0.6, 0.7};
// Pass the values to arrayfire
array data = array(3,2, h_data);
// Create a 2D grid from the 1D range vectors
array Xi = tile(array(3, 1, h_Xirange), 1, 4);
array Yi = tile(array(1, 4, h_Yirange), 3, 1);
// Perform interpolation
array result = approx2(data, // Original sample data
Xi, Yi, // locations for interpolation
'L'); // linear interpolation
print(result);
// result =
// 0.1230 0.1240 0.1260 0.1270
// 0.1430 0.1440 0.1460 0.1470
// 0.1630 0.1640 0.1660 0.1670

Function Documentation

afError af_approx1_S ( float *  d_YI,
unsigned  n,
const float *  d_Y,
unsigned  batch_Y,
unsigned  ni,
const float *  d_XI,
unsigned  batch_XI,
char  method,
float  offgrid 
)
afError af_approx1_D ( double *  d_YI,
unsigned  n,
const double *  d_Y,
unsigned  batch_Y,
unsigned  ni,
const double *  d_XI,
unsigned  batch_XI,
char  method,
float  offgrid 
)
afError af_approx1_C ( cfloat d_YI,
unsigned  n,
const cfloat d_Y,
unsigned  batch_Y,
unsigned  ni,
const float *  d_XI,
unsigned  batch_XI,
char  method,
float  offgrid 
)
afError af_approx1_Z ( cdouble d_YI,
unsigned  n,
const cdouble d_Y,
unsigned  batch_Y,
unsigned  ni,
const double *  d_XI,
unsigned  batch_XI,
char  method,
float  offgrid 
)
afError af_approx2_S ( float *  d_ZI,
unsigned  nx,
unsigned  ny,
const float *  d_Z,
unsigned  batch_Z,
unsigned  ni,
const float *  d_XI,
unsigned  batch_XI,
const float *  d_YI,
unsigned  batch_YI,
char  method,
float  offgrid 
)
afError af_approx2_D ( double *  d_ZI,
unsigned  nx,
unsigned  ny,
const double *  d_Z,
unsigned  batch_Z,
unsigned  ni,
const double *  d_XI,
unsigned  batch_XI,
const double *  d_YI,
unsigned  batch_YI,
char  method,
float  offgrid 
)
afError af_approx2_C ( cfloat d_ZI,
unsigned  nx,
unsigned  ny,
const cfloat d_Z,
unsigned  batch_Z,
unsigned  ni,
const float *  d_XI,
unsigned  batch_XI,
const float *  d_YI,
unsigned  batch_YI,
char  method,
float  offgrid 
)
afError af_approx2_Z ( cdouble d_ZI,
unsigned  nx,
unsigned  ny,
const cdouble d_Z,
unsigned  batch_Z,
unsigned  ni,
const double *  d_XI,
unsigned  batch_XI,
const double *  d_YI,
unsigned  batch_YI,
char  method,
float  offgrid 
)