Indian Ocean Skipjack
variable.hpp
1 #pragma once
2 
3 template<class Distribution>
4 class Variable : public Distribution, public Structure<Variable<Distribution>> {
5 public:
6 
7  using Structure<Variable<Distribution>>::derived;
8  using Structure<Variable<Distribution>>::derived_nullptr;
9 
10  double value = NAN;
11 
12  bool is_na(void) const {
13  return std::isnan(value);
14  }
15 
16  operator double(void) const {
17  return value;
18  }
19 
20  #define OP_(op) void operator op(const double& other){ value op other; }
21  OP_(=)
22  OP_(+=)
23  OP_(-=)
24  OP_(*=)
25  OP_(/=)
26  #undef OP_
27 
28  double loglike(void) const {
29  if(not is_na() and Distribution::valid()){
30  return Distribution::loglike(value);
31  }
32  return 0;
33  }
34 
35  template<class Mirror>
36  void reflect(Mirror& mirror) {
37  mirror
38  .data(value,"value");
39  Distribution::reflect(mirror);
40  }
41 };
Definition: variable.hpp:4