Go to the documentation of this file.
11 #ifndef EIGEN_EIGENSOLVER_H
12 #define EIGEN_EIGENSOLVER_H
146 template<
typename InputType>
277 template<
typename InputType>
323 template<
typename MatrixType>
326 eigen_assert(m_isInitialized &&
"EigenSolver is not initialized.");
328 Index n = m_eivalues.rows();
344 template<
typename MatrixType>
347 eigen_assert(m_isInitialized &&
"EigenSolver is not initialized.");
348 eigen_assert(m_eigenvectorsOk &&
"The eigenvectors have not been computed together with the eigenvalues.");
357 matV.col(
j) = m_eivec.col(
j).template cast<ComplexScalar>();
358 matV.col(
j).normalize();
368 matV.col(
j).normalize();
369 matV.col(
j+1).normalize();
376 template<
typename MatrixType>
377 template<
typename InputType>
381 check_template_parameters();
389 m_realSchur.compute(
matrix.derived(), computeEigenvectors);
391 m_info = m_realSchur.info();
395 m_matT = m_realSchur.matrixT();
396 if (computeEigenvectors)
397 m_eivec = m_realSchur.matrixU();
400 m_eivalues.resize(
matrix.cols());
406 m_eivalues.coeffRef(
i) = m_matT.coeff(
i,
i);
409 m_isInitialized =
true;
410 m_eigenvectorsOk =
false;
425 Scalar maxval = numext::maxi<Scalar>(
abs(
p),numext::maxi<Scalar>(
abs(t0),
abs(t1)));
436 m_isInitialized =
true;
437 m_eigenvectorsOk =
false;
446 if (computeEigenvectors)
447 doComputeEigenvectors();
450 m_isInitialized =
true;
451 m_eigenvectorsOk = computeEigenvectors;
457 template<
typename MatrixType>
479 Scalar p = m_eivalues.coeff(
n).real();
480 Scalar q = m_eivalues.coeff(
n).imag();
485 Scalar lastr(0), lastw(0);
492 Scalar r = m_matT.row(
i).segment(
l,
n-
l+1).dot(m_matT.col(
n).segment(
l,
n-
l+1));
494 if (m_eivalues.coeff(
i).imag() <
Scalar(0))
502 if (m_eivalues.coeff(
i).imag() ==
Scalar(0))
505 m_matT.coeffRef(
i,
n) = -r /
w;
507 m_matT.coeffRef(
i,
n) = -r / (eps * norm);
513 Scalar denom = (m_eivalues.coeff(
i).real() -
p) * (m_eivalues.coeff(
i).real() -
p) + m_eivalues.coeff(
i).imag() * m_eivalues.coeff(
i).imag();
514 Scalar t = (
x * lastr - lastw * r) / denom;
515 m_matT.coeffRef(
i,
n) =
t;
517 m_matT.coeffRef(
i+1,
n) = (-r -
w *
t) /
x;
519 m_matT.coeffRef(
i+1,
n) = (-lastr -
y *
t) / lastw;
525 m_matT.col(
n).tail(
size-
i) /=
t;
531 Scalar lastra(0), lastsa(0), lastw(0);
535 if (
abs(m_matT.coeff(
n,
n-1)) >
abs(m_matT.coeff(
n-1,
n)))
537 m_matT.coeffRef(
n-1,
n-1) =
q / m_matT.coeff(
n,
n-1);
538 m_matT.coeffRef(
n-1,
n) = -(m_matT.coeff(
n,
n) -
p) / m_matT.coeff(
n,
n-1);
550 Scalar ra = m_matT.row(
i).segment(
l,
n-
l+1).dot(m_matT.col(
n-1).segment(
l,
n-
l+1));
551 Scalar sa = m_matT.row(
i).segment(
l,
n-
l+1).dot(m_matT.col(
n).segment(
l,
n-
l+1));
554 if (m_eivalues.coeff(
i).imag() <
Scalar(0))
574 Scalar vr = (m_eivalues.coeff(
i).real() -
p) * (m_eivalues.coeff(
i).real() -
p) + m_eivalues.coeff(
i).imag() * m_eivalues.coeff(
i).imag() -
q *
q;
584 m_matT.coeffRef(
i+1,
n-1) = (-ra -
w * m_matT.coeff(
i,
n-1) +
q * m_matT.coeff(
i,
n)) /
x;
585 m_matT.coeffRef(
i+1,
n) = (-sa -
w * m_matT.coeff(
i,
n) -
q * m_matT.coeff(
i,
n-1)) /
x;
596 Scalar t = numext::maxi<Scalar>(
abs(m_matT.coeff(
i,
n-1)),
abs(m_matT.coeff(
i,
n)));
598 m_matT.block(
i,
n-1,
size-
i, 2) /=
t;
608 eigen_assert(0 &&
"Internal bug in EigenSolver (INF or NaN has not been detected)");
615 m_tmp.noalias() = m_eivec.leftCols(
j+1) * m_matT.col(
j).segment(0,
j+1);
616 m_eivec.col(
j) = m_tmp;
622 #endif // EIGEN_EIGENSOLVER_H
void doComputeEigenvectors()
Namespace containing all symbols from the Eigen library.
EigenSolver & setMaxIterations(Index maxIters)
Sets the maximum number of iterations allowed.
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool() isfinite(const Eigen::bfloat16 &h)
MatrixType::Scalar Scalar
Scalar type for matrices of type MatrixType.
EigenSolver(const EigenBase< InputType > &matrix, bool computeEigenvectors=true)
Constructor; computes eigendecomposition of given matrix.
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
RealSchur< MatrixType > m_realSchur
NumTraits< Scalar >::Real RealScalar
EIGEN_DEVICE_FUNC bool isMuchSmallerThan(const Scalar &x, const OtherScalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
EigenSolver & compute(const EigenBase< InputType > &matrix, bool computeEigenvectors=true)
Computes eigendecomposition of given matrix.
const MatrixType & pseudoEigenvectors() const
Returns the pseudo-eigenvectors of given matrix.
static void check_template_parameters()
Matrix< Scalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > ColumnVectorType
Matrix< ComplexScalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > EigenvalueType
Type for vector of eigenvalues as returned by eigenvalues().
EigenSolver(Index size)
Default constructor with memory preallocation.
EIGEN_DEVICE_FUNC const Scalar & q
std::complex< RealScalar > ComplexScalar
Complex scalar type for MatrixType.
MatrixType pseudoEigenvalueMatrix() const
Returns the block-diagonal matrix in the pseudo-eigendecomposition.
static const Line3 l(Rot3(), 1, 1)
Index getMaxIterations()
Returns the maximum number of iterations.
const EIGEN_DEVICE_FUNC ImagReturnType imag() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
EigenvectorsType eigenvectors() const
Returns the eigenvectors of given matrix.
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
NumTraits< Scalar >::Real RealScalar
_MatrixType MatrixType
Synonym for the template parameter _MatrixType.
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
Computes eigenvalues and eigenvectors of general matrices.
Matrix< ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime > EigenvectorsType
Type for matrix of eigenvectors as returned by eigenvectors().
RealSchur & setMaxIterations(Index maxIters)
Sets the maximum number of iterations allowed.
ComputationInfo info() const
EigenvalueType m_eivalues
EigenSolver()
Default constructor.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Jet< T, N > sqrt(const Jet< T, N > &f)
Index getMaxIterations()
Returns the maximum number of iterations.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
const EigenvalueType & eigenvalues() const
Returns the eigenvalues of given matrix.
#define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE)
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:15