pnumpy icon indicating copy to clipboard operation
pnumpy copied to clipboard

np.exp outputs wrong results

Open Muuuh219 opened this issue 4 years ago • 1 comments

Hi everyone,

when I use np.exp(A) with the development version 2.0.23 where A is some matrix, the results are totally wrong.

Example: import numpy as np A = np.arange(9).reshape((3, 3)) print(np.exp(A)) array([[1.00000000e+00, 2.71828183e+00, 7.38905610e+00], [2.00855369e+01, 5.45981500e+01, 1.48413159e+02], [4.03428793e+02, 1.09663316e+03, 2.98095799e+03]])

import pnumpy as pn print(np.exp(A)) array([[ 8.98846567e+307, inf, -2.05514945e-308], [-5.58647539e-308, -1.51856145e-307, -4.12787801e-307], [-1.12207358e-306, -3.05011222e-306, 2.98095799e+003]])

To me, it kind of looks like the first two entries are garbage, the last one is in this case correct (but it's not for arange(12) and reshape((4,3))), and the rest of the wrong entries should be divided by -2.78134232e-309 which is approximately e times 1e-309. I hope you can help me!

Thanks in advance!

Muuuh219 avatar Dec 13 '21 10:12 Muuuh219

this affects log as well :

alphas = np.linspace(0.001,0.999,999) np.log(alphas)

change the length of the input, the last 3 are fine the rest of them are all garbage.

elliot-kulakow-ent avatar Jan 10 '23 23:01 elliot-kulakow-ent