Click or drag to resize
mpfr_lib.mpfr_root Method
Set rop to the kth root of op rounded in the direction rnd.

Namespace:  Math.Mpfr.Native
Assembly:  Math.Mpfr.Native (in Math.Mpfr.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public static int mpfr_root(
	mpfr_t rop,
	mpfr_t op,
	uint k,
	mpfr_rnd_t rnd
)

Parameters

rop
Type: Math.Mpfr.Native.mpfr_t
The result floating-point number.
op
Type: Math.Mpfr.Native.mpfr_t
The operand floating-point number.
k
Type: System.UInt32
The degree of the root.
rnd
Type: Math.Mpfr.Native.mpfr_rnd_t
The rounding direction.

Return Value

Type: Int32
Return zero, a positive, or a negative value if rop is respectively equal to, greater than, or lower than the exact result. See GNU MPFR - Rounding Modes for details.
Remarks

This function is the same as mpfr_rootn_ui(mpfr_t, mpfr_t, UInt32, mpfr_rnd_t) except when op is −0 and k is even: the result is −0 instead of +0 (the reason was to be consistent with mpfr_sqrt(mpfr_t, mpfr_t, mpfr_rnd_t)). Said otherwise, if op is zero, set rop to op.

This function predates the IEEE 754-2008 standard and behaves differently from its rootn function. It is marked as deprecated and will be removed in a future release.

Examples
// Create, initialize, and set a new floating-point number op to 32.0.
mpfr_t op = new mpfr_t();
mpfr_lib.mpfr_init2(op, 64U);
Assert.IsTrue(mpfr_lib.mpfr_set_d(op, 32.0, mpfr_rnd_t.MPFR_RNDN) == 0);

// Create and initialize a new floating-point number rop.
mpfr_t rop = new mpfr_t();
mpfr_lib.mpfr_init2(rop, 64U);

// Set rop = op^(1/5).
Assert.IsTrue(mpfr_lib.mpfr_root(rop, op, 5, mpfr_rnd_t.MPFR_RNDN) == 0);

// Assert the value of rop.
Assert.IsTrue(rop.ToString() == "0.200000000000000000000e1");

// Release unmanaged memory allocated for rop and op.
mpfr_lib.mpfr_clears(rop, op, null);
See Also