gmp_lib.mpn_sec_mul Method

GMP Native Interface for .NET

gmp_libmpn_sec_mul Method
Set R to A * B, where A = {ap, an}, B = {bp, bn}, and R = {rp, an + bn}.

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_sec_mul(
	mp_ptr rp,
	mp_ptr ap,
	mp_size_t an,
	mp_ptr bp,
	mp_size_t bn,
	mp_ptr tp
)
Public Shared Sub mpn_sec_mul ( 
	rp As mp_ptr,
	ap As mp_ptr,
	an As mp_size_t,
	bp As mp_ptr,
	bn As mp_size_t,
	tp As mp_ptr
)
public:
static void mpn_sec_mul(
	mp_ptr^ rp, 
	mp_ptr^ ap, 
	mp_size_t an, 
	mp_ptr^ bp, 
	mp_size_t bn, 
	mp_ptr^ tp
)
static member mpn_sec_mul : 
        rp : mp_ptr * 
        ap : mp_ptr * 
        an : mp_size_t * 
        bp : mp_ptr * 
        bn : mp_size_t * 
        tp : mp_ptr -> unit 

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
ap
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
an
Type: Math.Gmp.Nativemp_size_t
The number of limbs of ap.
bp
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
bn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of bp.
tp
Type: Math.Gmp.Nativemp_ptr
The scratch operand integer.
Remarks

It is required that an ≥ bn > 0.

No overlapping between R and the input operands is allowed. For A = B, use mpn_sec_sqr for optimal performance.

This function requires scratch space of mpn_sec_mul_itch(an, bn) limbs to be passed in the tp parameter. The scratch space requirements are guaranteed to increase monotonously in the operand sizes.

Examples
// Create multi-precision operands, and expected result.
mp_ptr ap = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr bp = new mp_ptr(new uint[] { 0x00000002 });
mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff, 0x00000001 });
mp_ptr rp = new mp_ptr(ap.Size + bp.Size);

// Create scratch space.
mp_size_t size = gmp_lib.mpn_sec_mul_itch(ap.Size, bp.Size);
mp_ptr tp = new mp_ptr(size);

// Set rp = ap * bp.
gmp_lib.mpn_sec_mul(rp, ap, ap.Size, bp, bp.Size, tp);

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

// Release unmanaged memory.
gmp_lib.free(rp, ap, bp, tp, result);
' Create multi-precision operands, and expected result.
Dim ap As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim bp As New mp_ptr(New UInteger() { &H2})
Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI, &H1})
Dim rp As New mp_ptr(ap.Size + bp.Size)

' Create scratch space.
Dim size As mp_size_t = gmp_lib.mpn_sec_mul_itch(ap.Size, bp.Size)
Dim tp As New mp_ptr(size)

' Set rp = ap * bp.
gmp_lib.mpn_sec_mul(rp, ap, ap.Size, bp, bp.Size, tp)

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

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