FunctionBinary searches of an ordered table for the entry coming closest to a specified value
Syntax C/C++#include <VFstd.h>
ui VF_searchC( fVector X, ui size, float C, int mode );
C++ VecObj#include <OptiVec.h>
ui vector<T>::searchC( const T& C, int mode );
Pascal/Delphiuses VFstd;
function VF_searchC( X:fVector; size:UIntSize; C:Single; mode:Integer ):UIntSize;
CUDA function C/C++#include <cudaVFstd.h>
int cudaVF_searchC( ui *h_Ind, fVector d_X, ui size, float C, int mode );
int cusdVF_searchC( ui *d_Ind, fVector d_X, ui size, float *d_C, int mode );
ui VFcu_searchC( fVector h_X, ui size, float C, int mode );
CUDA function Pascal/Delphiuses VFstd;
function cudaVF_searchC( d_X:fVector; size:UIntSize; C:Single; mode:Integer ): IntBool;
function cusdVF_searchC( d_X:fVector; size:UIntSize; d_C:PSingle; mode:Integer ): IntBool;
function VFcu_searchC( h_X:fVector; size:UIntSize; C:Single; mode:Integer ):UIntSize;
DescriptionIn a binary search, the element of X is located that is closest to the value specified as C. X has to be an ordered table (either ascending or descending); if this condition is not fulfilled, the result will be wrong. If C is outside the range covered by X, the first or the last element of X is chosen, whichever is closer to C. If C is within the range of the table, three modes of the search are available:
mode = +1:find the next element greater than or equal to C
mode =   0:find the element closest to C; if two elements are within equal distance, choose the lower index
mode =  -1:find the next element less than or equal to C
Error handlingnone
Return valueindex of the element found.
See alsoVF_searchV,   VF_sort,   VF_polyinterpol

VectorLib Table of Contents  OptiVec home