Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
print_progress.hpp
Go to the documentation of this file.
1 #ifndef STAN__COMMON__PRINT_PROGRESS_HPP
2 #define STAN__COMMON__PRINT_PROGRESS_HPP
3 
4 #include <cmath>
5 #include <iomanip>
7 
8 #include <iostream>
9 
10 namespace stan {
11  namespace common {
12 
13  void print_progress(const int m,
14  const int start,
15  const int finish,
16  const int refresh,
17  const bool warmup,
18  const std::string prefix,
19  const std::string suffix,
20  std::ostream& o) {
21  int it_print_width = std::ceil(std::log10((double) finish));
22  if (do_print(m, (start + m + 1 == finish), refresh)) {
23  o << prefix;
24  o << "Iteration: ";
25  o << std::setw(it_print_width) << m + 1 + start
26  << " / " << finish;
27  o << " [" << std::setw(3)
28  << static_cast<int>( (100.0 * (start + m + 1)) / finish )
29  << "%] ";
30  o << (warmup ? " (Warmup)" : " (Sampling)");
31  o << suffix;
32  o << std::flush;
33  }
34  }
35 
36  } // namespace common
37 
38 } // namespace stan
39 
40 #endif
bool do_print(const int n, const bool special, const int refresh)
Indicates whether it should print on the current iteration.
Definition: do_print.hpp:25
fvar< T > ceil(const fvar< T > &x)
Definition: ceil.hpp:15
void warmup(stan::mcmc::base_mcmc *sampler, int num_warmup, int num_samples, int num_thin, int refresh, bool save, stan::io::mcmc_writer< Model, SampleRecorder, DiagnosticRecorder, MessageRecorder > &writer, stan::mcmc::sample &init_s, Model &model, RNG &base_rng, const std::string &prefix, const std::string &suffix, std::ostream &o, StartTransitionCallback &callback)
Definition: warmup.hpp:13
void print_progress(const int m, const int start, const int finish, const int refresh, const bool warmup, const std::string prefix, const std::string suffix, std::ostream &o)
fvar< T > log10(const fvar< T > &x)
Definition: log10.hpp:15

     [ Stan Home Page ] © 2011–2014, Stan Development Team.