1#ifndef STAN_MATH_REV_FUN_READ_COV_L_HPP
2#define STAN_MATH_REV_FUN_READ_COV_L_HPP
29template <
typename T_CPCs,
typename T_sds,
30 require_any_var_vector_t<T_CPCs, T_sds>* =
nullptr,
31 require_vt_same<T_CPCs, T_sds>* =
nullptr>
32inline auto read_cov_L(
const T_CPCs& CPCs,
const T_sds& sds,
34 size_t K = sds.rows();
40 = sds.val().matrix().asDiagonal() * corr_L.val();
43 size_t K = sds.size();
45 corr_L.adj() += sds.val().matrix().asDiagonal() * res.adj();
46 sds.adj() += (res.adj().cwiseProduct(corr_L.val())).rowwise().sum();
48 sds.adj() += (K * log_prob.adj() / sds.val().array()).matrix();
void reverse_pass_callback(F &&functor)
Puts a callback on the autodiff stack to be called in reverse pass.
fvar< T > log(const fvar< T > &x)
static constexpr double LOG_TWO
The natural logarithm of 2, .
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...
auto sum(const std::vector< T > &m)
Return the sum of the entries of the specified standard vector.
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...
typename scalar_type< T >::type scalar_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...