summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/reuse.c1
-rw-r--r--zeta.c45
2 files changed, 25 insertions, 21 deletions
diff --git a/tests/reuse.c b/tests/reuse.c
index e9ea078a4..8e49a38d6 100644
--- a/tests/reuse.c
+++ b/tests/reuse.c
@@ -592,6 +592,7 @@ main (void)
testfunc = (fct_t) mpfr_tan; test2 ("mpfr_tan", 53, GMP_RNDN);
testfunc = (fct_t) mpfr_log10; test2 ("mpfr_log10", 53, GMP_RNDN);
testfunc = (fct_t) mpfr_log2; test2 ("mpfr_log2", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_zeta; test2 ("mpfr_zeta", 53, GMP_RNDN);
testfunc = (fct_t) mpfr_pow; test3 ("mpfr_pow", 53, GMP_RNDN);
testfunc = (fct_t) mpfr_fma; test4 ("mpfr_fma", 53, GMP_RNDN);
diff --git a/zeta.c b/zeta.c
index 2cb7d7395..3407e76a3 100644
--- a/zeta.c
+++ b/zeta.c
@@ -154,7 +154,8 @@ mpfr_zeta_part_a (mpfr_t sum, mpfr_srcptr s, int n)
}
/* Input: s - a floating-point number >= 1/2.
- rnd_mode - a rounding mode
+ rnd_mode - a rounding mode.
+ Assumes s is neither NaN nor Infinite.
Output: z - Zeta(s) rounded to the precision of z with direction rnd_mode
*/
void
@@ -166,26 +167,6 @@ mpfr_zeta_pos (mpfr_t z, mpfr_srcptr s, mp_rnd_t rnd_mode)
mpfr_t *tc1;
mp_prec_t precz, precs;
- if (mpfr_nan_p (s))
- {
- mpfr_set_nan (z); /* Zeta(NaN) = NaN */
- return;
- }
-
- if (mpfr_inf_p (s))
- {
- if (MPFR_SIGN(s) > 0)
- {
- mpfr_set_ui (z, 1, GMP_RNDN); /* Zeta(+Inf) = 1 */
- return;
- }
- else
- {
- mpfr_set_nan (z); /* Zeta(-Inf) = NaN */
- return;
- }
- }
-
precz = mpfr_get_prec (z);
precs = mpfr_get_prec (s);
@@ -332,6 +313,28 @@ mpfr_zeta (mpfr_t z, mpfr_srcptr s, mp_rnd_t rnd_mode)
mpfr_t z_pre, s1, s2, y, sfrac, sint, p;
mp_prec_t precz, prec1, precs, precs1;
+ if (mpfr_nan_p (s))
+ {
+ mpfr_set_nan (z); /* Zeta(NaN) = NaN */
+ return;
+ }
+
+ if (mpfr_inf_p (s))
+ {
+ if (MPFR_SIGN(s) > 0)
+ {
+ mpfr_set_ui (z, 1, GMP_RNDN); /* Zeta(+Inf) = 1 */
+ return;
+ }
+ else
+ {
+ mpfr_set_nan (z); /* Zeta(-Inf) = NaN */
+ return;
+ }
+ }
+
+ /* now s is neither NaN nor Infinite */
+
if (mpfr_cmp_ui(s,0) == 0) /* Case s = 0 */
{
mpfr_set_ui(z, 1, rnd_mode);