.Wavelet.General.findIndex

Information

This function searches the index of the input vector, u, according to x, so that:

If x is between u[k] and u[k+1], id1 = k and id2 = k+1.

If x is equal to u[k], id1 = id2 = k.

If x is smaller than all elements of u, id1 = id2 = 0.

If x is larger than all elements of u, id1 = id2 = size(u,1)+1.

The searching method is binary search, which has high efficiency for large searching spaces.

Interface

function findIndex
  input Real u[:] = {1, 2, 3, 3, 3, 4, 5, 6, 7, 8} "A monotone vector, in which u[k+1] >= u[k] for all k";
  input Real x = 3 "The value to be located in u";
  output Integer id1 "The largest index, id1, so that u[id1] <= x";
  output Integer id2 "The smallest index, id2, so that u[id2] >= x";
end findIndex;

Generated at 2024-12-21T19:25:56Z by OpenModelicaOpenModelica 1.24.3 using GenerateDoc.mos