Set {rp, retval} to the greatest common divisor of {xp, xn} and {yp, yn}.
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_size_t mpn_gcd(
mp_ptr rp,
mp_ptr xp,
mp_size_t xn,
mp_ptr yp,
mp_size_t yn
)
Public Shared Function mpn_gcd (
rp As mp_ptr,
xp As mp_ptr,
xn As mp_size_t,
yp As mp_ptr,
yn As mp_size_t
) As mp_size_t
public:
static mp_size_t mpn_gcd(
mp_ptr^ rp,
mp_ptr^ xp,
mp_size_t xn,
mp_ptr^ yp,
mp_size_t yn
)
static member mpn_gcd :
rp : mp_ptr *
xp : mp_ptr *
xn : mp_size_t *
yp : mp_ptr *
yn : mp_size_t -> mp_size_t
Parameters
- rp
- Type: Math.Gmp.Nativemp_ptr
The result integer. - xp
- Type: Math.Gmp.Nativemp_ptr
The first operand integer. - xn
- Type: Math.Gmp.Nativemp_size_t
The number of limbs of xp. - yp
- Type: Math.Gmp.Nativemp_ptr
The second operand integer. - yn
- Type: Math.Gmp.Nativemp_size_t
The number of limbs of yp.
Return Value
Type:
mp_size_tThe result can be up to
yn limbs, the return value is the actual number produced; i.e. the number of limbs of
rp.
Remarks
Both source operands are destroyed.
It is required that xn ≥ yn > 0, and the most significant limb
of {yp, yn} must be non-zero.
No overlap is permitted between {xp, xn} and {yp, yn}.
Examples
mp_ptr xp = new mp_ptr(new uint[] { 0x964619c7, 0x00000002 });
mp_ptr yp = new mp_ptr(new uint[] { 0xc2d24d55, 0x00000007 });
mp_ptr rp = new mp_ptr(yp.Size);
mp_ptr result = new mp_ptr(new uint[] { 0x964619c7, 0x00000002 });
mp_size_t size = gmp_lib.mpn_gcd(rp, xp, xp.Size, yp, yp.Size);
Assert.IsTrue(size == result.Size);
Assert.IsTrue(rp.SequenceEqual(result));
gmp_lib.free(rp, xp, yp, result);
Dim xp As New mp_ptr(New UInteger() { &H964619c7UI, &H2})
Dim yp As New mp_ptr(New UInteger() { &Hc2d24d55UI, &H7})
Dim rp As New mp_ptr(yp.Size)
Dim result As New mp_ptr(New UInteger() { &H964619c7UI, &H2})
Dim size As mp_size_t = gmp_lib.mpn_gcd(rp, xp, xp.Size, yp, yp.Size)
Assert.IsTrue(size = result.Size)
Assert.IsTrue(rp.SequenceEqual(result))
gmp_lib.free(rp, xp, yp, 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