-
Notifications
You must be signed in to change notification settings - Fork 4
/
DCProgsConfig.h.in
148 lines (127 loc) · 5.09 KB
/
DCProgsConfig.h.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/***********************
DCProgs computes missed-events likelihood as described in
Hawkes, Jalali and Colquhoun (1990, 1992)
Copyright (C) 2013 University College London
This program 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 3 of the License, or
(at your option) any later version.
This program 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
************************/
#ifndef DCPROGS_CONFIG_H
#define DCPROGS_CONFIG_H
#include <iso646.h>
#include <vector>
#include <limits>
#include <type_traits>
#include <Eigen/Dense>
#cmakedefine HAS_CXX11_TYPE_TRAITS
#cmakedefine HAS_CXX11_TRIVIAL_TYPE_TRAITS
#cmakedefine HAS_CXX11_CONSTEXPR
#cmakedefine noexcept throw()
#cmakedefine MSWINDOBE __declspec(dllimport)
#cmakedefine HAS_CXX11_CONSTEXPR
#cmakedefine HAS_CXX11_RANDOM_DEVICE
#cmakedefine HAS_CXX11_UNIQUE_PTR
#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
#else
# define DCPROGS_INIT_CONSTEXPR(TYPEANDNAME, VALUE) const static TYPEANDNAME
# define DCPROGS_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)
# undef MSWINDOBE
# define MSWINDOBE __declspec(dllexport)
#endif
#ifndef MSWINDOBE
# define MSWINDOBE
#endif
#cmakedefine DCPROGS_PYTHON_BINDINGS
#cmakedefine NUMPY_NPY_LONG_DOUBLE
#cmakedefine NUMPY_NPY_BOOL
#cmakedefine NUMPY_NPY_ARRAY
#cmakedefine NUMPY_NPY_ENABLEFLAGS
#cmakedefine NUMPY_VERSION_MAJOR @NUMPY_VERSION_MAJOR@
#cmakedefine NUMPY_VERSION_MINOR @NUMPY_VERSION_MINOR@
#cmakedefine CXX_HAS_STD_ISNAN
#cmakedefine CXX_HAS_ISNAN
#cmakedefine CXX_HAS__ISNAN
#cmakedefine CXX_HAS_FLOAT_H_ISNAN
#ifdef CXX_HAS_STD_ISNAN
# include <cmath>
# define DCPROGS_ISNAN(X) std::isnan(X)
#elif defined(CXX_HAS_ISNAN)
# include <math.h>
# define DCPROGS_ISNAN(X) ::isnan(X)
#elif defined CXX_HAS___ISNAN
# include <math.h>
# define DCPROGS_ISNAN(X) __isnan(X)
#elif defined(CXX_HAS_FLOAT_H_ISNAN)
# include <float.h>
# define DCPROGS_ISNAN(X) _isnan(X)
#else
# error no macro defined for isnan
#endif
#cmakedefine DCPROGS_LONG_DOUBLE
#cmakedefine DCPROGS_PYTHON3
namespace DCProgs {
# ifdef DCPROGS_LONG_DOUBLE
//! Types of reals across DCProgs.
typedef long double t_real;
# else
//! Types of reals across DCProgs.
typedef double t_real;
# endif
//! Complex real type
typedef std::complex<t_real> t_complex;
//! Types of integers across DCProgs.
typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE t_int;
//! Types of unsigned integers across DCProgs.
typedef std::make_unsigned<t_int>::type t_uint;
//! Types of real matrices across DCProgs.
typedef Eigen::Matrix<t_real, ::Eigen::Dynamic, ::Eigen::Dynamic> t_rmatrix;
//! Types of boolean matrices across DCProgs.
typedef Eigen::Matrix<bool, ::Eigen::Dynamic, ::Eigen::Dynamic> t_bmatrix;
//! Types of initial state vectors across DCProgs.
typedef Eigen::Matrix<t_real, 1, ::Eigen::Dynamic> t_initvec;
//! Types of final state vectors across DCProgs.
typedef Eigen::Matrix<t_real, ::Eigen::Dynamic, 1> t_rvector;
//! Type of complex matrices.
typedef Eigen::Matrix<t_complex, ::Eigen::Dynamic, ::Eigen::Dynamic> t_cmatrix;
//! Type of complex vectors.
typedef Eigen::Matrix<t_complex, ::Eigen::Dynamic, 1> t_cvector;
//! Type of a burst
typedef std::vector<t_real> t_Burst;
//! Type holding the bursts.
typedef std::vector<t_Burst> t_Bursts;
//! Dumps eigen array in format we can copy/paste to python
template<class T>
auto numpy_io(Eigen::DenseBase<T> const &_matrix, std::string const &_indent="")
-> decltype(_matrix.format(Eigen::IOFormat())) {
return _matrix.format(Eigen::IOFormat(Eigen::FullPrecision, 0, ", ", ",\n" + _indent,
"[", "]", "[", "]"));
}
//! Checks whether a numpy array has any NaN.
template<class T>
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;
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.");
//! The quiet NaN value
t_real static const quiet_nan = std::numeric_limits<t_real>::quiet_NaN();
}
#endif