All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
inv_wishart_rng.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_MAT_PROB_INV_WISHART_RNG_HPP
#define STAN_MATH_PRIM_MAT_PROB_INV_WISHART_RNG_HPP
#include <stan/math/prim/mat/err/check_ldlt_factor.hpp>
#include <stan/math/prim/scal/err/check_greater.hpp>
#include <stan/math/prim/scal/err/check_size_match.hpp>
#include <stan/math/prim/mat/err/check_square.hpp>
#include <stan/math/prim/mat/meta/index_type.hpp>
#include <stan/math/prim/mat/fun/log_determinant_ldlt.hpp>
#include <stan/math/prim/mat/fun/mdivide_left_ldlt.hpp>
#include <stan/math/prim/scal/fun/constants.hpp>
#include <stan/math/prim/scal/meta/include_summand.hpp>
#include <stan/math/prim/mat/prob/wishart_rng.hpp>
namespace stan {
namespace math {
template <class RNG>
inline Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>
inv_wishart_rng(const double nu,
const Eigen::Matrix
<double, Eigen::Dynamic, Eigen::Dynamic>& S,
RNG& rng) {
static const char* function("stan::math::inv_wishart_rng");
using stan::math::check_greater;
using stan::math::check_square;
using Eigen::MatrixXd;
using stan::math::index_type;
typename index_type<MatrixXd>::type k = S.rows();
check_greater(function, "Degrees of freedom parameter", nu, k-1);
check_square(function, "scale parameter", S);
MatrixXd S_inv = MatrixXd::Identity(k, k);
S_inv = S.ldlt().solve(S_inv);
return wishart_rng(nu, S_inv, rng).inverse();
}
}
}
#endif
check_size_match.hpp
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–2015, Stan Development Team.