forked from kthohr/mcmc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
445 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
# core compiling options | ||
CC = @CC@ | ||
CXX = @CXX@ | ||
FC = @FC@ | ||
|
||
CXX_STD = -std=c++11 | ||
OPT_FLAGS = @MCMC_OPT_FLAGS@ | ||
|
||
ARMA_INCLUDE_PATH = @ARMA_INCLUDE_PATH@ | ||
|
||
# install location | ||
INSTALL_PATH=@MCMC_INSTALL_PATH@ | ||
|
||
# source directories | ||
SDIR = ./.. | ||
MCMC_DIR = $(SDIR) | ||
MCMC_HEADER_DIR = @MCMC_INCLUDE_PATH@ | ||
MCMC_TEST_DIR = . | ||
|
||
# general flags | ||
CXXFLAGS = $(CXX_STD) -Wall $(OPT_FLAGS) -I$(ARMA_INCLUDE_PATH) -I$(MCMC_HEADER_DIR) | ||
LIBS= -L@MCMC_INSTALL_PATH@ -l@MCMC_SHLIB_NAME@ @MCMC_BLAS_LAPACK@ | ||
|
||
# TraME Test Files | ||
SOURCES_MCMC= $(MCMC_TEST_DIR)/determine_bounds_type.cpp $(MCMC_TEST_DIR)/log_jacobian.cpp $(MCMC_TEST_DIR)/rwmh.cpp $(MCMC_TEST_DIR)/transform_vals.cpp | ||
OBJECTS_MCMC= $(SOURCES_MCMC:.cpp=.test) | ||
|
||
all: $(OBJECTS_MCMC) | ||
|
||
# core TraME files | ||
$(MCMC_TEST_DIR)/%.test: $(MCMC_TEST_DIR)/%.cpp | ||
$(CXX) $(CXXFLAGS) $< -o $@ $(LIBS) | ||
|
||
# cleanup and install | ||
.PHONY: clean | ||
clean: | ||
@rm -rf *.so ./*.gcov ./*.gcno ./*.gcda ./*.dSYM ./*.test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/bin/bash | ||
## MCMC tests config script | ||
|
||
while getopts b:c option | ||
do | ||
case "${option}" | ||
in | ||
b) MCMC_BUILD=${OPTARG};; | ||
c) MCMC_COVERAGE="y";; | ||
esac | ||
done | ||
|
||
if [ -z ${CC+x} ]; then | ||
CC=gcc | ||
fi | ||
if [ -z ${CXX+x} ]; then | ||
CXX=g++ | ||
fi | ||
if [ -z ${FC+x} ]; then | ||
FC=gfortran | ||
fi | ||
|
||
if [[ !(-z ${KEITH_DEV_SETTINGS+x}) ]]; then | ||
CC=gcc-mp-7 | ||
CXX=g++-mp-7 | ||
FC=gfortran-mp-7 | ||
fi | ||
|
||
WDIR=${PWD} | ||
|
||
if [ -z ${ARMA_INCLUDE_PATH+x} ]; then | ||
echo "MCMC: ARMA_INCLUDE_PATH not set" | ||
if [ -f /usr/include/armadillo ]; then | ||
ARMA_INCLUDE_PATH="/usr/include" | ||
elif [ -f /usr/local/include/armadillo ]; then | ||
ARMA_INCLUDE_PATH="/usr/local/include" | ||
elif [ -f /opt/include/armadillo ]; then | ||
ARMA_INCLUDE_PATH="/opt/include" | ||
elif [ -f /opt/local/include/armadillo ]; then | ||
ARMA_INCLUDE_PATH="/opt/local/include" | ||
else | ||
echo "MCMC tests: cannot find the armadillo library." | ||
echo "" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
echo "MCMC tests: ARMA_INCLUDE_PATH set to ${ARMA_INCLUDE_PATH}" | ||
|
||
# coverage build? used for codecov | ||
|
||
if [[ "${MCMC_COVERAGE}" == "y" ]]; then | ||
echo "MCMC tests: coverage build" | ||
MCMC_OPT_FLAGS="-g -O0 -Wall --coverage -fno-inline -fno-inline-small-functions -fno-default-inline" | ||
else | ||
MCMC_OPT_FLAGS="-O3 -Wall" | ||
fi | ||
|
||
MCMC_SHLIB_NAME="mcmc" | ||
|
||
# dev build | ||
|
||
if [[ "${MCMC_BUILD}" == "dev" ]]; then | ||
echo "MCMC: dev version" | ||
cd ../.. | ||
MCMC_INCLUDE_PATH=${PWD}/include | ||
MCMC_INSTALL_PATH=${PWD} | ||
cd ${WDIR} | ||
else | ||
MCMC_INSTALL_PATH="/usr/local" | ||
fi | ||
|
||
# BLAS and LAPACK settings | ||
|
||
if [[ $OSTYPE == darwin* ]] ; then | ||
MCMC_BLAS_LAPACK="-framework Accelerate" | ||
elif [[ $OSTYPE == *linux* ]] ; then | ||
MCMC_BLAS_LAPACK="-lblas -llapack" | ||
else | ||
MCMC_BLAS_LAPACK="-lblas -llapack" | ||
fi | ||
|
||
sed -e "s|@CC@|${CC}|" \ | ||
-e "s|@CXX@|${CXX}|" \ | ||
-e "s|@FC@|${FC}|" \ | ||
-e "s|@ARMA_INCLUDE_PATH@|${ARMA_INCLUDE_PATH}|" \ | ||
-e "s|@MCMC_BLAS_LAPACK@|${MCMC_BLAS_LAPACK}|" \ | ||
-e "s|@MCMC_OPT_FLAGS@|${MCMC_OPT_FLAGS}|" \ | ||
-e "s|@MCMC_SHLIB_NAME@|${MCMC_SHLIB_NAME}|" \ | ||
-e "s|@MCMC_INCLUDE_PATH@|${MCMC_INCLUDE_PATH}|" \ | ||
-e "s|@MCMC_INSTALL_PATH@|${MCMC_INSTALL_PATH}|" \ | ||
Makefile.in > Makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
if [ -z ${CXXCOV+x} ]; then | ||
CXXCOV=gcov | ||
fi | ||
|
||
if [[ !(-z ${KEITH_DEV_SETTINGS+x}) ]]; then | ||
CXXCOV=gcov-mp-7 | ||
fi | ||
|
||
for t in ./*.test; do | ||
"$t" | ||
done | ||
|
||
for t in ./*.cpp; do | ||
$CXXCOV "$t" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/*################################################################################ | ||
## | ||
## Copyright (C) 2011-2017 Keith O'Hara | ||
## | ||
## This file is part of the MCMC C++ library. | ||
## | ||
## MCMC is free software: you can redistribute it and/or modify | ||
## it under the terms of the GNU General Public License as published by | ||
## the Free Software Foundation, either version 2 of the License, or | ||
## (at your option) any later version. | ||
## | ||
## MCMC is distributed in the hope that it will be useful, | ||
## but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
## GNU General Public License for more details. | ||
## | ||
################################################################################*/ | ||
|
||
/* | ||
* unit test | ||
* | ||
* Keith O'Hara | ||
* 08/12/2017 | ||
* | ||
* This version: | ||
* 08/12/2017 | ||
*/ | ||
|
||
#include "mcmc.hpp" | ||
|
||
int main() | ||
{ | ||
const bool vals_bound = true; | ||
const int n_vals = 4; | ||
|
||
arma::vec lb(n_vals); | ||
lb(0) = 1; | ||
lb(1) = 1; | ||
lb(2) = -arma::datum::inf; | ||
lb(3) = -arma::datum::inf; | ||
|
||
arma::vec ub(n_vals); | ||
ub(0) = 2; | ||
ub(1) = arma::datum::inf; | ||
ub(2) = 2; | ||
ub(4) = arma::datum::inf; | ||
|
||
arma::uvec bounds_type = determine_bounds_type(vals_bound,n_vals,lb,ub); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/*################################################################################ | ||
## | ||
## Copyright (C) 2011-2017 Keith O'Hara | ||
## | ||
## This file is part of the MCMC C++ library. | ||
## | ||
## MCMC is free software: you can redistribute it and/or modify | ||
## it under the terms of the GNU General Public License as published by | ||
## the Free Software Foundation, either version 2 of the License, or | ||
## (at your option) any later version. | ||
## | ||
## MCMC is distributed in the hope that it will be useful, | ||
## but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
## GNU General Public License for more details. | ||
## | ||
################################################################################*/ | ||
|
||
/* | ||
* unit test | ||
* | ||
* Keith O'Hara | ||
* 08/12/2017 | ||
* | ||
* This version: | ||
* 08/12/2017 | ||
*/ | ||
|
||
#include "mcmc.hpp" | ||
|
||
int main() | ||
{ | ||
const bool vals_bound = true; | ||
const int n_vals = 4; | ||
|
||
arma::vec lb(n_vals); | ||
lb(0) = 0; | ||
lb(1) = 0; | ||
lb(2) = -arma::datum::inf; | ||
lb(3) = -arma::datum::inf; | ||
|
||
arma::vec ub(n_vals); | ||
ub(0) = 2; | ||
ub(1) = arma::datum::inf; | ||
ub(2) = 2; | ||
ub(4) = arma::datum::inf; | ||
|
||
arma::uvec bounds_type = mcmc::determine_bounds_type(vals_bound,n_vals,lb,ub); | ||
|
||
arma::vec initial_vals = arma::ones(n_vals,1); | ||
|
||
arma::vec vals_trans = mcmc::transform(initial_vals,bounds_type,lb,ub); | ||
|
||
double lj_val = log_jacobian(vals_trans,bounds_type,lb,ub); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.