Click or drag to resize
gmp_libmpn_sqr Method
Compute the square of {s1p, 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_sqr(
	mp_ptr rp,
	mp_ptr s1p,
	mp_size_t n
)

Parameters

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

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

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

// Set rp = s1^2.
gmp_lib.mpn_sqr(rp, s1p, s1p.Size);

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

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