Public Types | Public Member Functions | Public Attributes | Private Attributes | List of all members
stan::io::writer< T > Class Template Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-09-17/CAFAna/Fit/StanFitter.h"

Public Types

typedef Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > matrix_t
 
typedef Eigen::Matrix< T, Eigen::Dynamic, 1 > vector_t
 
typedef Eigen::Matrix< T, 1, Eigen::Dynamic > row_vector_t
 
typedef Eigen::Array< T, Eigen::Dynamic, 1 > array_vec_t
 

Public Member Functions

 writer (std::vector< T > &data_r, std::vector< int > &data_i)
 
 ~writer ()
 
std::vector< T > & data_r ()
 
std::vector< int > & data_i ()
 
void integer (int n)
 
void scalar_unconstrain (T &y)
 
void scalar_pos_unconstrain (T &y)
 
void scalar_lb_unconstrain (double lb, T &y)
 
void scalar_ub_unconstrain (double ub, T &y)
 
void scalar_lub_unconstrain (double lb, double ub, T &y)
 
void corr_unconstrain (T &y)
 
void prob_unconstrain (T &y)
 
void ordered_unconstrain (vector_t &y)
 
void positive_ordered_unconstrain (vector_t &y)
 
void vector_unconstrain (const vector_t &y)
 
void row_vector_unconstrain (const vector_t &y)
 
void matrix_unconstrain (const matrix_t &y)
 
void vector_lb_unconstrain (double lb, vector_t &y)
 
void row_vector_lb_unconstrain (double lb, row_vector_t &y)
 
void matrix_lb_unconstrain (double lb, matrix_t &y)
 
void vector_ub_unconstrain (double ub, vector_t &y)
 
void row_vector_ub_unconstrain (double ub, row_vector_t &y)
 
void matrix_ub_unconstrain (double ub, matrix_t &y)
 
void vector_lub_unconstrain (double lb, double ub, vector_t &y)
 
void row_vector_lub_unconstrain (double lb, double ub, row_vector_t &y)
 
void matrix_lub_unconstrain (double lb, double ub, matrix_t &y)
 
void unit_vector_unconstrain (vector_t &y)
 
void simplex_unconstrain (vector_t &y)
 
void cholesky_factor_unconstrain (matrix_t &y)
 
void cholesky_corr_unconstrain (matrix_t &y)
 
void cov_matrix_unconstrain (matrix_t &y)
 
void corr_matrix_unconstrain (matrix_t &y)
 

Public Attributes

const double CONSTRAINT_TOLERANCE
 

Private Attributes

std::vector< Tdata_r_
 
std::vector< intdata_i_
 

Detailed Description

template<typename T>
class stan::io::writer< T >

A stream-based writer for integer, scalar, vector, matrix and array data types, which transforms from constrained to a sequence of constrained variables.

This class converts constrained values to unconstrained values with mappings that invert those defined in stan::io::reader to convert unconstrained values to constrained values.

Template Parameters
TBasic scalar type.

Definition at line 51 of file StanFitter.h.

Member Typedef Documentation

template<typename T>
typedef Eigen::Array<T, Eigen::Dynamic, 1> stan::io::writer< T >::array_vec_t

Definition at line 35 of file writer.hpp.

template<typename T>
typedef Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> stan::io::writer< T >::matrix_t

Definition at line 31 of file writer.hpp.

template<typename T>
typedef Eigen::Matrix<T, 1, Eigen::Dynamic> stan::io::writer< T >::row_vector_t

Definition at line 33 of file writer.hpp.

template<typename T>
typedef Eigen::Matrix<T, Eigen::Dynamic, 1> stan::io::writer< T >::vector_t

Definition at line 32 of file writer.hpp.

Constructor & Destructor Documentation

template<typename T>
stan::io::writer< T >::writer ( std::vector< T > &  data_r,
std::vector< int > &  data_i 
)
inline

Construct a writer that writes to the specified scalar and integer vectors.

