-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommon.hpp
47 lines (36 loc) · 1019 Bytes
/
Common.hpp
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
// Common.hpp
// Age Structured Assessment Modeling System (ASAMS)
//
//
#ifndef Common_h
#define Common_h
#include <vector>
#include <cmath>
#define variable double
template <class T>
/// A class for a general model framework.
///
/// Provides a framework for a model.
class model_base{
protected:
std::vector<T*> estimable_parameters;
std::vector<DistributionBase<T>*> parameter_priors;
std::vector<int> phase;
public:
void register_parameter(T& par, int phase = 1, DistributionBase<T>* prior = new asams::NormalDistribution()){
estimable_parameters.pushback(&par);
phase.pushback(phase);
parameter_priors.pushback(prior);
}
};
namespace asams {
template <class T>
const T exp(const T& x){return std::exp(x);}
template <class T>
const T log(const T& x){return std::log(x);}
template <class T>
inline const T logistic(const T& a50, const T& slope, const T& age){
return (1.0) / (1.0 + asams::exp(-1.0 * (age - a50) / slope));
}
}
#endif /* Common_h */