Stan Math Library  2.6.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
inv_wishart_rng.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_PROB_INV_WISHART_RNG_HPP
2 #define STAN_MATH_PRIM_MAT_PROB_INV_WISHART_RNG_HPP
3 
11 
15 
16 namespace stan {
17  namespace math {
18 
19  template <class RNG>
20  inline Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>
21  inv_wishart_rng(const double nu,
22  const Eigen::Matrix
23  <double, Eigen::Dynamic, Eigen::Dynamic>& S,
24  RNG& rng) {
25  static const char* function("stan::math::inv_wishart_rng");
26 
29  using Eigen::MatrixXd;
31 
32  typename index_type<MatrixXd>::type k = S.rows();
33 
34  check_greater(function, "Degrees of freedom parameter", nu, k-1);
35  check_square(function, "scale parameter", S);
36 
37  MatrixXd S_inv = MatrixXd::Identity(k, k);
38  S_inv = S.ldlt().solve(S_inv);
39 
40  return wishart_rng(nu, S_inv, rng).inverse();
41  }
42  }
43 }
44 #endif
Primary template class for the metaprogram to compute the index type of a container.
Definition: index_type.hpp:19
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > wishart_rng(const double nu, const Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > &S, RNG &rng)
Definition: wishart_rng.hpp:29
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > inv_wishart_rng(const double nu, const Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > &S, RNG &rng)
bool check_square(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y)
Return true if the specified matrix is square.
bool check_greater(const char *function, const char *name, const T_y &y, const T_low &low)
Return true if y is strictly greater than low.

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