diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2016-08-29 13:20:14 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2016-08-29 13:20:14 +0000 |
commit | 39a275897d0ea0bf3a11fb7d70870b61a16b115a (patch) | |
tree | 60eda56802bbb71d507c2ab0eb4934d40134045b /src/atan.c | |
parent | 153ba0f04f18c97faa9edfbbbfcf46282c978e41 (diff) | |
download | mpfr-39a275897d0ea0bf3a11fb7d70870b61a16b115a.tar.gz |
[src/atan.c] fixed TODOs, and simplified code
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@10760 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/atan.c')
-rw-r--r-- | src/atan.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/src/atan.c b/src/atan.c index f3bd2f967..335144481 100644 --- a/src/atan.c +++ b/src/atan.c @@ -274,8 +274,7 @@ mpfr_atan (mpfr_ptr atan, mpfr_srcptr x, mpfr_rnd_t rnd_mode) prec = realprec + GMP_NUMB_BITS; /* Initialisation */ - /* TODO: determine a bound on the maximum size and use mpz_init2. */ - mpz_init (ukz); + mpz_init2 (ukz, prec); /* ukz will need 'prec' bits below */ MPFR_GROUP_INIT_4 (group, prec, sk, tmp, tmp2, arctgt); oldn0 = 0; @@ -306,20 +305,12 @@ mpfr_atan (mpfr_ptr atan, mpfr_srcptr x, mpfr_rnd_t rnd_mode) /* Initialisation */ MPFR_GROUP_REPREC_4 (group, prec, sk, tmp, tmp2, arctgt); MPFR_ASSERTD (n0 <= MPFR_PREC_BITS); - if (MPFR_LIKELY (oldn0 == 0)) - { - oldn0 = 3 * (n0 + 1); - /* TODO: determine a bound on the maximum size and use mpz_init2. */ - for (i = 0; i < oldn0; i++) - mpz_init (tabz[i]); - } - else if (oldn0 < 3 * (n0 + 1)) - { - /* TODO: determine a bound on the maximum size and use mpz_init2. */ - for (i = oldn0; i < 3 * (n0 + 1); i++) - mpz_init (tabz[i]); - oldn0 = 3 * (n0 + 1); - } + /* Note: the tabz[] entries are used to get a rational approximation + of atan(x) to precision 'prec', thus allocating them to 'prec' bits + should be good enough. */ + for (i = oldn0; i < 3 * (n0 + 1); i++) + mpz_init2 (tabz[i], prec); + oldn0 = 3 * (n0 + 1); /* The mpfr_ui_div below mustn't underflow. This is guaranteed by MPFR_SAVE_EXPO_MARK, but let's check that for maintainability. */ |