gmp_libmpn_sec_invert Method |
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 mpn_sec_invert( mp_ptr rp, mp_ptr ap, mp_ptr mp, mp_size_t n, mp_bitcnt_t nbcnt, mp_ptr tp )
Public Shared Function mpn_sec_invert ( rp As mp_ptr, ap As mp_ptr, mp As mp_ptr, n As mp_size_t, nbcnt As mp_bitcnt_t, tp As mp_ptr ) As Integer
public: static int mpn_sec_invert( mp_ptr^ rp, mp_ptr^ ap, mp_ptr^ mp, mp_size_t n, mp_bitcnt_t nbcnt, mp_ptr^ tp )
static member mpn_sec_invert : rp : mp_ptr * ap : mp_ptr * mp : mp_ptr * n : mp_size_t * nbcnt : mp_bitcnt_t * tp : mp_ptr -> int
Parameters
- rp
- Type: Math.Gmp.Nativemp_ptr
The result integer. - ap
- Type: Math.Gmp.Nativemp_ptr
The first operand integer. - mp
- Type: Math.Gmp.Nativemp_ptr
The second operand integer. - n
- Type: Math.Gmp.Nativemp_size_t
The number of limbs of ap and mp. - nbcnt
- Type: Math.Gmp.Nativemp_bitcnt_t
The third operand integer. - tp
- Type: Math.Gmp.Nativemp_ptr
The scratch operand integer.
Return Value
Type: Int32If an inverse exists, return 1, otherwise return 0 and leave R undefined.

If an inverse exists, return 1, otherwise return 0 and leave R undefined. In either case, the input A is destroyed.
It is required that M is odd, and that nbcnt ≥ ceil(log(A + 1)) + ceil(log(M + 1)). A safe choice is nbcnt = 2 * n * mp_bits_per_limb, but a smaller value might improve performance if M or A are known to have leading zero bits.
This function requires scratch space of mpn_sec_invert_itch(n) limbs to be passed in the tp parameter.

// Create multi-precision operands, and expected result. mp_ptr ap = new mp_ptr(new uint[] { 3 }); mp_ptr mp = new mp_ptr(new uint[] { 11 }); mp_ptr rp = new mp_ptr(ap.Size); mp_ptr result = new mp_ptr(new uint[] { 4 }); // Create scratch space. mp_size_t size = gmp_lib.mpn_sec_invert_itch(ap.Size); mp_ptr tp = new mp_ptr(size); // Set rp = ap^-1 mod mp. gmp_lib.mpn_sec_invert(rp, ap, mp, ap.Size, (uint)(2 * ap.Size* gmp_lib.mp_bits_per_limb), tp); // Assert result of operation. Assert.IsTrue(rp[0] == result[0]); // Release unmanaged memory. gmp_lib.free(ap, mp, rp, result, tp);
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.
