GMP Native Interface for .NET
gmp_libmpn_sec_div_r Method |
Set R to N modulo D, where N = {np, nn}, D = {dp, dn}, and R = {np, dn}.
Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)

public static void mpn_sec_div_r( mp_ptr np, mp_size_t nn, mp_ptr dp, mp_size_t dn, mp_ptr tp )
Public Shared Sub mpn_sec_div_r ( np As mp_ptr, nn As mp_size_t, dp As mp_ptr, dn As mp_size_t, tp As mp_ptr )
public: static void mpn_sec_div_r( mp_ptr^ np, mp_size_t nn, mp_ptr^ dp, mp_size_t dn, mp_ptr^ tp )
static member mpn_sec_div_r : np : mp_ptr * nn : mp_size_t * dp : mp_ptr * dn : mp_size_t * tp : mp_ptr -> unit
Parameters
- np
- Type: Math.Gmp.Nativemp_ptr
The first operand and result integer. - nn
- Type: Math.Gmp.Nativemp_size_t
The number of limbs of np. - dp
- Type: Math.Gmp.Nativemp_ptr
The second operand integer - dn
- Type: Math.Gmp.Nativemp_size_t
The number of limbs of dp. - tp
- Type: Math.Gmp.Nativemp_ptr
The scratch operand integer.

It is required that nn ≥ dn ≥ 1, and that dp[dn - 1] ≠ 0. This does not imply that N ≥ D since N might be zero-padded.
Note the overlapping between N and R. No other operand overlapping is allowed. The entire space occupied by N is overwritten.
This function requires scratch space of mpn_sec_div_r_itch(nn, dn) limbs to be passed in the tp parameter.

// Create multi-precision operands, and expected result. mp_ptr np = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff }); mp_ptr dp = new mp_ptr(new uint[] { 0x00000004 }); // Create scratch space. mp_size_t size = gmp_lib.mpn_sec_div_r_itch(np.Size, dp.Size); mp_ptr tp = new mp_ptr(size); // Set np = np mod dp. gmp_lib.mpn_sec_div_r(np, np.Size, dp, dp.Size, tp); // Assert result of operation. Assert.IsTrue(np[0] == 3); // Release unmanaged memory. gmp_lib.free(np, dp, tp);
' Create multi-precision operands, and expected result. Dim np As New mp_ptr(New UInteger() { &HffffffffUI, &Hffff}) Dim dp As New mp_ptr(New UInteger() { &H4}) ' Create scratch space. Dim size As mp_size_t = gmp_lib.mpn_sec_div_r_itch(np.Size, dp.Size) Dim tp As New mp_ptr(size) ' Set np = np mod dp. gmp_lib.mpn_sec_div_r(np, np.Size, dp, dp.Size, tp) ' Assert result of operation. Assert.IsTrue(np(0) = 3) ' Release unmanaged memory. gmp_lib.free(np, dp, 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.
