mpfr_lib.mpfr_atan2 Method |
Set rop to the arc-tangent2 of y and x 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)
Syntaxpublic static int mpfr_atan2(
mpfr_t rop,
mpfr_t y,
mpfr_t x,
mpfr_rnd_t rnd
)
Public Shared Function mpfr_atan2 (
rop As mpfr_t,
y As mpfr_t,
x As mpfr_t,
rnd As mpfr_rnd_t
) As Integer
public:
static int mpfr_atan2(
mpfr_t^ rop,
mpfr_t^ y,
mpfr_t^ x,
mpfr_rnd_t rnd
)
static member mpfr_atan2 :
rop : mpfr_t *
y : mpfr_t *
x : mpfr_t *
rnd : mpfr_rnd_t -> int
Parameters
- rop
- Type: Math.Mpfr.Native.mpfr_t
The result floating-point number. - y
- Type: Math.Mpfr.Native.mpfr_t
The ordinate floating-point value. - x
- Type: Math.Mpfr.Native.mpfr_t
The abscissa floating-point value. - rnd
- Type: Math.Mpfr.Native.mpfr_rnd_t
The rounding direction.
Return Value
Type:
Int32Return 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
If x > 0, atan2(y, x) = atan(y/x);
if x < 0, atan2(y, x) = sign(y) * (Pi - atan(abs(y/x))),
thus a number from -Pi to Pi.
As for atan, in case the exact mathematical result is +Pi or -Pi, its rounded result might be outside the function output range.
atan2(y, 0) does not raise any floating-point exception.
Special values are handled as described in the ISO C99 and IEEE 754-2008 standards for the atan2 function:
-
atan2(+0, -0) returns +Pi.
-
atan2(-0, -0) returns -Pi.
-
atan2(+0, +0) returns +0.
-
atan2(-0, +0) returns -0.
-
atan2(+0, x) returns +Pi for x < 0.
-
atan2(-0, x) returns -Pi for x < 0.
-
atan2(+0, x) returns +0 for x > 0.
-
atan2(-0, x) returns -0 for x > 0.
-
atan2(y, 0) returns -Pi/2 for y < 0.
-
atan2(y, 0) returns +Pi/2 for y > 0.
-
atan2(+Inf, -Inf) returns +3 * Pi/4.
-
atan2(-Inf, -Inf) returns -3 * Pi/4.
-
atan2(+Inf, +Inf) returns +Pi/4.
-
atan2(-Inf, +Inf) returns -Pi/4.
-
atan2(+Inf, x) returns +Pi/2 for finite x.
-
atan2(-Inf, x) returns -Pi/2 for finite x.
-
atan2(y, -Inf) returns +Pi for finite y > 0.
-
atan2(y, -Inf) returns -Pi for finite y < 0.
-
atan2(y, +Inf) returns +0 for finite y > 0.
-
atan2(y, +Inf) returns -0 for finite y < 0.
Examples
mpfr_t x = new mpfr_t();
mpfr_lib.mpfr_init2(x, 64U);
Assert.IsTrue(mpfr_lib.mpfr_set_si(x, -1, mpfr_rnd_t.MPFR_RNDN) == 0);
mpfr_t y = new mpfr_t();
mpfr_lib.mpfr_init2(y, 64U);
Assert.IsTrue(mpfr_lib.mpfr_set_si(y, 0, mpfr_rnd_t.MPFR_RNDN) == 0);
mpfr_t rop = new mpfr_t();
mpfr_lib.mpfr_init2(rop, 64U);
Assert.IsTrue(mpfr_lib.mpfr_atan2(rop, y, x, mpfr_rnd_t.MPFR_RNDN) == 1);
Assert.IsTrue(mpfr_lib.mpfr_const_pi(x, mpfr_rnd_t.MPFR_RNDN) == 1);
Assert.IsTrue(mpfr_lib.mpfr_cmp(rop, x) == 0);
mpfr_lib.mpfr_clears(x, y, rop, null);
Dim x As mpfr_t = New mpfr_t()
mpfr_lib.mpfr_init2(x, 64U)
Assert.IsTrue(mpfr_lib.mpfr_set_si(x, -1, mpfr_rnd_t.MPFR_RNDN) = 0)
Dim y As mpfr_t = New mpfr_t()
mpfr_lib.mpfr_init2(y, 64U)
Assert.IsTrue(mpfr_lib.mpfr_set_si(y, 0, mpfr_rnd_t.MPFR_RNDN) = 0)
Dim rop As mpfr_t = New mpfr_t()
mpfr_lib.mpfr_init2(rop, 64U)
Assert.IsTrue(mpfr_lib.mpfr_atan2(rop, y, x, mpfr_rnd_t.MPFR_RNDN) = 1)
Assert.IsTrue(mpfr_lib.mpfr_const_pi(x, mpfr_rnd_t.MPFR_RNDN) = 1)
Assert.IsTrue(mpfr_lib.mpfr_cmp(rop, x) = 0)
mpfr_lib.mpfr_clears(x, y, rop, 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