Automatic Differentiation
 
Loading...
Searching...
No Matches
corr_matrix_constrain.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_CONSTRAINT_CORR_MATRIX_CONSTRAIN_HPP
2#define STAN_MATH_REV_CONSTRAINT_CORR_MATRIX_CONSTRAIN_HPP
3
13#include <utility>
14
15namespace stan {
16namespace math {
17
43template <typename T, require_var_vector_t<T>* = nullptr>
45 Eigen::Index k_choose_2 = (k * (k - 1)) / 2;
46 check_size_match("cov_matrix_constrain", "x.size()", x.size(), "k_choose_2",
47 k_choose_2);
49 internal::cholesky_corr_factor<internal::CorrOrder::column>(
50 std::forward<T>(x), k));
51}
52
73template <typename T, require_var_vector_t<T>* = nullptr>
75 scalar_type_t<T>& lp) {
76 Eigen::Index k_choose_2 = (k * (k - 1)) / 2;
77 check_size_match("cov_matrix_constrain", "x.size()", x.size(), "k_choose_2",
78 k_choose_2);
80 log_cosh(x));
82 internal::cholesky_corr_factor<internal::CorrOrder::column>(
83 std::forward<T>(x), k));
84}
85
86} // namespace math
87} // namespace stan
88
89#endif
auto corr_matrix_log_jacobian_coefficients(Eigen::Index K)
Return a lazy expression of the coefficients c for which the log absolute Jacobian determinant of cor...
Eigen::Matrix< value_type_t< EigMat >, EigMat::RowsAtCompileTime, EigMat::RowsAtCompileTime > multiply_lower_tri_self_transpose(const EigMat &m)
fvar< T > log_cosh(const fvar< T > &x)
Return the natural logarithm of the hyperbolic cosine of the argument.
Definition log_cosh.hpp:21
Eigen::Matrix< value_type_t< T >, Eigen::Dynamic, Eigen::Dynamic > corr_matrix_constrain(T &&x, Eigen::Index k)
Return the correlation matrix of the specified dimensionality derived from the specified vector of un...
void check_size_match(const char *function, const char *name_i, T_size1 i, const char *name_j, T_size2 j)
Check if the provided sizes match.
auto dot_product(const T_a &a, const T_b &b)
Returns the dot product of the specified vectors.
typename scalar_type< T >::type scalar_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...