flintlib / arb

Arb has been merged into FLINT -- use https://github.com/flintlib/flint/ instead
http://arblib.org/
GNU Lesser General Public License v2.1
455 stars 137 forks source link

failures on windows #312

Closed tthsqe12 closed 4 years ago

tthsqe12 commented 4 years ago

There are many failures on my windows box. Here are two of them. The setup is mingw64, msys64, gmp 6.2, latest flint, and latest arb. The flint test code runs fine.

The argument to arccos is very small, so the answer should be close to pi/2, but it is instead about 0.9934. fails from t-acos.c:

----------- iter: 195, prec1 = 153 ----------
a = (104748499452676539840422070298483132523278200365431360983353623623521707269547686303243966877636692228338181944426021220913036872055943703685673496084479 * 2^-77371179101268452197728760) +/- (536870976 * 2^-77371179101268452197728895)
b = (8967661732516052580829697655748654547762021531 * 2^-152) +/- (805306369 * 2^-181)
c = (9628953465686786407419986994252084419659888117768598501 * 2^-182) +/- (805306369 * 2^-211)
c = (1172875221225 * 2^-192) +/- (806354946 * 2^-181)
----------- iter: 196, prec1 = 36 ----------
a = (1 * 2^-4294967297) +/- (536870912 * 2^-4294968154)
b = (17067273311 * 2^-34) +/- (536870913 * 2^-65)
c = (36651690351360295937 * 2^-65) +/- (536870913 * 2^-95)
c = (37507476239 * 2^-36) +/- (997589020 * 2^-65)
FAIL: functional equation

a = (1 * 2^-4294967297) +/- (536870912 * 2^-4294968154)

b = (17067273311 * 2^-34) +/- (536870913 * 2^-65)

c = (37507476239 * 2^-36) +/- (997589020 * 2^-65)

We also had some challenges with integration. In general the output of the integrator is just way too small. Luckily the test code also fails:

$ make check MOD=acb_calc
make[1]: Entering directory '/c/Users/lap/Desktop/git/arb-master'
make[1]: Nothing to be done for 'shared'.
make[1]: Leaving directory '/c/Users/lap/Desktop/git/arb-master'
make[1]: Entering directory '/c/Users/lap/Desktop/git/arb-master/acb_calc'
    CC   ../build/acb_calc/test/t-cauchy_bound.exe
    CC   ../build/acb_calc/test/t-integrate.exe
    CC   ../build/acb_calc/test/t-integrate_taylor.exe
cauchy_bound....PASS
integrate....FAIL! (iter = 3)
integral = 6, prec = 85, goal = 154
a = 1.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
b = 0
res = [-5.3988510640309e-34 +/- 2.87e-48]

ans = [-0.21080273550054927737564325 +/- 9.35e-27]

Not too important, but here is where I modified t-acos.c with prints:

    /* check large arguments */
    for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
    {
        arb_t a, b, c;
        slong prec1, prec2;

        prec1 = 2 + n_randint(state, 1000);
        prec2 = prec1 + 30;

flint_printf("----------- iter: %wd, prec1 = %wd ----------\n", iter, prec1);

        arb_init(a);
        arb_init(b);
        arb_init(c);

        arb_randtest_precise(a, state, 1 + n_randint(state, 1000), 100);

flint_printf("a = "); arb_print(a); flint_printf("\n");

        arb_acos(b, a, prec1);
flint_printf("b = "); arb_print(b); flint_printf("\n");

        arb_acos(c, a, prec2);
flint_printf("c = "); arb_print(c); flint_printf("\n");

        if (!arb_overlaps(b, c))
        {
            flint_printf("FAIL: overlap\n\n");
            flint_printf("a = "); arb_print(a); flint_printf("\n\n");
            flint_printf("b = "); arb_print(b); flint_printf("\n\n");
            flint_printf("c = "); arb_print(c); flint_printf("\n\n");
            flint_abort();
        }

        /* check sin(asin(x)) = x */
        arb_cos(c, b, prec1);

flint_printf("c = "); arb_print(c); flint_printf("\n");

        if (!arb_contains(c, a))
        {
            flint_printf("FAIL: functional equation\n\n");
            flint_printf("a = "); arb_print(a); flint_printf("\n\n");
            flint_printf("b = "); arb_print(b); flint_printf("\n\n");
            flint_printf("c = "); arb_print(c); flint_printf("\n\n");
            flint_abort();
        }

        arb_clear(a);
        arb_clear(b);
        arb_clear(c);
    }
duhadler commented 4 years ago

