Stan Math Library: stan/math/prim/mat/prob/inv_wishart_rng.hpp Source File

| Stan Math Library 2.10.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 #include <stan/math/prim/mat/err/check_ldlt_factor.hpp>
5 #include <stan/math/prim/scal/err/check_greater.hpp>
6 #include <stan/math/prim/scal/err/check_size_match.hpp>
7 #include <stan/math/prim/mat/err/check_square.hpp>
8 #include <stan/math/prim/mat/meta/index_type.hpp>
9 #include <stan/math/prim/mat/fun/log_determinant_ldlt.hpp>
10 #include <stan/math/prim/mat/fun/mdivide_left_ldlt.hpp>
11
12 #include <stan/math/prim/scal/fun/constants.hpp>
13 #include <stan/math/prim/scal/meta/include_summand.hpp>
14 #include <stan/math/prim/mat/prob/wishart_rng.hpp>
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
27 using stan::math::check_greater;
28 using stan::math::check_square;
29 using Eigen::MatrixXd;
30 using stan::math::index_type;
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
check_size_match.hpp
stan
Definition: log_sum_exp.hpp:8
wishart_rng.hpp
include_summand.hpp
check_greater.hpp
check_ldlt_factor.hpp
stan::math::index_type
Primary template class for the metaprogram to compute the index type of a container.
Definition: index_type.hpp:19
stan::math::wishart_rng
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
index_type.hpp
constants.hpp
stan::math::inv_wishart_rng
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > inv_wishart_rng(const double nu, const Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > &S, RNG &rng)
Definition: inv_wishart_rng.hpp:21
mdivide_left_ldlt.hpp
stan::math::check_square
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.
Definition: check_square.hpp:28
stan::math::check_greater
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.
Definition: check_greater.hpp:84
log_determinant_ldlt.hpp
check_square.hpp

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