gmp_lib.mpz_root Method

GMP Native Interface for .NET

gmp_libmpz_root Method
Set rop to the truncated integer part of the nth root of op.

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 int mpz_root(
	mpz_t rop,
	mpz_t op,
	uint n
)
Public Shared Function mpz_root ( 
	rop As mpz_t,
	op As mpz_t,
	n As UInteger
) As Integer
public:
static int mpz_root(
	mpz_t^ rop, 
	mpz_t^ op, 
	unsigned int n
)
static member mpz_root : 
        rop : mpz_t * 
        op : mpz_t * 
        n : uint32 -> int 

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result root integer.
op
Type: Math.Gmp.Nativempz_t
The first operand integer.
n
Type: SystemUInt32
The second operand integer.

Return Value

Type: Int32
Return non-zero if the computation was exact, i.e., if op is rop to the nth power.
Examples
// Create, initialize, and set the value of op to 10000.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_si(op, 10000);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop = trunc(cbrt(10000)).
gmp_lib.mpz_root(rop, op, 3U);

// Assert that rop is 21.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 21);

// Release unmanaged memory allocated for rop.
gmp_lib.mpz_clears(rop, op, null);
' Create, initialize, and set the value of op to 10000.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_si(op, 10000)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop = trunc(cbrt(10000)).
gmp_lib.mpz_root(rop, op, 3UI)

' Assert that rop is 21.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 21)

' Release unmanaged memory allocated for rop.
gmp_lib.mpz_clears(rop, op, Nothing)

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