GMP Native Interface for .NET
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)

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

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.

// 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);
' Create multi-precision operands, and expected result. Dim ap As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) Dim result As New mp_ptr(New UInteger() { &H1, &H0, &HfffffffeUI, &HffffffffUI}) Dim rp As New mp_ptr(2 * ap.Size) ' Create scratch space. Dim size As mp_size_t = gmp_lib.mpn_sec_sqr_itch(ap.Size) Dim tp As 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)
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.
