1 #ifndef STAN_SERVICES_UTIL_CREATE_UNIT_E_DIAG_INV_METRIC_HPP
2 #define STAN_SERVICES_UTIL_CREATE_UNIT_E_DIAG_INV_METRIC_HPP
3 
4 #include <stan/io/dump.hpp>
5 #include <sstream>
6 
7 namespace stan {
8 namespace services {
9 namespace util {
10 
11 /**
12  * Create a stan::dump object which contains vector "metric"
13  * of specified size where all elements are ones.
14  *
15  * @param[in] num_params expected number of diagonal elements
16  * @return var_context
17  */
create_unit_e_diag_inv_metric(size_t num_params)18 inline stan::io::dump create_unit_e_diag_inv_metric(size_t num_params) {
19   std::string dims("),.Dim=c(" + std::to_string(num_params) + "))");
20   Eigen::IOFormat RFmt(Eigen::StreamPrecision, Eigen::DontAlignCols, ", ", ",",
21                        "", "", "inv_metric <- structure(c(", dims);
22   std::stringstream txt;
23   txt << Eigen::VectorXd::Ones(num_params).format(RFmt);
24   return stan::io::dump(txt);
25 }
26 }  // namespace util
27 }  // namespace services
28 }  // namespace stan
29 
30 #endif
31