2016-04-26 17:20:05 +02:00
|
|
|
/*
|
2012-09-02 06:09:40 +02:00
|
|
|
Copyright (C) 2012 Fredrik Johansson
|
|
|
|
|
2016-04-26 17:20:05 +02:00
|
|
|
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-02 06:09:40 +02:00
|
|
|
|
|
|
|
#include "fmpr.h"
|
|
|
|
|
2015-11-10 13:41:43 +00:00
|
|
|
slong
|
2015-11-05 18:03:08 +00:00
|
|
|
fmpr_log(fmpr_t y, const fmpr_t x, slong prec, fmpr_rnd_t rnd)
|
2012-09-02 06:09:40 +02:00
|
|
|
{
|
|
|
|
if (fmpr_is_special(x))
|
|
|
|
{
|
|
|
|
if (fmpr_is_zero(x))
|
|
|
|
fmpr_neg_inf(y);
|
|
|
|
else if (fmpr_is_pos_inf(x))
|
|
|
|
fmpr_pos_inf(y);
|
|
|
|
else
|
|
|
|
fmpr_nan(y);
|
|
|
|
|
|
|
|
return FMPR_RESULT_EXACT;
|
|
|
|
}
|
2012-09-07 12:19:27 +02:00
|
|
|
else if (fmpr_sgn(x) < 0)
|
2012-09-02 06:09:40 +02:00
|
|
|
{
|
|
|
|
fmpr_nan(y);
|
|
|
|
return FMPR_RESULT_EXACT;
|
|
|
|
}
|
2012-09-07 12:19:27 +02:00
|
|
|
else if (fmpr_is_one(x))
|
2012-09-02 06:09:40 +02:00
|
|
|
{
|
|
|
|
fmpr_zero(y);
|
|
|
|
return FMPR_RESULT_EXACT;
|
|
|
|
}
|
2012-09-07 12:19:27 +02:00
|
|
|
else
|
2012-09-02 06:09:40 +02:00
|
|
|
{
|
2015-11-05 18:03:08 +00:00
|
|
|
slong r;
|
2012-09-07 12:19:27 +02:00
|
|
|
CALL_MPFR_FUNC(r, mpfr_log, y, x, prec, rnd);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
2012-09-02 06:09:40 +02:00
|
|
|
|
2015-11-10 13:41:43 +00:00
|
|
|
slong
|
2015-11-05 18:03:08 +00:00
|
|
|
fmpr_log1p(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
|
|
|
|
fmpr_nan(y);
|
2012-09-02 06:09:40 +02:00
|
|
|
|
2012-09-07 12:19:27 +02:00
|
|
|
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_log1p, y, x, prec, rnd);
|
2012-09-02 06:09:40 +02:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|