template<typename Scalar>
JacobiRotation class
Rotation given by a cosine-sine pair.
Contents
This is defined in the Jacobi module. #include <Eigen/Jacobi>
This class represents a Jacobi or Givens rotation. This is a 2D rotation in the plane J
of angle defined by its cosine c
and sine s
as follow:
You can apply the respective counter-clockwise rotation to a column vector v
by applying its adjoint on the left: that translates to the following Eigen code: v.applyOnTheLeft(J.adjoint());
Public types
- using RealScalar = NumTraits<Scalar>::Real
Constructors, destructors, conversion operators
- JacobiRotation()
- JacobiRotation(const Scalar& c, const Scalar& s)
Public functions
- auto adjoint() const -> JacobiRotation
- auto c() -> Scalar&
- auto c() const -> Scalar
- void makeGivens(const Scalar& p, const Scalar& q, Scalar* r = 0)
-
template<typename Derived>auto makeJacobi(const MatrixBase<Derived>&, Index p, Index q) -> bool
- auto makeJacobi(const RealScalar& x, const Scalar& y, const RealScalar& z) -> bool
- auto operator*(const JacobiRotation& other) -> JacobiRotation
- auto s() -> Scalar&
- auto s() const -> Scalar
- auto transpose() const -> JacobiRotation
Protected functions
- void makeGivens(const Scalar& p, const Scalar& q, Scalar* r, internal::true_type)
- void makeGivens(const Scalar& p, const Scalar& q, Scalar* r, internal::false_type)
Protected variables
Typedef documentation
template<typename Scalar>
typedef NumTraits<Scalar>::Real Eigen:: JacobiRotation<Scalar>:: RealScalar
Function documentation
template<typename Scalar>
Eigen:: JacobiRotation<Scalar>:: JacobiRotation()
Default constructor without any initialization.
template<typename Scalar>
Eigen:: JacobiRotation<Scalar>:: JacobiRotation(const Scalar& c,
const Scalar& s)
Construct a planar rotation from a cosine-sine pair (c, s
).
template<typename Scalar>
JacobiRotation Eigen:: JacobiRotation<Scalar>:: adjoint() const
Returns the adjoint transformation
template<typename Scalar>
Scalar& Eigen:: JacobiRotation<Scalar>:: c()
template<typename Scalar>
Scalar Eigen:: JacobiRotation<Scalar>:: c() const
template<typename Scalar>
void Eigen:: JacobiRotation<Scalar>:: makeGivens(const Scalar& p,
const Scalar& q,
Scalar* r = 0)
Makes *this
as a Givens rotation G
such that applying to the left of the vector yields: .
The value of r is returned if r is not null (the default is null). Also note that G is built such that the cosine is always real.
Example:
Vector2f v = Vector2f::Random(); JacobiRotation<float> G; G.makeGivens(v.x(), v.y()); cout << "Here is the vector v:" << endl << v << endl; v.applyOnTheLeft(0, 1, G.adjoint()); cout << "Here is the vector J' * v:" << endl << v << endl;
Output:
Here is the vector v: 0.68 -0.211 Here is the vector J' * v: 0.712 0
This function implements the continuous Givens rotation generation algorithm found in Anderson (2000), Discontinuous Plane Rotations and the Symmetric Eigenvalue Problem. LAPACK Working Note 150, University of Tennessee, UT-CS-00-454, December 4, 2000.
template<typename Scalar>
template<typename Derived>
bool Eigen:: JacobiRotation<Scalar>:: makeJacobi(const MatrixBase<Derived>&,
Index p,
Index q)
Makes *this
as a Jacobi rotation J
such that applying J on both the right and left sides of the 2x2 selfadjoint matrix yields a diagonal matrix
Example:
Matrix2f m = Matrix2f::Random(); m = (m + m.adjoint()).eval(); JacobiRotation<float> J; J.makeJacobi(m, 0, 1); cout << "Here is the matrix m:" << endl << m << endl; m.applyOnTheLeft(0, 1, J.adjoint()); m.applyOnTheRight(0, 1, J); cout << "Here is the matrix J' * m * J:" << endl << m << endl;
Output:
Here is the matrix m: 1.36 0.355 0.355 1.19 Here is the matrix J' * m * J: 1.64 0 0 0.913
template<typename Scalar>
bool Eigen:: JacobiRotation<Scalar>:: makeJacobi(const RealScalar& x,
const Scalar& y,
const RealScalar& z)
Makes *this
as a Jacobi rotation J such that applying J on both the right and left sides of the selfadjoint 2x2 matrix yields a diagonal matrix
template<typename Scalar>
JacobiRotation Eigen:: JacobiRotation<Scalar>:: operator*(const JacobiRotation& other)
Concatenates two planar rotation
template<typename Scalar>
Scalar& Eigen:: JacobiRotation<Scalar>:: s()
template<typename Scalar>
Scalar Eigen:: JacobiRotation<Scalar>:: s() const
template<typename Scalar>
JacobiRotation Eigen:: JacobiRotation<Scalar>:: transpose() const
Returns the transposed transformation