Skip to content

Commit

Permalink
put guards around GSL code in moment_sequence.cpp. Makefile in src di…
Browse files Browse the repository at this point in the history
…rectory can now compile with GSL support
  • Loading branch information
terencewtli committed Jul 30, 2020
1 parent 3f09c9d commit 8dafbff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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/, \
Expand Down
8 changes: 7 additions & 1 deletion src/moment_sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifdef HAVE_GSL
#include <gsl/gsl_sf_gamma.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_multiroots.h>
#include <gsl/gsl_linalg.h>
#include <gsl/gsl_poly.h>
#include <gsl/gsl_randist.h>
#endif

#include "moment_sequence.hpp"

Expand All @@ -35,6 +37,7 @@
#include <iostream>
#include <cassert>
#include <algorithm>
#include <cmath>

using std::string;
using std::vector;
Expand All @@ -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
Expand Down Expand Up @@ -110,6 +115,7 @@ ensure_pos_def_mom_seq(vector <double> &moments,

return max(hankel_dim - 1, min_hankel_dim);
}
#endif


/////////////////////////////////////////////////////
Expand Down

0 comments on commit 8dafbff

Please sign in to comment.