Disable NaN and Inf

Pelle Månsson pelle.mansson at gmail.com
Sat Feb 6 01:13:04 PST 2010


On 02/06/2010 09:16 AM, Andrei Alexandrescu wrote:
> Jonathan Crapuchettes wrote:
>> I would like to divide one array by another using the slice syntax so
>> that I can benefit from the vectorized operation, but I am running
>> into a problem. Some of the numbers is my denominator array are 0,
>> producing NaNs and Infs in the result.
>>
>> My question is: Is there a way to force 0/0 and x/0 to result in 0?
>>
>> Thank you,
>> JC
>
> I don't know of a way. You may want to try first running a loop
> replacing 0 with inf throughout the denominator array. Then run
> vectorized division; any non-inf divided by inf yields 0.
>
> Andrei
I would not recommend this unless you use the denominator array to 
divide several other arrays.

A single pass will be faster and more clear, I think.



More information about the Digitalmars-d mailing list