bug-gmp
[Top][All Lists]
Advanced

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

Bugs!!


From: Kaushik Chakraborty
Subject: Bugs!!
Date: Tue, 28 Nov 2000 23:19:16 +0530 (IST)

VERSION gmp-3.0

COMPILER
*************
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)

PLATFORM
************
Linux on Pentium III (i686)

PROGRAM
************
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <gmp.h>


main(int argc, char **argv)
{
mpz_t n;
mpz_t p;
mpz_init_set_str(n, argv[1], 10);
mpz_init_set_str(p, argv[2], 10);
printf("jacobi = %d\n", mpz_jacobi(n, p));
printf("legendre= %d\n",mpz_legendre(n, p));
}

************************************
(Simply call to jacobi & legendre functions)

OUTPUT
************************************

 ./test 0 0
Floating point exception (core dumped) [NO CHECK IS THERE FOR 0 CASE]

./test 0 1
jacobi = 1
legendre= 1         

 ./test 0 5
jacobi = 0
legendre= 0          

[HOW CAN BE THE ABOVE TWO DIFFERENT??]

./test 0 -5
jacobi = 0
legendre= 0          

BUT

 ./test 0 -3 

[HANGS!! CONTROL DOESNOT RETURN!!]

Actually the domain of values for which legendre & jacobi are defined is
not checked for correctness...
so the user has to be careful...
otherwise if he runs a long program
where one step is..
for primes in (0,1,2,.........)
it is difficult for him to figure out that the legendre or jacobi call is
making problem for 0,1, or say -ve values..

So, the legendre or jacobi source code may have some error checking code
in the beginning to avoid above situations..


Regards,




                                                Kaushik Chakraborty
                                                M.Tech Computational Science;
                                                SERC IISC BANGALORE;
                                                E-Mail:address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]