Parameters
data_rScalar values.
data_iInteger values.

Definition at line 50 of file writer.hpp.

52  : data_r_(data_r),
53  data_i_(data_i),
55  data_r_.clear();
56  data_i_.clear();
57  }
std::vector< T > & data_r()
Definition: writer.hpp:70
std::vector< int > data_i_
Definition: writer.hpp:28
Float_t E
Definition: plot.C:20
std::vector< T > data_r_
Definition: writer.hpp:27
std::vector< int > & data_i()
Definition: writer.hpp:81
const double CONSTRAINT_TOLERANCE
Definition: writer.hpp:41
template<typename T>
stan::io::writer< T >::~writer ( )
inline

Destroy this writer.

Definition at line 62 of file writer.hpp.

62 { }

Member Function Documentation

template<typename T>
void stan::io::writer< T >::cholesky_corr_unconstrain ( matrix_t y)
inline

Writes the unconstrained Cholesky factor for a correlation matrix corresponding to the specified constrained matrix.

The unconstraining operation is the inverse of the constraining operation in cov_matrix_constrain(Matrix<T,Dynamic,Dynamic).

Parameters
yConstrained covariance matrix.
Exceptions
std::runtime_errorif y has no elements or if it is not square

Definition at line 420 of file writer.hpp.

References stan::math::cholesky_corr_free(), and MECModelEnuComparisons::i.

420  {
421  typedef typename stan::math::index_type<matrix_t>::type idx_t;
422 
423  // FIXME: optimize by unrolling cholesky_factor_free
424  Eigen::Matrix<T, Eigen::Dynamic, 1> y_free
426  for (idx_t i = 0; i < y_free.size(); ++i)
427  data_r_.push_back(y_free[i]);
428  }
Eigen::Matrix< T, Eigen::Dynamic, 1 > cholesky_corr_free(const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &x)
std::vector< T > data_r_
Definition: writer.hpp:27
template<typename T>
void stan::io::writer< T >::cholesky_factor_unconstrain ( matrix_t y)
inline

Writes the unconstrained Cholesky factor corresponding to the specified constrained matrix.

The unconstraining operation is the inverse of the constraining operation in cov_matrix_constrain(Matrix<T,Dynamic,Dynamic).

Parameters
yConstrained covariance matrix.
Exceptions
std::runtime_errorif y has no elements or if it is not square

Definition at line 398 of file writer.hpp.

References stan::math::cholesky_factor_free(), and MECModelEnuComparisons::i.

Referenced by TEST().

398  {
399  typedef typename stan::math::index_type<matrix_t>::type idx_t;
400 
401  // FIXME: optimize by unrolling cholesky_factor_free
402  Eigen::Matrix<T, Eigen::Dynamic, 1> y_free
404  for (idx_t i = 0; i < y_free.size(); ++i)
405  data_r_.push_back(y_free[i]);
406  }
Eigen::Matrix< T, Eigen::Dynamic, 1 > cholesky_factor_free(const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &y)
std::vector< T > data_r_
Definition: writer.hpp:27
template<typename T>
void stan::io::writer< T >::corr_matrix_unconstrain ( matrix_t y)
inline

Writes the unconstrained correlation matrix corresponding to the specified constrained correlation matrix.

The unconstraining operation is the inverse of the constraining operation in corr_matrix_constrain(Matrix<T,Dynamic,Dynamic).

Parameters
yConstrained correlation matrix.
Exceptions
std::runtime_errorif the correlation matrix has no elements or is not a square matrix.
std::runtime_errorif the correlation matrix cannot be factorized by factor_cov_matrix() or if the sds returned by factor_cov_matrix() on log scale are unconstrained.

Definition at line 472 of file writer.hpp.

References stan::math::check_corr_matrix(), stan::math::corr_matrix_free(), and MECModelEnuComparisons::i.

Referenced by TEST().

