Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

sing of 32 float

needle__brosh
Beginner
272 Views

Hi, 

I need to get the sign value of each element in a vector.

is there a simple way to do so. 

exp: 

input: (32float)  1.26 0 63.54 -8.3 -1.2 1.6 5 -9 ....

output:   1    1  1   -1 -1 1 1 -1 

 

thanks 

0 Kudos
3 Replies
Chao_Y_Intel
Moderator
272 Views

Hello, 

Can you check the ippsThreshold_LTValGTVal  function?

Thanks,
Chao

0 Kudos
Zhen_Z_Intel
Employee
272 Views

Dear customer,

You could use IPP threshold_LT & GT function, for instance:

ippsThreshold_LT_32s(pSrc, pDst, len, -1); //replace all value with -1, if <-1
ippsThreshold_GT_32s(pSrc, pDst, len, 1); //otherwise set to 1

Hope it would be useful to you.

Best regards,
Fiona

0 Kudos
Igor_A_Intel
Employee
272 Views

Hi,

another, may be the fastest, method is to use ippsRShiftC functions - just cast pointers as (Ipp32s*) and shift on 31:

IPPAPI(IppStatus, ippsRShiftC_32s,   (const Ipp32s* pSrc, int val, Ipp32s* pDst,    int len))

and then in-place ippsOrC with 1 (cast pointers as Ipp32u):

IPPAPI(IppStatus, ippsOrC_32u_I, (                    Ipp32u val, Ipp32u* pSrcDst, int len))

regards, Igor

0 Kudos
Reply