Closed
Description
E AssertionError: out=(4+512128000j), but should be roughly x²=512128008j [square()]
E x=(16002+16002j)
E assert False
E + where False = isclose(4.0, 0.0, 3.4028234663852886e+38)
E + where 4.0 = (4+512128000j).real
E + and 0.0 = 512128008j.real
E Falsifying example: test_square(
E x=Array(16002.+16002.j, dtype=complex64),
E )
I haven't investigated further other than to confirm that it does indeed do that
>>> np.square(np.asarray(16002.+16002.j, dtype=np.complex64))
(4+512128000j)
I don't know if this is a bug in NumPy or just an expected numerical inaccuracy that we shouldn't b testing. I suspect the latter. Note that the relative error is around 1e-8
>>> abs(512128008j - (4+512128000j))/abs(512128008j)
1.7464914572684647e-08
OTOH, PyTorch does give a purely imaginary answer as expected:
>>> torch.square(torch.asarray(16002.+16002.j, dtype=torch.complex64))
tensor(0.+5.1213e+08j)
Metadata
Metadata
Assignees
Labels
No labels