jsoftware / jsource

J engine source mirror
Other
645 stars 91 forks source link

computation idioms (+/!.0) and (+/@:*"1!.0) throw NaN error #184

Open jip opened 4 months ago

jip commented 4 months ago
   JVERSION
Engine: j9.6.0-beta1/j64/linux
Build: commercial/2023-12-27T20:27:14/clang-11-0-0/SLEEF=1
Library: 9.6.1
Qt IDE: 2.5.2/5.12.8(5.15.8)
OS Ver: openSUSE Leap 15.5 5.14.21-150500.55.49-default
Platform: Linux 64
Installer: j9.6 install
InstallPath: /home/user/j9.6.0-beta1_j64avx2
Contact: www.jsoftware.com

   FP_OVFL=. (2 - 2^_52) * 2 ^ 1023  NB. max normalized positive number
   2 (3!:3) FP_OVFL
e200000000000000
0000000000000008
0000000000000001
0000000000000000
7fefffffffffffff

   1 0 (+/@:*) 0 , FP_OVFL  NB. inner product with floating precision
0
   1 0 (+/@:*"1!.0) 0 , FP_OVFL  NB. inner product with floating16 precision
|NaN error, executing dyad +/@:*"1
|you have calculated the equivalent of _-_ or _%_
|   1 0    (+/@:*"1!.0)0,FP_OVFL

I've expected the last sentence succeed just like its predecessor.

jip commented 4 months ago

One more example:

   (+/!.0) _ 0
_
   (+/!.0) _ 0 _
|NaN error, executing monad +/
|you have calculated the equivalent of _-_ or _%_
|       (+/!.0)_ 0 _
LdBeth commented 5 days ago

They use fundamentally different algorithms so it is really not a surprise when their behavior does not match