Vectors.find(e, v); Vectors.find(e, v, eps=0);
The function call "Vectors.find(e, v)
" returns the
index of the first occurrence of input e in vector
v. The test of equality is performed by
"abs(e-v[i]) ≤ eps", where "eps" can be provided as third argument
of the function. Default is "eps = 0".
Real v[3] = {1, 2, 3}; Real e1 = 2; Real e2 = 3.01; Boolean result; algorithm result := Vectors.find(e1,v); // = 2 result := Vectors.find(e2,v); // = 0 result := Vectors.find(e2,v,eps=0.1); // = 3
function find extends Modelica.Icons.Function; input Real e "Search for e"; input Real v[:] "Real vector"; input Real eps(min = 0) = 0 "Element e is equal to a element v[i] of vector v if abs(e-v[i]) <= eps"; output Integer result "v[result] = e (first occurrence of e); result=0, if not found"; end find;