Automatic Differentiation
 
Loading...
Searching...
No Matches
eigenvalues_sym.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_EIGENVALUES_SYM_HPP
2#define STAN_MATH_PRIM_FUN_EIGENVALUES_SYM_HPP
3
7
8namespace stan {
9namespace math {
10
21template <typename EigMat, require_eigen_matrix_dynamic_t<EigMat>* = nullptr,
22 require_not_st_var<EigMat>* = nullptr>
23inline Eigen::Matrix<value_type_t<EigMat>, -1, 1> eigenvalues_sym(
24 const EigMat& m) {
25 if (unlikely(m.size() == 0)) {
26 return Eigen::Matrix<value_type_t<EigMat>, -1, 1>(0, 1);
27 }
28 using PlainMat = plain_type_t<EigMat>;
29 const PlainMat& m_eval = m;
30 check_symmetric("eigenvalues_sym", "m", m_eval);
31
32 Eigen::SelfAdjointEigenSolver<PlainMat> solver(m_eval,
33 Eigen::EigenvaluesOnly);
34 return solver.eigenvalues();
35}
36
37} // namespace math
38} // namespace stan
39
40#endif
#define unlikely(x)
void check_symmetric(const char *function, const char *name, const matrix_cl< T > &y)
Check if the matrix_cl is symmetric.
matrix_cl< double > eigenvalues_sym(const matrix_cl< double > &m)
typename plain_type< std::decay_t< T > >::type plain_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...