ROCm-Device-Libs icon indicating copy to clipboard operation
ROCm-Device-Libs copied to clipboard

lgamma becomes inf for tiny negative values

Open VinInn opened this issue 3 years ago • 2 comments

for values that corresponds to x*x ~ 0 lgamma becomes inf for negative x.

__global__ void doit(double x) {
   auto y =log(x);
   auto z1= lgamma(x);
   auto z2= lgamma(-x);
   printf ("double %a %a %a %a\n",x,y,z1,z2);
}

produces double 0x1p-472 -0x1.472a5c30ead69p+8 0x1.472a5c30ead69p+8 0x1.472a5c30ead69p+8 double 0x1p-522 -0x1.69d2a4df51d11p+8 0x1.69d2a4df51d11p+8 inf

in my opinion this is due to the code at line 273 (actually line 276). (as you quote fo x<0 lgamma(x) = log(pi/(|xsin(pix)|)) - lgamma(-x); that for tiny x becomes -2log(-x) + log(-x) = -log(-x);

VinInn avatar Aug 04 '21 11:08 VinInn

Thanks for the report. We'll look into it.

b-sumner avatar Aug 04 '21 21:08 b-sumner

Thanks again for the report. This will be fixed in a future ROCm release.

b-sumner avatar Aug 05 '21 14:08 b-sumner

This has been fixed.

b-sumner avatar Mar 28 '23 01:03 b-sumner