mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-01-30 14:49:36 +08:00
move eigen values related stuff of the QR module to a new EigenSolver module.
- perhaps we can find a better name ? - note that the QR module still includes the EigenSolver module for compatibility
This commit is contained in:
parent
9515b00876
commit
a54b99fa72
@ -1,4 +1,4 @@
|
||||
set(Eigen_HEADERS Core LU Cholesky QR Geometry Sparse Array SVD LeastSquares QtAlignedMalloc StdVector Householder Jacobi)
|
||||
set(Eigen_HEADERS Core LU Cholesky QR Geometry Sparse Array SVD LeastSquares QtAlignedMalloc StdVector Householder Jacobi EigenSolver)
|
||||
|
||||
if(EIGEN_BUILD_LIB)
|
||||
set(Eigen_SRCS
|
||||
|
74
Eigen/EigenSolver
Normal file
74
Eigen/EigenSolver
Normal file
@ -0,0 +1,74 @@
|
||||
#ifndef EIGEN_EIGEN_SOLVER_MODULE_H
|
||||
#define EIGEN_EIGEN_SOLVER_MODULE_H
|
||||
|
||||
#include "Core"
|
||||
|
||||
#include "src/Core/util/DisableMSVCWarnings.h"
|
||||
|
||||
#include "Cholesky"
|
||||
#include "Jacobi"
|
||||
#include "Householder"
|
||||
|
||||
// Note that EIGEN_HIDE_HEAVY_CODE has to be defined per module
|
||||
#if (defined EIGEN_EXTERN_INSTANTIATIONS) && (EIGEN_EXTERN_INSTANTIATIONS>=2)
|
||||
#ifndef EIGEN_HIDE_HEAVY_CODE
|
||||
#define EIGEN_HIDE_HEAVY_CODE
|
||||
#endif
|
||||
#elif defined EIGEN_HIDE_HEAVY_CODE
|
||||
#undef EIGEN_HIDE_HEAVY_CODE
|
||||
#endif
|
||||
|
||||
namespace Eigen {
|
||||
|
||||
/** \defgroup EigenSolver_Module Eigen Solver module
|
||||
*
|
||||
* \nonstableyet
|
||||
*
|
||||
* This module mainly provides various eigen value solvers.
|
||||
* This module also provides some MatrixBase methods, including:
|
||||
* - MatrixBase::eigenvalues(),
|
||||
* - MatrixBase::operatorNorm()
|
||||
*
|
||||
* \code
|
||||
* #include <Eigen/EigenSolver>
|
||||
* \endcode
|
||||
*/
|
||||
|
||||
#include "src/EigenSolver/Tridiagonalization.h"
|
||||
#include "src/EigenSolver/EigenSolver.h"
|
||||
#include "src/EigenSolver/SelfAdjointEigenSolver.h"
|
||||
#include "src/EigenSolver/HessenbergDecomposition.h"
|
||||
#include "src/EigenSolver/ComplexSchur.h"
|
||||
#include "src/EigenSolver/ComplexEigenSolver.h"
|
||||
|
||||
// declare all classes for a given matrix type
|
||||
#define EIGEN_EIGEN_SOLVER_MODULE_INSTANTIATE_TYPE(MATRIXTYPE,PREFIX) \
|
||||
PREFIX template class Tridiagonalization<MATRIXTYPE>; \
|
||||
PREFIX template class HessenbergDecomposition<MATRIXTYPE>; \
|
||||
PREFIX template class SelfAdjointEigenSolver<MATRIXTYPE>
|
||||
|
||||
// removed because it does not support complex yet
|
||||
// PREFIX template class EigenSolver<MATRIXTYPE>
|
||||
|
||||
// declare all class for all types
|
||||
#define EIGEN_EIGEN_SOLVER_MODULE_INSTANTIATE(PREFIX) \
|
||||
EIGEN_EIGEN_SOLVER_MODULE_INSTANTIATE_TYPE(Matrix2f,PREFIX); \
|
||||
EIGEN_EIGEN_SOLVER_MODULE_INSTANTIATE_TYPE(Matrix2d,PREFIX); \
|
||||
EIGEN_EIGEN_SOLVER_MODULE_INSTANTIATE_TYPE(Matrix3f,PREFIX); \
|
||||
EIGEN_EIGEN_SOLVER_MODULE_INSTANTIATE_TYPE(Matrix3d,PREFIX); \
|
||||
EIGEN_EIGEN_SOLVER_MODULE_INSTANTIATE_TYPE(Matrix4f,PREFIX); \
|
||||
EIGEN_EIGEN_SOLVER_MODULE_INSTANTIATE_TYPE(Matrix4d,PREFIX); \
|
||||
EIGEN_EIGEN_SOLVER_MODULE_INSTANTIATE_TYPE(MatrixXf,PREFIX); \
|
||||
EIGEN_EIGEN_SOLVER_MODULE_INSTANTIATE_TYPE(MatrixXd,PREFIX); \
|
||||
EIGEN_EIGEN_SOLVER_MODULE_INSTANTIATE_TYPE(MatrixXcf,PREFIX); \
|
||||
EIGEN_EIGEN_SOLVER_MODULE_INSTANTIATE_TYPE(MatrixXcd,PREFIX)
|
||||
|
||||
#ifdef EIGEN_EXTERN_INSTANTIATIONS
|
||||
EIGEN_EIGEN_SOLVER_MODULE_INSTANTIATE(extern);
|
||||
#endif // EIGEN_EXTERN_INSTANTIATIONS
|
||||
|
||||
} // namespace Eigen
|
||||
|
||||
#include "src/Core/util/EnableMSVCWarnings.h"
|
||||
|
||||
#endif // EIGEN_EIGEN_SOLVER_MODULE_H
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "src/Core/util/DisableMSVCWarnings.h"
|
||||
|
||||
#include "QR"
|
||||
#include "EigenSolver"
|
||||
#include "Geometry"
|
||||
|
||||
namespace Eigen {
|
||||
|
19
Eigen/QR
19
Eigen/QR
@ -24,11 +24,9 @@ namespace Eigen {
|
||||
*
|
||||
* \nonstableyet
|
||||
*
|
||||
* This module mainly provides QR decomposition and an eigen value solver.
|
||||
* This module provides various QR decompositions
|
||||
* This module also provides some MatrixBase methods, including:
|
||||
* - MatrixBase::qr(),
|
||||
* - MatrixBase::eigenvalues(),
|
||||
* - MatrixBase::operatorNorm()
|
||||
*
|
||||
* \code
|
||||
* #include <Eigen/QR>
|
||||
@ -38,22 +36,10 @@ namespace Eigen {
|
||||
#include "src/QR/HouseholderQR.h"
|
||||
#include "src/QR/FullPivotingHouseholderQR.h"
|
||||
#include "src/QR/ColPivotingHouseholderQR.h"
|
||||
#include "src/QR/Tridiagonalization.h"
|
||||
#include "src/QR/EigenSolver.h"
|
||||
#include "src/QR/SelfAdjointEigenSolver.h"
|
||||
#include "src/QR/HessenbergDecomposition.h"
|
||||
#include "src/QR/ComplexSchur.h"
|
||||
#include "src/QR/ComplexEigenSolver.h"
|
||||
|
||||
// declare all classes for a given matrix type
|
||||
#define EIGEN_QR_MODULE_INSTANTIATE_TYPE(MATRIXTYPE,PREFIX) \
|
||||
PREFIX template class HouseholderQR<MATRIXTYPE>; \
|
||||
PREFIX template class Tridiagonalization<MATRIXTYPE>; \
|
||||
PREFIX template class HessenbergDecomposition<MATRIXTYPE>; \
|
||||
PREFIX template class SelfAdjointEigenSolver<MATRIXTYPE>
|
||||
|
||||
// removed because it does not support complex yet
|
||||
// PREFIX template class EigenSolver<MATRIXTYPE>
|
||||
|
||||
// declare all class for all types
|
||||
#define EIGEN_QR_MODULE_INSTANTIATE(PREFIX) \
|
||||
@ -76,4 +62,7 @@ namespace Eigen {
|
||||
|
||||
#include "src/Core/util/EnableMSVCWarnings.h"
|
||||
|
||||
// FIXME for compatibility we include EigenSolver here:
|
||||
#include "EigenSolver"
|
||||
|
||||
#endif // EIGEN_QR_MODULE_H
|
||||
|
@ -9,3 +9,4 @@ ADD_SUBDIRECTORY(LeastSquares)
|
||||
ADD_SUBDIRECTORY(Sparse)
|
||||
ADD_SUBDIRECTORY(Jacobi)
|
||||
ADD_SUBDIRECTORY(Householder)
|
||||
ADD_SUBDIRECTORY(EigenSolver)
|
||||
|
6
Eigen/src/EigenSolver/CMakeLists.txt
Normal file
6
Eigen/src/EigenSolver/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
||||
FILE(GLOB Eigen_EIGENSOLVER_SRCS "*.h")
|
||||
|
||||
INSTALL(FILES
|
||||
${Eigen_EIGENSOLVER_SRCS}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/EigenSolver COMPONENT Devel
|
||||
)
|
@ -79,6 +79,7 @@ template<typename _MatrixType> class ComplexEigenSolver
|
||||
template<typename MatrixType>
|
||||
void ComplexEigenSolver<MatrixType>::compute(const MatrixType& matrix)
|
||||
{
|
||||
// this code is inspired from Jampack
|
||||
assert(matrix.cols() == matrix.rows());
|
||||
int n = matrix.cols();
|
||||
m_eivalues.resize(n,1);
|
@ -120,6 +120,7 @@ std::complex<RealScalar> ei_sqrt(const std::complex<RealScalar> &z)
|
||||
template<typename MatrixType>
|
||||
void ComplexSchur<MatrixType>::compute(const MatrixType& matrix)
|
||||
{
|
||||
// this code is inspired from Jampack
|
||||
assert(matrix.cols() == matrix.rows());
|
||||
int n = matrix.cols();
|
||||
|
@ -25,7 +25,7 @@
|
||||
#ifndef EIGEN_EIGENSOLVER_H
|
||||
#define EIGEN_EIGENSOLVER_H
|
||||
|
||||
/** \ingroup QR_Module
|
||||
/** \ingroup EigenSolver_Module
|
||||
* \nonstableyet
|
||||
*
|
||||
* \class EigenSolver
|
||||
@ -53,7 +53,7 @@ template<typename _MatrixType> class EigenSolver
|
||||
typedef Matrix<RealScalar, MatrixType::ColsAtCompileTime, 1> RealVectorType;
|
||||
typedef Matrix<RealScalar, Dynamic, 1> RealVectorTypeX;
|
||||
|
||||
/**
|
||||
/**
|
||||
* \brief Default Constructor.
|
||||
*
|
||||
* The default constructor is useful in cases in which the user intends to
|
||||
@ -103,19 +103,19 @@ template<typename _MatrixType> class EigenSolver
|
||||
*
|
||||
* \sa pseudoEigenvalueMatrix()
|
||||
*/
|
||||
const MatrixType& pseudoEigenvectors() const
|
||||
{
|
||||
const MatrixType& pseudoEigenvectors() const
|
||||
{
|
||||
ei_assert(m_isInitialized && "EigenSolver is not initialized.");
|
||||
return m_eivec;
|
||||
return m_eivec;
|
||||
}
|
||||
|
||||
MatrixType pseudoEigenvalueMatrix() const;
|
||||
|
||||
/** \returns the eigenvalues as a column vector */
|
||||
EigenvalueType eigenvalues() const
|
||||
{
|
||||
EigenvalueType eigenvalues() const
|
||||
{
|
||||
ei_assert(m_isInitialized && "EigenSolver is not initialized.");
|
||||
return m_eivalues;
|
||||
return m_eivalues;
|
||||
}
|
||||
|
||||
EigenSolver& compute(const MatrixType& matrix);
|
||||
@ -265,7 +265,7 @@ void EigenSolver<MatrixType>::orthes(MatrixType& matH, RealVectorType& ort)
|
||||
ort.segment(m+1, high-m) = matH.col(m-1).segment(m+1, high-m);
|
||||
|
||||
int bSize = high-m+1;
|
||||
m_eivec.block(m, m, bSize, bSize).noalias() += ( (ort.segment(m, bSize) / (matH.coeff(m,m-1) * ort.coeff(m)))
|
||||
m_eivec.block(m, m, bSize, bSize).noalias() += ( (ort.segment(m, bSize) / (matH.coeff(m,m-1) * ort.coeff(m)))
|
||||
* (ort.segment(m, bSize).transpose() * m_eivec.block(m, m, bSize, bSize)) );
|
||||
}
|
||||
}
|
@ -25,7 +25,7 @@
|
||||
#ifndef EIGEN_HESSENBERGDECOMPOSITION_H
|
||||
#define EIGEN_HESSENBERGDECOMPOSITION_H
|
||||
|
||||
/** \ingroup QR_Module
|
||||
/** \ingroup EigenSolver_Module
|
||||
* \nonstableyet
|
||||
*
|
||||
* \class HessenbergDecomposition
|
||||
@ -156,7 +156,7 @@ void HessenbergDecomposition<MatrixType>::_compute(MatrixType& matA, CoeffVector
|
||||
|
||||
// Apply similarity transformation to remaining columns,
|
||||
// i.e., compute A = H A H'
|
||||
|
||||
|
||||
// A = H A
|
||||
matA.corner(BottomRight, remainingSize, remainingSize)
|
||||
.applyHouseholderOnTheLeft(matA.col(i).end(remainingSize-1), h, &temp.coeffRef(0));
|
@ -25,7 +25,7 @@
|
||||
#ifndef EIGEN_SELFADJOINTEIGENSOLVER_H
|
||||
#define EIGEN_SELFADJOINTEIGENSOLVER_H
|
||||
|
||||
/** \qr_module \ingroup QR_Module
|
||||
/** \eigensolver_module \ingroup EigenSolver_Module
|
||||
* \nonstableyet
|
||||
*
|
||||
* \class SelfAdjointEigenSolver
|
||||
@ -137,7 +137,7 @@ template<typename _MatrixType> class SelfAdjointEigenSolver
|
||||
|
||||
/** \internal
|
||||
*
|
||||
* \qr_module
|
||||
* \eigensolver_module
|
||||
*
|
||||
* Performs a QR step on a tridiagonal symmetric matrix represented as a
|
||||
* pair of two vectors \a diag and \a subdiag.
|
||||
@ -266,7 +266,7 @@ compute(const MatrixType& matA, const MatrixType& matB, bool computeEigenvectors
|
||||
|
||||
#endif // EIGEN_HIDE_HEAVY_CODE
|
||||
|
||||
/** \qr_module
|
||||
/** \eigensolver_module
|
||||
*
|
||||
* \returns a vector listing the eigenvalues of this matrix.
|
||||
*/
|
||||
@ -307,7 +307,7 @@ template<typename Derived> struct ei_operatorNorm_selector<Derived, false>
|
||||
}
|
||||
};
|
||||
|
||||
/** \qr_module
|
||||
/** \eigensolver_module
|
||||
*
|
||||
* \returns the matrix norm of this matrix.
|
||||
*/
|
@ -25,7 +25,7 @@
|
||||
#ifndef EIGEN_TRIDIAGONALIZATION_H
|
||||
#define EIGEN_TRIDIAGONALIZATION_H
|
||||
|
||||
/** \ingroup QR_Module
|
||||
/** \ingroup EigenSolver_Module
|
||||
* \nonstableyet
|
||||
*
|
||||
* \class Tridiagonalization
|
@ -33,11 +33,6 @@
|
||||
namespace Eigen
|
||||
{
|
||||
|
||||
template static void ei_tridiagonal_qr_step(float* , float* , int, int, float* , int);
|
||||
template static void ei_tridiagonal_qr_step(double* , double* , int, int, double* , int);
|
||||
template static void ei_tridiagonal_qr_step(float* , float* , int, int, std::complex<float>* , int);
|
||||
template static void ei_tridiagonal_qr_step(double* , double* , int, int, std::complex<double>* , int);
|
||||
|
||||
EIGEN_QR_MODULE_INSTANTIATE();
|
||||
|
||||
}
|
||||
|
@ -212,6 +212,7 @@ ALIASES = "only_for_vectors=This is only for vectors (either row-
|
||||
"svd_module=This is defined in the %SVD module. \code #include <Eigen/SVD> \endcode" \
|
||||
"geometry_module=This is defined in the %Geometry module. \code #include <Eigen/Geometry> \endcode" \
|
||||
"leastsquares_module=This is defined in the %LeastSquares module. \code #include <Eigen/LeastSquares> \endcode" \
|
||||
"eigensolver_module=This is defined in the %EigenSolver module. \code #include <Eigen/EigenSolver> \endcode" \
|
||||
"label=\bug" \
|
||||
"redstar=<a href='#warningarraymodule' style='color:red;text-decoration: none;'>*</a>" \
|
||||
"nonstableyet=\warning This is not considered to be part of the stable public API yet. Changes may happen in future releases. See \ref Experimental \"Experimental parts of Eigen\""
|
||||
|
@ -23,7 +23,7 @@
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "main.h"
|
||||
#include <Eigen/QR>
|
||||
#include <Eigen/EigenSolver>
|
||||
#include <Eigen/LU>
|
||||
|
||||
template<typename MatrixType> void eigensolver(const MatrixType& m)
|
||||
|
@ -23,7 +23,7 @@
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "main.h"
|
||||
#include <Eigen/QR>
|
||||
#include <Eigen/EigenSolver>
|
||||
|
||||
#ifdef HAS_GSL
|
||||
#include "gsl_helper.h"
|
||||
|
@ -23,7 +23,7 @@
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "main.h"
|
||||
#include <Eigen/QR>
|
||||
#include <Eigen/EigenSolver>
|
||||
|
||||
#ifdef HAS_GSL
|
||||
#include "gsl_helper.h"
|
||||
|
@ -71,8 +71,6 @@ template<typename MatrixType> void product_notemporary(const MatrixType& m)
|
||||
VERIFY_EVALUATION_COUNT( m3 = (m1 * m2.adjoint()), 1);
|
||||
VERIFY_EVALUATION_COUNT( m3.noalias() = m1 * m2.adjoint(), 0);
|
||||
|
||||
// NOTE in this case the slow product is used:
|
||||
// FIXME:
|
||||
VERIFY_EVALUATION_COUNT( m3.noalias() = s1 * (m1 * m2.transpose()), 0);
|
||||
|
||||
VERIFY_EVALUATION_COUNT( m3.noalias() = s1 * m1 * s2 * m2.adjoint(), 0);
|
||||
|
Loading…
Reference in New Issue
Block a user