Skip to content

Namespace and documentation refactoring #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ addons:

env:
global:
- DOLONGDOUBLE="-DDCPROGS_LONG_DOUBLE=OFF"
- DOLONGDOUBLE="-DHJCFIT_LONG_DOUBLE=OFF"
- UPLOADDOCS=false
matrix:
include:
Expand All @@ -48,7 +48,7 @@ matrix:
env: UPLOADDOCS=true
- os: linux
python: 3.5
env: DOLONGDOUBLE="-DDCPROGS_LONG_DOUBLE=ON"
env: DOLONGDOUBLE="-DHJCFIT_LONG_DOUBLE=ON"
- os: osx
osx_image: xcode7.3
python: 2.7
Expand Down
28 changes: 14 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
########################
# DCProgs computes missed-events likelihood as described in
# HJCFIT computes missed-events likelihood as described in
# Hawkes, Jalali and Colquhoun (1990, 1992)
#
# Copyright (C) 2013 University College London
Expand Down Expand Up @@ -35,7 +35,7 @@ option(pythonBindings "Enable python bindings." on)
option(compileDocs "Compile c++11 documentation examples." on)
option(openmp "Enable OpenMP parallelization." on)
option(executenotebooks "Execute example Jupyter notebooks." on)
CMAKE_DEPENDENT_OPTION(DCPROGS_USE_MPFR "Enable fallback to MPFR Multi precision" ON "UNIX" OFF)
CMAKE_DEPENDENT_OPTION(HJCFIT_USE_MPFR "Enable fallback to MPFR Multi precision" ON "UNIX" OFF)

set(JUPYTER_KERNEL "" CACHE STRING "Jupyter kernel to run notebooks with defaults to python2 or python3 depending on python version")
# Provides backwards compatibility and prevents MACOS_RPATH warning
Expand Down Expand Up @@ -132,28 +132,28 @@ if(NOT HAS_CXX11_NOEXCEPT)
set(noexcept TRUE)
endif()

