Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

math/ulp: data interval #29

Open
chenxuqiang opened this issue Jun 5, 2020 · 1 comment
Open

math/ulp: data interval #29

chenxuqiang opened this issue Jun 5, 2020 · 1 comment

Comments

@chenxuqiang
Copy link

I have a question. In the ulp program, we formulate the data interval [-0.5, 1.0] for the program, but the value of the data in the program will exceed this interval, as shown below:
#./ulp -e 0.5 -r n -f atan2 -0.5 1.0 x -0.5 1.0 1000
atan2(-758032640005901072196627021490030084817733292767880968699295757878579464642193680699563542925245279209783296.0000000000000000, -98853056707272881102131689990518198269559039123449359701054226822449015051621586121797799515563919741145680595210207232.0000000000000000) got -98853056707272881102131689990518198269559039123449359701054226822449015051621586121797799515563919741145680595210207232.0000000000000000, want -3.1415926535821250 tail = +0.149384, ulp err -2.22597e+134
Because g->len = b-a gets a very large number, g->start + randn(g->len) is an uncontrolled number.
This is no problem in the interval [0.5, 1.0], because b-a gets the number of machines in [a, b]. But it is not applicable for the interval [-0.5, 1.0].

@nsz-arm
Copy link
Contributor

nsz-arm commented Jun 8, 2020

the ulp program has several limitations, one is that the intervals you pass to it must be in representation order (e.g. -1.0 -2.0 is a valid interval, but -2.0 -1.0 is not, even though as real number interval the latter makes more sense, i think i should change the code to print an error message for wrong order, i will keep this bug open until i fix that).

note that the sampling is done based on representation i.e. 0.5 -0.5 interval means

0.5 .. 2 .. 1234.5 .. 0x1p1023 .. inf .. nan ... -0 .. -0x1p-1000 .. -0.25 .. -0.5

this is important to keep in mind when using the tool, e.g. 0 0.5 interval does not mean uniform sampling of the real number interval but uniform sampling of all float numbers in that interval so it will sample just as many numbers between 0x1p-100 and 0x1p-99 as between 0.25 and 0.5.

this is not exactly intuitive, but originally the tool was only working with representations as input (i.e. 0 0xffffffff meant all numers for single precision floats and 0x7f800001 0x7fffffff meant all nans with positive sign, this still works and useful for testing nans).

and yes this can be annoying when you want to sample both positive and negative numbers, currently you have to use separate calls for that i.e.

#./ulp -e 0.5 -r n -f atan2 -0x1p-20 -0.5 x -0x1p-20 -0.5 1000
#./ulp -e 0.5 -r n -f atan2 -0x1p-20 -0.5 x +0x1p-20 +1.0 1000
#./ulp -e 0.5 -r n -f atan2 +0x1p-20 +1.0 x -0x1p-20 -0.5 1000
#./ulp -e 0.5 -r n -f atan2 +0x1p-20 +1.0 x +0x1p-20 +1.0 1000

if you have an idea how to usefully do sampling of real intervals (preferred syntax and semantics) let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants