Are Infs still faster than NaNs?
3 views (last 30 days)
Show older comments
Years ago, I was advised that the processing of Inf elements was much faster than the processing of NaN elements, and was advised to use Infs instead of NaNs unless there was a compelling reason. When I replaced NaNs with Infs, I did indeed find that Infs crunched much faster. In recent days, though (R2013), I'm finding that the playing field is pretty even among Infs, NaNs, and finite array elements, e.g.,
>> A=nan(3e3); tic;fft2(A);toc
Elapsed time is 0.192480 seconds.
>> A=inf(3e3); tic;fft2(A);toc
Elapsed time is 0.200329 seconds.
>> A=rand(3e3); tic;fft2(A);toc
Elapsed time is 0.211940 seconds.
Was I hallucinating back then, or has there been an improvement in the hardware/software that handles NaNs and Infs?
2 Comments
dpb
on 5 Jan 2014
Don't recall ever hearing it; could be.
Earliest version installed here is R12; essentially same result as yours above with it (altho precedes time at which nan and inf had arguments). So, if were so, would seem to have been even earlier.
More Answers (1)
Jan
on 5 Jan 2014
It depends on the processor. AMD CPUs and SSE engines of Intel cpus process NaNs efficiently.
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!