Click or drag to resize

MathUtilGetIntervalT Method (Double, T, FuncT, Double, Double)

Finds the interval in a vector where the argument lays in between. Assumes that the vector has at least two elements.

The vector must increase strictly monotonically. If argument is below the first value, 0 is returned. If argument is above last value, the length of the vector is returned.

The result is the interval number, one based, meaning that the arg fullfills:

(vector[res-1] < arg && arg <= vector[res])

Also the scale factor for interpolating is returned. For linear interpolation

arg = vector[res-1] + fraction*(vector[res]-vector[res-1])
or
arg = (1-fraction)*vector[res-1] + fraction*vector[res]

If arg exists in vector, the result is such that

arg = vector[res]
i.e., fraction is one (except when arg = vector[0], then res = 1 and fraction = 0).

Namespace:  DHI.Mike1D.Generic
Assembly:  DHI.Mike1D.Generic (in DHI.Mike1D.Generic.dll) Version: 19.0.0.0 (11.1.1.1111)
Syntax
public static int GetInterval<T>(
	double arg,
	T[] vector,
	Func<T, double> valueSelector,
	out double fraction
)

Parameters

arg
Type: SystemDouble
Value to look up in table
vector
Type: T
Vector, must be monoton increasing
valueSelector
Type: SystemFuncT, Double
Function that returns a double from type T
fraction
Type: SystemDouble
number with wich to scale the highest

Type Parameters

T

[Missing <typeparam name="T"/> documentation for "M:DHI.Mike1D.Generic.MathUtil.GetInterval``1(System.Double,``0[],System.Func{``0,System.Double},System.Double@)"]

Return Value

Type: Int32

[Missing <returns> documentation for "M:DHI.Mike1D.Generic.MathUtil.GetInterval``1(System.Double,``0[],System.Func{``0,System.Double},System.Double@)"]

See Also