@@ -27,13 +27,13 @@ namespace math {
2727template <typename M, require_eigen_dense_dynamic_t <M>* = nullptr >
2828inline Eigen::Matrix<complex_return_t <scalar_type_t <M>>, -1 , -1 >
2929complex_schur_decompose_u (const M& m) {
30- if (m.size () == 0 )
30+ if (unlikely ( m.size () == 0 )) {
3131 return m;
32+ }
3233 check_square (" complex_schur_decompose_u" , " m" , m);
3334 using MatType = Eigen::Matrix<scalar_type_t <M>, -1 , -1 >;
3435 // copy because ComplexSchur requires Eigen::Matrix type
35- MatType mv = m;
36- Eigen::ComplexSchur<MatType> cs (mv);
36+ Eigen::ComplexSchur<MatType> cs{MatType (m)};
3737 return cs.matrixU ();
3838}
3939
@@ -51,13 +51,13 @@ complex_schur_decompose_u(const M& m) {
5151template <typename M, require_eigen_dense_dynamic_t <M>* = nullptr >
5252inline Eigen::Matrix<complex_return_t <scalar_type_t <M>>, -1 , -1 >
5353complex_schur_decompose_t (const M& m) {
54- if (m.size () == 0 )
54+ if (unlikely ( m.size () == 0 )) {
5555 return m;
56+ }
5657 check_square (" complex_schur_decompose_t" , " m" , m);
5758 using MatType = Eigen::Matrix<scalar_type_t <M>, -1 , -1 >;
5859 // copy because ComplexSchur requires Eigen::Matrix type
59- MatType mv = m;
60- Eigen::ComplexSchur<MatType> cs (mv, false );
60+ Eigen::ComplexSchur<MatType> cs{MatType (m), false };
6161 return cs.matrixT ();
6262}
6363
@@ -81,13 +81,13 @@ template <typename M, require_eigen_dense_dynamic_t<M>* = nullptr>
8181inline std::tuple<Eigen::Matrix<complex_return_t <scalar_type_t <M>>, -1 , -1 >,
8282 Eigen::Matrix<complex_return_t <scalar_type_t <M>>, -1 , -1 >>
8383complex_schur_decompose (const M& m) {
84- if (m.size () == 0 )
84+ if (unlikely ( m.size () == 0 )) {
8585 return std::make_tuple (m, m);
86+ }
8687 check_square (" complex_schur_decompose" , " m" , m);
8788 using MatType = Eigen::Matrix<scalar_type_t <M>, -1 , -1 >;
8889 // copy because ComplexSchur requires Eigen::Matrix type
89- MatType mv = m;
90- Eigen::ComplexSchur<MatType> cs (mv);
90+ Eigen::ComplexSchur<MatType> cs{MatType (m)};
9191 return std::make_tuple (std::move (cs.matrixU ()), std::move (cs.matrixT ()));
9292}
9393
0 commit comments