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);tocElapsed time is 0.192480 seconds.>> A=inf(3e3); tic;fft2(A);tocElapsed time is 0.200329 seconds.>> A=rand(3e3); tic;fft2(A);tocElapsed 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?
Best Answer