472  {
473  typedef typename stan::math::index_type<matrix_t>::type idx_t;
474 
475  stan::math::check_corr_matrix("stan::io::corr_matrix_unconstrain",
476  "Matrix", y);
477  idx_t k = y.rows();
478  idx_t k_choose_2 = (k * (k-1)) / 2;
480  for (idx_t i = 0; i < k_choose_2; ++i)
481  data_r_.push_back(cpcs[i]);
482  }
void check_corr_matrix(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y)
Eigen::Matrix< T, Eigen::Dynamic, 1 > vector_t
Definition: writer.hpp:32
Eigen::Matrix< T, Eigen::Dynamic, 1 > corr_matrix_free(const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &y)
std::vector< T > data_r_
Definition: writer.hpp:27
template<typename T>
void stan::io::writer< T >::corr_unconstrain ( T y)
inline

Write the unconstrained value corresponding to the specified correlation-constrained variable.

The unconstraining transform is atanh(y), which reverses the transfrom in corr_constrain().

Parameters
yCorrelation value.
Exceptions
std::runtime_errorif y is not between -1.0 and 1.0

Definition at line 177 of file writer.hpp.

References stan::math::corr_free().

Referenced by TEST().

177  {
178  data_r_.push_back(stan::math::corr_free(y));
179  }
T corr_free(const T &y)
Definition: corr_free.hpp:27
std::vector< T > data_r_
Definition: writer.hpp:27
template<typename T>
void stan::io::writer< T >::cov_matrix_unconstrain ( matrix_t y)
inline

Writes the unconstrained covariance matrix corresponding to the specified constrained correlation matrix.

The unconstraining operation is the inverse of the constraining operation in cov_matrix_constrain(Matrix<T,Dynamic,Dynamic).

Parameters
yConstrained covariance matrix.
Exceptions
std::runtime_errorif y has no elements or if it is not square

Definition at line 442 of file writer.hpp.

References stan::math::cov_matrix_free(), MECModelEnuComparisons::i, m, and getGoodRuns4SAM::n.

Referenced by TEST().

442  {
443  typedef typename stan::math::index_type<matrix_t>::type idx_t;
444  idx_t k = y.rows();
445  if (k == 0 || y.cols() != k)
446  BOOST_THROW_EXCEPTION(
447  std::runtime_error("y must have elements and"
448  " y must be a square matrix"));
450  int i = 0;
451  for (idx_t m = 0; m < k; ++m) {
452  for (idx_t n = 0; n <= m; ++n)
453  data_r_.push_back(L_vec.coeff(i++));
454  }
455  }
Eigen::Matrix< T, Eigen::Dynamic, 1 > vector_t
Definition: writer.hpp:32
std::vector< T > data_r_
Definition: writer.hpp:27
Eigen::Matrix< T, Eigen::Dynamic, 1 > cov_matrix_free(const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &y)
template<typename T>
std::vector<int>& stan::io::writer< T >::data_i ( )
inline

Return a reference to the underlying vector of integer values that have been written.

Returns
Values that have been written.

Definition at line 81 of file writer.hpp.

References stan::io::writer< T >::data_i_.

Referenced by TEST(), and ana::StanFitter::transform_inits().

81  {
82  return data_i_;
83  }
std::vector< int > data_i_
Definition: writer.hpp:28
template<typename T>
std::vector<T>& stan::io::writer< T >::data_r ( )
inline

Return a reference to the underlying vector of real values that have been written.

Returns
Values that have been written.

Definition at line 70 of file writer.hpp.

References stan::io::writer< T >::data_r_.

Referenced by TEST(), and ana::StanFitter::transform_inits().

70  {
71  return data_r_;
72  }
std::vector< T > data_r_
Definition: writer.hpp:27
template<typename T>
void stan::io::writer< T >::integer ( int  n)
inline

Write the specified integer to the sequence of integer values.

Parameters
nInteger to write.

Definition at line 90 of file writer.hpp.

Referenced by TEST().

