summaryrefslogtreecommitdiff
path: root/src/sum.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2017-05-04 09:40:05 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2017-05-04 09:40:05 +0000
commitaf5a1593331d686b9cc5fbbbbdc47e1733a4644e (patch)
treeff8210e41ae8ced432dbcd42e8be2a919f8dddc6 /src/sum.c
parent87ff38458263c9a9ed79a7ebd547fd32a66ae843 (diff)
parentd79a8111e6b7851b15bac211d8dca0e67a2979b5 (diff)
downloadmpfr-af5a1593331d686b9cc5fbbbbdc47e1733a4644e.tar.gz
Merged the latest changes from the trunk, including some old changesets
related to mpfr_zeta that were skipped, resolving conflicts. Added RNDF support to new code introduced by this merge: * mpfr_mul_1n in src/mul.c (from r11281); * mpfr_sqr_1n in src/sqr.c (from r11283); * mpfr_div_1n in src/div.c (from r11284); * mpfr_sqrt1n in src/sqrt.c (from r11293). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/faithful@11456 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/sum.c')
-rw-r--r--src/sum.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/sum.c b/src/sum.c
index 9fd9d693d..a77c116ab 100644
--- a/src/sum.c
+++ b/src/sum.c
@@ -23,6 +23,25 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
#define MPFR_NEED_LONGLONG_H
#include "mpfr-impl.h"
+/* Note: In the prototypes, one uses
+ *
+ * const mpfr_ptr *x i.e.: __mpfr_struct *const *x
+ *
+ * instead of
+ *
+ * const mpfr_srcptr *x i.e.: const __mpfr_struct *const *x
+ *
+ * because here one has a double indirection and the type matching rules
+ * from the C standard in such a case are stricter and they would yield
+ * annoying errors for the user in practice. See:
+ *
+ * Why can't I pass a char ** to a function which expects a const char **?
+ *
+ * in the comp.lang.c FAQ:
+ *
+ * http://c-faq.com/ansi/constmismatch.html
+ */
+
/* See the doc/sum.txt file for the algorithm and a part of its proof
(this will later go into algorithms.tex).
@@ -127,7 +146,7 @@ int __gmpfr_cov_sum_tmd[MPFR_RND_MAX][2][2][3][2][2] = { 0 };
* iteration (= maxexp2 of the last iteration).
*/
static mpfr_prec_t
-sum_raw (mp_limb_t *wp, mp_size_t ws, mpfr_prec_t wq, mpfr_ptr *const x,
+sum_raw (mp_limb_t *wp, mp_size_t ws, mpfr_prec_t wq, const mpfr_ptr *x,
unsigned long n, mpfr_exp_t minexp, mpfr_exp_t maxexp,
mp_limb_t *tp, mp_size_t ts, int logn, mpfr_prec_t prec,
mpfr_exp_t *ep, mpfr_exp_t *minexpp, mpfr_exp_t *maxexpp)
@@ -465,6 +484,7 @@ sum_raw (mp_limb_t *wp, mp_size_t ws, mpfr_prec_t wq, mpfr_ptr *const x,
MPFR_ASSERTD (diffexp < cancel - 2);
shiftq = cancel - 2 - (mpfr_prec_t) diffexp;
+ /* equivalent to: minexp + wq - 2 - max(e,err) */
MPFR_ASSERTD (shiftq > 0);
shifts = shiftq / GMP_NUMB_BITS;
shiftc = shiftq % GMP_NUMB_BITS;
@@ -503,7 +523,7 @@ sum_raw (mp_limb_t *wp, mp_size_t ws, mpfr_prec_t wq, mpfr_ptr *const x,
/* Generic case: all the inputs are finite numbers,
with at least 3 regular numbers. */
static int
-sum_aux (mpfr_ptr sum, mpfr_ptr *const x, unsigned long n, mpfr_rnd_t rnd,
+sum_aux (mpfr_ptr sum, const mpfr_ptr *x, unsigned long n, mpfr_rnd_t rnd,
mpfr_exp_t maxexp, unsigned long rn)
{
mp_limb_t *sump;
@@ -1236,7 +1256,7 @@ sum_aux (mpfr_ptr sum, mpfr_ptr *const x, unsigned long n, mpfr_rnd_t rnd,
/**********************************************************************/
int
-mpfr_sum (mpfr_ptr sum, mpfr_ptr *const x, unsigned long n, mpfr_rnd_t rnd)
+mpfr_sum (mpfr_ptr sum, const mpfr_ptr *x, unsigned long n, mpfr_rnd_t rnd)
{
MPFR_LOG_FUNC
(("n=%lu rnd=%d", n, rnd),