gmp_lib.mpn_mul_n Method

GMP Native Interface for .NET

gmp_libmpn_mul_n Method
Multiply {s1p, n} and {s2p, n}, and write the (2 * n)-limb result to rp.

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_mul_n(
	mp_ptr rp,
	mp_ptr s1p,
	mp_ptr s2p,
	mp_size_t n
)
Public Shared Sub mpn_mul_n ( 
	rp As mp_ptr,
	s1p As mp_ptr,
	s2p As mp_ptr,
	n As mp_size_t
)
public:
static void mpn_mul_n(
	mp_ptr^ rp, 
	mp_ptr^ s1p, 
	mp_ptr^ s2p, 
	mp_size_t n
)
static member mpn_mul_n : 
        rp : mp_ptr * 
        s1p : mp_ptr * 
        s2p : mp_ptr * 
        n : mp_size_t -> unit 

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s2p
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p and s2p.
Remarks

The destination has to have space for 2 * n limbs, even if the product’s most significant limb is zero. No overlap is permitted between the destination and either source.

If the two input operands are the same, use mpn_sqr.

Examples
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr s2p = new mp_ptr(new uint[] { 0x00000002, 0x00000000 });
mp_ptr rp = new mp_ptr(new uint[4]);
mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff, 0x00000001, 0x00000000 });

// Set rp = s1 * s2.
gmp_lib.mpn_mul_n(rp, s1p, s2p, s1p.Size);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim s2p As New mp_ptr(New UInteger() { &H2, &H0})
Dim rp As New mp_ptr(New UInteger(3) { })
Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI, &H1, &H0})

' Set rp = s1 * s2.
gmp_lib.mpn_mul_n(rp, s1p, s2p, s1p.Size)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, 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