mini-gmp and mpq
Bradley Lucier
lucier at math.purdue.edu
Tue Feb 27 21:39:30 UTC 2018
On 02/27/2018 01:43 PM, Marco Bodrato wrote:
> Ciao,
>
> Il Lun, 26 Febbraio 2018 9:03 pm, Bradley Lucier ha scritto:
>> 2. I stumbled on this issue when approximating the golden ratio $\phi$,
>> the root of $\phi^2-\phi-1=0$, using the naive iteration
>> $\phi_{n+1}=1+1/\phi_n$ with $\phi_1=1$, or, in Scheme:
>
> Ok, I tested the following code with the naïve implementation I sent to
> this list.
Thank you for running this test. I tried to run some things myself.
I downloaded the development gmp to get current mini-gmp.[ch] and used
mini-mpq.[ch] from your previous email. I couldn't get mini-mpq.c to
compiler, my error messages were:
gcc -o test mini-gmp.c mini-mpq.c test.c
mini-mpq.c: In function ‘__mpq_canonical_sign’:
mini-mpq.c:52:2: warning: implicit declaration of function ‘gmp_die’;
did you mean ‘mpq_div’? [-Wimplicit-function-declaration]
gmp_die("mpq: Fraction with zero denominator.");
^~~~~~~
mpq_div
mini-mpq.c: In function ‘__mpq_helper_canonicalize’:
mini-mpq.c:67:7: warning: implicit declaration of function ‘mpz_div_qr’;
did you mean ‘mpz_tdiv_qr’? [-Wimplicit-function-declaration]
mpz_div_qr (NUM(r), NULL, NUM(r), g, GMP_DIV_TRUNC);
^~~~~~~~~~
mpz_tdiv_qr
mini-mpq.c:67:44: error: ‘GMP_DIV_TRUNC’ undeclared (first use in this
function)
mpz_div_qr (NUM(r), NULL, NUM(r), g, GMP_DIV_TRUNC);
^~~~~~~~~~~~~
mini-mpq.c:67:44: note: each undeclared identifier is reported only once
for each function it appears in
mini-mpq.c: In function ‘mpz_set_q’:
mini-mpq.c:94:40: error: ‘GMP_DIV_TRUNC’ undeclared (first use in this
function)
mpz_div_qr (r, NULL, NUM(q), DEN(q), GMP_DIV_TRUNC);
^~~~~~~~~~~~~
mini-mpq.c: In function ‘mpq_set_ui’:
mini-mpq.c:107:3: warning: implicit declaration of function ‘assert’
[-Wimplicit-function-declaration]
assert (d != 0);
^~~~~~
mini-mpq.c: In function ‘mpq_cmp_si’:
mini-mpq.c:218:27: warning: implicit declaration of function
‘GMP_NEG_CAST’ [-Wimplicit-function-declaration]
unsigned long l_n = GMP_NEG_CAST (unsigned long, n);
^~~~~~~~~~~~
mini-mpq.c:218:41: error: expected expression before ‘unsigned’
unsigned long l_n = GMP_NEG_CAST (unsigned long, n);
^~~~~~~~
mini-mpq.c: In function ‘mpq_set_d’:
mini-mpq.c:338:26: error: ‘GMP_LIMB_HIGHBIT’ undeclared (first use in
this function)
B = 2.0 * (double) GMP_LIMB_HIGHBIT;
^~~~~~~~~~~~~~~~
mini-mpq.c:339:38: error: ‘GMP_LIMB_BITS’ undeclared (first use in this
function); did you mean ‘GMP_LIMB_HIGHBIT’?
for (e = 0; x != x + 0.5; e += GMP_LIMB_BITS)
^~~~~~~~~~~~~
GMP_LIMB_HIGHBIT
mini-mpq.c: In function ‘mpq_get_d’:
mini-mpq.c:361:27: error: ‘GMP_LIMB_BITS’ undeclared (first use in this
function)
ee = (ee + de - ne) / GMP_LIMB_BITS + 1;
^~~~~~~~~~~~~
mini-mpq.c:365:35: error: ‘GMP_DIV_TRUNC’ undeclared (first use in this
function)
mpz_div_qr (z, NULL, z, DEN(u), GMP_DIV_TRUNC);
^~~~~~~~~~~~~
mini-mpq.c:369:22: error: ‘GMP_LIMB_HIGHBIT’ undeclared (first use in
this function); did you mean ‘GMP_LIMB_BITS’?
B = 2.0 * (double) GMP_LIMB_HIGHBIT;
^~~~~~~~~~~~~~~~
GMP_LIMB_BITS
How should I fix this?
Brad
More information about the gmp-devel
mailing list