mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
* remove EIGEN_DONT_INLINE that harm performance for small sizes
* normalize left Jacobi rotations to avoid having to swap rows * set precision to 2*machine_epsilon instead of machine_epsilon, we lose 1 bit of precision but gain between 10% and 100% speed, plus reduce the risk that some day we hit a bad matrix where it's impossible to approach machine precision
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
#define EIGEN_JACOBI_H
|
||||
|
||||
template<typename Derived>
|
||||
void MatrixBase<Derived>::applyJacobiOnTheLeft(int p, int q, Scalar c, Scalar s)
|
||||
inline void MatrixBase<Derived>::applyJacobiOnTheLeft(int p, int q, Scalar c, Scalar s)
|
||||
{
|
||||
RowXpr x(row(p));
|
||||
RowXpr y(row(q));
|
||||
@@ -34,7 +34,7 @@ void MatrixBase<Derived>::applyJacobiOnTheLeft(int p, int q, Scalar c, Scalar s)
|
||||
}
|
||||
|
||||
template<typename Derived>
|
||||
void MatrixBase<Derived>::applyJacobiOnTheRight(int p, int q, Scalar c, Scalar s)
|
||||
inline void MatrixBase<Derived>::applyJacobiOnTheRight(int p, int q, Scalar c, Scalar s)
|
||||
{
|
||||
ColXpr x(col(p));
|
||||
ColXpr y(col(q));
|
||||
@@ -89,5 +89,17 @@ inline bool MatrixBase<Derived>::makeJacobiForAAt(int p, int q, Scalar *c, Scala
|
||||
c,s);
|
||||
}
|
||||
|
||||
template<typename Scalar>
|
||||
inline void ei_normalizeJacobi(Scalar *c, Scalar *s, const Scalar& x, const Scalar& y)
|
||||
{
|
||||
Scalar a = x * *c - y * *s;
|
||||
Scalar b = x * *s + y * *c;
|
||||
if(ei_abs(b)>ei_abs(a)) {
|
||||
Scalar x = *c;
|
||||
*c = -*s;
|
||||
*s = x;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif // EIGEN_JACOBI_H
|
||||
|
||||
Reference in New Issue
Block a user