Interpolation in one or two dimensions. More...

Modules

 approx
 C++ interface for Interpolation.
 
 af_approx
 C interface for Interpolation.
 

Detailed Description

Interpolation in one or two dimensions.

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