/*-*- compile-command: "/usr/bin/gcc -c -o mainEK.gp.o -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -fPIC -I\"/usr/local/include\" mainEK.gp.c && /usr/bin/gcc -o mainEK.gp.so -bundle -undefined dynamic_lookup -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -fPIC mainEK.gp.o "; -*-*/ #include /* GP;install("my_init_mainEK","v","init_mainEK","./mainEK.gp.so"); GP;install("my_mainEK","vD0,G,","mainEK","./mainEK.gp.so"); */ void my_init_mainEK(void); void my_mainEK(GEN my_q); /*End of prototype*/ void my_init_mainEK(void) /* void */ { pari_sp ltop = avma; avma = ltop; return; } /* Copyright (C) 2019 Alessandro Languasco */ /**************** A. LANGUASCO ******************** ************* COMPUTATION OF THE EULER KRONECKER CONSTANTS MOD q(PRIME) *******/ /***************** Precomputations for the external C program ****************/ /* \p needed to decide the precision default (format, f) for the floating point */ void my_mainEK(GEN my_q) /* void */ { pari_sp ltop = avma; GEN my_g = gen_0, my_g1 = gen_0, my_minutes = gen_0, my_millisec = gen_0, my_seconds = gen_0, my_elaptimeprecomp = gen_0, my_prootfile = gen_0, my_f = pol_x(fetch_user_var("f")); default0("format", GENtostr_unquoted(my_f)); /* print numbers with floating point notation (not E notation) */ if ((gequal0(gisprime(my_q, 0))) || gequalgs(my_q, 2)) { pari_printf("****** error: q has to be an odd prime ******\n"); avma = ltop; return; } /* initialization */ my_prootfile = stoi(gp_fileopen("./primroot.res", "w")); gp_filewrite(gtos(my_prootfile), GENtostr_unquoted(my_q)); gettime(); pari_printf("Computing the primitive root for q = %Ps and saving on file\n", my_q); my_g1 = znprimroot(my_q); my_g = lift(my_g1); my_elaptimeprecomp = stoi(gettime()); gp_filewrite(gtos(my_prootfile), GENtostr_unquoted(my_g)); gp_fileclose(gtos(my_prootfile)); /* print computation time */ my_seconds = gmodgs(gfloor(gdivgs(my_elaptimeprecomp, 1000)), 60); my_minutes = gfloor(gdivgs(my_elaptimeprecomp, 60000)); my_millisec = gsub(gsub(my_elaptimeprecomp, gmulgs(my_minutes, 60000)), gmulgs(my_seconds, 1000)); /*print(elaptimeprecomp); */ pari_printf("Primitive root generation time: %Ps min, %Ps sec, %Ps millisec\n", my_minutes, my_seconds, my_millisec); pari_printf("******************************************\n"); pari_printf("Now you can call the precomputation programs\n"); pari_printf("******************************************\n"); avma = ltop; return; }