Search code examples
macosieee-754blasintel-mklaccelerate-framework

Incoherence in DSCAL between MKL BLAS and Accelerate Framework BLAS in OSX


Under OSX with the OSX BLAS (Accelerate Framework). The following program

  real*8 :: x(2)
  real*8 :: zero=0.0d0
  x(1)=1.0d0
  x(2)=1/zero
  print*, x(2)*0.0d0
  call dscal(2,0.d0,x,1)
  print*, x
  end

gives me the following output

                   NaN
0.0000000000000000        0.0000000000000000

and the following output on OSX+MKL BLAS

                   NaN
0.0000000000000000                            NaN

i.e. it seems that the OSX BLAS DSCAL makes a short-circuit in the multiplication by 0 (we got X(2)=0 although 0*Inf=NaN should be obtained)

Is it a known bug/feature ?


Solution

  • This is neither a bug nor a feature. It is in the discretion of the implementer what the result of 0*NaN 0*Inf is. What is the purpose of the above anyway?