Click or drag to resize
gmp_libmpn_sec_sqr Method
Set R to A^2, where A = {ap, an}, and R = {rp, 2 * an}.

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_sqr(
	mp_ptr rp,
	mp_ptr ap,
	mp_size_t an,
	mp_ptr tp
)

Parameters

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

It is required that an > 0.

No overlapping between R and the input operands is allowed.

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

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

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

// Set rp = s1^2.
gmp_lib.mpn_sec_sqr(rp, ap, ap.Size, tp);

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

// Release unmanaged memory.
gmp_lib.free(rp, ap, tp, result);
See Also