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>
23Eigen::Matrix<value_type_t<EigMat>, -1, 1> eigenvalues_sym(const EigMat& m) {
24 if (unlikely(m.size() == 0)) {
25 return Eigen::Matrix<value_type_t<EigMat>, -1, 1>(0, 1);
26 }
27 using PlainMat = plain_type_t<EigMat>;
28 const PlainMat& m_eval = m;
29 check_symmetric("eigenvalues_sym", "m", m_eval);
30
31 Eigen::SelfAdjointEigenSolver<PlainMat> solver(m_eval,
32 Eigen::EigenvaluesOnly);
33 return solver.eigenvalues();
34}
35
36} // namespace math
37} // namespace stan
38
39#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< T >::type plain_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...