gmp_libmpn_cnd_swap Method |
If cnd is non-zero, swaps the contents of the areas {ap, n} and {bp, n}. Otherwise, the areas are left unmodified.
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 void mpn_cnd_swap(
mp_limb_t cnd,
mp_ptr ap,
mp_ptr bp,
mp_size_t n
)
Public Shared Sub mpn_cnd_swap (
cnd As mp_limb_t,
ap As mp_ptr,
bp As mp_ptr,
n As mp_size_t
)
public:
static void mpn_cnd_swap(
mp_limb_t cnd,
mp_ptr^ ap,
mp_ptr^ bp,
mp_size_t n
)
static member mpn_cnd_swap :
cnd : mp_limb_t *
ap : mp_ptr *
bp : mp_ptr *
n : mp_size_t -> unit
Parameters
- cnd
- Type: Math.Gmp.Nativemp_limb_t
Conditonal value: non-zero for true, zero for false. - ap
- Type: Math.Gmp.Nativemp_ptr
The first operand integer. - bp
- Type: Math.Gmp.Nativemp_ptr
The second operand integer. - n
- Type: Math.Gmp.Nativemp_size_t
The number of limbs of ap and bp.
Remarks
Implemented using logical operations on the limbs, with the same memory accesses independent of the value of cnd.
Examples
mp_ptr ap = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr bp = new mp_ptr(new uint[] { 0x00000001, 0x00000000 });
mp_ptr a1p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 });
mp_ptr b1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
gmp_lib.mpn_cnd_swap(1, ap, bp, ap.Size);
Assert.IsTrue(ap.SequenceEqual(a1p));
Assert.IsTrue(bp.SequenceEqual(b1p));
gmp_lib.free(ap, bp, a1p, b1p);
Dim ap As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim bp As New mp_ptr(New UInteger() { &H1, &H0})
Dim a1p As New mp_ptr(New UInteger() { &H1, &H0})
Dim b1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
gmp_lib.mpn_cnd_swap(1, ap, bp, ap.Size)
Assert.IsTrue(ap.SequenceEqual(a1p))
Assert.IsTrue(bp.SequenceEqual(b1p))
gmp_lib.free(ap, bp, a1p, b1p)
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