Automatic Differentiation
 
Loading...
Searching...
No Matches
singular_values.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_SINGULAR_VALUES_HPP
2#define STAN_MATH_PRIM_FUN_SINGULAR_VALUES_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 auto singular_values(EigMat&& m) {
24 if (unlikely(m.size() == 0)) {
25 return Eigen::Matrix<base_type_t<EigMat>, Eigen::Dynamic, 1>(0, 1);
26 }
27 return Eigen::JacobiSVD<Eigen::Matrix<value_type_t<EigMat>, Eigen::Dynamic,
28 Eigen::Dynamic> >(
29 to_ref(std::forward<EigMat>(m)))
30 .singularValues();
31}
32
33} // namespace math
34} // namespace stan
35
36#endif
#define unlikely(x)
auto singular_values(EigMat &&m)
Return the vector of the singular values of the specified matrix in decreasing order of magnitude.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
Definition to_ref.hpp:18
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...