gmp_lib.mpq_swap Method

GMP Native Interface for .NET

gmp_libmpq_swap Method
Swap the values rop1 and rop2 efficiently.

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 mpq_swap(
	mpq_t rop1,
	mpq_t rop2
)
Public Shared Sub mpq_swap ( 
	rop1 As mpq_t,
	rop2 As mpq_t
)
public:
static void mpq_swap(
	mpq_t^ rop1, 
	mpq_t^ rop2
)
static member mpq_swap : 
        rop1 : mpq_t * 
        rop2 : mpq_t -> unit 

Parameters

rop1
Type: Math.Gmp.Nativempq_t
The first rational.
rop2
Type: Math.Gmp.Nativempq_t
The second rational.
Examples
// Create, initialize, and set a new rational x to 10 / 11.
mpq_t x = new mpq_t();
gmp_lib.mpq_init(x);
gmp_lib.mpq_set_si(x, 10, 11U);

// Create, initialize, and set a new rational x to -210 / 13.
mpq_t y = new mpq_t();
gmp_lib.mpq_init(y);
gmp_lib.mpq_set_si(y, -210, 13U);

// Swap the values of x and y.
gmp_lib.mpq_swap(x, y);

// Assert that the values have been swapped.
Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 13U) == 0);
Assert.IsTrue(gmp_lib.mpq_cmp_si(y, 10, 11U) == 0);

// Release unmanaged memory allocated for x and y.
gmp_lib.mpq_clears(x, y, null);
' Create, initialize, and set a new rational x to 10 / 11.
Dim x As New mpq_t()
gmp_lib.mpq_init(x)
gmp_lib.mpq_set_si(x, 10, 11UI)

' Create, initialize, and set a new rational x to -210 / 13.
Dim y As New mpq_t()
gmp_lib.mpq_init(y)
gmp_lib.mpq_set_si(y, -210, 13UI)

' Swap the values of x and y.
gmp_lib.mpq_swap(x, y)

' Assert that the values have been swapped.
Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 13UI) = 0)
Assert.IsTrue(gmp_lib.mpq_cmp_si(y, 10, 11UI) = 0)

' Release unmanaged memory allocated for x and y.
gmp_lib.mpq_clears(x, y, 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