mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-09-11 00:43:13 +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)
|
if(EIGEN_BUILD_LIB)
|
||||||
set(Eigen_SRCS
|
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 "src/Core/util/DisableMSVCWarnings.h"
|
||||||
|
|
||||||
#include "QR"
|
#include "EigenSolver"
|
||||||
#include "Geometry"
|
#include "Geometry"
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
19
Eigen/QR
19
Eigen/QR
@ -24,11 +24,9 @@ namespace Eigen {
|
|||||||
*
|
*
|
||||||
* \nonstableyet
|
* \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:
|
* This module also provides some MatrixBase methods, including:
|
||||||
* - MatrixBase::qr(),
|
* - MatrixBase::qr(),
|
||||||
* - MatrixBase::eigenvalues(),
|
|
||||||
* - MatrixBase::operatorNorm()
|
|
||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
* #include <Eigen/QR>
|
* #include <Eigen/QR>
|
||||||
@ -38,22 +36,10 @@ namespace Eigen {
|
|||||||
#include "src/QR/HouseholderQR.h"
|
#include "src/QR/HouseholderQR.h"
|
||||||
#include "src/QR/FullPivotingHouseholderQR.h"
|
#include "src/QR/FullPivotingHouseholderQR.h"
|
||||||
#include "src/QR/ColPivotingHouseholderQR.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
|
// declare all classes for a given matrix type
|
||||||
#define EIGEN_QR_MODULE_INSTANTIATE_TYPE(MATRIXTYPE,PREFIX) \
|
#define EIGEN_QR_MODULE_INSTANTIATE_TYPE(MATRIXTYPE,PREFIX) \
|
||||||
PREFIX template class HouseholderQR<MATRIXTYPE>; \
|
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
|
// declare all class for all types
|
||||||
#define EIGEN_QR_MODULE_INSTANTIATE(PREFIX) \
|
#define EIGEN_QR_MODULE_INSTANTIATE(PREFIX) \
|
||||||
@ -76,4 +62,7 @@ namespace Eigen {
|
|||||||
|
|
||||||
#include "src/Core/util/EnableMSVCWarnings.h"
|
#include "src/Core/util/EnableMSVCWarnings.h"
|
||||||
|
|
||||||
|
// FIXME for compatibility we include EigenSolver here:
|
||||||
|
#include "EigenSolver"
|
||||||
|
|
||||||
#endif // EIGEN_QR_MODULE_H
|
#endif // EIGEN_QR_MODULE_H
|
||||||
|
@ -9,3 +9,4 @@ ADD_SUBDIRECTORY(LeastSquares)
|
|||||||
ADD_SUBDIRECTORY(Sparse)
|
ADD_SUBDIRECTORY(Sparse)
|
||||||
ADD_SUBDIRECTORY(Jacobi)
|
ADD_SUBDIRECTORY(Jacobi)
|
||||||
ADD_SUBDIRECTORY(Householder)
|
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>
|
template<typename MatrixType>
|
||||||
void ComplexEigenSolver<MatrixType>::compute(const MatrixType& matrix)
|
void ComplexEigenSolver<MatrixType>::compute(const MatrixType& matrix)
|
||||||
{
|
{
|
||||||
|
// this code is inspired from Jampack
|
||||||
assert(matrix.cols() == matrix.rows());
|
assert(matrix.cols() == matrix.rows());
|
||||||
int n = matrix.cols();
|
int n = matrix.cols();
|
||||||
m_eivalues.resize(n,1);
|
m_eivalues.resize(n,1);
|
@ -120,6 +120,7 @@ std::complex<RealScalar> ei_sqrt(const std::complex<RealScalar> &z)
|
|||||||
template<typename MatrixType>
|
template<typename MatrixType>
|
||||||
void ComplexSchur<MatrixType>::compute(const MatrixType& matrix)
|
void ComplexSchur<MatrixType>::compute(const MatrixType& matrix)
|
||||||
{
|
{
|
||||||
|
// this code is inspired from Jampack
|
||||||
assert(matrix.cols() == matrix.rows());
|
assert(matrix.cols() == matrix.rows());
|
||||||
int n = matrix.cols();
|
int n = matrix.cols();
|
||||||
|
|
@ -25,7 +25,7 @@
|
|||||||
#ifndef EIGEN_EIGENSOLVER_H
|
#ifndef EIGEN_EIGENSOLVER_H
|
||||||
#define EIGEN_EIGENSOLVER_H
|
#define EIGEN_EIGENSOLVER_H
|
||||||
|
|
||||||
/** \ingroup QR_Module
|
/** \ingroup EigenSolver_Module
|
||||||
* \nonstableyet
|
* \nonstableyet
|
||||||
*
|
*
|
||||||
* \class EigenSolver
|
* \class EigenSolver
|
@ -25,7 +25,7 @@
|
|||||||
#ifndef EIGEN_HESSENBERGDECOMPOSITION_H
|
#ifndef EIGEN_HESSENBERGDECOMPOSITION_H
|
||||||
#define EIGEN_HESSENBERGDECOMPOSITION_H
|
#define EIGEN_HESSENBERGDECOMPOSITION_H
|
||||||
|
|
||||||
/** \ingroup QR_Module
|
/** \ingroup EigenSolver_Module
|
||||||
* \nonstableyet
|
* \nonstableyet
|
||||||
*
|
*
|
||||||
* \class HessenbergDecomposition
|
* \class HessenbergDecomposition
|
@ -25,7 +25,7 @@
|
|||||||
#ifndef EIGEN_SELFADJOINTEIGENSOLVER_H
|
#ifndef EIGEN_SELFADJOINTEIGENSOLVER_H
|
||||||
#define EIGEN_SELFADJOINTEIGENSOLVER_H
|
#define EIGEN_SELFADJOINTEIGENSOLVER_H
|
||||||
|
|
||||||
/** \qr_module \ingroup QR_Module
|
/** \eigensolver_module \ingroup EigenSolver_Module
|
||||||
* \nonstableyet
|
* \nonstableyet
|
||||||
*
|
*
|
||||||
* \class SelfAdjointEigenSolver
|
* \class SelfAdjointEigenSolver
|
||||||
@ -137,7 +137,7 @@ template<typename _MatrixType> class SelfAdjointEigenSolver
|
|||||||
|
|
||||||
/** \internal
|
/** \internal
|
||||||
*
|
*
|
||||||
* \qr_module
|
* \eigensolver_module
|
||||||
*
|
*
|
||||||
* Performs a QR step on a tridiagonal symmetric matrix represented as a
|
* Performs a QR step on a tridiagonal symmetric matrix represented as a
|
||||||
* pair of two vectors \a diag and \a subdiag.
|
* 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
|
#endif // EIGEN_HIDE_HEAVY_CODE
|
||||||
|
|
||||||
/** \qr_module
|
/** \eigensolver_module
|
||||||
*
|
*
|
||||||
* \returns a vector listing the eigenvalues of this matrix.
|
* \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.
|
* \returns the matrix norm of this matrix.
|
||||||
*/
|
*/
|
@ -25,7 +25,7 @@
|
|||||||
#ifndef EIGEN_TRIDIAGONALIZATION_H
|
#ifndef EIGEN_TRIDIAGONALIZATION_H
|
||||||
#define EIGEN_TRIDIAGONALIZATION_H
|
#define EIGEN_TRIDIAGONALIZATION_H
|
||||||
|
|
||||||
/** \ingroup QR_Module
|
/** \ingroup EigenSolver_Module
|
||||||
* \nonstableyet
|
* \nonstableyet
|
||||||
*
|
*
|
||||||
* \class Tridiagonalization
|
* \class Tridiagonalization
|
@ -33,11 +33,6 @@
|
|||||||
namespace Eigen
|
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();
|
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" \
|
"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" \
|
"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" \
|
"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" \
|
"label=\bug" \
|
||||||
"redstar=<a href='#warningarraymodule' style='color:red;text-decoration: none;'>*</a>" \
|
"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\""
|
"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/>.
|
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include <Eigen/QR>
|
#include <Eigen/EigenSolver>
|
||||||
#include <Eigen/LU>
|
#include <Eigen/LU>
|
||||||
|
|
||||||
template<typename MatrixType> void eigensolver(const MatrixType& m)
|
template<typename MatrixType> void eigensolver(const MatrixType& m)
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include <Eigen/QR>
|
#include <Eigen/EigenSolver>
|
||||||
|
|
||||||
#ifdef HAS_GSL
|
#ifdef HAS_GSL
|
||||||
#include "gsl_helper.h"
|
#include "gsl_helper.h"
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include <Eigen/QR>
|
#include <Eigen/EigenSolver>
|
||||||
|
|
||||||
#ifdef HAS_GSL
|
#ifdef HAS_GSL
|
||||||
#include "gsl_helper.h"
|
#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 = (m1 * m2.adjoint()), 1);
|
||||||
VERIFY_EVALUATION_COUNT( m3.noalias() = m1 * m2.adjoint(), 0);
|
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 * m2.transpose()), 0);
|
||||||
|
|
||||||
VERIFY_EVALUATION_COUNT( m3.noalias() = s1 * m1 * s2 * m2.adjoint(), 0);
|
VERIFY_EVALUATION_COUNT( m3.noalias() = s1 * m1 * s2 * m2.adjoint(), 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user