Automatic Differentiation
 
Loading...
Searching...
No Matches
eigenvectors_sym.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_EIGENVECTORS_SYM_HPP
2#define STAN_MATH_PRIM_FUN_EIGENVECTORS_SYM_HPP
3
7
8namespace stan {
9namespace math {
10
11template <typename EigMat, require_eigen_t<EigMat>* = nullptr,
12 require_not_st_var<EigMat>* = nullptr>
13inline Eigen::Matrix<value_type_t<EigMat>, Eigen::Dynamic, Eigen::Dynamic>
14eigenvectors_sym(EigMat&& m) {
15 if (unlikely(m.size() == 0)) {
16 return Eigen::Matrix<value_type_t<EigMat>, -1, -1>(0, 0);
17 }
18 using PlainMat = plain_type_t<EigMat>;
19 decltype(auto) m_ref = to_ref(std::forward<EigMat>(m));
20 check_symmetric("eigenvalues_sym", "m", m_ref);
21
22 Eigen::SelfAdjointEigenSolver<PlainMat> solver(
23 std::forward<decltype(m_ref)>(m_ref));
24 return solver.eigenvectors();
25}
26
27} // namespace math
28} // namespace stan
29#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 > eigenvectors_sym(const matrix_cl< double > &m)
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
Definition to_ref.hpp:18
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 ...