From e259f71477c05de231118a114398be22697feaaa Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Tue, 19 Oct 2010 21:56:26 -0400 Subject: rename PlanarRotation -> JacobiRotation --- Eigen/src/Core/MatrixBase.h | 4 +-- Eigen/src/Core/util/ForwardDeclarations.h | 2 +- Eigen/src/Eigenvalues/ComplexSchur.h | 2 +- Eigen/src/Eigenvalues/RealSchur.h | 2 +- Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h | 2 +- Eigen/src/Jacobi/Jacobi.h | 42 +++++++++++----------- Eigen/src/SVD/JacobiSVD.h | 10 +++--- bench/btl/libs/eigen2/eigen2_interface.hh | 2 +- blas/level1_impl.h | 8 ++--- doc/snippets/Jacobi_makeGivens.cpp | 2 +- doc/snippets/Jacobi_makeJacobi.cpp | 2 +- test/jacobi.cpp | 2 +- .../Eigen/src/MatrixFunctions/MatrixFunction.h | 2 +- .../NonLinearOptimization/HybridNonLinearSolver.h | 4 +-- .../Eigen/src/NonLinearOptimization/qrsolv.h | 2 +- .../Eigen/src/NonLinearOptimization/r1mpyq.h | 2 +- .../Eigen/src/NonLinearOptimization/r1updt.h | 6 ++-- .../Eigen/src/NonLinearOptimization/rwupdt.h | 4 +-- 18 files changed, 50 insertions(+), 50 deletions(-) diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index e6091313d..3e45cdaf1 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -377,9 +377,9 @@ template class MatrixBase ///////// Jacobi module ///////// template - void applyOnTheLeft(Index p, Index q, const PlanarRotation& j); + void applyOnTheLeft(Index p, Index q, const JacobiRotation& j); template - void applyOnTheRight(Index p, Index q, const PlanarRotation& j); + void applyOnTheRight(Index p, Index q, const JacobiRotation& j); ///////// MatrixFunctions module ///////// diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h index f6cf3fe41..4b1740c82 100644 --- a/Eigen/src/Core/util/ForwardDeclarations.h +++ b/Eigen/src/Core/util/ForwardDeclarations.h @@ -173,7 +173,7 @@ template class LLT; template class LDLT; template class HouseholderSequence; -template class PlanarRotation; +template class JacobiRotation; // Geometry module: template class RotationBase; diff --git a/Eigen/src/Eigenvalues/ComplexSchur.h b/Eigen/src/Eigenvalues/ComplexSchur.h index edda4211b..612573895 100644 --- a/Eigen/src/Eigenvalues/ComplexSchur.h +++ b/Eigen/src/Eigenvalues/ComplexSchur.h @@ -411,7 +411,7 @@ void ComplexSchur::reduceToTriangularForm(bool computeU) bulge is chased down to the bottom of the active submatrix. */ ComplexScalar shift = computeShift(iu, iter); - PlanarRotation rot; + JacobiRotation rot; rot.makeGivens(m_matT.coeff(il,il) - shift, m_matT.coeff(il+1,il)); m_matT.rightCols(m_matT.cols()-il).applyOnTheLeft(il, il+1, rot.adjoint()); m_matT.topRows(std::min(il+2,iu)+1).applyOnTheRight(il, il+1, rot); diff --git a/Eigen/src/Eigenvalues/RealSchur.h b/Eigen/src/Eigenvalues/RealSchur.h index eb713339b..1d299d5f6 100644 --- a/Eigen/src/Eigenvalues/RealSchur.h +++ b/Eigen/src/Eigenvalues/RealSchur.h @@ -326,7 +326,7 @@ inline void RealSchur::splitOffTwoRows(Index iu, bool computeU, Scal if (q >= 0) // Two real eigenvalues { Scalar z = ei_sqrt(ei_abs(q)); - PlanarRotation rot; + JacobiRotation rot; if (p >= 0) rot.makeGivens(p + z, m_matT.coeff(iu, iu-1)); else diff --git a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h index f14baa333..d32e223fb 100644 --- a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +++ b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h @@ -438,7 +438,7 @@ static void ei_tridiagonal_qr_step(RealScalar* diag, RealScalar* subdiag, Index for (Index k = start; k < end; ++k) { - PlanarRotation rot; + JacobiRotation rot; rot.makeGivens(x, z); // do T = G' T G diff --git a/Eigen/src/Jacobi/Jacobi.h b/Eigen/src/Jacobi/Jacobi.h index 6fd1ed389..39420bf42 100644 --- a/Eigen/src/Jacobi/Jacobi.h +++ b/Eigen/src/Jacobi/Jacobi.h @@ -28,8 +28,8 @@ /** \ingroup Jacobi_Module * \jacobi_module - * \class PlanarRotation - * \brief Represents a rotation in the plane from a cosine-sine pair. + * \class JacobiRotation + * \brief Represents a rotation given by a cosine-sine pair. * * This class represents a Jacobi or Givens rotation. * This is a 2D rotation in the plane \c J of angle \f$ \theta \f$ defined by @@ -44,16 +44,16 @@ * * \sa MatrixBase::applyOnTheLeft(), MatrixBase::applyOnTheRight() */ -template class PlanarRotation +template class JacobiRotation { public: typedef typename NumTraits::Real RealScalar; /** Default constructor without any initialization. */ - PlanarRotation() {} + JacobiRotation() {} /** Construct a planar rotation from a cosine-sine pair (\a c, \c s). */ - PlanarRotation(const Scalar& c, const Scalar& s) : m_c(c), m_s(s) {} + JacobiRotation(const Scalar& c, const Scalar& s) : m_c(c), m_s(s) {} Scalar& c() { return m_c; } Scalar c() const { return m_c; } @@ -61,17 +61,17 @@ template class PlanarRotation Scalar s() const { return m_s; } /** Concatenates two planar rotation */ - PlanarRotation operator*(const PlanarRotation& other) + JacobiRotation operator*(const JacobiRotation& other) { - return PlanarRotation(m_c * other.m_c - ei_conj(m_s) * other.m_s, + return JacobiRotation(m_c * other.m_c - ei_conj(m_s) * other.m_s, ei_conj(m_c * ei_conj(other.m_s) + ei_conj(m_s) * ei_conj(other.m_c))); } /** Returns the transposed transformation */ - PlanarRotation transpose() const { return PlanarRotation(m_c, -ei_conj(m_s)); } + JacobiRotation transpose() const { return JacobiRotation(m_c, -ei_conj(m_s)); } /** Returns the adjoint transformation */ - PlanarRotation adjoint() const { return PlanarRotation(ei_conj(m_c), -m_s); } + JacobiRotation adjoint() const { return JacobiRotation(ei_conj(m_c), -m_s); } template bool makeJacobi(const MatrixBase&, typename Derived::Index p, typename Derived::Index q); @@ -92,7 +92,7 @@ template class PlanarRotation * \sa MatrixBase::makeJacobi(const MatrixBase&, Index, Index), MatrixBase::applyOnTheLeft(), MatrixBase::applyOnTheRight() */ template -bool PlanarRotation::makeJacobi(RealScalar x, Scalar y, RealScalar z) +bool JacobiRotation::makeJacobi(RealScalar x, Scalar y, RealScalar z) { typedef typename NumTraits::Real RealScalar; if(y == Scalar(0)) @@ -129,11 +129,11 @@ bool PlanarRotation::makeJacobi(RealScalar x, Scalar y, RealScalar z) * Example: \include Jacobi_makeJacobi.cpp * Output: \verbinclude Jacobi_makeJacobi.out * - * \sa PlanarRotation::makeJacobi(RealScalar, Scalar, RealScalar), MatrixBase::applyOnTheLeft(), MatrixBase::applyOnTheRight() + * \sa JacobiRotation::makeJacobi(RealScalar, Scalar, RealScalar), MatrixBase::applyOnTheLeft(), MatrixBase::applyOnTheRight() */ template template -inline bool PlanarRotation::makeJacobi(const MatrixBase& m, typename Derived::Index p, typename Derived::Index q) +inline bool JacobiRotation::makeJacobi(const MatrixBase& m, typename Derived::Index p, typename Derived::Index q) { return makeJacobi(ei_real(m.coeff(p,p)), m.coeff(p,q), ei_real(m.coeff(q,q))); } @@ -155,7 +155,7 @@ inline bool PlanarRotation::makeJacobi(const MatrixBase& m, typ * \sa MatrixBase::applyOnTheLeft(), MatrixBase::applyOnTheRight() */ template -void PlanarRotation::makeGivens(const Scalar& p, const Scalar& q, Scalar* z) +void JacobiRotation::makeGivens(const Scalar& p, const Scalar& q, Scalar* z) { makeGivens(p, q, z, typename ei_meta_if::IsComplex, ei_meta_true, ei_meta_false>::ret()); } @@ -163,7 +163,7 @@ void PlanarRotation::makeGivens(const Scalar& p, const Scalar& q, Scalar // specialization for complexes template -void PlanarRotation::makeGivens(const Scalar& p, const Scalar& q, Scalar* r, ei_meta_true) +void JacobiRotation::makeGivens(const Scalar& p, const Scalar& q, Scalar* r, ei_meta_true) { if(q==Scalar(0)) { @@ -218,7 +218,7 @@ void PlanarRotation::makeGivens(const Scalar& p, const Scalar& q, Scalar // specialization for reals template -void PlanarRotation::makeGivens(const Scalar& p, const Scalar& q, Scalar* r, ei_meta_false) +void JacobiRotation::makeGivens(const Scalar& p, const Scalar& q, Scalar* r, ei_meta_false) { if(q==0) @@ -267,17 +267,17 @@ void PlanarRotation::makeGivens(const Scalar& p, const Scalar& q, Scalar * \sa MatrixBase::applyOnTheLeft(), MatrixBase::applyOnTheRight() */ template -void ei_apply_rotation_in_the_plane(VectorX& _x, VectorY& _y, const PlanarRotation& j); +void ei_apply_rotation_in_the_plane(VectorX& _x, VectorY& _y, const JacobiRotation& j); /** \jacobi_module * Applies the rotation in the plane \a j to the rows \a p and \a q of \c *this, i.e., it computes B = J * B, * with \f$ B = \left ( \begin{array}{cc} \text{*this.row}(p) \\ \text{*this.row}(q) \end{array} \right ) \f$. * - * \sa class PlanarRotation, MatrixBase::applyOnTheRight(), ei_apply_rotation_in_the_plane() + * \sa class JacobiRotation, MatrixBase::applyOnTheRight(), ei_apply_rotation_in_the_plane() */ template template -inline void MatrixBase::applyOnTheLeft(Index p, Index q, const PlanarRotation& j) +inline void MatrixBase::applyOnTheLeft(Index p, Index q, const JacobiRotation& j) { RowXpr x(this->row(p)); RowXpr y(this->row(q)); @@ -288,11 +288,11 @@ inline void MatrixBase::applyOnTheLeft(Index p, Index q, const PlanarRo * Applies the rotation in the plane \a j to the columns \a p and \a q of \c *this, i.e., it computes B = B * J * with \f$ B = \left ( \begin{array}{cc} \text{*this.col}(p) & \text{*this.col}(q) \end{array} \right ) \f$. * - * \sa class PlanarRotation, MatrixBase::applyOnTheLeft(), ei_apply_rotation_in_the_plane() + * \sa class JacobiRotation, MatrixBase::applyOnTheLeft(), ei_apply_rotation_in_the_plane() */ template template -inline void MatrixBase::applyOnTheRight(Index p, Index q, const PlanarRotation& j) +inline void MatrixBase::applyOnTheRight(Index p, Index q, const JacobiRotation& j) { ColXpr x(this->col(p)); ColXpr y(this->col(q)); @@ -301,7 +301,7 @@ inline void MatrixBase::applyOnTheRight(Index p, Index q, const PlanarR template -void /*EIGEN_DONT_INLINE*/ ei_apply_rotation_in_the_plane(VectorX& _x, VectorY& _y, const PlanarRotation& j) +void /*EIGEN_DONT_INLINE*/ ei_apply_rotation_in_the_plane(VectorX& _x, VectorY& _y, const JacobiRotation& j) { typedef typename VectorX::Index Index; typedef typename VectorX::Scalar Scalar; diff --git a/Eigen/src/SVD/JacobiSVD.h b/Eigen/src/SVD/JacobiSVD.h index 44880dcf4..56ffea131 100644 --- a/Eigen/src/SVD/JacobiSVD.h +++ b/Eigen/src/SVD/JacobiSVD.h @@ -479,7 +479,7 @@ struct ei_svd_precondition_2x2_block_to_be_real rot; + JacobiRotation rot; RealScalar n = ei_sqrt(ei_abs2(work_matrix.coeff(p,p)) + ei_abs2(work_matrix.coeff(q,p))); if(n==0) { @@ -514,13 +514,13 @@ struct ei_svd_precondition_2x2_block_to_be_real void ei_real_2x2_jacobi_svd(const MatrixType& matrix, Index p, Index q, - PlanarRotation *j_left, - PlanarRotation *j_right) + JacobiRotation *j_left, + JacobiRotation *j_right) { Matrix m; m << ei_real(matrix.coeff(p,p)), ei_real(matrix.coeff(p,q)), ei_real(matrix.coeff(q,p)), ei_real(matrix.coeff(q,q)); - PlanarRotation rot1; + JacobiRotation rot1; RealScalar t = m.coeff(0,0) + m.coeff(1,1); RealScalar d = m.coeff(1,0) - m.coeff(0,1); if(t == RealScalar(0)) @@ -584,7 +584,7 @@ JacobiSVD::compute(const MatrixType& matrix, unsig // perform SVD decomposition of 2x2 sub-matrix corresponding to indices p,q to make it diagonal ei_svd_precondition_2x2_block_to_be_real::run(m_workMatrix, *this, p, q); - PlanarRotation j_left, j_right; + JacobiRotation j_left, j_right; ei_real_2x2_jacobi_svd(m_workMatrix, p, q, &j_left, &j_right); // accumulate resulting Jacobi rotations diff --git a/bench/btl/libs/eigen2/eigen2_interface.hh b/bench/btl/libs/eigen2/eigen2_interface.hh index 9bd9e8a62..428ddc547 100644 --- a/bench/btl/libs/eigen2/eigen2_interface.hh +++ b/bench/btl/libs/eigen2/eigen2_interface.hh @@ -166,7 +166,7 @@ public : } static EIGEN_DONT_INLINE void rot(gene_vector & A, gene_vector & B, real c, real s, int N){ - ei_apply_rotation_in_the_plane(A, B, PlanarRotation(c,s)); + ei_apply_rotation_in_the_plane(A, B, JacobiRotation(c,s)); } static inline void atv_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){ diff --git a/blas/level1_impl.h b/blas/level1_impl.h index 1665310c4..174ede3ce 100644 --- a/blas/level1_impl.h +++ b/blas/level1_impl.h @@ -233,9 +233,9 @@ int EIGEN_BLAS_FUNC(rot)(int *n, RealScalar *px, int *incx, RealScalar *py, int Reverse rvx(vx); Reverse rvy(vy); - if(*incx<0 && *incy>0) ei_apply_rotation_in_the_plane(rvx, vy, PlanarRotation(c,s)); - else if(*incx>0 && *incy<0) ei_apply_rotation_in_the_plane(vx, rvy, PlanarRotation(c,s)); - else ei_apply_rotation_in_the_plane(vx, vy, PlanarRotation(c,s)); + if(*incx<0 && *incy>0) ei_apply_rotation_in_the_plane(rvx, vy, JacobiRotation(c,s)); + else if(*incx>0 && *incy<0) ei_apply_rotation_in_the_plane(vx, rvy, JacobiRotation(c,s)); + else ei_apply_rotation_in_the_plane(vx, vy, JacobiRotation(c,s)); return 0; @@ -293,7 +293,7 @@ int EIGEN_BLAS_FUNC(rotg)(RealScalar *pa, RealScalar *pb, RealScalar *pc, RealSc } #endif -// PlanarRotation r; +// JacobiRotation r; // r.makeGivens(a,b); // *c = r.c(); // *s = r.s(); diff --git a/doc/snippets/Jacobi_makeGivens.cpp b/doc/snippets/Jacobi_makeGivens.cpp index 3a4defe24..4b733c306 100644 --- a/doc/snippets/Jacobi_makeGivens.cpp +++ b/doc/snippets/Jacobi_makeGivens.cpp @@ -1,5 +1,5 @@ Vector2f v = Vector2f::Random(); -PlanarRotation G; +JacobiRotation G; G.makeGivens(v.x(), v.y()); cout << "Here is the vector v:" << endl << v << endl; v.applyOnTheLeft(0, 1, G.adjoint()); diff --git a/doc/snippets/Jacobi_makeJacobi.cpp b/doc/snippets/Jacobi_makeJacobi.cpp index 5c0ab7374..0cc331d9f 100644 --- a/doc/snippets/Jacobi_makeJacobi.cpp +++ b/doc/snippets/Jacobi_makeJacobi.cpp @@ -1,6 +1,6 @@ Matrix2f m = Matrix2f::Random(); m = (m + m.adjoint()).eval(); -PlanarRotation J; +JacobiRotation J; J.makeJacobi(m, 0, 1); cout << "Here is the matrix m:" << endl << m << endl; m.applyOnTheLeft(0, 1, J.adjoint()); diff --git a/test/jacobi.cpp b/test/jacobi.cpp index 1c8d96e3c..623a5ac6c 100644 --- a/test/jacobi.cpp +++ b/test/jacobi.cpp @@ -45,7 +45,7 @@ void jacobi(const MatrixType& m = MatrixType()) JacobiVector v = JacobiVector::Random().normalized(); JacobiScalar c = v.x(), s = v.y(); - PlanarRotation rot(c, s); + JacobiRotation rot(c, s); { Index p = ei_random(0, rows-1); diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h b/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h index ae5dcab59..e83e055e9 100644 --- a/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h +++ b/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h @@ -358,7 +358,7 @@ void MatrixFunction::permuteSchur() template void MatrixFunction::swapEntriesInSchur(Index index) { - PlanarRotation rotation; + JacobiRotation rotation; rotation.makeGivens(m_T(index, index+1), m_T(index+1, index+1) - m_T(index, index)); m_T.applyOnTheLeft(index, index+1, rotation.adjoint()); m_T.applyOnTheRight(index, index+1, rotation); diff --git a/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h b/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h index 0ef3ecafa..3308a4a34 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h +++ b/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h @@ -201,7 +201,7 @@ HybridNonLinearSolver::solveOneStep(FVectorType &x) assert(x.size()==n); // check the caller is not cheating us Index j; - std::vector > v_givens(n), w_givens(n); + std::vector > v_givens(n), w_givens(n); jeval = true; @@ -440,7 +440,7 @@ HybridNonLinearSolver::solveNumericalDiffOneStep(FVectorType assert(x.size()==n); // check the caller is not cheating us Index j; - std::vector > v_givens(n), w_givens(n); + std::vector > v_givens(n), w_givens(n); jeval = true; if (parameters.nb_of_subdiagonals<0) parameters.nb_of_subdiagonals= n-1; diff --git a/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h b/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h index 15a27d53d..2a602fedf 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h +++ b/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h @@ -18,7 +18,7 @@ void ei_qrsolv( Scalar temp; Index n = s.cols(); Matrix< Scalar, Dynamic, 1 > wa(n); - PlanarRotation givens; + JacobiRotation givens; /* Function Body */ // the following will only change the lower triangular part of s, including diff --git a/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h b/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h index ad319d9eb..b2ea20d77 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h +++ b/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h @@ -2,7 +2,7 @@ // TODO : move this to GivensQR once there's such a thing in Eigen template -void ei_r1mpyq(DenseIndex m, DenseIndex n, Scalar *a, const std::vector > &v_givens, const std::vector > &w_givens) +void ei_r1mpyq(DenseIndex m, DenseIndex n, Scalar *a, const std::vector > &v_givens, const std::vector > &w_givens) { typedef DenseIndex Index; diff --git a/unsupported/Eigen/src/NonLinearOptimization/r1updt.h b/unsupported/Eigen/src/NonLinearOptimization/r1updt.h index e01d02910..881327af7 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/r1updt.h +++ b/unsupported/Eigen/src/NonLinearOptimization/r1updt.h @@ -3,8 +3,8 @@ template void ei_r1updt( Matrix< Scalar, Dynamic, Dynamic > &s, const Matrix< Scalar, Dynamic, 1> &u, - std::vector > &v_givens, - std::vector > &w_givens, + std::vector > &v_givens, + std::vector > &w_givens, Matrix< Scalar, Dynamic, 1> &v, Matrix< Scalar, Dynamic, 1> &w, bool *sing) @@ -16,7 +16,7 @@ void ei_r1updt( const Index n = s.cols(); Index i, j=1; Scalar temp; - PlanarRotation givens; + JacobiRotation givens; // ei_r1updt had a broader usecase, but we dont use it here. And, more // importantly, we can not test it. diff --git a/unsupported/Eigen/src/NonLinearOptimization/rwupdt.h b/unsupported/Eigen/src/NonLinearOptimization/rwupdt.h index aa0bf7d0f..ec97b707a 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/rwupdt.h +++ b/unsupported/Eigen/src/NonLinearOptimization/rwupdt.h @@ -10,7 +10,7 @@ void ei_rwupdt( const Index n = r.cols(); assert(r.rows()>=n); - std::vector > givens(n); + std::vector > givens(n); /* Local variables */ Scalar temp, rowj; @@ -29,7 +29,7 @@ void ei_rwupdt( if (rowj == 0.) { - givens[j] = PlanarRotation(1,0); + givens[j] = JacobiRotation(1,0); continue; } -- cgit v1.2.3