Interpolation across a single dimension. More...
Functions | |
AFAPI array | approx1 (const array &in, const array &pos, const interpType method=AF_INTERP_LINEAR, const float off_grid=0.0f) |
C++ Interface for data interpolation on one-dimensional signals. More... | |
AFAPI array | approx1 (const array &in, const array &pos, const int interp_dim, const double idx_start, const double idx_step, const interpType method=AF_INTERP_LINEAR, const float off_grid=0.0f) |
C++ Interface for data interpolation on one-dimensional signals. More... | |
AFAPI af_err | af_approx1 (af_array *out, const af_array in, const af_array pos, const af_interp_type method, const float off_grid) |
C Interface for signals interpolation on one dimensional signals. More... | |
AFAPI af_err | af_approx1_v2 (af_array *out, const af_array in, const af_array pos, const af_interp_type method, const float off_grid) |
C Interface for the version of af_approx1 that accepts a preallocated output array. More... | |
AFAPI af_err | af_approx1_uniform (af_array *out, const af_array in, const af_array pos, const int interp_dim, const double idx_start, const double idx_step, const af_interp_type method, const float off_grid) |
C Interface for signals interpolation on one dimensional signals along specified dimension. More... | |
AFAPI af_err | af_approx1_uniform_v2 (af_array *out, const af_array in, const af_array pos, const int interp_dim, const double idx_start, const double idx_step, const af_interp_type method, const float off_grid) |
C Interface for the version of af_approx1_uniform that accepts a preallocated output array. More... | |
Interpolation across a single dimension.
Performs interpolation on data along a single dimension.
Interpolation is the process of computing for unknown values within a continuous range described by a discrete set of known values. These known values (in
) 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 array (pos
) contains the interpolating points (indices whose values we want to find) along a given dimension. 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 off_grid
, whose default value is 0.0.
The following image illustrates a simple example (known values represented by blue dots, unknown values represented by red dots):
Several interpolation methods are supported by approx1:
Unless specified, linear interpolation is performed by default. Refer to af_interp_type for more information about ArrayFire's interpolation types.
AFAPI af_err af_approx1 | ( | af_array * | out, |
const af_array | in, | ||
const af_array | pos, | ||
const af_interp_type | method, | ||
const float | off_grid | ||
) |
C Interface for signals interpolation on one dimensional signals.
[out] | out | is the interpolated array. |
[in] | in | is the multidimensional input array. Values assumed to lie uniformly spaced indices in the range of [0, n) , where n is the number of elements in the array. |
[in] | pos | positions of the interpolation points along the first dimension. |
[in] | method | is the interpolation method to be used. The following types (defined in enum af_interp_type) are supported: nearest neighbor, linear, and cubic. |
[in] | off_grid | is the default value for any indices outside the valid range of indices. |
AFAPI af_err af_approx1_uniform | ( | af_array * | out, |
const af_array | in, | ||
const af_array | pos, | ||
const int | interp_dim, | ||
const double | idx_start, | ||
const double | idx_step, | ||
const af_interp_type | method, | ||
const float | off_grid | ||
) |
C Interface for signals interpolation on one dimensional signals along specified dimension.
af_approx1_uniform() accepts the dimension to perform the interpolation along the input. It also accepts start and step values which define the uniform range of corresponding indices.
The following image illustrates what the range of indices corresponding to the input values look like if idx_start
and idx_step
are set to an arbitrary value of 10,
The blue dots represent indices whose values are known. The red dots represent indices whose values are unknown.
[out] | out | the interpolated array. |
[in] | in | is the multidimensional input array. Values lie on uniformly spaced indices determined by idx_start and idx_step . |
[in] | pos | positions of the interpolation points along interp_dim . |
[in] | interp_dim | is the dimension to perform interpolation across. |
[in] | idx_start | is the first index value along interp_dim . |
[in] | idx_step | is the uniform spacing value between subsequent indices along interp_dim . |
[in] | method | is the interpolation method to be used. The following types (defined in enum af_interp_type) are supported: nearest neighbor, linear, and cubic. |
[in] | off_grid | is the default value for any indices outside the valid range of indices. |
AFAPI af_err af_approx1_uniform_v2 | ( | af_array * | out, |
const af_array | in, | ||
const af_array | pos, | ||
const int | interp_dim, | ||
const double | idx_start, | ||
const double | idx_step, | ||
const af_interp_type | method, | ||
const float | off_grid | ||
) |
C Interface for the version of af_approx1_uniform that accepts a preallocated output array.
[in,out] | out | the interpolated array (can be preallocated). |
[in] | in | is the multidimensional input array. Values lie on uniformly spaced indices determined by idx_start and idx_step . |
[in] | pos | positions of the interpolation points along interp_dim . |
[in] | interp_dim | is the dimension to perform interpolation across. |
[in] | idx_start | is the first index value along interp_dim . |
[in] | idx_step | is the uniform spacing value between subsequent indices along interp_dim . |
[in] | method | is the interpolation method to be used. The following types (defined in enum af_interp_type) are supported: nearest neighbor, linear, and cubic. |
[in] | off_grid | is the default value for any indices outside the valid range of indices. |
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 af_array
to out
that has not been initialized will cause undefined behavior. AFAPI af_err af_approx1_v2 | ( | af_array * | out, |
const af_array | in, | ||
const af_array | pos, | ||
const af_interp_type | method, | ||
const float | off_grid | ||
) |
C Interface for the version of af_approx1 that accepts a preallocated output array.
[in,out] | out | is the interpolated array (can be preallocated). |
[in] | in | is the multidimensional input array. Values assumed to lie uniformly spaced indices in the range of [0, n) , where n is the number of elements in the array. |
[in] | pos | positions of the interpolation points along the first dimension. |
[in] | method | is the interpolation method to be used. The following types (defined in enum af_interp_type) are supported: nearest neighbor, linear, and cubic. |
[in] | off_grid | is the default value for any indices outside the valid range of indices. |
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 af_array
that has not been initialized to out
will cause undefined behavior. AFAPI array approx1 | ( | const array & | in, |
const array & | pos, | ||
const int | interp_dim, | ||
const double | idx_start, | ||
const double | idx_step, | ||
const interpType | method = AF_INTERP_LINEAR , |
||
const float | off_grid = 0.0f |
||
) |
C++ Interface for data interpolation on one-dimensional signals.
The following version of approx1() accepts the dimension to perform the interpolation along the input. It also accepts start and step values which define the uniform range of corresponding indices.
The following image illustrates what the range of indices corresponding to the input values look like if idx_start
and idx_step
are set to an arbitrary value of 10,
The blue dots represent indices whose values are known. The red dots represent indices whose values are unknown.
[in] | in | is the multidimensional input array. Values lie on uniformly spaced indices determined by idx_start and idx_step . |
[in] | pos | positions of the interpolation points along interp_dim . |
[in] | interp_dim | is the dimension to perform interpolation across. |
[in] | idx_start | is the first index value along interp_dim . |
[in] | idx_step | is the uniform spacing value between subsequent indices along interp_dim . |
[in] | method | is the interpolation method to be used. The following types (defined in enum af_interp_type) are supported: nearest neighbor, linear, and cubic. |
[in] | off_grid | is the default value for any indices outside the valid range of indices. |
The code sample below demonstrates usage:
AFAPI array approx1 | ( | const array & | in, |
const array & | pos, | ||
const interpType | method = AF_INTERP_LINEAR , |
||
const float | off_grid = 0.0f |
||
) |
C++ Interface for data interpolation on one-dimensional signals.
[in] | in | is the multidimensional input array. Values assumed to lie uniformly spaced indices in the range of [0, n) , where n is the number of elements in the array. |
[in] | pos | positions of the interpolation points along the first dimension. |
[in] | method | is the interpolation method to be used. The following types (defined in enum af_interp_type) are supported: nearest neighbor, linear, and cubic. |
[in] | off_grid | is the default value for any indices outside the valid range of indices. |
The code sample below demonstrates approx1()'s usage: