GMP Native Interface for .NET
gmp_libmpz_legendre Method |
Calculate the Legendre symbol (a/p).
Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public static int mpz_legendre( mpz_t a, mpz_t p )
Public Shared Function mpz_legendre ( a As mpz_t, p As mpz_t ) As Integer
public: static int mpz_legendre( mpz_t^ a, mpz_t^ p )
static member mpz_legendre : a : mpz_t * p : mpz_t -> int
Parameters
- a
- Type: Math.Gmp.Nativempz_t
The first operand integer. - p
- Type: Math.Gmp.Nativempz_t
The second operand integer.
Return Value
Type: Int32The Legendre symbol (a/p).
Remarks
This is defined only for p an odd positive prime, and for such p it’s identical to the Jacobi symbol.
Examples
// Create, initialize, and set the value of a to 20. mpz_t a = new mpz_t(); gmp_lib.mpz_init_set_ui(a, 20U); // Create, initialize, and set the value of p to 11. mpz_t p = new mpz_t(); gmp_lib.mpz_init_set_ui(p, 11U); // Assert that the Legendre symbol of (a/p) is 1. Assert.IsTrue(gmp_lib.mpz_legendre(a, p) == 1); // Release unmanaged memory allocated for a and p. gmp_lib.mpz_clears(a, p, null);
' Create, initialize, and set the value of a to 20. Dim a As New mpz_t() gmp_lib.mpz_init_set_ui(a, 20UI) ' Create, initialize, and set the value of p to 11. Dim p As New mpz_t() gmp_lib.mpz_init_set_ui(p, 11UI) ' Assert that the Legendre symbol of (a/p) is 1. Assert.IsTrue(gmp_lib.mpz_legendre(a, p) = 1) ' Release unmanaged memory allocated for a and p. gmp_lib.mpz_clears(a, p, Nothing)
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also