118 lines
4.1 KiB
Diff
118 lines
4.1 KiB
Diff
Index: src/norm.c
|
|
===================================================================
|
|
--- src/norm.c (revision 529)
|
|
+++ src/norm.c (revision 530)
|
|
@@ -30,15 +30,15 @@ mpc_norm (mpfr_ptr a, mpc_srcptr b, mp_r
|
|
|
|
prec = MPFR_PREC(a);
|
|
|
|
- mpfr_init (u);
|
|
- mpfr_init (v);
|
|
-
|
|
/* handling of special values; consistent with abs in that
|
|
norm = abs^2; so norm (+-inf, nan) = norm (nan, +-inf) = +inf */
|
|
if ( (mpfr_nan_p (MPC_RE (b)) || mpfr_nan_p (MPC_IM (b)))
|
|
|| (mpfr_inf_p (MPC_RE (b)) || mpfr_inf_p (MPC_IM (b))))
|
|
return mpc_abs (a, b, rnd);
|
|
|
|
+ mpfr_init (u);
|
|
+ mpfr_init (v);
|
|
+
|
|
if (!mpfr_zero_p(MPC_RE(b)) && !mpfr_zero_p(MPC_IM(b)) &&
|
|
2 * SAFE_ABS (mp_exp_t, MPFR_EXP (MPC_RE (b)) - MPFR_EXP (MPC_IM (b)))
|
|
> (mp_exp_t)prec)
|
|
Index: src/inp_str.c
|
|
===================================================================
|
|
--- src/inp_str.c (revision 529)
|
|
+++ src/inp_str.c (revision 530)
|
|
@@ -1,6 +1,6 @@
|
|
/* mpc_inp_str -- Input a complex number from a given stream.
|
|
|
|
-Copyright (C) 2009 Andreas Enge, Philippe Th\'eveny, Paul Zimmermann.
|
|
+Copyright (C) 2009 Andreas Enge, Philippe Th\'eveny, Paul Zimmermann
|
|
|
|
This file is part of the MPC Library.
|
|
|
|
@@ -80,6 +80,7 @@ extract_string (FILE *stream)
|
|
size_t nread = 0;
|
|
size_t strsize = 100;
|
|
char *str = mpc_alloc_str (strsize);
|
|
+ size_t lenstr;
|
|
|
|
c = getc (stream);
|
|
while (c != EOF && c != '\n'
|
|
@@ -101,6 +102,8 @@ extract_string (FILE *stream)
|
|
if (nread == 0)
|
|
return str;
|
|
|
|
+ lenstr = nread;
|
|
+
|
|
if (c == '(') {
|
|
size_t n;
|
|
char *suffix;
|
|
@@ -127,7 +130,7 @@ extract_string (FILE *stream)
|
|
strsize = nread + 1;
|
|
}
|
|
|
|
- n = sprintf (str, "%s(%s", str, suffix);
|
|
+ n = lenstr + sprintf (str + lenstr, "(%s", suffix);
|
|
MPC_ASSERT (n == nread);
|
|
|
|
c = getc (stream);
|
|
@@ -151,7 +154,9 @@ extract_string (FILE *stream)
|
|
|
|
|
|
int
|
|
-mpc_inp_str (mpc_ptr rop, FILE *stream, size_t *read, int base, mpc_rnd_t rnd_mode) {
|
|
+mpc_inp_str (mpc_ptr rop, FILE *stream, size_t *read, int base,
|
|
+mpc_rnd_t rnd_mode)
|
|
+{
|
|
size_t white, nread = 0;
|
|
int inex = -1;
|
|
int c;
|
|
Index: tests/random.c
|
|
===================================================================
|
|
--- tests/random.c (revision 529)
|
|
+++ tests/random.c (revision 530)
|
|
@@ -96,6 +96,7 @@ test_end (void)
|
|
rands_initialized = 0;
|
|
gmp_randclear (rands);
|
|
}
|
|
+ mpfr_free_cache ();
|
|
}
|
|
|
|
/* wrapper for gmp_urandomb_ui, which did not exist in old versions of GMP */
|
|
Index: tests/Makefile.am
|
|
===================================================================
|
|
--- tests/Makefile.am (revision 529)
|
|
+++ tests/Makefile.am (revision 530)
|
|
@@ -3,19 +3,19 @@ AM_CFLAGS=@WARNINGCFLAGS@
|
|
AM_CPPFLAGS = -I$(top_srcdir)/src
|
|
LDADD = libmpc-tests.la $(top_builddir)/src/libmpc.la
|
|
|
|
-check_PROGRAMS = tio_str tabs tadd tadd_fr tadd_ui targ tconj tcos tcosh tdiv \
|
|
-tdiv_2exp tdiv_fr tdiv_ui texp tfr_div tfr_sub tget_version timag tlog tmul \
|
|
-tmul_2exp tmul_fr tmul_i tmul_si tmul_ui tneg tnorm tprec tproj treal tset \
|
|
-tsin tsinh tsqr tsqrt tstrtoc tsub tsub_fr tsub_ui ttan ttanh tui_div \
|
|
+check_PROGRAMS = tio_str tabs tadd tadd_fr tadd_ui targ tconj tcos tcosh tdiv \
|
|
+tdiv_2exp tdiv_fr tdiv_ui texp tfr_div tfr_sub tget_version timag tlog tmul \
|
|
+tmul_2exp tmul_fr tmul_i tmul_si tmul_ui tneg tnorm tprec tproj treal tset \
|
|
+tsin tsinh tsqr tsqrt tstrtoc tsub tsub_fr tsub_ui ttan ttanh tui_div \
|
|
tui_ui_sub treimref
|
|
|
|
check_LTLIBRARIES=libmpc-tests.la
|
|
-libmpc_tests_la_SOURCES=mpc-tests.h random.c tgeneric.c read_data.c \
|
|
+libmpc_tests_la_SOURCES=mpc-tests.h random.c tgeneric.c read_data.c \
|
|
comparisons.c
|
|
|
|
-EXTRA_DIST = abs.dat add.dat add_fr.dat arg.dat conj.dat cos.dat cosh.dat \
|
|
-div.dat div_fr.dat exp.dat fr_div.dat fr_sub.dat inp_str.dat log.dat mul.dat \
|
|
-mul_fr.dat neg.dat norm.dat proj.dat sin.dat sinh.dat sqr.dat sqrt.dat \
|
|
+EXTRA_DIST = abs.dat add.dat add_fr.dat arg.dat conj.dat cos.dat cosh.dat \
|
|
+div.dat div_fr.dat exp.dat fr_div.dat fr_sub.dat inp_str.dat log.dat mul.dat \
|
|
+mul_fr.dat neg.dat norm.dat proj.dat sin.dat sinh.dat sqr.dat sqrt.dat \
|
|
strtoc.dat sub.dat sub_fr.dat tan.dat tanh.dat
|
|
|
|
TESTS = $(check_PROGRAMS)
|
|
|