hermann on Tue, 16 Jul 2024 20:33:55 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: void mpz_set_GEN(mpz_ptr z, GEN x) and GEN mpz_get_GEN(mpz_srcptr z)


On 2023-06-19 21:56, hermann@stamm-wilbrandt.de wrote:
On 2023-06-19 10:04, Andreas Enge wrote:
you may be interested in the PariTwine project:
   https://www.multiprecision.org/paritwine/home.html
which provides a link to GMP, but also MPFR, MPC, FLINT/ARB and CMH.
There are conversion functions and helpers to call functions of the
other libraries from GP scripts.

Thanks, that code looks like the posting I pointed to.
...
The basic difference of pointed to posting and paritwine conversion code
https://github.com/Hermann-SW/RSA_numbers_factored/blob/main/c%2B%2B/sqrtm1.smallest_known_1million_digit_prime.cc

to new version of based on Karim's code is that the first two create a
copy using realloc2(), while Karim's code does a shallow copy:
https://github.com/Hermann-SW/RSA_numbers_factored/blob/main/c%2B%2B/sqrtm1.smallest_known_1million_digit_prime.cc#L30

Today I found another small difference, this time in Karim's mpz2GEN(mpz_t X).
That function had a bug in processing X being 0.
I noticed this today when working with cgal4gp repo, this is the fix commit:
https://github.com/Hermann-SW/cgal4gp/commit/3b519d4e6e245188f3319059fec6f4602cd86d79


While working with cgal4gp "get_all_build_directions()"
https://github.com/Hermann-SW/cgal4gp?tab=readme-ov-file#ternary-quadratic-form-width

I noticed that too many directions might get returned and created new issue:
https://github.com/CGAL/cgal/issues/8358

Nice how easy this can be corrected in GP with "Set(...)" workaround:

        print("optimal solutions: ",get_number_of_optimal_solutions());
        get_all_build_directions(dir);
print("workaround(all build directions): ", Set([d/gcd(d)*if(d[1]<0,-1,1) | d<-dir]));

The output shows discrepancy between CGAL "get_number_of_optimal_solutions()" and "Set([d/gcd(d)*if(d[1]<0,-1,1) | d<-dir])" workaround for unique directions:

optimal solutions: 8
workaround(all build directions): [[10, 112, -5]]


Regards,

Hermann.