summaryrefslogtreecommitdiff
path: root/gmpxx.h
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2003-07-24 00:52:44 +0200
committerKevin Ryde <user42@zip.com.au>2003-07-24 00:52:44 +0200
commitcdb026a713ddc9be710a089225a5c3305d751d72 (patch)
treec24eb4c794c46e44a03ed5527e635c9514b5ed89 /gmpxx.h
parentc2ceee3783fe6cde592911a410bd074b096fbffa (diff)
downloadgmp-cdb026a713ddc9be710a089225a5c3305d751d72.tar.gz
* gmpxx.h (struct __gmp_hypot_function): Use mpfr_hypot.
Diffstat (limited to 'gmpxx.h')
-rw-r--r--gmpxx.h64
1 files changed, 19 insertions, 45 deletions
diff --git a/gmpxx.h b/gmpxx.h
index f7996cf86..a270bf80c 100644
--- a/gmpxx.h
+++ b/gmpxx.h
@@ -1916,80 +1916,54 @@ struct __gmp_hypot_function
#ifdef __MPFR_H
static void eval(mpfr_ptr f, mpfr_srcptr g, mpfr_srcptr h)
- {
- mpfr_t temp;
- mpfr_init2(temp, mpfr_get_prec(f));
- mpfr_mul(temp, g, g, __gmp_default_rounding_mode);
- mpfr_mul(f, h, h, __gmp_default_rounding_mode);
- mpfr_add(f, f, temp, __gmp_default_rounding_mode);
- mpfr_sqrt(f, f, __gmp_default_rounding_mode);
- mpfr_clear(temp);
- }
+ { mpfr_hypot (f, g, h, __gmp_default_rounding_mode); }
static void eval(mpfr_ptr f, mpfr_srcptr g, unsigned long int l)
{
mpfr_t temp;
- mpfr_init2(temp, mpfr_get_prec(f));
- mpfr_mul(temp, g, g, __gmp_default_rounding_mode);
- mpfr_set_ui(f, l, __gmp_default_rounding_mode);
- mpfr_mul(f, f, f, __gmp_default_rounding_mode);
- mpfr_add(f, f, temp, __gmp_default_rounding_mode);
- mpfr_sqrt(f, f, __gmp_default_rounding_mode);
+ mpfr_init2 (temp, 8*sizeof(l));
+ mpfr_set_ui (temp, l, GMP_RNDZ); /* no rounding */
+ mpfr_hypot (f, g, temp, __gmp_default_rounding_mode);
mpfr_clear(temp);
}
static void eval(mpfr_ptr f, unsigned long int l, mpfr_srcptr g)
{
mpfr_t temp;
- mpfr_init2(temp, mpfr_get_prec(f));
- mpfr_mul(temp, g, g, __gmp_default_rounding_mode);
- mpfr_set_ui(f, l, __gmp_default_rounding_mode);
- mpfr_mul(f, f, f, __gmp_default_rounding_mode);
- mpfr_add(f, f, temp, __gmp_default_rounding_mode);
- mpfr_sqrt(f, f, __gmp_default_rounding_mode);
+ mpfr_init2 (temp, 8*sizeof(l));
+ mpfr_set_ui (temp, l, GMP_RNDZ); /* no rounding */
+ mpfr_hypot (f, g, temp, __gmp_default_rounding_mode);
mpfr_clear(temp);
}
static void eval(mpfr_ptr f, mpfr_srcptr g, signed long int l)
{
mpfr_t temp;
- mpfr_init2(temp, mpfr_get_prec(f));
- mpfr_mul(temp, g, g, __gmp_default_rounding_mode);
- mpfr_set_si(f, l, __gmp_default_rounding_mode);
- mpfr_mul(f, f, f, __gmp_default_rounding_mode);
- mpfr_add(f, f, temp, __gmp_default_rounding_mode);
- mpfr_sqrt(f, f, __gmp_default_rounding_mode);
+ mpfr_init2 (temp, 8*sizeof(l));
+ mpfr_set_si (temp, l, GMP_RNDZ); /* no rounding */
+ mpfr_hypot (f, g, temp, __gmp_default_rounding_mode);
mpfr_clear(temp);
}
static void eval(mpfr_ptr f, signed long int l, mpfr_srcptr g)
{
mpfr_t temp;
- mpfr_init2(temp, mpfr_get_prec(f));
- mpfr_mul(temp, g, g, __gmp_default_rounding_mode);
- mpfr_set_si(f, l, __gmp_default_rounding_mode);
- mpfr_mul(f, f, f, __gmp_default_rounding_mode);
- mpfr_add(f, f, temp, __gmp_default_rounding_mode);
- mpfr_sqrt(f, f, __gmp_default_rounding_mode);
+ mpfr_init2 (temp, 8*sizeof(l));
+ mpfr_set_si (temp, l, GMP_RNDZ); /* no rounding */
+ mpfr_hypot (f, g, temp, __gmp_default_rounding_mode);
mpfr_clear(temp);
}
static void eval(mpfr_ptr f, mpfr_srcptr g, double d)
{
mpfr_t temp;
- mpfr_init2(temp, mpfr_get_prec(f));
- mpfr_mul(temp, g, g, __gmp_default_rounding_mode);
- mpfr_set_d(f, d, __gmp_default_rounding_mode);
- mpfr_mul(f, f, f, __gmp_default_rounding_mode);
- mpfr_add(f, f, temp, __gmp_default_rounding_mode);
- mpfr_sqrt(f, f, __gmp_default_rounding_mode);
+ mpfr_init2 (temp, 8*sizeof(l));
+ mpfr_set_d (temp, l, GMP_RNDZ); /* no rounding */
+ mpfr_hypot (f, g, temp, __gmp_default_rounding_mode);
mpfr_clear(temp);
}
static void eval(mpfr_ptr f, double d, mpfr_srcptr g)
{
mpfr_t temp;
- mpfr_init2(temp, mpfr_get_prec(f));
- mpfr_mul(temp, g, g, __gmp_default_rounding_mode);
- mpfr_set_d(f, d, __gmp_default_rounding_mode);
- mpfr_mul(f, f, f, __gmp_default_rounding_mode);
- mpfr_add(f, f, temp, __gmp_default_rounding_mode);
- mpfr_sqrt(f, f, __gmp_default_rounding_mode);
+ mpfr_init2 (temp, 8*sizeof(l));
+ mpfr_set_d (temp, l, GMP_RNDZ); /* no rounding */
+ mpfr_hypot (f, g, temp, __gmp_default_rounding_mode);
mpfr_clear(temp);
}
#endif