90  {
91  data_i_.push_back(n);
92  }
std::vector< int > data_i_
Definition: writer.hpp:28
template<typename T>
void stan::io::writer< T >::matrix_lb_unconstrain ( double  lb,
matrix_t y 
)
inline

Definition at line 295 of file writer.hpp.

References MECModelEnuComparisons::i, calib::j, stan::io::writer< T >::scalar_lb_unconstrain(), and submit_syst::y.

Referenced by TEST().

295  {
296  typedef typename stan::math::index_type<matrix_t>::type idx_t;
297  for (idx_t j = 0; j < y.cols(); ++j)
298  for (idx_t i = 0; i < y.rows(); ++i)
299  scalar_lb_unconstrain(lb, y(i, j));
300  }
void scalar_lb_unconstrain(double lb, T &y)
Definition: writer.hpp:133
const double j
Definition: BetheBloch.cxx:29
template<typename T>
void stan::io::writer< T >::matrix_lub_unconstrain ( double  lb,
double  ub,
matrix_t y 
)
inline

Definition at line 330 of file writer.hpp.

References MECModelEnuComparisons::i, calib::j, stan::io::writer< T >::scalar_lub_unconstrain(), and submit_syst::y.

Referenced by TEST().

330  {
331  typedef typename stan::math::index_type<matrix_t>::type idx_t;
332  for (idx_t j = 0; j < y.cols(); ++j)
333  for (idx_t i = 0; i < y.rows(); ++i)
334  scalar_lub_unconstrain(lb, ub, y(i, j));
335  }
void scalar_lub_unconstrain(double lb, double ub, T &y)
Definition: writer.hpp:163
const double j
Definition: BetheBloch.cxx:29
static const double ub
Definition: Units.h:88
template<typename T>
void stan::io::writer< T >::matrix_ub_unconstrain ( double  ub,
matrix_t y 
)
inline

Definition at line 312 of file writer.hpp.

References MECModelEnuComparisons::i, calib::j, stan::io::writer< T >::scalar_ub_unconstrain(), and submit_syst::y.

Referenced by TEST().

312  {
313  typedef typename stan::math::index_type<matrix_t>::type idx_t;
314  for (idx_t j = 0; j < y.cols(); ++j)
315  for (idx_t i = 0; i < y.rows(); ++i)
317  }
const double j
Definition: BetheBloch.cxx:29
static const double ub
Definition: Units.h:88
void scalar_ub_unconstrain(double ub, T &y)
Definition: writer.hpp:147
template<typename T>
void stan::io::writer< T >::matrix_unconstrain ( const matrix_t y)
inline

Write the specified unconstrained matrix.

Parameters
yMatrix to write.

Definition at line 278 of file writer.hpp.

References MECModelEnuComparisons::i, and calib::j.

Referenced by TEST().

278  {
279  typedef typename stan::math::index_type<matrix_t>::type idx_t;
280  for (idx_t j = 0; j < y.cols(); ++j)
281  for (idx_t i = 0; i < y.rows(); ++i)
282  data_r_.push_back(y(i, j));
283  }
const double j
Definition: BetheBloch.cxx:29
std::vector< T > data_r_
Definition: writer.hpp:27
template<typename T>
void stan::io::writer< T >::ordered_unconstrain ( vector_t y)
inline

Write the unconstrained vector that corresponds to the specified ascendingly ordered vector.

The unconstraining transform is defined for input vector y to produce an output vector x of the same size, defined by x[0] = log(y[0]) and by x[k] = log(y[k] - y[k-1]) for k > 0. This unconstraining transform inverts the constraining transform specified in ordered_constrain(size_t).

Parameters
yAscendingly ordered vector.
Returns
Unconstrained vector corresponding to the specified vector.
Exceptions
std::runtime_errorif vector is not in ascending order.

Definition at line 211 of file writer.hpp.

References stan::math::check_ordered(), MECModelEnuComparisons::i, and test_ParserArtEvents::log.

