From 980589a3834262fdf8e5fd21e51fc78cea6e87f2 Mon Sep 17 00:00:00 2001 From: "Erik M. Bray" Date: Tue, 11 Feb 2020 10:48:09 +0000 Subject: [PATCH 1/7] add a trivial .travis.yml that tests with gcc and clang on Ubuntu Bionic --- .travis.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..67a089c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: cpp +dist: bionic +compiler: + - gcc + - clang +os: + - linux +script: + - autoreconf -f -i + - ./configure + - make + - make check From 0f5d13e59f0b7d1ebec65373086b2b9f5f6a17f9 Mon Sep 17 00:00:00 2001 From: "Erik M. Bray" Date: Tue, 11 Feb 2020 11:06:47 +0000 Subject: [PATCH 2/7] use the AP addon to install mpfr headers --- .travis.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 67a089c..8e2bcd7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,15 @@ language: cpp +os: linux dist: bionic compiler: - - gcc - - clang -os: - - linux + - gcc + - clang +addons: + apt: + packages: + - libmpfr-dev script: - - autoreconf -f -i - - ./configure - - make - - make check + - autoreconf -f -i + - ./configure + - make + - make check From 91835d17281faf72e0e75bee0297fd0a12ed68a6 Mon Sep 17 00:00:00 2001 From: "Erik M. Bray" Date: Tue, 11 Feb 2020 11:38:13 +0000 Subject: [PATCH 3/7] fix warnings identified by clang --- include/polynomial.hpp | 12 +++++++----- include/sirocco.h | 4 +++- include/sirocco.hpp | 4 +++- lib/icomplex.cpp | 6 ++++-- lib/interval.cpp | 6 ++++-- lib/mp_interval.cpp | 4 ++++ lib/sirocco.cpp | 2 ++ 7 files changed, 27 insertions(+), 11 deletions(-) diff --git a/include/polynomial.hpp b/include/polynomial.hpp index 88d1299..fa0ca90 100644 --- a/include/polynomial.hpp +++ b/include/polynomial.hpp @@ -73,7 +73,7 @@ template std::ostream & operator<< (std::ostream &output, const Polynomial &op) { int allZero = 1; for (int i=0; i<=op.degree; ++i) - for (int j=0; j<=i; ++j){ + for (int j=0; j<=i; ++j) { if (op.coef[i*(i+1)/2 + j] == 0.0) continue; allZero = 0; if (op.coef[i*(i+1)/2 + j] == -1.0) @@ -85,26 +85,28 @@ std::ostream & operator<< (std::ostream &output, const Polynomial &op) { if (i == 0) if (op.coef[0] == T(1)) output << "1"; - if (i != 0) - if (i-j == 0) + if (i != 0) { + if (i-j == 0) { if (j == 1) output << "y"; else output << "y^" << j; - else if (i-j == 1) + } else if (i-j == 1) { if (j == 0) output << "x"; else if (j == 1) output << "x*y"; else output << "x*y^" << j; - else + } else { if (j == 0) output << "x^" << i; else if (j == 1) output << "x^" << (i-j) << "*y"; else output << "x^" << (i-j) << "*y^" << j; + } + } } if (allZero) output << "0"; return output; diff --git a/include/sirocco.h b/include/sirocco.h index 53f74bd..c63b6e6 100644 --- a/include/sirocco.h +++ b/include/sirocco.h @@ -5,7 +5,9 @@ #include // ACTIVATE ROUND MODE CONTROL -#pragma STDC FENV_ACCESS on +#ifndef __clang__ +#pragma STDC FENV_ACCESS ON +#endif double * homotopyPath (int degree, double *_coef, double _y0R, double _y0I); diff --git a/include/sirocco.hpp b/include/sirocco.hpp index 536a054..52d1c1d 100644 --- a/include/sirocco.hpp +++ b/include/sirocco.hpp @@ -8,7 +8,9 @@ // ACTIVATE ROUND MODE CONTROL -#pragma STDC FENV_ACCESS on +#ifndef __clang__ +#pragma STDC FENV_ACCESS ON +#endif typedef std::complex Complex; diff --git a/lib/icomplex.cpp b/lib/icomplex.cpp index 9ca65ef..f93fac0 100644 --- a/lib/icomplex.cpp +++ b/lib/icomplex.cpp @@ -5,7 +5,9 @@ #define MIN(a,b) (((a) < (b))? (a) : (b)) #define MAX(a,b) (((a) > (b))? (a) : (b)) -#pragma STDC FENV_ACCESS on +#ifndef __clang__ +#pragma STDC FENV_ACCESS ON +#endif // CONSTRUCTORS @@ -386,4 +388,4 @@ double f (double x, double c) { } double g (double x, double c) { return -c / (x*x + c*c); -} \ No newline at end of file +} diff --git a/lib/interval.cpp b/lib/interval.cpp index 2aba233..cc0e138 100644 --- a/lib/interval.cpp +++ b/lib/interval.cpp @@ -5,7 +5,9 @@ // ACTIVATE ROUND MODE CONTROL -#pragma STDC FENV_ACCESS on +#ifndef __clang__ +#pragma STDC FENV_ACCESS ON +#endif // MACROS FOR MIN AND MAX #define MIN(a,b) (((a) < (b))? (a) : (b)) @@ -365,4 +367,4 @@ Interval operator/ (double op1, const Interval &op2) { // RESTORE OLD ROUNDING MODE fesetround (oldRound); return rop; -} \ No newline at end of file +} diff --git a/lib/mp_interval.cpp b/lib/mp_interval.cpp index 22f5062..0e8fe42 100644 --- a/lib/mp_interval.cpp +++ b/lib/mp_interval.cpp @@ -80,21 +80,25 @@ MPInterval & MPInterval::operator= (const MPInterval &op) { // UPDATE VALUES mpfr_set (this->a, op.a, MPFR_RNDD); mpfr_set (this->b, op.b, MPFR_RNDU); + return *this; } MPInterval & MPInterval::operator= (const Interval &op) { // UPDATE VALUES mpfr_set_d (this->a, op.a, MPFR_RNDD); mpfr_set_d (this->b, op.b, MPFR_RNDU); + return *this; } MPInterval & MPInterval::operator= (const mpfr_t op) { // UPDATE VALUES mpfr_set (this->a, op, MPFR_RNDD); mpfr_set (this->b, op, MPFR_RNDU); + return *this; } MPInterval & MPInterval::operator= (double op) { // UPDATE VALUES mpfr_set_d (this->a, op, MPFR_RNDD); mpfr_set_d (this->b, op, MPFR_RNDU); + return *this; } diff --git a/lib/sirocco.cpp b/lib/sirocco.cpp index 1657a1d..8216638 100644 --- a/lib/sirocco.cpp +++ b/lib/sirocco.cpp @@ -17,7 +17,9 @@ using namespace std; // z2 = t(1+0.01i) ******************************************/ +#ifndef __clang__ #pragma STDC FENV_ACCESS ON +#endif // PERFORM A MINIMUM OF 5 ITERATIONS OF NEWTON METHOD TO CORRECT THE APPROXIMATION OF THE ROOT (SUPPOSED TO BE GOOD ENOUGH) template <> From 300c430e12a178cbdcead18cbef994872bc71a1f Mon Sep 17 00:00:00 2001 From: "Erik M. Bray" Date: Tue, 11 Feb 2020 11:40:15 +0000 Subject: [PATCH 4/7] add some test files to .gitignore --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 2e78688..7b5fe3a 100644 --- a/.gitignore +++ b/.gitignore @@ -17,5 +17,10 @@ lib/*.la libtool m4/ tests/.deps/ +tests/.libs/ +tests/*.log +tests/*.o +tests/*.trs +tests/*_test tests/Makefile tests/Makefile.in From 2c76fab76a85baeaf9743e95040d98ecad1bb5eb Mon Sep 17 00:00:00 2001 From: "Erik M. Bray" Date: Tue, 11 Feb 2020 11:47:30 +0000 Subject: [PATCH 5/7] after test failure show test logs, if any --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 8e2bcd7..56c7c79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,3 +13,5 @@ script: - ./configure - make - make check +after_failure: + - tail -n +1 tests/*.log 2>/dev/null From c8b9268a9a4aacf28138c897ad360c1ea373bf7a Mon Sep 17 00:00:00 2001 From: "E. Madison Bray" Date: Mon, 10 Feb 2020 19:20:15 +0100 Subject: [PATCH 6/7] remove brute-force disabling of optimizations --- configure.ac | 1 - 1 file changed, 1 deletion(-) diff --git a/configure.ac b/configure.ac index 64f87bb..68cda7c 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,6 @@ AC_INIT([libsirocco], [2.0], [mmarco@unizar.es]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) -: ${CXXFLAGS=-O0 -g} AM_INIT_AUTOMAKE([foreign -Wall]) AM_PROG_AR AC_PROG_CXX From 252ec0b7c810d1732d53e0a1bd490981903c3f21 Mon Sep 17 00:00:00 2001 From: "E. Madison Bray" Date: Mon, 10 Feb 2020 19:21:18 +0100 Subject: [PATCH 7/7] declare these template specializations to ensure they will be used in modules that include polynomial.hpp we may be able to achieve better performance, however, if these are defined inline --- include/polynomial.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/polynomial.hpp b/include/polynomial.hpp index fa0ca90..3aae66f 100644 --- a/include/polynomial.hpp +++ b/include/polynomial.hpp @@ -232,6 +232,10 @@ T Polynomial::operator() (const T &x, const T &y) const { return this->evalPolClassic (x,y); } +// Defined in lib/polynomial.cpp +template <> IComplex Polynomial::operator() (const IComplex &x, const IComplex &y) const; +template <> MPIComplex Polynomial::operator () (const MPIComplex &x, const MPIComplex &y) const; + template T Polynomial::diffX (const T &x, const T &y) const { // coef[(i*(i+1))/2 + j] is coeficient of monomial of degree 'i', @@ -313,6 +317,10 @@ T Polynomial::diffY (const T &x, const T &y) const { return this->evalPolYClassic (x,y); } +// Defined in lib/polynomial.cpp +template <> IComplex Polynomial::diffY (const IComplex &x, const IComplex &y) const; +template <> MPIComplex Polynomial::diffY (const MPIComplex &x, const MPIComplex &y) const; + template T Polynomial::diffXX (const T &x, const T &y) const {