[ILNumerics Interpolation Toolbox]
Namespace: ILNumerics.Toolboxes
Assembly: ILNumerics.Toolboxes.Interpolation (in ILNumerics.Toolboxes.Interpolation.dll) Version: 5.5.0.0 (5.5.7503.3146)
public NearestInterpolatorComplex( InArray<complex> V, InArray<double> X, Nullable<complex> outOfRangeValues = null, InterpolationMethod method = InterpolationMethod.nearest )
Parameters
- V
- Type: ILNumericsInArraycomplex
Given values. Vector of length m or n-dimensional array of size [m, l1, l2, ..., l_(n-1)]. - X
- Type: ILNumericsInArrayDouble
Strictly monotonically increasing x coordinates. Vector or n-dimensional array with m elements. - outOfRangeValues (Optional)
- Type: SystemNullablecomplex
[Optional] Value to be assigned to all interpolation results outside of the domain specified by X. Default: (null) extrapolate. - method (Optional)
- Type: ILNumerics.ToolboxesInterpolationMethod
[Optional] Next, Previous or Nearest neighbor interpolation method. Nearest is default.
Exception | Condition |
---|---|
ArgumentException | If arguments length X or V less than 2 elements |
ArgumentException | If argument X not ascending and distinct |
ArgumentException | If arguments X or V are specified not as vector or array. |
ArgumentException | If argument method is specified not as nearest, next or previous. |
ArgumentNullException | If any of input parameters are NULL |
ArgumentException | If arguments X or V have different size. |
For an input vector V, NearestInterpolatorDouble prepares a 1-dimensional, linear interpolation object, for the given set of m measured values. Subsequently, interpolated values can be derived by help of this object efficiently. After all values have been acquired, the object should be released in order to free its resources. Commonly, in .NET, the utiliziation of NearestInterpolatorDouble inside of a using directive is recommended.
Once created object could be reused to get interpolated values using Apply() method.
- nearest - Nearest neighbor interpolation returns the corresponding sample point from V which is closest to a new query point. This method needs little computing ressources.
- previous - returns the sample point left from a new query point; corresponds to the floor() function. For query points outside of the specified domain the nearest available sample point is returned. At least 2 samples are required in each dimension. This function requires little resources and performs at about the same speed as nearest.
- next - returns the sample point from V which is right from a new query point; corresponds to the ceil() function. If no 'next' sample is available (for extrapolating query points) the sample at the right edge is returned. At least 2 samples are required in each dimension. This function needs little resources and performs with about the same speed as nearest and previous.
If V is provided as a matrix or a n-dim array, the columns of V are considered as m individual sets of measurements, all at the same positions as determined by X. It performs interpolation through the columns of sample values V. Each element requested in Apply(Xn) method will be interpolated for each column of V. In this case m becomes: V.S.NumberOfElements / V.S[0].
If V is defined as vector row or column with size m, number of elements X must be m
[ILNumerics Interpolation Toolbox]
// Define some sample points as a function: f(x) = sin(x); Array<complex> X = linspace<complex>(-pi, pi, 10); Array<complex> V = sin(X); // Create Interpolator Object using (var interp = new NearestInterpolatorDouble(V, X, method:InterpolationMethod.next)) { // Get some random scalar values complex val1 = (complex)interp.Apply(0.024); complex val2 = (complex)interp.Apply(-0.21); // Get 10 linear spaced values defined on range (-0.5, 1.25) Array<complex> valRange = interp.Apply(linspace<complex>(-0.5, 1.25, 10)); // Get 30 interpolated values using Xn query points defined as array[3 x 2 x 5] Array<complex> Xn = counter(0.0, 0.1, 3, 2, 5); Array<complex> Vn = interp.Apply(Xn); }