Referenced by TEST().

211  {
212  typedef typename stan::math::index_type<vector_t>::type idx_t;
213  if (y.size() == 0) return;
214  stan::math::check_ordered("stan::io::ordered_unconstrain", "Vector", y);
215  data_r_.push_back(y[0]);
216  for (idx_t i = 1; i < y.size(); ++i) {
217  data_r_.push_back(log(y[i] - y[i-1]));
218  }
219  }
void check_ordered(const char *function, const char *name, const std::vector< T_y > &y)
std::vector< T > data_r_
Definition: writer.hpp:27
template<typename T>
void stan::io::writer< T >::positive_ordered_unconstrain ( vector_t y)
inline

Write the unconstrained vector that corresponds to the specified postiive ascendingly ordered vector.

The unconstraining transform is defined for input vector y to produce an output vector x of the same size, defined by x[0] = log(y[0]) and by x[k] = log(y[k] - y[k-1]) for k > 0. This unconstraining transform inverts the constraining transform specified in positive_ordered_constrain(size_t).

Parameters
yPositive ascendingly ordered vector.
Returns
Unconstrained vector corresponding to the specified vector.
Exceptions
std::runtime_errorif vector is not in ascending order.

Definition at line 237 of file writer.hpp.

References stan::math::check_positive_ordered(), MECModelEnuComparisons::i, and test_ParserArtEvents::log.

Referenced by TEST().

237  {
238  typedef typename stan::math::index_type<vector_t>::type idx_t;
239 
240  // reimplements pos_ordered_free in prob to avoid malloc
241  if (y.size() == 0) return;
243  ("stan::io::positive_ordered_unconstrain", "Vector", y);
244  data_r_.push_back(log(y[0]));
245  for (idx_t i = 1; i < y.size(); ++i) {
246  data_r_.push_back(log(y[i] - y[i-1]));
247  }
248  }
void check_positive_ordered(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, 1 > &y)
std::vector< T > data_r_
Definition: writer.hpp:27
template<typename T>
void stan::io::writer< T >::prob_unconstrain ( T y)
inline

Write the unconstrained value corresponding to the specified probability value.

The unconstraining transform is logit(y), which inverts the constraining transform defined in prob_constrain().

Parameters
yProbability value.
Exceptions
std::runtime_errorif y is not between 0.0 and 1.0

Definition at line 192 of file writer.hpp.

References stan::math::prob_free().

Referenced by TEST().

192  {
193  data_r_.push_back(stan::math::prob_free(y));
194  }
T prob_free(const T &y)
Definition: prob_free.hpp:26
std::vector< T > data_r_
Definition: writer.hpp:27
template<typename T>
void stan::io::writer< T >::row_vector_lb_unconstrain ( double  lb,
row_vector_t y 
)
inline

Definition at line 290 of file writer.hpp.

References MECModelEnuComparisons::i, stan::io::writer< T >::scalar_lb_unconstrain(), and submit_syst::y.

Referenced by TEST().

290  {
291  typedef typename stan::math::index_type<row_vector_t>::type idx_t;
292  for (idx_t i = 0; i < y.size(); ++i)
293  scalar_lb_unconstrain(lb, y(i));
294  }
void scalar_lb_unconstrain(double lb, T &y)
Definition: writer.hpp:133
template<typename T>
void stan::io::writer< T >::row_vector_lub_unconstrain ( double  lb,
double  ub,
row_vector_t y 
)
inline

Definition at line 325 of file writer.hpp.

References MECModelEnuComparisons::i, stan::io::writer< T >::scalar_lub_unconstrain(), and submit_syst::y.

Referenced by TEST().

325  {
326  typedef typename stan::math::index_type<row_vector_t>::type idx_t;
327  for (idx_t i = 0; i < y.size(); ++i)
328  scalar_lub_unconstrain(lb, ub, y(i));
329  }
void scalar_lub_unconstrain(double lb, double ub, T &y)
Definition: writer.hpp:163
static const double ub
Definition: Units.h:88
template<typename T>
void stan::io::writer< T >::row_vector_ub_unconstrain ( double  ub,
row_vector_t y 
)
inline

