gmp_libmpn_sec_add_1 Method |
Set R to A + b, where R = {rp, n}, A = {ap, n}, and b is a single limb.
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 mp_limb_t mpn_sec_add_1(
mp_ptr rp,
mp_ptr ap,
mp_size_t n,
mp_limb_t b,
mp_ptr tp
)
Public Shared Function mpn_sec_add_1 (
rp As mp_ptr,
ap As mp_ptr,
n As mp_size_t,
b As mp_limb_t,
tp As mp_ptr
) As mp_limb_t
public:
static mp_limb_t mpn_sec_add_1(
mp_ptr^ rp,
mp_ptr^ ap,
mp_size_t n,
mp_limb_t b,
mp_ptr^ tp
)
static member mpn_sec_add_1 :
rp : mp_ptr *
ap : mp_ptr *
n : mp_size_t *
b : mp_limb_t *
tp : mp_ptr -> mp_limb_t
Parameters
- rp
- Type: Math.Gmp.Nativemp_ptr
The result integer. - ap
- Type: Math.Gmp.Nativemp_ptr
The first operand integer. - n
- Type: Math.Gmp.Nativemp_size_t
The number of limbs of ap and rp. - b
- Type: Math.Gmp.Nativemp_limb_t
The second operand integer. - tp
- Type: Math.Gmp.Nativemp_ptr
The scratch operand integer.
Return Value
Type:
mp_limb_tReturns carry, either 0 or 1.
Remarks
This function takes O(N) time, unlike the leaky functions mpn_add_1 which is O(1) on average.
It requires scratch space of mpn_sec_add_1_itch(n) limbs, to be passed in the tp parameter.
The scratch space requirements are guaranteed to be at most n limbs, and increase monotonously in the operand size.
Examples
mp_ptr ap = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 });
mp_ptr rp = new mp_ptr(result.Size);
mp_size_t size = gmp_lib.mpn_sec_add_1_itch(ap.Size);
mp_ptr tp = new mp_ptr(size);
mp_limb_t carry = gmp_lib.mpn_sec_add_1(rp, ap, ap.Size, 1, tp);
Assert.IsTrue(carry == 1);
Assert.IsTrue(rp.SequenceEqual(result));
gmp_lib.free(rp, ap, tp, result);
Dim ap As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim result As New mp_ptr(New UInteger() { &H0, &H0})
Dim rp As New mp_ptr(result.Size)
Dim size As mp_size_t = gmp_lib.mpn_sec_add_1_itch(ap.Size)
Dim tp As New mp_ptr(size)
Dim carry As mp_limb_t = gmp_lib.mpn_sec_add_1(rp, ap, ap.Size, 1, tp)
Assert.IsTrue(carry = 1)
Assert.IsTrue(rp.SequenceEqual(result))
gmp_lib.free(rp, ap, tp, result)
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