Automatic Differentiation
 
Loading...
Searching...
No Matches
read_cov_L.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_READ_COV_L_HPP
2#define STAN_MATH_PRIM_FUN_READ_COV_L_HPP
3
9
10namespace stan {
11namespace math {
12
27template <typename T_CPCs, typename T_sds,
28 require_all_eigen_vector_t<T_CPCs, T_sds>* = nullptr,
29 require_vt_same<T_CPCs, T_sds>* = nullptr>
30Eigen::Matrix<value_type_t<T_CPCs>, Eigen::Dynamic, Eigen::Dynamic> read_cov_L(
31 const T_CPCs& CPCs, const T_sds& sds, value_type_t<T_CPCs>& log_prob) {
32 size_t K = sds.rows();
33 // adjust due to transformation from correlations to covariances
34 log_prob += (sum(log(sds)) + LOG_TWO) * K;
35 return make_holder(
36 [](const auto& b, const auto& sds) {
37 return sds.matrix().asDiagonal() * b;
38 },
39 read_corr_L(CPCs, K, log_prob), to_ref(sds));
40}
41
42} // namespace math
43} // namespace stan
44
45#endif
typename value_type< T >::type value_type_t
Helper function for accessing underlying type.
auto make_holder(const F &func, Args &&... args)
Constructs an expression from given arguments using given functor.
Definition holder.hpp:352
fvar< T > log(const fvar< T > &x)
Definition log.hpp:15
static constexpr double LOG_TWO
The natural logarithm of 2, .
Definition constants.hpp:80
fvar< T > sum(const std::vector< fvar< T > > &m)
Return the sum of the entries of the specified standard vector.
Definition sum.hpp:22
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
Definition to_ref.hpp:17
Eigen::Matrix< value_type_t< T_CPCs >, Eigen::Dynamic, Eigen::Dynamic > read_cov_L(const T_CPCs &CPCs, const T_sds &sds, value_type_t< T_CPCs > &log_prob)
This is the function that should be called prior to evaluating the density of any elliptical distribu...
Eigen::Matrix< value_type_t< T >, Eigen::Dynamic, Eigen::Dynamic > read_corr_L(const T &CPCs, size_t K)
Return the Cholesky factor of the correlation matrix of the specified dimensionality corresponding to...
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Definition fvar.hpp:9