Definition at line 307 of file writer.hpp.

References MECModelEnuComparisons::i, stan::io::writer< T >::scalar_ub_unconstrain(), and submit_syst::y.

Referenced by TEST().

307  {
308  typedef typename stan::math::index_type<row_vector_t>::type idx_t;
309  for (idx_t i = 0; i < y.size(); ++i)
311  }
static const double ub
Definition: Units.h:88
void scalar_ub_unconstrain(double ub, T &y)
Definition: writer.hpp:147
template<typename T>
void stan::io::writer< T >::row_vector_unconstrain ( const vector_t y)
inline

Write the specified unconstrained vector.

Parameters
yVector to write.

Definition at line 267 of file writer.hpp.

References MECModelEnuComparisons::i.

Referenced by TEST().

267  {
268  typedef typename stan::math::index_type<vector_t>::type idx_t;
269  for (idx_t i = 0; i < y.size(); ++i)
270  data_r_.push_back(y[i]);
271  }
std::vector< T > data_r_
Definition: writer.hpp:27
template<typename T>
void stan::io::writer< T >::scalar_lb_unconstrain ( double  lb,
T y 
)
inline

Return the unconstrained version of the specified input, which is constrained to be above the specified lower bound. The unconstraining transform is log(y - lb), which inverts the constraining transform defined in reader::scalar_lb_constrain(double),

Parameters
lbLower bound.
yLower-bounded value.
Exceptions
std::runtime_errorif y is lower than the lower bound provided.

Definition at line 133 of file writer.hpp.

References stan::math::lb_free().

Referenced by stan::io::writer< T >::matrix_lb_unconstrain(), stan::io::writer< T >::row_vector_lb_unconstrain(), TEST(), and stan::io::writer< T >::vector_lb_unconstrain().

133  {
134  data_r_.push_back(stan::math::lb_free(y, lb));
135  }
boost::math::tools::promote_args< T, L >::type lb_free(const T &y, const L &lb)
Definition: lb_free.hpp:29
std::vector< T > data_r_
Definition: writer.hpp:27
template<typename T>
void stan::io::writer< T >::scalar_lub_unconstrain ( double  lb,
double  ub,
T y 
)
inline

Write the unconstrained value corresponding to the specified value with the specified bounds. The unconstraining transform is given by reader::logit((y-L)/(U-L)), which inverts the constraining transform defined in scalar_lub_constrain(double,double).

Parameters
lbLower bound.
ubUpper bound.
yBounded value.
Exceptions
std::runtime_errorif y is not between the lower and upper bounds

Definition at line 163 of file writer.hpp.

References stan::math::lub_free().

Referenced by stan::io::writer< T >::matrix_lub_unconstrain(), stan::io::writer< T >::row_vector_lub_unconstrain(), TEST(), ana::StanFitter::transform_helper(), and stan::io::writer< T >::vector_lub_unconstrain().

163  {
164  data_r_.push_back(stan::math::lub_free(y, lb, ub));
165  }
static const double ub
Definition: Units.h:88
std::vector< T > data_r_
Definition: writer.hpp:27
boost::math::tools::promote_args< T, L, U >::type lub_free(const T &y, const L &lb, const U &ub)
Definition: lub_free.hpp:46
template<typename T>
void stan::io::writer< T >::scalar_pos_unconstrain ( T y)
inline

Write the unconstrained value corresponding to the specified positive-constrained scalar. The transformation applied is log(y), which is the inverse of constraining transform specified in reader::scalar_pos_constrain().

This method will fail if the argument is not non-negative.

Parameters
yThe positive value.
Exceptions
std::runtime_errorif y is negative.

Definition at line 116 of file writer.hpp.

References test_ParserArtEvents::log.

Referenced by TEST().

