Click or drag to resize
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
)

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);
See Also