Automatic Differentiation
 
Loading...
Searching...
No Matches
complex_schur_decompose.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_COMPLEX_SCHUR_DECOMPOSE_HPP
2#define STAN_MATH_PRIM_FUN_COMPLEX_SCHUR_DECOMPOSE_HPP
3
7
8namespace stan {
9namespace math {
10
27template <typename M, require_eigen_dense_dynamic_t<M>* = nullptr>
28inline Eigen::Matrix<complex_return_t<scalar_type_t<M>>, -1, -1>
30 if (unlikely(m.size() == 0)) {
31 return m;
32 }
33 check_square("complex_schur_decompose_u", "m", m);
34 using MatType = Eigen::Matrix<scalar_type_t<M>, -1, -1>;
35 // copy because ComplexSchur requires Eigen::Matrix type
36 Eigen::ComplexSchur<MatType> cs{MatType(m)};
37 return cs.matrixU();
38}
39
51template <typename M, require_eigen_dense_dynamic_t<M>* = nullptr>
52inline Eigen::Matrix<complex_return_t<scalar_type_t<M>>, -1, -1>
54 if (unlikely(m.size() == 0)) {
55 return m;
56 }
57 check_square("complex_schur_decompose_t", "m", m);
58 using MatType = Eigen::Matrix<scalar_type_t<M>, -1, -1>;
59 // copy because ComplexSchur requires Eigen::Matrix type
60 Eigen::ComplexSchur<MatType> cs{MatType(m), false};
61 return cs.matrixT();
62}
63
80template <typename M, require_eigen_dense_dynamic_t<M>* = nullptr>
81inline std::tuple<Eigen::Matrix<complex_return_t<scalar_type_t<M>>, -1, -1>,
82 Eigen::Matrix<complex_return_t<scalar_type_t<M>>, -1, -1>>
84 if (unlikely(m.size() == 0)) {
85 return std::make_tuple(m, m);
86 }
87 check_square("complex_schur_decompose", "m", m);
88 using MatType = Eigen::Matrix<scalar_type_t<M>, -1, -1>;
89 // copy because ComplexSchur requires Eigen::Matrix type
90 Eigen::ComplexSchur<MatType> cs{MatType(m)};
91 return std::make_tuple(std::move(cs.matrixU()), std::move(cs.matrixT()));
92}
93
94} // namespace math
95} // namespace stan
96#endif
#define unlikely(x)
void check_square(const char *function, const char *name, const T_y &y)
Check if the specified matrix is square.
std::tuple< Eigen::Matrix< complex_return_t< scalar_type_t< M > >, -1, -1 >, Eigen::Matrix< complex_return_t< scalar_type_t< M > >, -1, -1 > > complex_schur_decompose(const M &m)
Return the complex Schur decomposition of the specified square matrix.
Eigen::Matrix< complex_return_t< scalar_type_t< M > >, -1, -1 > complex_schur_decompose_u(const M &m)
Return the unitary matrix of the complex Schur decomposition of the specified square matrix.
Eigen::Matrix< complex_return_t< scalar_type_t< M > >, -1, -1 > complex_schur_decompose_t(const M &m)
Return the Schur form matrix of the complex Schur decomposition of the specified square matrix.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Definition fvar.hpp:9