Community
cancel
Showing results for 
Search instead for 
Did you mean: 
siddy
Beginner
73 Views

divide by zero

In matlab, I usually search for NaN's and set it to zero. In some cases a divide by zero is
unavoidable, like dividing 2 images. What is generally done in Ipp? I am trying to transcode some
Matlab routines to IPP based versions, and wanted to know what the experts use in such cases?

Thanks,
Sid.
0 Kudos
3 Replies
Naveen_G_Intel
Employee
73 Views

Hi,

As I know IPP will not check not a number (NaN), this library is specifically for performance oriented functions. Better to check before applying IPP functions in your application.

Please check these two documents, how IPP handles NaN and other arithmetic operations

http://software.intel.com/sites/products/documentation/hpc/composerxe/en-us/ippxe/ipp_manual_lnx/hh_...


http://software.intel.com/sites/products/documentation/hpc/composerxe/en-us/ippxe/ipp_manual_lnx/hh_...

Regards,

Naveen Gv

siddy
Beginner
73 Views

Hi Naveen,
Thanks. What I want is that I can set the divide by zeros to zero in the result per iteration. Since the image regions are zero, they are featureless and uninteresting for the application that I am implementing. If I can set them to zero, then I can ensure that these pixels will not be a part of my calculations, and further, not propogate due to an intended neighborhood operation in subsequent iterations.
In Matlab, I would just have done Image(find(isnan(Image))) = 0 and carried on. How can I do something similar in IPP ?

Based on the documentation, It seems that a hack could be to represent images as 16sc vectors, and divide, as with 16sc format, x/0 = 0. This seems to be the most vectorized way for me to do this, for now.

Thanks again,
Sid.
Naveen_G_Intel
Employee
73 Views

Hi,

Isnan() is not in IPP, you can use it from Intel compiler and add .

Another interesting way to find NaN in the below forum thread.

http://software.intel.com/en-us/forums/showpost.php?p=146248

Regards,

Naveen Gv

Reply