if(NOT DCPROGS_LONG_DOUBLE)
set(DCPROGS_LONG_DOUBLE False CACHE BOOL
if(NOT HJCFIT_LONG_DOUBLE)
set(HJCFIT_LONG_DOUBLE False CACHE BOOL
"If True, will use long doubles rather than simple doubles.")
endif(NOT DCPROGS_LONG_DOUBLE)
endif(NOT HJCFIT_LONG_DOUBLE)

if(NOT DCPROGS_USE_MPFR)
set(DCPROGS_USE_MPFR False CACHE BOOL
if(NOT HJCFIT_USE_MPFR)
set(HJCFIT_USE_MPFR False CACHE BOOL
"If True, will use MPFR arbitrary precision floats as fall back if regular double calculations fail.")
endif(NOT DCPROGS_USE_MPFR)
endif(NOT HJCFIT_USE_MPFR)

if(DCPROGS_USE_MPFR)
if(HJCFIT_USE_MPFR)
find_or_add_hunter_package(GMP)
find_or_add_hunter_package(MPFR)
include_directories(${PROJECT_SOURCE_DIR}/mpfr)
endif(DCPROGS_USE_MPFR)
endif(HJCFIT_USE_MPFR)
configure_file (
"${PROJECT_SOURCE_DIR}/DCProgsConfig.h.in"
"${PROJECT_BINARY_DIR}/DCProgsConfig.h"
"${PROJECT_SOURCE_DIR}/HJCFITConfig.h.in"
"${PROJECT_BINARY_DIR}/HJCFITConfig.h"
)

# Save all DCPROGS headers in the same place in Windows
install(FILES ${PROJECT_BINARY_DIR}/DCProgsConfig.h DESTINATION include/dcprogs)
# Save all HJCFIT headers in the same place in Windows
install(FILES ${PROJECT_BINARY_DIR}/HJCFITConfig.h DESTINATION include/HJCFIT)

include(${CMAKE_SCRIPTS}/documentation.cmake)

Expand Down
76 changes: 38 additions & 38 deletions DCProgsConfig.h.in → HJCFITConfig.h.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***********************
DCProgs computes missed-events likelihood as described in
HJCFIT computes missed-events likelihood as described in
Hawkes, Jalali and Colquhoun (1990, 1992)

Copyright (C) 2013 University College London
Expand All @@ -18,17 +18,17 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
************************/

#ifndef DCPROGS_CONFIG_H
#define DCPROGS_CONFIG_H
#ifndef HJCFIT_CONFIG_H
#define HJCFIT_CONFIG_H

#include <iso646.h>
#include <vector>
#include <limits>
#include <type_traits>
#include <Eigen/Dense>
#cmakedefine DCPROGS_USE_MPFR
#cmakedefine HJCFIT_USE_MPFR

#ifdef DCPROGS_USE_MPFR
#ifdef HJCFIT_USE_MPFR
# include <unsupported/Eigen/MPRealSupport>
#endif

Expand All @@ -47,26 +47,26 @@
#cmakedefine HAS_CXX11_CONSTRUCTOR_DELEGATE

#ifdef HAS_CXX11_CONSTEXPR
# define DCPROGS_INIT_CONSTEXPR(TYPEANDNAME, VALUE) constexpr static TYPEANDNAME = VALUE
# define DCPROGS_DECL_CONSTEXPR(TYPEANDNAME, VALUE) constexpr TYPEANDNAME
# define HJCFIT_INIT_CONSTEXPR(TYPEANDNAME, VALUE) constexpr static TYPEANDNAME = VALUE
# define HJCFIT_DECL_CONSTEXPR(TYPEANDNAME, VALUE) constexpr TYPEANDNAME
#else
# define DCPROGS_INIT_CONSTEXPR(TYPEANDNAME, VALUE) const static TYPEANDNAME
# define DCPROGS_DECL_CONSTEXPR(TYPEANDNAME, VALUE) const TYPEANDNAME = VALUE
# define HJCFIT_INIT_CONSTEXPR(TYPEANDNAME, VALUE) const static TYPEANDNAME
# define HJCFIT_DECL_CONSTEXPR(TYPEANDNAME, VALUE) const TYPEANDNAME = VALUE
#endif

// one should alway known when one is working on crapware
#cmakedefine MSVC


#if defined(MSWINDOBE) && defined(DCPROGS_LIKELIHOOD_DLLEXPORT)
#if defined(MSWINDOBE) && defined(HJCFIT_LIKELIHOOD_DLLEXPORT)
# undef MSWINDOBE
# define MSWINDOBE __declspec(dllexport)
#endif
#ifndef MSWINDOBE
# define MSWINDOBE
#endif

#cmakedefine DCPROGS_PYTHON_BINDINGS
#cmakedefine HJCFIT_PYTHON_BINDINGS
#cmakedefine NUMPY_NPY_LONG_DOUBLE
#cmakedefine NUMPY_NPY_BOOL
#cmakedefine NUMPY_NPY_ARRAY
Expand All @@ -81,48 +81,48 @@
#cmakedefine CXX_HAS_FLOAT_H_ISNAN
#ifdef CXX_HAS_STD_ISNAN
# include <cmath>
# define DCPROGS_ISNAN(X) std::isnan(X)
# define HJCFIT_ISNAN(X) std::isnan(X)
#elif defined(CXX_HAS_ISNAN)
# include <math.h>
# define DCPROGS_ISNAN(X) ::isnan(X)
# define HJCFIT_ISNAN(X) ::isnan(X)
#elif defined CXX_HAS___ISNAN
# include <math.h>
# define DCPROGS_ISNAN(X) __isnan(X)
# define HJCFIT_ISNAN(X) __isnan(X)
#elif defined(CXX_HAS_FLOAT_H_ISNAN)
# include <float.h>
# define DCPROGS_ISNAN(X) _isnan(X)
# define HJCFIT_ISNAN(X) _isnan(X)
#else
# error no macro defined for isnan
#endif

#cmakedefine DCPROGS_LONG_DOUBLE
#cmakedefine DCPROGS_PYTHON3
#cmakedefine HJCFIT_LONG_DOUBLE
#cmakedefine HJCFIT_PYTHON3

#define DCPROGS_STACK_MATRIX_MAX 50
#define HJCFIT_STACK_MATRIX_MAX 50

namespace DCProgs {
# ifdef DCPROGS_LONG_DOUBLE
//! Types of reals across DCProgs.
namespace HJCFIT {
# ifdef HJCFIT_LONG_DOUBLE
//! Types of reals across HJCFIT.
typedef long double t_real;
# else
//! Types of reals across DCProgs.
//! Types of reals across HJCFIT.
typedef double t_real;
# endif
//! Complex real type
typedef std::complex<t_real> t_complex;
//! Types of integers across DCProgs.
//! Types of integers across HJCFIT.
typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE t_int;
//! Types of unsigned integers across DCProgs.
//! Types of unsigned integers across HJCFIT.
typedef std::make_unsigned<t_int>::type t_uint;
//! Types of real matrices across DCProgs.
//! Types of real matrices across HJCFIT.
typedef Eigen::Matrix<t_real, ::Eigen::Dynamic, ::Eigen::Dynamic, 0, ::Eigen::Dynamic, ::Eigen::Dynamic> t_rmatrix;
//! Types of real matrices across DCProgs guaranteed to be allocated on the stack. Max size DCPROGS_STACK_MATRIX_MAX by DCPROGS_STACK_MATRIX_MAX
typedef Eigen::Matrix<t_real, ::Eigen::Dynamic, ::Eigen::Dynamic, 0, DCPROGS_STACK_MATRIX_MAX, DCPROGS_STACK_MATRIX_MAX> t_stack_rmatrix;
//! Types of boolean matrices across DCProgs.
//! Types of real matrices across HJCFIT guaranteed to be allocated on the stack. Max size HJCFIT_STACK_MATRIX_MAX by HJCFIT_STACK_MATRIX_MAX
typedef Eigen::Matrix<t_real, ::Eigen::Dynamic, ::Eigen::Dynamic, 0, HJCFIT_STACK_MATRIX_MAX, HJCFIT_STACK_MATRIX_MAX> t_stack_rmatrix;
//! Types of boolean matrices across HJCFIT.
typedef Eigen::Matrix<bool, ::Eigen::Dynamic, ::Eigen::Dynamic, 0, ::Eigen::Dynamic, ::Eigen::Dynamic> t_bmatrix;
//! Types of initial state vectors across DCProgs.
//! Types of initial state vectors across HJCFIT.
typedef Eigen::Matrix<t_real, 1, ::Eigen::Dynamic, ::Eigen::RowMajor, 1, ::Eigen::Dynamic> t_initvec;
//! Types of final state vectors across DCProgs.
//! Types of final state vectors across HJCFIT.
typedef Eigen::Matrix<t_real, ::Eigen::Dynamic, 1, 0, ::Eigen::Dynamic, 1> t_rvector;
//! Type of complex matrices.
typedef Eigen::Matrix<t_complex, ::Eigen::Dynamic, ::Eigen::Dynamic, 0, ::Eigen::Dynamic, ::Eigen::Dynamic> t_cmatrix;
Expand All @@ -134,14 +134,14 @@ namespace DCProgs {
//! Type holding the bursts.
typedef std::vector<t_Burst> t_Bursts;

# ifdef DCPROGS_USE_MPFR
//! Types of multi-precision float across DCProgs.
# ifdef HJCFIT_USE_MPFR
//! Types of multi-precision float across HJCFIT.
typedef mpfr::mpreal t_mpfr_real;
//! Types of multi-precision complex across DCProgs.
//! Types of multi-precision complex across HJCFIT.
typedef std::complex<t_mpfr_real> t_mpfr_complex;
//! Types of multi-precision complex vector across DCProgs.
//! Types of multi-precision complex vector across HJCFIT.
typedef Eigen::Matrix<t_mpfr_complex, ::Eigen::Dynamic, 1, 0, ::Eigen::Dynamic, 1> t_mpfr_cvector;
//! Types of multi-precision real matrix across DCProgs.
//! Types of multi-precision real matrix across HJCFIT.
typedef Eigen::Matrix<t_mpfr_real, ::Eigen::Dynamic, ::Eigen::Dynamic, 0, ::Eigen::Dynamic, ::Eigen::Dynamic> t_mpfr_rmatrix;

# endif
Expand All @@ -158,17 +158,17 @@ namespace DCProgs {
bool eigen_nan(Eigen::DenseBase<T> const &_matrix) {
for(typename Eigen::DenseBase<T>::Index i(0); i < _matrix.rows(); ++i)
for(typename Eigen::ArrayBase<T>::Index j(0); j < _matrix.cols(); ++j)
if(DCPROGS_ISNAN(_matrix(i, j))) return true;
if(HJCFIT_ISNAN(_matrix(i, j))) return true;
return false;
}

// Check that quiet nan exists. Otherwise fails to compile here and now.
static_assert(std::numeric_limits<t_real>::has_quiet_NaN == true,
"Quiet NaN is not defined for the reals used by DCProgs.");
"Quiet NaN is not defined for the reals used by HJCFIT.");

//! The quiet NaN value
t_real static const quiet_nan = std::numeric_limits<t_real>::quiet_NaN();

t_uint static const dcprogs_stack_matrix = DCPROGS_STACK_MATRIX_MAX;
t_uint static const HJCFIT_stack_matrix = HJCFIT_STACK_MATRIX_MAX;
}
#endif
1 change: 1 addition & 0 deletions LaunchNotebook.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jupyter notebook
4 changes: 2 additions & 2 deletions cmake_modules/AllPythonBindings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ if(MSYS)
unset(NEED_CMATH_INCLUDE)
endif(MSYS)

set(DCPROGS_PYTHON_BINDINGS True)
set(HJCFIT_PYTHON_BINDINGS True)

if(tests)
if(NOT DEFINED TEST_INSTALL_DIRECTORY)
Expand Down Expand Up @@ -142,5 +142,5 @@ else()
endif(WIN32)

if(NOT PYTHON_VERSION VERSION_LESS "3.0.0")
set(DCPROGS_PYTHON3 TRUE)
set(HJCFIT_PYTHON3 TRUE)
endif(NOT PYTHON_VERSION VERSION_LESS "3.0.0")
8 changes: 4 additions & 4 deletions cmake_modules/documentation.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ if(SPHINX_FOUND)
else()
set(SPHINX_EXTENSIONS "'sphinxcontrib.bibtex'")
endif(DOXYGEN_FOUND)
if(DCPROGS_USE_MPFR)
set(SPHINX_DCPROGS_USE_MPFR "True")
if(HJCFIT_USE_MPFR)
set(SPHINX_HJCFIT_USE_MPFR "True")
else()
set(SPHINX_DCPROGS_USE_MPFR "False")
endif(DCPROGS_USE_MPFR)
set(SPHINX_HJCFIT_USE_MPFR "False")
endif(HJCFIT_USE_MPFR)
endif(SPHINX_FOUND)

if (DOXYGEN_FOUND)
Expand Down
4 changes: 2 additions & 2 deletions data/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
########################
# DCProgs computes missed-events likelihood as described in
# HJCFIT computes missed-events likelihood as described in
# Hawkes, Jalali and Colquhoun (1990, 1992)
#
# Copyright (C) 2013 University College London
Expand All @@ -17,7 +17,7 @@

if(pythonBindings)

install(FILES CH82.scn CCO.scn CO.scn DESTINATION ${PYINSTALL_DIRECTORY}/dcprogs/data)
install(FILES CH82.scn CCO.scn CO.scn DESTINATION ${PYINSTALL_DIRECTORY}/hjcfit/data)

endif(pythonBindings)

2 changes: 1 addition & 1 deletion documentation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
########################
# DCProgs computes missed-events likelihood as described in
# HJCFIT computes missed-events likelihood as described in
# Hawkes, Jalali and Colquhoun (1990, 1992)
#
# Copyright (C) 2013 University College London
Expand Down
16 changes: 8 additions & 8 deletions documentation/code/approx_survivor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@
int main() {

// Define parameters.
DCProgs::t_rmatrix matrix(5 ,5);
HJCFIT::t_rmatrix matrix(5 ,5);
matrix << -3050, 50, 3000, 0, 0,
2./3., -1502./3., 0, 500, 0,
15, 0, -2065, 50, 2000,
0, 15000, 4000, -19000, 0,
0, 0, 10, 0, -10;
DCProgs::QMatrix qmatrix(matrix, /*nopen=*/2);
HJCFIT::QMatrix qmatrix(matrix, /*nopen=*/2);

DCProgs::ApproxSurvivor survivor(qmatrix, 1e-4);
HJCFIT::ApproxSurvivor survivor(qmatrix, 1e-4);

std::cout << survivor << std::endl;

std::cout << "AF values\n"
"---------\n\n";
std::cout << " * at time t=" << 1e-4 <<":\n "
<< DCProgs::numpy_io(survivor.af(1e-4), " ") << "\n"
<< HJCFIT::numpy_io(survivor.af(1e-4), " ") << "\n"
<< " * at time t=" << 1.5e-4 <<":\n "
<< DCProgs::numpy_io(survivor.af(1.5e-4), " ") << "\n"
<< HJCFIT::numpy_io(survivor.af(1.5e-4), " ") << "\n"
<< " * at time t=" << 2.0e-4 <<":\n "
<< DCProgs::numpy_io(survivor.af(2.0e-4), " ") << "\n"
<< HJCFIT::numpy_io(survivor.af(2.0e-4), " ") << "\n"
<< " * at time t=" << 2.5e-4 <<":\n "
<< DCProgs::numpy_io(survivor.af(2.5e-4), " ") << "\n\n";
<< HJCFIT::numpy_io(survivor.af(2.5e-4), " ") << "\n\n";

std::cout << " * Exponents: ";
for(DCProgs::t_uint i(0); i < survivor.nb_af_components(); ++i)
for(HJCFIT::t_uint i(0); i < survivor.nb_af_components(); ++i)
std::cout << std::get<1>(survivor.get_af_components(i)) << " ";
std::cout << std::endl;

Expand Down
2 changes: 1 addition & 1 deletion documentation/code/approx_survivor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dcprogs.likelihood import QMatrix, ApproxSurvivor
from HJCFIT.likelihood import QMatrix, ApproxSurvivor

# Define parameters.
qmatrix = QMatrix([ [-3050, 50, 3000, 0, 0],
Expand Down
Loading