diff options
author | Gael Guennebaud <g.gael@free.fr> | 2009-08-13 11:42:02 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2009-08-13 11:42:02 +0200 |
commit | 1b257a7620d122a05f71b6ebd52e14fe5f1b18ef (patch) | |
tree | 56b66ea6ea98e2bf6be7fb51c9c9f8d1dbb48205 /Eigen/src/Jacobi | |
parent | 1d80f561ad48a96e9852dd8bfdbc400574aa67e5 (diff) |
add an optimized "apply in place a rotation in the plane",
and make Jacobi and SelfAdjointEigenSolver use it
=> ~ x1.75 speedup for JacobiSVD and x2 for SelfAdjointEigenSolver
Diffstat (limited to 'Eigen/src/Jacobi')
-rw-r--r-- | Eigen/src/Jacobi/Jacobi.h | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/Eigen/src/Jacobi/Jacobi.h b/Eigen/src/Jacobi/Jacobi.h index 785dd26ab..10ae9eb8f 100644 --- a/Eigen/src/Jacobi/Jacobi.h +++ b/Eigen/src/Jacobi/Jacobi.h @@ -28,23 +28,17 @@ template<typename Derived> void MatrixBase<Derived>::applyJacobiOnTheLeft(int p, int q, Scalar c, Scalar s) { - for(int i = 0; i < cols(); ++i) - { - Scalar tmp = coeff(p,i); - coeffRef(p,i) = c * tmp - s * coeff(q,i); - coeffRef(q,i) = s * tmp + c * coeff(q,i); - } + RowXpr x(row(p)); + RowXpr y(row(q)); + ei_apply_rotation_in_the_plane(x, y, c, s); } template<typename Derived> void MatrixBase<Derived>::applyJacobiOnTheRight(int p, int q, Scalar c, Scalar s) { - for(int i = 0; i < rows(); ++i) - { - Scalar tmp = coeff(i,p); - coeffRef(i,p) = c * tmp - s * coeff(i,q); - coeffRef(i,q) = s * tmp + c * coeff(i,q); - } + ColXpr x(col(p)); + ColXpr y(col(q)); + ei_apply_rotation_in_the_plane(x, y, c, s); } template<typename Scalar> |