As a follow-up: On msys2, mingw64, 32 bit, all tests pass, except

arf/test/t-dump_file.c arb/test/t-dump_file.c mag/test/t-dump_file.c

The reason these tests fail is that the directive

if !defined(_MSC_VER)

does not cover mingw64, but for example

if !defined(_MSC_VER) && !defined( MINGW32)

would (both 32 and 64 bit). By the way, and contrary to what the comments in the source code of these files suggest, tmpfile() is not "broken" on Windows: its just that apparently MS does not like users without admin rights to write individual files into the root directory. Using tmpnam(NULL) instead, which on Windows writes into the current work (temp) directory of the local user, would fix this. "Its not a bug, its a feature ... :-)"

There are, however, lots of additional test failures on mingw64 64 bit. I have not found a particular pattern yet, but it seems possible that the "a long is 32 bit on 64 bit Windows" thing is back.

fredrik-johansson commented 4 years ago

tmpfile() is not "broken" on Windows: its just that apparently MS does not like users without admin rights to write individual files into the root directory.

Yes, it's completely broken design by MS to make tmpfile() write into the root directory. :-)

There are, however, lots of additional test failures on mingw64 64 bit. I have not found a particular pattern yet, but it seems possible that the "a long is 32 bit on 64 bit Windows" thing is back.

Perhaps. I don't think long is used anywhere, but it could be something indirect.

tthsqe12 commented 4 years ago

There is a bug in _arf_add_mpn. You pass an slong shift into a possibly 32 bit mp_bitcnt_t shift. You can thank the gmp folks for this nonsense. Thats why we have flint_bitcnt_t now.

fredrik-johansson commented 4 years ago

Ah, that could certainly be an issue. I just batch replaced mp_bitcnt_t -> flint_bitcnt_t; let's see if that fixes anything.

duhadler commented 4 years ago

Well, this is a big improvement, at least on my system. Now most tests pass on mingw64 64 bit, except for the three test cases mentioned above (for the same reasons), the integration failure as pointed out by tthsqe12 (same findings), and the following failures:

C:\msys64\home\MP64\arb-2.18.0\build\acb_elliptic\test>t-pi.exe
pi....FAIL: overlap (testdata)
prec = 32, accuracy = 59
n = (2 + 0j)  +/-  (0, 0j)
m = (0 + 1j)  +/-  (0, 0j)
r1 = (1.53434798224551594567413581593 + 0.243360727582369938616808913157j)  +/-  (9.42e-19, 2.14e-19j)
r2 = (0.534863235492801347703561987146 - 1.70021219074857787845189704967j)  +/-  (5.35e-15, 1.7e-14j)

C:\msys64\home\MP64\arb-2.18.0\build\acb_elliptic\test>t-pi_inc.exe
pi_inc....FAIL: overlap
times_pi = 0
z1 = (-0.5 - 0.999999999999999999972894946092j)  +/-  (0, 1.34e-138j)
z2 = (-0.5 - 0.999999999999999999972894946092j)  +/-  (0, 1.34e-138j)
n = (-0.249938964845568985947644814233 - 0.4999999999927382532405317761j)  +/-  (2.45e-91, 7.85e-90j)
m = (-0.999999970197678056392203284168 - 0.6237883754074573516845703125j)  +/-  (3e-95, 0j)
k = 0
r1 = (-0.900517890264439497250299272348 - 0.891196118936044910354114622628j)  +/-  (1.35e-28, 1.64e-28j)
r2 = (-1.5716537497937679290771484375 - 0.96314419806003570556640625j)  +/-  (0.0675, 0.0669j)
r3 = (-1.5716537497937679290771484375 - 0.96314419806003570556640625j)  +/-  (0.0675, 0.0669j)

C:\msys64\home\MP64\arb-2.18.0\build\acb_elliptic\test>t-rj.exe
j....FAIL: overlap (testdata rj)
rec = 64, accuracy = 61
 = (2 + 0j)  +/-  (0, 0j)
 = (3 + 0j)  +/-  (0, 0j)
 = (4 + 0j)  +/-  (0, 0j)
 = (-1 + 1j)  +/-  (0, 0j)
1 = (0.0882312305296406993834388253484 - 0.0570191741220224007493462461266j)  +/-  (1.36e-20, 6.86e-21j)
2 = (0.136139458277705349686925728747 - 0.382075616244271665244980340503j)  +/-  (1.36e-15, 3.82e-15j)

