mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Add QR and Cholesky module instantiations in the lib.
To try it with the unit tests set the cmake variable TEST_LIB to ON.
This commit is contained in:
parent
53289a8b64
commit
f07f907810
@ -4,12 +4,16 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
|
|||||||
|
|
||||||
OPTION(BUILD_TESTS "Build tests" OFF)
|
OPTION(BUILD_TESTS "Build tests" OFF)
|
||||||
OPTION(BUILD_DOC "Build documentation and examples" OFF)
|
OPTION(BUILD_DOC "Build documentation and examples" OFF)
|
||||||
|
OPTION(TEST_LIB "Build the unit tests using the library (disable -pedantic)" OFF)
|
||||||
|
|
||||||
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
|
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
IF(CMAKE_SYSTEM_NAME MATCHES Linux)
|
IF(CMAKE_SYSTEM_NAME MATCHES Linux)
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -fno-exceptions -fno-check-new -fno-common -fstrict-aliasing")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -fno-exceptions -fno-check-new -fno-common -fstrict-aliasing")
|
||||||
|
IF(NOT TEST_LIB)
|
||||||
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
|
||||||
|
ENDIF(NOT TEST_LIB)
|
||||||
IF(TEST_OPENMP)
|
IF(TEST_OPENMP)
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
|
||||||
MESSAGE("Enabling OpenMP in tests/examples")
|
MESSAGE("Enabling OpenMP in tests/examples")
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
SET(Eigen_HEADERS Core CoreDeclarations LU Cholesky QR)
|
SET(Eigen_HEADERS Core CoreDeclarations LU Cholesky QR)
|
||||||
|
|
||||||
SET(Eigen_SRCS
|
SET(Eigen_SRCS
|
||||||
src/Core/CoreInstanciations.cpp
|
src/Core/CoreInstantiations.cpp
|
||||||
src/QR/QrInstanciations.cpp
|
src/Cholesky/CholeskyInstantiations.cpp
|
||||||
|
src/QR/QrInstantiations.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_LIBRARY(Eigen2 ${Eigen_SRCS})
|
ADD_LIBRARY(Eigen2 SHARED ${Eigen_SRCS})
|
||||||
|
|
||||||
|
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g1 -O2")
|
||||||
|
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g1 -O2")
|
||||||
|
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
|
||||||
SET(INCLUDE_INSTALL_DIR
|
SET(INCLUDE_INSTALL_DIR
|
||||||
"${CMAKE_INSTALL_PREFIX}/include/eigen2"
|
"${CMAKE_INSTALL_PREFIX}/include/eigen2"
|
||||||
|
@ -3,6 +3,15 @@
|
|||||||
|
|
||||||
#include "Core"
|
#include "Core"
|
||||||
|
|
||||||
|
// 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 {
|
namespace Eigen {
|
||||||
|
|
||||||
#include "src/Cholesky/Cholesky.h"
|
#include "src/Cholesky/Cholesky.h"
|
||||||
@ -10,4 +19,27 @@ namespace Eigen {
|
|||||||
|
|
||||||
} // namespace Eigen
|
} // namespace Eigen
|
||||||
|
|
||||||
|
#define EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(MATRIXTYPE,PREFIX) \
|
||||||
|
PREFIX template class Cholesky<MATRIXTYPE>; \
|
||||||
|
PREFIX template class CholeskyWithoutSquareRoot<MATRIXTYPE>
|
||||||
|
|
||||||
|
#define EIGEN_CHOLESKY_MODULE_INSTANTIATE(PREFIX) \
|
||||||
|
EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(Matrix2f,PREFIX); \
|
||||||
|
EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(Matrix2d,PREFIX); \
|
||||||
|
EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(Matrix3f,PREFIX); \
|
||||||
|
EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(Matrix3d,PREFIX); \
|
||||||
|
EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(Matrix4f,PREFIX); \
|
||||||
|
EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(Matrix4d,PREFIX); \
|
||||||
|
EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(MatrixXf,PREFIX); \
|
||||||
|
EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(MatrixXd,PREFIX); \
|
||||||
|
EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(MatrixXcf,PREFIX); \
|
||||||
|
EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(MatrixXcd,PREFIX)
|
||||||
|
|
||||||
|
#ifdef EIGEN_EXTERN_INSTANTIATIONS
|
||||||
|
|
||||||
|
namespace Eigen {
|
||||||
|
EIGEN_CHOLESKY_MODULE_INSTANTIATE(extern);
|
||||||
|
} // namespace Eigen
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // EIGEN_CHOLESKY_MODULE_H
|
#endif // EIGEN_CHOLESKY_MODULE_H
|
||||||
|
@ -57,7 +57,7 @@ namespace Eigen {
|
|||||||
#include "src/Core/Extract.h"
|
#include "src/Core/Extract.h"
|
||||||
#include "src/Core/Part.h"
|
#include "src/Core/Part.h"
|
||||||
|
|
||||||
#ifndef EIGEN_EXTERN_INSTANCIATIONS
|
#ifndef EIGEN_EXTERN_INSTANTIATIONS
|
||||||
#include "src/Core/CacheFriendlyProduct.h"
|
#include "src/Core/CacheFriendlyProduct.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
36
Eigen/QR
36
Eigen/QR
@ -3,6 +3,15 @@
|
|||||||
|
|
||||||
#include "Core"
|
#include "Core"
|
||||||
|
|
||||||
|
// 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 {
|
namespace Eigen {
|
||||||
|
|
||||||
#include "src/QR/QR.h"
|
#include "src/QR/QR.h"
|
||||||
@ -11,6 +20,33 @@ namespace Eigen {
|
|||||||
#include "src/QR/SelfAdjointEigenSolver.h"
|
#include "src/QR/SelfAdjointEigenSolver.h"
|
||||||
#include "src/QR/HessenbergDecomposition.h"
|
#include "src/QR/HessenbergDecomposition.h"
|
||||||
|
|
||||||
|
// declare all classes for a given matrix type
|
||||||
|
#define EIGEN_QR_MODULE_INSTANTIATE_TYPE(MATRIXTYPE,PREFIX) \
|
||||||
|
PREFIX template class QR<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) \
|
||||||
|
EIGEN_QR_MODULE_INSTANTIATE_TYPE(Matrix2f,PREFIX); \
|
||||||
|
EIGEN_QR_MODULE_INSTANTIATE_TYPE(Matrix2d,PREFIX); \
|
||||||
|
EIGEN_QR_MODULE_INSTANTIATE_TYPE(Matrix3f,PREFIX); \
|
||||||
|
EIGEN_QR_MODULE_INSTANTIATE_TYPE(Matrix3d,PREFIX); \
|
||||||
|
EIGEN_QR_MODULE_INSTANTIATE_TYPE(Matrix4f,PREFIX); \
|
||||||
|
EIGEN_QR_MODULE_INSTANTIATE_TYPE(Matrix4d,PREFIX); \
|
||||||
|
EIGEN_QR_MODULE_INSTANTIATE_TYPE(MatrixXf,PREFIX); \
|
||||||
|
EIGEN_QR_MODULE_INSTANTIATE_TYPE(MatrixXd,PREFIX); \
|
||||||
|
EIGEN_QR_MODULE_INSTANTIATE_TYPE(MatrixXcf,PREFIX); \
|
||||||
|
EIGEN_QR_MODULE_INSTANTIATE_TYPE(MatrixXcd,PREFIX)
|
||||||
|
|
||||||
|
#ifdef EIGEN_EXTERN_INSTANTIATIONS
|
||||||
|
EIGEN_QR_MODULE_INSTANTIATE(extern);
|
||||||
|
#endif // EIGEN_EXTERN_INSTANTIATIONS
|
||||||
|
|
||||||
} // namespace Eigen
|
} // namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_QR_MODULE_H
|
#endif // EIGEN_QR_MODULE_H
|
||||||
|
35
Eigen/src/Cholesky/CholeskyInstantiations.cpp
Normal file
35
Eigen/src/Cholesky/CholeskyInstantiations.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// This file is part of Eigen, a lightweight C++ template library
|
||||||
|
// for linear algebra. Eigen itself is part of the KDE project.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
|
||||||
|
//
|
||||||
|
// Eigen is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 3 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Alternatively, you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 2 of
|
||||||
|
// the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License and a copy of the GNU General Public License along with
|
||||||
|
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef EIGEN_EXTERN_INSTANTIATIONS
|
||||||
|
#define EIGEN_EXTERN_INSTANTIATIONS
|
||||||
|
#endif
|
||||||
|
#include "../../Core"
|
||||||
|
#undef EIGEN_EXTERN_INSTANTIATIONS
|
||||||
|
|
||||||
|
#include "../../Cholesky"
|
||||||
|
|
||||||
|
namespace Eigen {
|
||||||
|
EIGEN_CHOLESKY_MODULE_INSTANTIATE();
|
||||||
|
}
|
@ -72,7 +72,8 @@ template<typename MatrixType> class CholeskyWithoutSquareRoot
|
|||||||
/** \returns whether the matrix is positive definite */
|
/** \returns whether the matrix is positive definite */
|
||||||
bool isPositiveDefinite(void) const
|
bool isPositiveDefinite(void) const
|
||||||
{
|
{
|
||||||
return m_matrix.diagonal().minCoeff() > Scalar(0);
|
// FIXME is it really correct ?
|
||||||
|
return m_matrix.diagonal().real().minCoeff() > RealScalar(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
// License and a copy of the GNU General Public License along with
|
// License and a copy of the GNU General Public License along with
|
||||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#ifdef EIGEN_EXTERN_INSTANCIATIONS
|
#ifdef EIGEN_EXTERN_INSTANTIATIONS
|
||||||
#undef EIGEN_EXTERN_INSTANCIATIONS
|
#undef EIGEN_EXTERN_INSTANTIATIONS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../../Core"
|
#include "../../Core"
|
||||||
@ -31,17 +31,17 @@
|
|||||||
namespace Eigen
|
namespace Eigen
|
||||||
{
|
{
|
||||||
|
|
||||||
#define EIGEN_INSTANCIATE_PRODUCT(TYPE) \
|
#define EIGEN_INSTANTIATE_PRODUCT(TYPE) \
|
||||||
template static void ei_cache_friendly_product<TYPE>( \
|
template static void ei_cache_friendly_product<TYPE>( \
|
||||||
int _rows, int _cols, int depth, \
|
int _rows, int _cols, int depth, \
|
||||||
bool _lhsRowMajor, const TYPE* _lhs, int _lhsStride, \
|
bool _lhsRowMajor, const TYPE* _lhs, int _lhsStride, \
|
||||||
bool _rhsRowMajor, const TYPE* _rhs, int _rhsStride, \
|
bool _rhsRowMajor, const TYPE* _rhs, int _rhsStride, \
|
||||||
bool resRowMajor, TYPE* res, int resStride)
|
bool resRowMajor, TYPE* res, int resStride)
|
||||||
|
|
||||||
EIGEN_INSTANCIATE_PRODUCT(float);
|
EIGEN_INSTANTIATE_PRODUCT(float);
|
||||||
EIGEN_INSTANCIATE_PRODUCT(double);
|
EIGEN_INSTANTIATE_PRODUCT(double);
|
||||||
EIGEN_INSTANCIATE_PRODUCT(int);
|
EIGEN_INSTANTIATE_PRODUCT(int);
|
||||||
EIGEN_INSTANCIATE_PRODUCT(std::complex<float>);
|
EIGEN_INSTANTIATE_PRODUCT(std::complex<float>);
|
||||||
EIGEN_INSTANCIATE_PRODUCT(std::complex<double>);
|
EIGEN_INSTANTIATE_PRODUCT(std::complex<double>);
|
||||||
|
|
||||||
}
|
}
|
@ -87,7 +87,7 @@ template<typename Scalar> struct ei_scalar_max_op;
|
|||||||
template<typename Scalar> struct ei_scalar_random_op;
|
template<typename Scalar> struct ei_scalar_random_op;
|
||||||
|
|
||||||
template<typename Scalar>
|
template<typename Scalar>
|
||||||
static void ei_cache_friendly_product(
|
void ei_cache_friendly_product(
|
||||||
int _rows, int _cols, int depth,
|
int _rows, int _cols, int depth,
|
||||||
bool _lhsRowMajor, const Scalar* _lhs, int _lhsStride,
|
bool _lhsRowMajor, const Scalar* _lhs, int _lhsStride,
|
||||||
bool _rhsRowMajor, const Scalar* _rhs, int _rhsStride,
|
bool _rhsRowMajor, const Scalar* _rhs, int _rhsStride,
|
||||||
|
@ -60,11 +60,11 @@ template<typename _MatrixType> class HessenbergDecomposition
|
|||||||
NestByValue<Block<
|
NestByValue<Block<
|
||||||
MatrixType,SizeMinusOne,SizeMinusOne> > > >::RealReturnType SubDiagonalReturnType;
|
MatrixType,SizeMinusOne,SizeMinusOne> > > >::RealReturnType SubDiagonalReturnType;
|
||||||
|
|
||||||
HessenbergDecomposition()
|
/** This constructor initializes a HessenbergDecomposition object for
|
||||||
{}
|
* further use with HessenbergDecomposition::compute()
|
||||||
|
*/
|
||||||
HessenbergDecomposition(int rows, int cols)
|
HessenbergDecomposition(int size = Size==Dynamic ? 2 : Size)
|
||||||
: m_matrix(rows,cols), m_hCoeffs(rows-1)
|
: m_matrix(size,size), m_hCoeffs(size-1)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
HessenbergDecomposition(const MatrixType& matrix)
|
HessenbergDecomposition(const MatrixType& matrix)
|
||||||
@ -121,6 +121,7 @@ template<typename _MatrixType> class HessenbergDecomposition
|
|||||||
CoeffVectorType m_hCoeffs;
|
CoeffVectorType m_hCoeffs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef EIGEN_HIDE_HEAVY_CODE
|
||||||
|
|
||||||
/** \internal
|
/** \internal
|
||||||
* Performs a tridiagonal decomposition of \a matA in place.
|
* Performs a tridiagonal decomposition of \a matA in place.
|
||||||
@ -223,6 +224,8 @@ HessenbergDecomposition<MatrixType>::matrixQ(void) const
|
|||||||
return matQ;
|
return matQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // EIGEN_HIDE_HEAVY_CODE
|
||||||
|
|
||||||
/** constructs and returns the matrix H.
|
/** constructs and returns the matrix H.
|
||||||
* Note that the matrix H is equivalent to the upper part of the packed matrix
|
* Note that the matrix H is equivalent to the upper part of the packed matrix
|
||||||
* (including the lower sub-diagonal). Therefore, it might be often sufficient
|
* (including the lower sub-diagonal). Therefore, it might be often sufficient
|
||||||
@ -233,7 +236,7 @@ typename HessenbergDecomposition<MatrixType>::MatrixType
|
|||||||
HessenbergDecomposition<MatrixType>::matrixH(void) const
|
HessenbergDecomposition<MatrixType>::matrixH(void) const
|
||||||
{
|
{
|
||||||
// FIXME should this function (and other similar) rather take a matrix as argument
|
// FIXME should this function (and other similar) rather take a matrix as argument
|
||||||
// and fill it (avoids temporaries)
|
// and fill it (to avoid temporaries)
|
||||||
int n = m_matrix.rows();
|
int n = m_matrix.rows();
|
||||||
MatrixType matH = m_matrix;
|
MatrixType matH = m_matrix;
|
||||||
matH.corner(BottomLeft,n-2, n-2).template part<Lower>().setZero();
|
matH.corner(BottomLeft,n-2, n-2).template part<Lower>().setZero();
|
||||||
|
@ -75,6 +75,8 @@ template<typename MatrixType> class QR
|
|||||||
VectorType m_hCoeffs;
|
VectorType m_hCoeffs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef EIGEN_HIDE_HEAVY_CODE
|
||||||
|
|
||||||
template<typename MatrixType>
|
template<typename MatrixType>
|
||||||
void QR<MatrixType>::_compute(const MatrixType& matrix)
|
void QR<MatrixType>::_compute(const MatrixType& matrix)
|
||||||
{
|
{
|
||||||
@ -157,6 +159,8 @@ MatrixType QR<MatrixType>::matrixQ(void) const
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // EIGEN_HIDE_HEAVY_CODE
|
||||||
|
|
||||||
/** \return the QR decomposition of \c *this.
|
/** \return the QR decomposition of \c *this.
|
||||||
*
|
*
|
||||||
* \sa class QR
|
* \sa class QR
|
||||||
|
@ -22,9 +22,11 @@
|
|||||||
// License and a copy of the GNU General Public License along with
|
// License and a copy of the GNU General Public License along with
|
||||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#ifdef EIGEN_EXTERN_INSTANCIATIONS
|
#ifndef EIGEN_EXTERN_INSTANTIATIONS
|
||||||
#undef EIGEN_EXTERN_INSTANCIATIONS
|
#define EIGEN_EXTERN_INSTANTIATIONS
|
||||||
#endif
|
#endif
|
||||||
|
#include "../../Core"
|
||||||
|
#undef EIGEN_EXTERN_INSTANTIATIONS
|
||||||
|
|
||||||
#include "../../QR"
|
#include "../../QR"
|
||||||
|
|
||||||
@ -36,4 +38,6 @@ template static void ei_tridiagonal_qr_step(double* , double* , int, int, double
|
|||||||
template static void ei_tridiagonal_qr_step(float* , float* , int, int, std::complex<float>* , 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);
|
template static void ei_tridiagonal_qr_step(double* , double* , int, int, std::complex<double>* , int);
|
||||||
|
|
||||||
|
EIGEN_QR_MODULE_INSTANTIATE();
|
||||||
|
|
||||||
}
|
}
|
@ -223,7 +223,7 @@ MatrixBase<Derived>::matrixNorm() const
|
|||||||
::matrixNorm(derived());
|
::matrixNorm(derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef EIGEN_EXTERN_INSTANCIATIONS
|
#ifndef EIGEN_EXTERN_INSTANTIATIONS
|
||||||
template<typename RealScalar, typename Scalar>
|
template<typename RealScalar, typename Scalar>
|
||||||
static void ei_tridiagonal_qr_step(RealScalar* diag, RealScalar* subdiag, int start, int end, Scalar* matrixQ, int n)
|
static void ei_tridiagonal_qr_step(RealScalar* diag, RealScalar* subdiag, int start, int end, Scalar* matrixQ, int n)
|
||||||
{
|
{
|
||||||
|
@ -60,11 +60,11 @@ template<typename _MatrixType> class Tridiagonalization
|
|||||||
NestByValue<Block<
|
NestByValue<Block<
|
||||||
MatrixType,SizeMinusOne,SizeMinusOne> > > >::RealReturnType SubDiagonalReturnType;
|
MatrixType,SizeMinusOne,SizeMinusOne> > > >::RealReturnType SubDiagonalReturnType;
|
||||||
|
|
||||||
Tridiagonalization()
|
/** This constructor initializes a Tridiagonalization object for
|
||||||
{}
|
* further use with Tridiagonalization::compute()
|
||||||
|
*/
|
||||||
Tridiagonalization(int rows, int cols)
|
Tridiagonalization(int size = Size==Dynamic ? 2 : Size)
|
||||||
: m_matrix(rows,cols), m_hCoeffs(rows-1)
|
: m_matrix(size,size), m_hCoeffs(size-1)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Tridiagonalization(const MatrixType& matrix)
|
Tridiagonalization(const MatrixType& matrix)
|
||||||
@ -90,7 +90,7 @@ template<typename _MatrixType> class Tridiagonalization
|
|||||||
*
|
*
|
||||||
* \sa packedMatrix()
|
* \sa packedMatrix()
|
||||||
*/
|
*/
|
||||||
CoeffVectorType householderCoefficients(void) const { return m_hCoeffs; }
|
inline CoeffVectorType householderCoefficients(void) const { return m_hCoeffs; }
|
||||||
|
|
||||||
/** \returns the internal result of the decomposition.
|
/** \returns the internal result of the decomposition.
|
||||||
*
|
*
|
||||||
@ -108,7 +108,7 @@ template<typename _MatrixType> class Tridiagonalization
|
|||||||
*
|
*
|
||||||
* See LAPACK for further details on this packed storage.
|
* See LAPACK for further details on this packed storage.
|
||||||
*/
|
*/
|
||||||
const MatrixType& packedMatrix(void) const { return m_matrix; }
|
inline const MatrixType& packedMatrix(void) const { return m_matrix; }
|
||||||
|
|
||||||
MatrixType matrixQ(void) const;
|
MatrixType matrixQ(void) const;
|
||||||
MatrixType matrixT(void) const;
|
MatrixType matrixT(void) const;
|
||||||
@ -128,6 +128,44 @@ template<typename _MatrixType> class Tridiagonalization
|
|||||||
CoeffVectorType m_hCoeffs;
|
CoeffVectorType m_hCoeffs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** \returns an expression of the diagonal vector */
|
||||||
|
template<typename MatrixType>
|
||||||
|
const typename Tridiagonalization<MatrixType>::DiagonalReturnType
|
||||||
|
Tridiagonalization<MatrixType>::diagonal(void) const
|
||||||
|
{
|
||||||
|
return m_matrix.diagonal().nestByValue().real();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \returns an expression of the sub-diagonal vector */
|
||||||
|
template<typename MatrixType>
|
||||||
|
const typename Tridiagonalization<MatrixType>::SubDiagonalReturnType
|
||||||
|
Tridiagonalization<MatrixType>::subDiagonal(void) const
|
||||||
|
{
|
||||||
|
int n = m_matrix.rows();
|
||||||
|
return Block<MatrixType,SizeMinusOne,SizeMinusOne>(m_matrix, 1, 0, n-1,n-1)
|
||||||
|
.nestByValue().diagonal().nestByValue().real();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** constructs and returns the tridiagonal matrix T.
|
||||||
|
* Note that the matrix T is equivalent to the diagonal and sub-diagonal of the packed matrix.
|
||||||
|
* Therefore, it might be often sufficient to directly use the packed matrix, or the vector
|
||||||
|
* expressions returned by diagonal() and subDiagonal() instead of creating a new matrix.
|
||||||
|
*/
|
||||||
|
template<typename MatrixType>
|
||||||
|
typename Tridiagonalization<MatrixType>::MatrixType
|
||||||
|
Tridiagonalization<MatrixType>::matrixT(void) const
|
||||||
|
{
|
||||||
|
// FIXME should this function (and other similar) rather take a matrix as argument
|
||||||
|
// and fill it (avoids temporaries)
|
||||||
|
int n = m_matrix.rows();
|
||||||
|
MatrixType matT = m_matrix;
|
||||||
|
matT.corner(TopRight,n-1, n-1).diagonal() = subDiagonal().conjugate();
|
||||||
|
matT.corner(TopRight,n-2, n-2).template part<Upper>().setZero();
|
||||||
|
matT.corner(BottomLeft,n-2, n-2).template part<Lower>().setZero();
|
||||||
|
return matT;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef EIGEN_HIDE_HEAVY_CODE
|
||||||
|
|
||||||
/** \internal
|
/** \internal
|
||||||
* Performs a tridiagonal decomposition of \a matA in place.
|
* Performs a tridiagonal decomposition of \a matA in place.
|
||||||
@ -235,43 +273,6 @@ Tridiagonalization<MatrixType>::matrixQ(void) const
|
|||||||
return matQ;
|
return matQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns an expression of the diagonal vector */
|
|
||||||
template<typename MatrixType>
|
|
||||||
const typename Tridiagonalization<MatrixType>::DiagonalReturnType
|
|
||||||
Tridiagonalization<MatrixType>::diagonal(void) const
|
|
||||||
{
|
|
||||||
return m_matrix.diagonal().nestByValue().real();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \returns an expression of the sub-diagonal vector */
|
|
||||||
template<typename MatrixType>
|
|
||||||
const typename Tridiagonalization<MatrixType>::SubDiagonalReturnType
|
|
||||||
Tridiagonalization<MatrixType>::subDiagonal(void) const
|
|
||||||
{
|
|
||||||
int n = m_matrix.rows();
|
|
||||||
return Block<MatrixType,SizeMinusOne,SizeMinusOne>(m_matrix, 1, 0, n-1,n-1)
|
|
||||||
.nestByValue().diagonal().nestByValue().real();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** constructs and returns the tridiagonal matrix T.
|
|
||||||
* Note that the matrix T is equivalent to the diagonal and sub-diagonal of the packed matrix.
|
|
||||||
* Therefore, it might be often sufficient to directly use the packed matrix, or the vector
|
|
||||||
* expressions returned by diagonal() and subDiagonal() instead of creating a new matrix.
|
|
||||||
*/
|
|
||||||
template<typename MatrixType>
|
|
||||||
typename Tridiagonalization<MatrixType>::MatrixType
|
|
||||||
Tridiagonalization<MatrixType>::matrixT(void) const
|
|
||||||
{
|
|
||||||
// FIXME should this function (and other similar) rather take a matrix as argument
|
|
||||||
// and fill it (avoids temporaries)
|
|
||||||
int n = m_matrix.rows();
|
|
||||||
MatrixType matT = m_matrix;
|
|
||||||
matT.corner(TopRight,n-1, n-1).diagonal() = subDiagonal().conjugate();
|
|
||||||
matT.corner(TopRight,n-2, n-2).template part<Upper>().setZero();
|
|
||||||
matT.corner(BottomLeft,n-2, n-2).template part<Lower>().setZero();
|
|
||||||
return matT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Performs a full decomposition in place */
|
/** Performs a full decomposition in place */
|
||||||
template<typename MatrixType>
|
template<typename MatrixType>
|
||||||
void Tridiagonalization<MatrixType>::decomposeInPlace(MatrixType& mat, DiagonalType& diag, SubDiagonalType& subdiag, bool extractQ)
|
void Tridiagonalization<MatrixType>::decomposeInPlace(MatrixType& mat, DiagonalType& diag, SubDiagonalType& subdiag, bool extractQ)
|
||||||
@ -337,4 +338,6 @@ void Tridiagonalization<MatrixType>::_decomposeInPlace3x3(MatrixType& mat, Diago
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // EIGEN_HIDE_HEAVY_CODE
|
||||||
|
|
||||||
#endif // EIGEN_TRIDIAGONALIZATION_H
|
#endif // EIGEN_TRIDIAGONALIZATION_H
|
||||||
|
@ -2,7 +2,9 @@ IF(BUILD_TESTS)
|
|||||||
|
|
||||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
IF(CMAKE_SYSTEM_NAME MATCHES Linux)
|
IF(CMAKE_SYSTEM_NAME MATCHES Linux)
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1 -g2")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1 -g1")
|
||||||
|
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g2")
|
||||||
|
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-inline-functions")
|
||||||
ENDIF(CMAKE_SYSTEM_NAME MATCHES Linux)
|
ENDIF(CMAKE_SYSTEM_NAME MATCHES Linux)
|
||||||
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
|
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
|
||||||
@ -53,7 +55,9 @@ MACRO(EI_ADD_TEST testname)
|
|||||||
|
|
||||||
EI_ADD_TARGET_PROPERTY(${targetname} COMPILE_FLAGS "-DEIGEN_TEST_FUNC=${testname}")
|
EI_ADD_TARGET_PROPERTY(${targetname} COMPILE_FLAGS "-DEIGEN_TEST_FUNC=${testname}")
|
||||||
|
|
||||||
target_link_libraries(${targetname} Eigen2)
|
IF(TEST_LIB)
|
||||||
|
target_link_libraries(${targetname} Eigen2)
|
||||||
|
ENDIF(TEST_LIB)
|
||||||
|
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
ADD_TEST(${testname} "${targetname}")
|
ADD_TEST(${testname} "${targetname}")
|
||||||
@ -66,7 +70,9 @@ ENDMACRO(EI_ADD_TEST)
|
|||||||
|
|
||||||
ENABLE_TESTING()
|
ENABLE_TESTING()
|
||||||
|
|
||||||
ADD_DEFINITIONS("-DEIGEN_EXTERN_INSTANCIATION=1")
|
IF(TEST_LIB)
|
||||||
|
ADD_DEFINITIONS("-DEIGEN_EXTERN_INSTANTIATIONS=1")
|
||||||
|
ENDIF(TEST_LIB)
|
||||||
|
|
||||||
EI_ADD_TEST(sizeof)
|
EI_ADD_TEST(sizeof)
|
||||||
EI_ADD_TEST(nomalloc)
|
EI_ADD_TEST(nomalloc)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user