@KrzysztofSakrej/TidyExtrasmallProlog-1
C++11

No description

I built🔨
THIS
Files
  • main.cpp
  • algorithm-responsibility.cpp
  • data-stream.hpp
  • interface-responsibility.cpp
  • relay.cpp
  • stan-interface-helpers.cpp
main.cpp
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
#include <iostream>
#include <vector>
#include <tuple>
#include <type_traits>
#include <cstddef>
#include <exception>
#include <string>
#include <algorithm>

#include "relay.cpp"
#include "algorithm-responsibility.cpp"
#include "interface-responsibility.cpp"


int main() {
  // Interface sets up relay, streams for the handler types
  // and links instances of the handler types to the relay.

  typedef relay<hmc_iter_stats, constrained_params> hmc_relay;
	hmc_relay r;
  csv_stream<constrained_params> params_stream(std::cout);
  r.set_stream<constrained_params>(&params_stream);

  csv_stream<hmc_iter_stats> stats_stream(std::cout);
  r.set_stream<hmc_iter_stats>(&stats_stream);

  // Stan-dev/stan initializes its fancy algorithm and
  // sets up the relay to handle various types of output
  std::vector<std::string> param_names;
  param_names.push_back("alpha");
  param_names.push_back("beta");
  r.send_headers<constrained_params>(param_names);
  hmc_iter_stats::header_def hmc_header;
  r.send_headers<hmc_iter_stats>(hmc_header);

  // Stan-dev/stan runs its fancy algorithm and 
  // calls the relay to handle various types of 
  // output.
  std::vector<double> param_values;
  param_values.push_back(0.1);
  param_values.push_back(0.2);
  r.send<constrained_params>({param_values});
  r.send<hmc_iter_stats>({0.5, 1, true});

  /* Uncomment to see error when stream is not defined 
  struct undefined_output {
 	  typedef no_header header_def;   
  };

  r.send_headers<undefined_output>(no_header::nh);
  */
}
gcc version 4.6.3