FindNearest

Finds table elements that are closest to the elements of the specified vector.

Syntax

IppStatus ippsFindNearest_16u(const Ipp16u* pVals, Ipp16u* pOutVals, int* pOutIndexes, int len, const Ipp16u *pTable, int tblLen);

Parameters

pVals

Pointer to the vector containing reference values.

pOutVals

Pointer to the output vector.

pOutIndexes

Pointer to the array that stores output indexes.

len

Number of elements in the input vector.

pTable

Pointer to the table for searching.

tblLen

Number of elements in the table.

Description

The function ippsFindNearest is declared in the ipps.h file. This function searches through the table pTable for elements which are closest to the reference elements of the input vector pVals. The resulting elements and their indexes are stored in pOutVals and pOutIndexes, respectively. The table elements must satisfy the condition pTable[n] pTable[n+1]. The function uses the following distance criterion for determining the table element closest to pVals[k] : min(|pVals[k] -pTable[n]|).

The example below shows how to use the function ippsFindNearest.

Return Values

ippStsNoErr

Indicates no error.

ippStsNullPtrErr

Indicates an error when at least one of the specified pointers is NULL.

ippStsSizeErr

Indicates an error when tblLen or len is less than or equal to 0.

Using the Function ippsFindNearest

Ipp16u pVals[] = { 12, 6, 78 };
Ipp16u pTable[] = { 1, 3, 5, 7, 18, 24, 35, 48 };
Ipp16u pOutVals[3];
int pOutIndexes[3];

		
ippsFindNearest_16u (pVals, pOutVals, pOutIndexes, 3, pTable, 8 );

		
Result
pOutVals = { 7, 5, 48 }
pOutIndexes = { 3, 2, 7 }

Submit feedback on this help topic

Copyright © 2000 - 2011, Intel Corporation. All rights reserved.