116  {
117  if (y < 0.0)
118  BOOST_THROW_EXCEPTION(std::runtime_error("y is negative"));
119  data_r_.push_back(log(y));
120  }
std::vector< T > data_r_
Definition: writer.hpp:27
template<typename T>
void stan::io::writer< T >::scalar_ub_unconstrain ( double  ub,
T y 
)
inline

Write the unconstrained value corresponding to the specified lower-bounded value. The unconstraining transform is log(ub - y), which reverses the constraining transform defined in reader::scalar_ub_constrain(double).

Parameters
ubUpper bound.
yConstrained value.
Exceptions
std::runtime_errorif y is higher than the upper bound provided.

Definition at line 147 of file writer.hpp.

References stan::math::ub_free().

Referenced by stan::io::writer< T >::matrix_ub_unconstrain(), stan::io::writer< T >::row_vector_ub_unconstrain(), TEST(), and stan::io::writer< T >::vector_ub_unconstrain().

147  {
148  data_r_.push_back(stan::math::ub_free(y, ub));
149  }
static const double ub
Definition: Units.h:88
boost::math::tools::promote_args< T, U >::type ub_free(const T &y, const U &ub)
Definition: ub_free.hpp:36
std::vector< T > data_r_
Definition: writer.hpp:27
template<typename T>
void stan::io::writer< T >::scalar_unconstrain ( T y)
inline

Write the unconstrained value corresponding to the specified scalar. Here, the unconstrain operation is a no-op, which matches reader::scalar_constrain().

Parameters
yThe value.

Definition at line 101 of file writer.hpp.

Referenced by TEST(), and ana::StanFitter::transform_helper().

101  {
102  data_r_.push_back(y);
103  }
std::vector< T > data_r_
Definition: writer.hpp:27
template<typename T>
void stan::io::writer< T >::simplex_unconstrain ( vector_t y)
inline

Write the unconstrained vector corresponding to the specified simplex value. If the specified constrained simplex is of size K, the returned unconstrained vector is of size K-1.

The transform takes y = y[1],...,y[K] and produces the unconstrained vector. This inverts the constraining transform of simplex_constrain(size_t).

Parameters
ySimplex constrained value.
Returns
Unconstrained value.
Exceptions
std::runtime_errorif the vector is not a simplex.

Definition at line 378 of file writer.hpp.

References stan::math::check_simplex(), MECModelEnuComparisons::i, and stan::math::simplex_free().

Referenced by TEST().

378  {
379  typedef typename stan::math::index_type<vector_t>::type idx_t;
380 
381  stan::math::check_simplex("stan::io::simplex_unconstrain", "Vector", y);
383  for (idx_t i = 0; i < uy.size(); ++i)
384  data_r_.push_back(uy[i]);
385  }
void check_simplex(const char *function, const char *name, const Eigen::Matrix< T_prob, Eigen::Dynamic, 1 > &theta)
Eigen::Matrix< T, Eigen::Dynamic, 1 > vector_t
Definition: writer.hpp:32
Eigen::Matrix< T, Eigen::Dynamic, 1 > simplex_free(const Eigen::Matrix< T, Eigen::Dynamic, 1 > &x)
std::vector< T > data_r_
Definition: writer.hpp:27
template<typename T>
void stan::io::writer< T >::unit_vector_unconstrain ( vector_t y)
inline

Write the unconstrained vector corresponding to the specified unit_vector value. If the specified constrained unit_vector is of size K, the returned unconstrained vector is of size K-1.

The transform takes y = y[1],...,y[K] and produces the unconstrained vector. This inverts the constraining transform of unit_vector_constrain(size_t).

Parameters
ySimplex constrained value.
Returns
Unconstrained value.
Exceptions
std::runtime_errorif the vector is not a unit_vector.

Definition at line 354 of file writer.hpp.

References stan::math::check_unit_vector(), MECModelEnuComparisons::i, and stan::math::unit_vector_free().

