From 8dafbff5e243282c966053e593758edcc80bca0c Mon Sep 17 00:00:00 2001 From: Terence Li Date: Thu, 30 Jul 2020 11:49:32 -0700 Subject: [PATCH] put guards around GSL code in moment_sequence.cpp. Makefile in src directory can now compile with GSL support --- src/Makefile | 7 ++++++- src/moment_sequence.cpp | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index 1bbc129..f46f21b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -20,7 +20,7 @@ endif INCLUDEDIRS = smithlab_cpp INCLUDEARGS = $(addprefix -I, $(INCLUDEDIRS)) -LIBS = -lgsl -lgslcblas -lz +LIBS = -lz CXX = g++ CXXFLAGS = -std=c++11 -Wall @@ -35,6 +35,11 @@ CXXFLAGS += -DHAVE_HTSLIB LIBS += -lhts endif +ifdef HAVE_GSL +CXXFLAGS += -DHAVE_GSL +LIBS += -lgsl -lgslcblas +endif + all: $(PROGS) $(PROGS): $(addprefix smithlab_cpp/, \ diff --git a/src/moment_sequence.cpp b/src/moment_sequence.cpp index 3c199ba..939b622 100644 --- a/src/moment_sequence.cpp +++ b/src/moment_sequence.cpp @@ -18,6 +18,7 @@ * along with this program. If not, see . */ +#ifdef HAVE_GSL #include #include #include @@ -25,6 +26,7 @@ #include #include #include +#endif #include "moment_sequence.hpp" @@ -35,6 +37,7 @@ #include #include #include +#include using std::string; using std::vector; @@ -45,8 +48,10 @@ using std::setprecision; using std::swap; using std::find_if; using std::transform; +using std::isfinite; +using std::isinf; - +#ifdef HAVE_GSL ///////////////////////////////////////////////////// // test Hankel moment matrix // ensure moment sequence is positive definite @@ -110,6 +115,7 @@ ensure_pos_def_mom_seq(vector &moments, return max(hankel_dim - 1, min_hankel_dim); } +#endif /////////////////////////////////////////////////////