本文整理汇总了C++中eigen::Array::inverse方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::inverse方法的具体用法?C++ Array::inverse怎么用?C++ Array::inverse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eigen::Array
的用法示例。
在下文中一共展示了Array::inverse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lp
typename boost::math::tools::promote_args<T_y,T_loc,T_scale,T_shape>::type
lkj_cov_log(const Eigen::Matrix<T_y,Eigen::Dynamic,Eigen::Dynamic>& y,
const Eigen::Matrix<T_loc,Eigen::Dynamic,1>& mu,
const Eigen::Matrix<T_scale,Eigen::Dynamic,1>& sigma,
const T_shape& eta,
const Policy&) {
static const char* function = "stan::prob::lkj_cov_log(%1%)";
using stan::math::check_size_match;
using stan::math::check_finite;
using stan::math::check_positive;
using boost::math::tools::promote_args;
typename promote_args<T_y,T_loc,T_scale,T_shape>::type lp(0.0);
if (!check_size_match(function,
mu.rows(), "Rows of location parameter",
sigma.rows(), "columns of scale parameter",
&lp, Policy()))
return lp;
if (!check_size_match(function,
y.rows(), "Rows of random variable",
y.cols(), "columns of random variable",
&lp, Policy()))
return lp;
if (!check_size_match(function,
y.rows(), "Rows of random variable",
mu.rows(), "rows of location parameter",
&lp, Policy()))
return lp;
if (!check_positive(function, eta, "Shape parameter", &lp, Policy()))
return lp;
if (!check_finite(function, mu, "Location parameter", &lp, Policy()))
return lp;
if (!check_finite(function, sigma, "Scale parameter", &lp, Policy()))
return lp;
// FIXME: build vectorized versions
for (int m = 0; m < y.rows(); ++m)
for (int n = 0; n < y.cols(); ++n)
if (!check_finite(function, y(m,n), "Covariance matrix", &lp, Policy()))
return lp;
const unsigned int K = y.rows();
const Eigen::Array<T_y,Eigen::Dynamic,1> sds
= y.diagonal().array().sqrt();
for (unsigned int k = 0; k < K; k++) {
lp += lognormal_log<propto>(sds(k), mu(k), sigma(k), Policy());
}
if (stan::is_constant<typename stan::scalar_type<T_shape> >::value
&& eta == 1.0) {
// no need to rescale y into a correlation matrix
lp += lkj_corr_log<propto,T_y,T_shape,Policy>(y, eta, Policy());
return lp;
}
Eigen::DiagonalMatrix<T_y,Eigen::Dynamic> D(K);
D.diagonal() = sds.inverse();
lp += lkj_corr_log<propto,T_y,T_shape,Policy>(D * y * D, eta, Policy());
return lp;
}