Referenced by TEST().

354  {
355  stan::math::check_unit_vector("stan::io::unit_vector_unconstrain",
356  "Vector", y);
357  typedef typename stan::math::index_type<vector_t>::type idx_t;
359  for (idx_t i = 0; i < uy.size(); ++i)
360  data_r_.push_back(uy[i]);
361  }
void check_unit_vector(const char *function, const char *name, const Eigen::Matrix< T_prob, Eigen::Dynamic, 1 > &theta)
Eigen::Matrix< T, Eigen::Dynamic, 1 > unit_vector_free(const Eigen::Matrix< T, Eigen::Dynamic, 1 > &x)
Eigen::Matrix< T, Eigen::Dynamic, 1 > vector_t
Definition: writer.hpp:32
std::vector< T > data_r_
Definition: writer.hpp:27
template<typename T>
void stan::io::writer< T >::vector_lb_unconstrain ( double  lb,
vector_t y 
)
inline

Definition at line 285 of file writer.hpp.

References MECModelEnuComparisons::i, stan::io::writer< T >::scalar_lb_unconstrain(), and submit_syst::y.

Referenced by TEST().

285  {
286  typedef typename stan::math::index_type<vector_t>::type idx_t;
287  for (idx_t i = 0; i < y.size(); ++i)
288  scalar_lb_unconstrain(lb, y(i));
289  }
void scalar_lb_unconstrain(double lb, T &y)
Definition: writer.hpp:133
template<typename T>
void stan::io::writer< T >::vector_lub_unconstrain ( double  lb,
double  ub,
vector_t y 
)
inline

Definition at line 320 of file writer.hpp.

References MECModelEnuComparisons::i, stan::io::writer< T >::scalar_lub_unconstrain(), and submit_syst::y.

Referenced by TEST().

320  {
321  typedef typename stan::math::index_type<vector_t>::type idx_t;
322  for (idx_t i = 0; i < y.size(); ++i)
323  scalar_lub_unconstrain(lb, ub, y(i));
324  }
void scalar_lub_unconstrain(double lb, double ub, T &y)
Definition: writer.hpp:163
static const double ub
Definition: Units.h:88
template<typename T>
void stan::io::writer< T >::vector_ub_unconstrain ( double  ub,
vector_t y 
)
inline

Definition at line 302 of file writer.hpp.

References MECModelEnuComparisons::i, stan::io::writer< T >::scalar_ub_unconstrain(), and submit_syst::y.

Referenced by TEST().

302  {
303  typedef typename stan::math::index_type<vector_t>::type idx_t;
304  for (idx_t i = 0; i < y.size(); ++i)
306  }
static const double ub
Definition: Units.h:88
void scalar_ub_unconstrain(double ub, T &y)
Definition: writer.hpp:147
template<typename T>
void stan::io::writer< T >::vector_unconstrain ( const vector_t y)
inline

Write the specified unconstrained vector.

Parameters
yVector to write.

Definition at line 256 of file writer.hpp.

References MECModelEnuComparisons::i.

256  {
257  typedef typename stan::math::index_type<vector_t>::type idx_t;
258  for (idx_t i = 0; i < y.size(); ++i)
259  data_r_.push_back(y[i]);
260  }
std::vector< T > data_r_
Definition: writer.hpp:27

Member Data Documentation

template<typename T>
const double stan::io::writer< T >::CONSTRAINT_TOLERANCE

This is the tolerance for checking arithmetic bounds in rank and in simplexes. The current value is 1E-8.

Definition at line 41 of file writer.hpp.

template<typename T>
std::vector<int> stan::io::writer< T >::data_i_
private

Definition at line 28 of file writer.hpp.

Referenced by stan::io::writer< T >::data_i().

template<typename T>
std::vector<T> stan::io::writer< T >::data_r_
private

Definition at line 27 of file writer.hpp.

Referenced by stan::io::writer< T >::data_r().


The documentation for this class was generated from the following files: