1 #ifndef STAN_MATH_PRIM_FUN_SVD_V_HPP
2 #define STAN_MATH_PRIM_FUN_SVD_V_HPP
3 
4 #include <stan/math/prim/meta.hpp>
5 #include <stan/math/prim/fun/Eigen.hpp>
6 
7 namespace stan {
8 namespace math {
9 
10 /**
11  * Given input matrix m, return matrix V where `m = UDV^{T}`
12  *
13  * @tparam EigMat type of the matrix
14  * @param m MxN input matrix
15  * @return Orthogonal matrix V
16  */
17 template <typename EigMat, require_eigen_matrix_dynamic_t<EigMat>* = nullptr,
18           require_not_st_var<EigMat>* = nullptr>
svd_V(const EigMat & m)19 Eigen::Matrix<value_type_t<EigMat>, Eigen::Dynamic, Eigen::Dynamic> svd_V(
20     const EigMat& m) {
21   check_nonzero_size("svd_V", "m", m);
22 
23   return Eigen::JacobiSVD<Eigen::Matrix<value_type_t<EigMat>, Eigen::Dynamic,
24                                         Eigen::Dynamic> >(m,
25                                                           Eigen::ComputeThinV)
26       .matrixV();
27 }
28 
29 }  // namespace math
30 }  // namespace stan
31 
32 #endif
33