/* mpz_millerrabin(n,reps) -- An implementation of the probabilistic primality test found in Knuth's Seminumerical Algorithms book. If the function mpz_millerrabin() returns 0 then n is not prime. If it returns 1, then n is 'probably' prime. The probability of a false positive is (1/4)**reps, where reps is the number of internal passes of the probabilistic algorithm. Knuth indicates that 25 passes are reasonable. THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN FUTURE GNU MP RELEASES. Copyright 1991, 1993, 1994, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2005 Free Software Foundation, Inc. Contributed by John Amanatides. Copyright 2011, Brian Gladman This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU MP Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "mpir.h" #include "gmp-impl.h" // This function is obsolete 4/12/2011 int mpz_millerrabin (mpz_srcptr n, int reps) { gmp_randstate_t rstate; int is_prime; gmp_randinit_default(rstate); is_prime = mpz_miller_rabin(n, reps, rstate); gmp_randclear(rstate); return is_prime; }