FunctionBinary search of an ordered table for the entries coming closest to the values specified as the elements of a vector
Syntax C/C++#include <VFstd.h>
void VF_searchV( uiVector Ind, fVector X, ui sizex, fVector Tab, ui sizetab, int mode );
C++ VecObj#include <OptiVec.h>
void vector<ui>::searchV( const vector<T>& X, const vector<T>& Tab, int mode );
Pascal/Delphiuses VFmath;
procedure VF_searchV( Ind:uiVector; X:fVector; sizex:UIntSize; Tab:fVector; sizetab:UIntSize; mode:Integer );
CUDA function C/C++#include <cudaVFstd.h>
int cudaVF_searchV( uiVector d_Ind, fVector d_X, ui sizex, fVector d_Tab, ui sizetab, int mode );
void VFcu_searchV( uiVector h_Ind, fVector h_X, ui sizex, fVector h_Tab, ui sizetab, int mode );
CUDA function Pascal/Delphiuses VFstd;
function cudaVF_searchV( d_Ind:uiVector; d_X:fVector; sizex:UIntSize; d_Tab:fVector; sizetab:UIntSize; mode:Integer ): IntBool;
procedure VFcu_searchV( h_Ind:uiVector; h_X:fVector; sizex:UIntSize; h_Tab:fVector; sizetab:UIntSize; mode:Integer );
DescriptionFor each element of X, the element of the table Tab is located that is closest to it. Tab has to be ordered (either ascending or descending); if this condition is not fulfilled, the results will be wrong.
If Xi is outside the range of the table, the first or the last element of the table is chosen, whichever is appropriate. Otherwise, three modes of the search are available:
mode = +1: find the next element greater than or equal to Xi
mode =   0:find the element closest to Xi; if two elements are within equal distance, choose the lower index
mode =  −1:find the next element less than or equal to Xi

sizex is the number of elements of X and of Ind, whereas sizetab denotes the number of elements of the table Tab.

Error handlingnone
Return valuenone
See alsoVF_searchC,   VF_indpick,   VF_sortind,   VF_polyinterpol

VectorLib Table of Contents  OptiVec home