Automatic Differentiation
 
Loading...
Searching...
No Matches
diag_matrix.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_DIAG_MATRIX_HPP
2#define STAN_MATH_PRIM_FUN_DIAG_MATRIX_HPP
3
6
7namespace stan {
8namespace math {
9
19template <typename EigVec, require_eigen_vector_t<EigVec>* = nullptr>
20inline Eigen::Matrix<value_type_t<EigVec>, Eigen::Dynamic, Eigen::Dynamic>
21diag_matrix(EigVec&& v) {
22 return make_holder(
23 [](auto&& v_) { return std::forward<decltype(v_)>(v_).asDiagonal(); },
24 std::forward<EigVec>(v));
25}
26
27} // namespace math
28} // namespace stan
29
30#endif
auto make_holder(F &&func, Args &&... args)
Calls given function with given arguments.
Definition holder.hpp:481
auto diag_matrix(T_x &&x)
Return a square diagonal matrix with the specified vector of coefficients as the diagonal values.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...