arb/fmpr/exp.c

61 lines
1.3 KiB
C
Raw Normal View History

/*
2012-09-07 12:19:27 +02:00
Copyright (C) 2012 Fredrik Johansson
This file is part of Arb.
Arb is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/
2012-09-07 12:19:27 +02:00
#include "fmpr.h"
2015-11-10 13:41:43 +00:00
slong
2015-11-05 18:03:08 +00:00
fmpr_exp(fmpr_t y, const fmpr_t x, slong prec, fmpr_rnd_t rnd)
2012-09-07 12:19:27 +02:00
{
if (fmpr_is_special(x))
{
if (fmpr_is_zero(x))
fmpr_one(y);
else if (fmpr_is_pos_inf(x))
fmpr_pos_inf(y);
else if (fmpr_is_neg_inf(x))
fmpr_zero(y);
else
fmpr_nan(y);
return FMPR_RESULT_EXACT;
}
else
{
2015-11-05 18:03:08 +00:00
slong r;
2012-09-07 12:19:27 +02:00
CALL_MPFR_FUNC(r, mpfr_exp, y, x, prec, rnd);
return r;
}
}
2015-11-10 13:41:43 +00:00
slong
2015-11-05 18:03:08 +00:00
fmpr_expm1(fmpr_t y, const fmpr_t x, slong prec, fmpr_rnd_t rnd)
2012-09-07 12:19:27 +02:00
{
if (fmpr_is_special(x))
{
if (fmpr_is_zero(x))
fmpr_zero(y);
else if (fmpr_is_pos_inf(x))
fmpr_pos_inf(y);
else if (fmpr_is_neg_inf(x))
2015-11-06 15:34:19 +00:00
fmpr_set_si(y, -WORD(1));
2012-09-07 12:19:27 +02:00
else
fmpr_nan(y);
return FMPR_RESULT_EXACT;
}
else
{
2015-11-05 18:03:08 +00:00
slong r;
2012-09-07 12:19:27 +02:00
CALL_MPFR_FUNC(r, mpfr_expm1, y, x, prec, rnd);
return r;
}
}