Interpolation across a single dimension. More...
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...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):
approx1() using idx_start=0.0, idx_step=1.0
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.
◆ af_approx1()C Interface for signals interpolation on one dimensional signals.
[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.
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,
approx1() using idx_start=10.0, idx_step=10.0
The blue dots represent indices whose values are known. The red dots represent indices whose values are unknown.
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.
C Interface for the version of af_approx1_uniform that accepts a preallocated output array.
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.
C Interface for the version of af_approx1 that accepts a preallocated output array.
[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.
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,
approx1() using idx_start=10.0, idx_step=10.0
The blue dots represent indices whose values are known. The red dots represent indices whose values are unknown.
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:
float input_vals[9] = {10.0f, 20.0f, 30.0f, 40.0f, 50.0f,
60.0f, 70.0f, 80.0f, 90.0f};
array in(dim4(3, 3), input_vals);
float pv[5] = {0.0f, 0.5, 1.0f, 1.5f, 2.0f};
array pos(dim4(5, 1), pv);
const double idx_start = 0.0;
const double idx_step = 1.0;
int interp_dim = 0;
array col_major_interp =
approx1(in, pos, interp_dim, idx_start, idx_step);
interp_dim = 1;
array row_major_interp =
AFAPI array transpose(const array &in, const bool conjugate=false)
C++ Interface to transpose a matrix.
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.
◆ approx1() [2/2]C++ Interface for data interpolation on one-dimensional signals.
[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:
float input_vals[3] = {10.0f, 20.0f, 30.0f};
array in(dim4(3, 1), input_vals);
float pv[5] = {0.0f, 0.5, 1.0f, 1.5, 2.0f};
array pos(dim4(5, 1), pv);
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4