GMP Native Interface for .NET
gmp_libmpz_invert Method |
Compute the inverse of op1 modulo op2 and put the result in rop.
Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)

public static int mpz_invert( mpz_t rop, mpz_t op1, mpz_t op2 )
Public Shared Function mpz_invert ( rop As mpz_t, op1 As mpz_t, op2 As mpz_t ) As Integer
public: static int mpz_invert( mpz_t^ rop, mpz_t^ op1, mpz_t^ op2 )
static member mpz_invert : rop : mpz_t * op1 : mpz_t * op2 : mpz_t -> int
Parameters
- rop
- Type: Math.Gmp.Nativempz_t
The result integer. - op1
- Type: Math.Gmp.Nativempz_t
The first operand integer. - op2
- Type: Math.Gmp.Nativempz_t
The second operand integer.
Return Value
Type: Int32If the inverse exists, the return value is non-zero. If an inverse doesn’t exist the return value is zero.

If the inverse exists, the return value is non-zero and rop will satisfy 0 ≤ rop < | op2 | (with rop = 0 possible only when | op2 | = 1, i.e., in the somewhat degenerate zero ring). If an inverse doesn’t exist the return value is zero and rop is undefined. The behaviour of this function is undefined when op2 is zero.

// Create, initialize, and set the value of op1 to 3. mpz_t op1 = new mpz_t(); gmp_lib.mpz_init_set_ui(op1, 3U); // Create, initialize, and set the value of op2 to 11. mpz_t op2 = new mpz_t(); gmp_lib.mpz_init_set_ui(op2, 11U); // Create, initialize, and set the value of rop to 0. mpz_t rop = new mpz_t(); gmp_lib.mpz_init(rop); // Set rop to the modular inverse of op1 mod op2, i.e. b, where op1 * b mod op1 = 1. gmp_lib.mpz_invert(rop, op1, op2); // Assert that rop is 4, Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 4); // Release unmanaged memory allocated for rop, op1, and op2. gmp_lib.mpz_clears(rop, op1, op2, null);
' Create, initialize, and set the value of op1 to 3. Dim op1 As New mpz_t() gmp_lib.mpz_init_set_ui(op1, 3UI) ' Create, initialize, and set the value of op2 to 11. Dim op2 As New mpz_t() gmp_lib.mpz_init_set_ui(op2, 11UI) ' Create, initialize, and set the value of rop to 0. Dim rop As New mpz_t() gmp_lib.mpz_init(rop) ' Set rop to the modular inverse of op1 mod op2, i.e. b, where op1 * b mod op1 = 1. gmp_lib.mpz_invert(rop, op1, op2) ' Assert that rop is 4, Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 4) ' Release unmanaged memory allocated for rop, op1, and op2. gmp_lib.mpz_clears(rop, op1, op2, 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.
