A high-performance general-purpose compute library

Interpolation along two dimensions. More...

Functions

AFAPI array approx2 (const array &in, const array &pos0, const array &pos1, const interpType method=AF_INTERP_LINEAR, const float off_grid=0.0f)
 C++ Interface for data interpolation on two-dimensional signals. More...
 
AFAPI array approx2 (const array &in, const array &pos0, const int interp_dim0, const double idx_start_dim0, const double idx_step_dim0, const array &pos1, const int interp_dim1, const double idx_start_dim1, const double idx_step_dim1, const interpType method=AF_INTERP_LINEAR, const float off_grid=0.0f)
 C++ Interface for data interpolation on two-dimensional signals. More...
 
AFAPI af_err af_approx2 (af_array *out, const af_array in, const af_array pos0, const af_array pos1, const af_interp_type method, const float off_grid)
 C Interface for signals interpolation on two dimensional signals. More...
 
AFAPI af_err af_approx2_v2 (af_array *out, const af_array in, const af_array pos0, const af_array pos1, const af_interp_type method, const float off_grid)
 C Interface for the version of af_approx2 that accepts a preallocated output array. More...
 
AFAPI af_err af_approx2_uniform (af_array *out, const af_array in, const af_array pos0, const int interp_dim0, const double idx_start_dim0, const double idx_step_dim0, const af_array pos1, const int interp_dim1, const double idx_start_dim1, const double idx_step_dim1, const af_interp_type method, const float off_grid)
 C Interface for signals interpolation on two dimensional signals along specified dimensions. More...
 
AFAPI af_err af_approx2_uniform_v2 (af_array *out, const af_array in, const af_array pos0, const int interp_dim0, const double idx_start_dim0, const double idx_step_dim0, const af_array pos1, const int interp_dim1, const double idx_start_dim1, const double idx_step_dim1, const af_interp_type method, const float off_grid)
 C Interface for the version of af_approx2_uniform that accepts a preallocated output array. More...
 

Detailed Description

Interpolation along two dimensions.

Performs interpolation on data along two dimensions.

Interpolation is the process of computing for unknown values within a continuous range described by a discrete set of known values. These known values correspond to a uniformly-spaced range of indices determined by start and step values, whose defaults are 0.0 and 1.0, respectively.

The positions arrays (pos0 and pos1) contain the interpolating points (indices whose values we want to find) along two given dimensions. Values of known indices will be looked up in the input array, while values of unknown indices will be found via interpolation. Indices outside of the index range are not extrapolated. Instead, those values are set to off_grid, whose default value is 0.0.

All of the interpolation methods defined in af_interp_type are supported by approx2. Unless specified, linear interpolation is performed by default.

Function Documentation

◆ af_approx2()

AFAPI af_err af_approx2 ( af_array out,
const af_array  in,
const af_array  pos0,
const af_array  pos1,
const af_interp_type  method,
const float  off_grid 
)

C Interface for signals interpolation on two dimensional signals.

Parameters
[out]outthe interpolated array.
[in]inis the multidimensional input array. Values assumed to lie uniformly spaced indices in the range of [0, n) along both interpolation dimensions. n is the number of elements in the array.
[in]pos0positions of the interpolation points along the first dimension.
[in]pos1positions of the interpolation points along the second dimension.
[in]methodis the interpolation method to be used. All interpolation types defined in af_interp_type are supported.
[in]off_gridis the default value for any indices outside the valid range of indices.
Returns
AF_SUCCESS if the interpolation operation is successful, otherwise an appropriate error code is returned.

◆ af_approx2_uniform()

AFAPI af_err af_approx2_uniform ( af_array out,
const af_array  in,
const af_array  pos0,
const int  interp_dim0,
const double  idx_start_dim0,
const double  idx_step_dim0,
const af_array  pos1,
const int  interp_dim1,
const double  idx_start_dim1,
const double  idx_step_dim1,
const af_interp_type  method,
const float  off_grid 
)

C Interface for signals interpolation on two dimensional signals along specified dimensions.

af_approx2_uniform() accepts two dimensions to perform the interpolation along the input. It also accepts start and step values which define the uniform range of corresponding indices.

