version 1.1.1.2, 2000/09/09 14:12:53 |
version 1.1.1.3, 2003/08/25 16:06:33 |
|
|
If X has an inverse, return non-zero and store inverse in INVERSE, |
If X has an inverse, return non-zero and store inverse in INVERSE, |
otherwise, return 0 and put garbage in INVERSE. |
otherwise, return 0 and put garbage in INVERSE. |
|
|
Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. |
Copyright 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. |
|
|
This file is part of the GNU MP Library. |
This file is part of the GNU MP Library. |
|
|
Line 25 MA 02111-1307, USA. */ |
|
Line 25 MA 02111-1307, USA. */ |
|
#include "gmp-impl.h" |
#include "gmp-impl.h" |
|
|
int |
int |
#if __STDC__ |
|
mpz_invert (mpz_ptr inverse, mpz_srcptr x, mpz_srcptr n) |
mpz_invert (mpz_ptr inverse, mpz_srcptr x, mpz_srcptr n) |
#else |
|
mpz_invert (inverse, x, n) |
|
mpz_ptr inverse; |
|
mpz_srcptr x, n; |
|
#endif |
|
{ |
{ |
mpz_t gcd, tmp; |
mpz_t gcd, tmp; |
mp_size_t xsize, nsize, size; |
mp_size_t xsize, nsize, size; |
Line 55 mpz_invert (inverse, x, n) |
|
Line 49 mpz_invert (inverse, x, n) |
|
mpz_gcdext (gcd, tmp, (mpz_ptr) 0, x, n); |
mpz_gcdext (gcd, tmp, (mpz_ptr) 0, x, n); |
|
|
/* If no inverse existed, return with an indication of that. */ |
/* If no inverse existed, return with an indication of that. */ |
if (gcd->_mp_size != 1 || (gcd->_mp_d)[0] != 1) |
if (SIZ (gcd) != 1 || PTR(gcd)[0] != 1) |
{ |
{ |
TMP_FREE (marker); |
TMP_FREE (marker); |
return 0; |
return 0; |