C:\msys64\home\MP64\arb-2.18.0\build\acb_dirichlet\test>t-stieltjes.exe
stieltjes....FAIL: overlap
iter = 1, alg1 = 1, alg2 = 2
n = 0
a = [-1.999999999999999999999999999999999999999999999999999665904411238475544232432941606064765148100389987 +/- 1.32e-100] + [-0.9999999999999999991326382620242182242683084100855782675039340443858223677459605427397804078282206319 +/- 2.73e-101]*I
b1 = [-0.90015281706279 +/- 3.46e-15] + [1.70164041920346 +/- 4.21e-15]*I
b2 = [-0.9946503206224769771554494437795414936082744 +/- 9.48e-44] + [2.776674047468581174495740555679013165428277 +/- 6.40e-43]*I

C:\msys64\home\MP64\arb-2.18.0\build\arb_hypgeom\test>t-legendre_p_ui.exe
legendre_p_ui....FAIL: overlap (2)
n = 684
x = [0.49999999999999999999999999999999999999999998883340 +/- 2.87e-51]
r1 = [6.1504054991891532865258460977090298045950947752189e+789 +/- 4.30e+739]
r2 = [-1.3010635330123368417316718905243287383830762243063e+792 +/- 6.63e+741]
r3 = [0.0084845823042582248086977816432045832772548629800928 +/- 4.70e-53]
s  = [1.4266047511100184668110437396100095815603906180675e+789 +/- 1.80e+739]
t  = [3.0752027495945766432629230488545149022975473189304e+789 +/- 2.90e+739]

C:\msys64\home\MP64\arb-2.18.0\build\arb_hypgeom\test>t-legendre_p_ui_deriv_bound.exe
legendre_p_ui_deriv_bound....FAIL: first derivative
n = 54
x = [0.12499999254941940307619829308081341232136620561510 +/- 2.99e-51]
z = [1.758054280168448486e+35 +/- 5.57e+16]
m1 = 11.8798181414604

C:\msys64\home\MP64\arb-2.18.0\build\arb_hypgeom\test>t-legendre_p_ui_one.exe
legendre_p_ui_one....FAIL: overlap
n = 24, K = 200
x = [0.96875000745057349149647052404862684594751346731027 +/- 4.89e-51]
r1 = [0.18870370657196201230442873356735436249386609603507 +/- 2.60e-51]
r2 = [209362637.31145399266419658355000010728407353599798 +/- 4.19e-42]

C:\msys64\home\MP64\arb-2.18.0\build\arb_hypgeom\test>t-legendre_p_ui_rec.exe
legendre_p_ui_rec....FAIL: overlap
n = 31
x = [0.0039062499999999999999999999999999999529802259671085 +/- 3.21e-55]
r1 = [-99260579421728.853425668581800411234123293186582741 +/- 1.81e-37]
r2 = [-0.017449730683715830145817593783157654693061406986273 +/- 4.79e-52]
r3 = [-125880012398355.26406911898920082436368533336062002 +/- 2.31e-36]
r4 = [-4.4446142320535512201226766715325829778534068604172 +/- 8.89e-52]

C:\msys64\home\MP64\arb-2.18.0\build\arb_hypgeom\test>t-legendre_p_ui_root.exe
legendre_p_ui_root....FAIL: polynomial containment
n = 100, prec = 98
pol = [(0.0877419288599054371121180704787 +/- 7.6917e-29), etc {too long to list}
pol2 = 101  12611418068195524166851562157/158456325028528675187087900672   etc {too long to list}

C:\msys64\home\MP64\arb-2.18.0\build\arb_hypgeom\test>t-legendre_p_ui_zero.exe
legendre_p_ui_zero....FAIL: overlap
n = 236, K = 72
x = [0.12499999999999999999999999999999961481401112255557 +/- 3.71e-51]
r1 = [-0.01060492158396878099823363491977 +/- 4.34e-33]
r2 = [-2.4857373555579576219219807537368259175603246109586e+224 +/- 3.58e+173]

All other tests pass!

By the way, I just became aware that Brian Gladman has created a beautiful fork of ARB fully taking advantage of all features of Visual Studio, matching his fork of FLINT. Maybe this could be included in the ARB documentation, just as it has been included in the FLINT documentation?

fredrik-johansson commented 4 years ago

I fixed some instances of mpz_foo_ui functions where we need to use the flint_mpz_foo_ui versions.

fredrik-johansson commented 4 years ago

No, I don't have a Windows box. Tests seem to pass on Appveyor now, so I hope that there are actually no remaining issues for you to fix :-)

tthsqe12 commented 4 years ago

Ok. I will give it a spin later just for fun.

tthsqe12 commented 4 years ago

Everything looks good. Both the test code and my code.