Parameters
[out]outthe interpolated array.
[in]inis the multidimensional input array.
[in]pos0positions of the interpolation points along interp_dim0.
[in]interp_dim0is the first dimension to perform interpolation across.
[in]idx_start_dim0is the first index value along interp_dim0.
[in]idx_step_dim0is the uniform spacing value between subsequent indices along interp_dim0.
[in]pos1positions of the interpolation points along interp_dim1.
[in]interp_dim1is the second dimension to perform interpolation across.
[in]idx_start_dim1is the first index value along interp_dim1.
[in]idx_step_dim1is the uniform spacing value between subsequent indices along interp_dim1.
[in]methodis the interpolation method to be used. All interpolation types defined in af_interp_type are supported.
[in]off_gridis the default value for any indices outside the valid range of indices.
Returns
AF_SUCCESS if the interpolation operation is successful, otherwise an appropriate error code is returned.

◆ af_approx2_uniform_v2()

AFAPI af_err af_approx2_uniform_v2 ( af_array out,
const af_array  in,
const af_array  pos0,
const int  interp_dim0,
const double  idx_start_dim0,
const double  idx_step_dim0,
const af_array  pos1,
const int  interp_dim1,
const double  idx_start_dim1,
const double  idx_step_dim1,
const af_interp_type  method,
const float  off_grid 
)

C Interface for the version of af_approx2_uniform that accepts a preallocated output array.

Parameters
[in,out]outthe interpolated array.
[in]inis the multidimensional input array.
[in]pos0positions of the interpolation points along interp_dim0.
[in]interp_dim0is the first dimension to perform interpolation across.
[in]idx_start_dim0is the first index value along interp_dim0.
[in]idx_step_dim0is the uniform spacing value between subsequent indices along interp_dim0.
[in]pos1positions of the interpolation points along interp_dim1.
[in]interp_dim1is the second dimension to perform interpolation across.
[in]idx_start_dim1is the first index value along interp_dim1.
[in]idx_step_dim1is the uniform spacing value between subsequent indices along interp_dim1.
[in]methodis the interpolation method to be used. All interpolation types defined in af_interp_type are supported.
[in]off_gridis the default value for any indices outside the valid range of indices.
Returns
AF_SUCCESS if the interpolation operation is successful, otherwise an appropriate error code is returned.
Note
out can either be a null or existing af_array object. If it is a sub-array of an existing af_array, only the corresponding portion of the af_array will be overwritten
Passing an af_array to out that has not been initialized will cause undefined behavior.

◆ af_approx2_v2()

AFAPI af_err af_approx2_v2 ( af_array out,
const af_array  in,
const af_array  pos0,
const af_array  pos1,
const af_interp_type  method,
const float  off_grid 
)

C Interface for the version of af_approx2 that accepts a preallocated output array.

Parameters
[in,out]outthe interpolated array (can be preallocated).
[in]inis the multidimensional input array. Values assumed to lie uniformly spaced indices in the range of [0, n) along both interpolation dimensions. n is the number of elements in the array.
[in]pos0positions of the interpolation points along the first dimension.
[in]pos1positions of the interpolation points along the second dimension.
[in]methodis the interpolation method to be used. All interpolation types defined in af_interp_type are supported.
[in]off_gridis the default value for any indices outside the valid range of indices.
Returns
AF_SUCCESS if the interpolation operation is successful, otherwise an appropriate error code is returned.
Note
out can either be a null or existing af_array object. If it is a sub-array of an existing af_array, only the corresponding portion of the af_array will be overwritten
Passing an af_array to out that has not been initialized will cause undefined behavior.

◆ approx2() [1/2]

AFAPI array approx2 ( const array in,
const array pos0,
const array pos1,
const interpType  method = AF_INTERP_LINEAR,
const float  off_grid = 0.0f 
)

C++ Interface for data interpolation on two-dimensional signals.

Parameters
[in]inis the multidimensional input array. Values assumed to lie uniformly spaced indices in the range of [0, n) along both interpolation dimensions. n is the number of elements in the array.
[in]pos0positions of the interpolation points along the first dimension.
[in]pos1positions of the interpolation points along the second dimension.
[in]methodis the interpolation method to be used. All interpolation types defined in af_interp_type are supported.
[in]off_gridis the default value for any indices outside the valid range of indices.
Returns
the interpolated array.

The code sample below demonstrates approx2()'s usage:

// Input data array.
float input_vals[9] = {1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0};
array input(3, 3, input_vals);
// [3 3 1 1]
// 1.0000 2.0000 3.0000
// 1.0000 2.0000 3.0000
// 1.0000 2.0000 3.0000
// First array of positions to be found along the first dimension.
float pv0[4] = {0.5, 1.5, 0.5, 1.5};
array pos0(2, 2, pv0);
// [2 2 1 1]
// 0.5000 0.5000
// 1.5000 1.5000
// Second array of positions to be found along the second
// dimension.
float pv1[4] = {0.5, 0.5, 1.5, 1.5};
array pos1(2, 2, pv1);
// [2 2 1 1]
// 0.5000 1.5000
// 0.5000 1.5000
array interp = approx2(input, pos0, pos1);
// [2 2 1 1]
// 1.5000 2.5000
// 1.5000 2.5000
AFAPI array approx2(const array &in, const array &pos0, const array &pos1, const interpType method=AF_INTERP_LINEAR, const float off_grid=0.0f)
C++ Interface for data interpolation on two-dimensional signals.

◆ approx2() [2/2]

AFAPI array approx2 ( const array in,
const array pos0,
const int  interp_dim0,
const double  idx_start_dim0,
const double  idx_step_dim0,
const array pos1,
const int  interp_dim1,
const double  idx_start_dim1,
const double  idx_step_dim1,
const interpType  method = AF_INTERP_LINEAR,
const float  off_grid = 0.0f 
)

C++ Interface for data interpolation on two-dimensional signals.

The following version of the approx2() accepts the two dimensions to perform the interpolation along the input. It also accepts start and step values which define the uniform range of corresponding indices.

Parameters
[in]inis the multidimensional input array.
[in]pos0positions of the interpolation points along interp_dim0.
[in]interp_dim0is the first dimension to perform interpolation across.
[in]idx_start_dim0is the first index value along interp_dim0.
[in]idx_step_dim0is the uniform spacing value between subsequent indices along interp_dim0.
[in]pos1positions of the interpolation points along interp_dim1.
[in]interp_dim1is the second dimension to perform interpolation across.
[in]idx_start_dim1is the first index value along interp_dim1.
[in]idx_step_dim1is the uniform spacing value between subsequent indices along interp_dim1.
[in]methodis the interpolation method to be used. All interpolation types defined in af_interp_type are supported.
[in]off_gridis the default value for any indices outside the valid range of indices.
Returns
the interpolated array.

The code sample below demonstrates usage:

// Input data array.
float input_vals[9] = {1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0};
array input(3, 3, input_vals);
// [3 3 1 1]
// 1.0000 2.0000 3.0000
// 1.0000 2.0000 3.0000
// 1.0000 2.0000 3.0000
// First array of positions to be found along the interpolation
// dimension, `interp_dim0`.
float pv0[4] = {0.5, 1.5, 0.5, 1.5};
array pos0(2, 2, pv0);
// [2 2 1 1]
// 0.5000 0.5000
// 1.5000 1.5000
// Second array of positions to be found along the interpolation
// dimension, `interp_dim1`.
float pv1[4] = {0.5, 0.5, 1.5, 1.5};
array pos1(2, 2, pv1);
// [2 2 1 1]
// 0.5000 1.5000
// 0.5000 1.5000
// Define range of indices with which the input values will
// correspond along both dimensions to be interpolated.
const double idx_start_dim0 = 0.0;
const double idx_step_dim0 = 1.0;
const int interp_dim0 = 0;
const int interp_dim1 = 1;
array interp =
approx2(input, pos0, interp_dim0, idx_start_dim0, idx_step_dim0, pos1,
interp_dim1, idx_start_dim0, idx_step_dim0);
// [2 2 1 1]
// 1.5000 2.5000
// 1.5000 2.5000