11 #ifndef EIGEN_REALSVD2X2_H 12 #define EIGEN_REALSVD2X2_H 18 template<
typename MatrixType,
typename RealScalar,
typename Index>
19 void real_2x2_jacobi_svd(
const MatrixType& matrix,
Index p,
Index q,
20 JacobiRotation<RealScalar> *j_left,
21 JacobiRotation<RealScalar> *j_right)
25 Matrix<RealScalar,2,2> m;
26 m << numext::real(matrix.coeff(p,p)), numext::real(matrix.coeff(p,q)),
27 numext::real(matrix.coeff(q,p)), numext::real(matrix.coeff(q,q));
28 JacobiRotation<RealScalar> rot1;
29 RealScalar t = m.coeff(0,0) + m.coeff(1,1);
30 RealScalar d = m.coeff(1,0) - m.coeff(0,1);
32 if(
abs(d) < (std::numeric_limits<RealScalar>::min)())
34 rot1.s() = RealScalar(0);
35 rot1.c() = RealScalar(1);
42 RealScalar tmp =
sqrt(RealScalar(1) + numext::abs2(u));
43 rot1.s() = RealScalar(1) / tmp;
46 m.applyOnTheLeft(0,1,rot1);
47 j_right->makeJacobi(m,0,1);
48 *j_left = rot1 * j_right->transpose();
55 #endif // EIGEN_REALSVD2X2_H const Eigen::CwiseUnaryOp< Eigen::internal::scalar_sqrt_op< typename Derived::Scalar >, const Derived > sqrt(const Eigen::ArrayBase< Derived > &x)
Namespace containing all symbols from the Eigen library.
Definition: Core:141
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_abs_op< typename Derived::Scalar >, const Derived > abs(const Eigen::ArrayBase< Derived > &x)
Definition: Eigen_Colamd.h:50