Skip to content

Commit 8dafbff

Browse files
committed
put guards around GSL code in moment_sequence.cpp. Makefile in src directory can now compile with GSL support
1 parent 3f09c9d commit 8dafbff

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ endif
2020

2121
INCLUDEDIRS = smithlab_cpp
2222
INCLUDEARGS = $(addprefix -I, $(INCLUDEDIRS))
23-
LIBS = -lgsl -lgslcblas -lz
23+
LIBS = -lz
2424
CXX = g++
2525
CXXFLAGS = -std=c++11 -Wall
2626

@@ -35,6 +35,11 @@ CXXFLAGS += -DHAVE_HTSLIB
3535
LIBS += -lhts
3636
endif
3737

38+
ifdef HAVE_GSL
39+
CXXFLAGS += -DHAVE_GSL
40+
LIBS += -lgsl -lgslcblas
41+
endif
42+
3843
all: $(PROGS)
3944

4045
$(PROGS): $(addprefix smithlab_cpp/, \

src/moment_sequence.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
*/
2020

21+
#ifdef HAVE_GSL
2122
#include <gsl/gsl_sf_gamma.h>
2223
#include <gsl/gsl_vector.h>
2324
#include <gsl/gsl_matrix.h>
2425
#include <gsl/gsl_multiroots.h>
2526
#include <gsl/gsl_linalg.h>
2627
#include <gsl/gsl_poly.h>
2728
#include <gsl/gsl_randist.h>
29+
#endif
2830

2931
#include "moment_sequence.hpp"
3032

@@ -35,6 +37,7 @@
3537
#include <iostream>
3638
#include <cassert>
3739
#include <algorithm>
40+
#include <cmath>
3841

3942
using std::string;
4043
using std::vector;
@@ -45,8 +48,10 @@ using std::setprecision;
4548
using std::swap;
4649
using std::find_if;
4750
using std::transform;
51+
using std::isfinite;
52+
using std::isinf;
4853

49-
54+
#ifdef HAVE_GSL
5055
/////////////////////////////////////////////////////
5156
// test Hankel moment matrix
5257
// ensure moment sequence is positive definite
@@ -110,6 +115,7 @@ ensure_pos_def_mom_seq(vector <double> &moments,
110115

111116
return max(hankel_dim - 1, min_hankel_dim);
112117
}
118+
#endif
113119

114120

115121
/////////////////////////////////////////////////////

0 commit comments

Comments
 (0)