Skip to content
GitLab
Explore
Sign in
Hide whitespace changes
Inline
Side-by-side
Some changes are not shown.
For a faster browsing experience, only
20 of 182+
files are shown. Download one of the files below to see all changes.
external/eigen3/Eigen/PardisoSupport
100644 → 100755
View file @
a394b22a
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef EIGEN_PARDISOSUPPORT_MODULE_H
#define EIGEN_PARDISOSUPPORT_MODULE_H
...
...
@@ -7,8 +14,6 @@
#include <mkl_pardiso.h>
#include <unsupported/Eigen/SparseExtra>
/** \ingroup Support_modules
* \defgroup PardisoSupport_Module PardisoSupport module
*
...
...
external/eigen3/Eigen/QR
View file @
a394b22a
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef EIGEN_QR_MODULE_H
#define EIGEN_QR_MODULE_H
...
...
@@ -15,31 +22,26 @@
*
* This module provides various QR decompositions
* This module also provides some MatrixBase methods, including:
* - MatrixBase::qr(),
* - MatrixBase::householderQr()
* - MatrixBase::colPivHouseholderQr()
* - MatrixBase::fullPivHouseholderQr()
*
* \code
* #include <Eigen/QR>
* \endcode
*/
#include
"src/misc/Solve.h"
#include
"src/QR/HouseholderQR.h"
#include
"src/QR/FullPivHouseholderQR.h"
#include
"src/QR/ColPivHouseholderQR.h"
#include
"src/QR/CompleteOrthogonalDecomposition.h"
#ifdef EIGEN_USE_LAPACKE
#include
"src/QR/HouseholderQR_MKL.h"
#include
"src/QR/ColPivHouseholderQR_MKL.h"
#endif
#ifdef EIGEN2_SUPPORT
#include
"src/Eigen2Support/QR.h"
#include
"src/misc/lapacke.h"
#include
"src/QR/HouseholderQR_LAPACKE.h"
#include
"src/QR/ColPivHouseholderQR_LAPACKE.h"
#endif
#include
"src/Core/util/ReenableStupidWarnings.h"
#ifdef EIGEN2_SUPPORT
#include
"Eigenvalues"
#endif
#endif // EIGEN_QR_MODULE_H
/* vim: set filetype=cpp et sw=2 ts=2 ai: */
external/eigen3/Eigen/QtAlignedMalloc
View file @
a394b22a
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef EIGEN_QTMALLOC_MODULE_H
#define EIGEN_QTMALLOC_MODULE_H
...
...
@@ -8,7 +14,7 @@
#include
"src/Core/util/DisableStupidWarnings.h"
void
*
qMalloc
(
size_t
size
)
void
*
qMalloc
(
std
::
size_t
size
)
{
return
Eigen
::
internal
::
aligned_malloc
(
size
);
}
...
...
@@ -18,7 +24,7 @@ void qFree(void *ptr)
Eigen
::
internal
::
aligned_free
(
ptr
);
}
void
*
qRealloc
(
void
*
ptr
,
size_t
size
)
void
*
qRealloc
(
void
*
ptr
,
std
::
size_t
size
)
{
void
*
newPtr
=
Eigen
::
internal
::
aligned_malloc
(
size
);
memcpy
(
newPtr
,
ptr
,
size
);
...
...
external/eigen3/Eigen/SPQRSupport
View file @
a394b22a
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef EIGEN_SPQRSUPPORT_MODULE_H
#define EIGEN_SPQRSUPPORT_MODULE_H
...
...
@@ -21,8 +28,6 @@
*
*/
#include "src/misc/Solve.h"
#include "src/misc/SparseSolve.h"
#include "src/CholmodSupport/CholmodSupport.h"
#include "src/SPQRSupport/SuiteSparseQRSupport.h"
...
...
external/eigen3/Eigen/SVD
View file @
a394b22a
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef EIGEN_SVD_MODULE_H
#define EIGEN_SVD_MODULE_H
...
...
@@ -12,23 +19,26 @@
*
*
* This module provides SVD decomposition for matrices (both real and complex).
* This decomposition is accessible via the following MatrixBase method:
* Two decomposition algorithms are provided:
* - JacobiSVD implementing two-sided Jacobi iterations is numerically very accurate, fast for small matrices, but very slow for larger ones.
* - BDCSVD implementing a recursive divide & conquer strategy on top of an upper-bidiagonalization which remains fast for large problems.
* These decompositions are accessible via the respective classes and following MatrixBase methods:
* - MatrixBase::jacobiSvd()
* - MatrixBase::bdcSvd()
*
* \code
* #include <Eigen/SVD>
* \endcode
*/
#include
"src/misc/Solve.h"
#include
"src/misc/RealSvd2x2.h"
#include
"src/SVD/UpperBidiagonalization.h"
#include
"src/SVD/SVDBase.h"
#include
"src/SVD/JacobiSVD.h"
#include
"src/SVD/BDCSVD.h"
#if defined(EIGEN_USE_LAPACKE) && !defined(EIGEN_USE_LAPACKE_STRICT)
#include
"src/SVD/JacobiSVD_MKL.h"
#endif
#include
"src/SVD/UpperBidiagonalization.h"
#ifdef EIGEN2_SUPPORT
#include
"src/Eigen2Support/SVD.h"
#include
"src/misc/lapacke.h"
#include
"src/SVD/JacobiSVD_LAPACKE.h"
#endif
#include
"src/Core/util/ReenableStupidWarnings.h"
...
...
external/eigen3/Eigen/Sparse
View file @
a394b22a
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef EIGEN_SPARSE_MODULE_H
#define EIGEN_SPARSE_MODULE_H
...
...
@@ -11,14 +18,16 @@
* - \ref SparseQR_Module
* - \ref IterativeLinearSolvers_Module
*
*
\code
*
#include <Eigen/Sparse>
*
\endcode
\code
#include <Eigen/Sparse>
\endcode
*/
#include "SparseCore"
#include "OrderingMethods"
#ifndef EIGEN_MPL2_ONLY
#include "SparseCholesky"
#endif
#include "SparseLU"
#include "SparseQR"
#include "IterativeLinearSolvers"
...
...
external/eigen3/Eigen/SparseCholesky
View file @
a394b22a
...
...
@@ -34,8 +34,6 @@
#error The SparseCholesky module has nothing to offer in MPL2 only mode
#endif
#include "src/misc/Solve.h"
#include "src/misc/SparseSolve.h"
#include "src/SparseCholesky/SimplicialCholesky.h"
#ifndef EIGEN_MPL2_ONLY
...
...
external/eigen3/Eigen/SparseCore
View file @
a394b22a
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef EIGEN_SPARSECORE_MODULE_H
#define EIGEN_SPARSECORE_MODULE_H
...
...
@@ -26,37 +33,35 @@
* This module depends on: Core.
*/
namespace Eigen {
/** The type used to identify a general sparse storage. */
struct Sparse {};
}
#include "src/SparseCore/SparseUtil.h"
#include "src/SparseCore/SparseMatrixBase.h"
#include "src/SparseCore/SparseAssign.h"
#include "src/SparseCore/CompressedStorage.h"
#include "src/SparseCore/AmbiVector.h"
#include "src/SparseCore/SparseCompressedBase.h"
#include "src/SparseCore/SparseMatrix.h"
#include "src/SparseCore/SparseMap.h"
#include "src/SparseCore/MappedSparseMatrix.h"
#include "src/SparseCore/SparseVector.h"
#include "src/SparseCore/SparseBlock.h"
#include "src/SparseCore/SparseTranspose.h"
#include "src/SparseCore/SparseRef.h"
#include "src/SparseCore/SparseCwiseUnaryOp.h"
#include "src/SparseCore/SparseCwiseBinaryOp.h"
#include "src/SparseCore/SparseTranspose.h"
#include "src/SparseCore/SparseBlock.h"
#include "src/SparseCore/SparseDot.h"
#include "src/SparseCore/SparsePermutation.h"
#include "src/SparseCore/SparseRedux.h"
#include "src/SparseCore/SparseFuzzy.h"
#include "src/SparseCore/SparseView.h"
#include "src/SparseCore/SparseDiagonalProduct.h"
#include "src/SparseCore/ConservativeSparseSparseProduct.h"
#include "src/SparseCore/SparseSparseProductWithPruning.h"
#include "src/SparseCore/SparseProduct.h"
#include "src/SparseCore/SparseDenseProduct.h"
#include "src/SparseCore/SparseDiagonalProduct.h"
#include "src/SparseCore/SparseTriangularView.h"
#include "src/SparseCore/SparseSelfAdjointView.h"
#include "src/SparseCore/SparseTriangularView.h"
#include "src/SparseCore/TriangularSolver.h"
#include "src/SparseCore/SparseView.h"
#include "src/SparseCore/SparsePermutation.h"
#include "src/SparseCore/SparseFuzzy.h"
#include "src/SparseCore/SparseSolverBase.h"
#include "src/Core/util/ReenableStupidWarnings.h"
...
...
external/eigen3/Eigen/SparseLU
View file @
a394b22a
...
...
@@ -20,9 +20,6 @@
* Please, see the documentation of the SparseLU class for more details.
*/
#include "src/misc/Solve.h"
#include "src/misc/SparseSolve.h"
// Ordering interface
#include "OrderingMethods"
...
...
external/eigen3/Eigen/SparseQR
View file @
a394b22a
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef EIGEN_SPARSEQR_MODULE_H
#define EIGEN_SPARSEQR_MODULE_H
...
...
@@ -21,9 +28,6 @@
*
*/
#include "src/misc/Solve.h"
#include "src/misc/SparseSolve.h"
#include "OrderingMethods"
#include "src/SparseCore/SparseColEtree.h"
#include "src/SparseQR/SparseQR.h"
...
...
external/eigen3/Eigen/StdDeque
View file @
a394b22a
...
...
@@ -14,7 +14,7 @@
#include "Core"
#include <deque>
#if
(defined(_MSC_VER) && defined(_WIN64)
) /* MSVC auto aligns in 64 bit builds */
#if
EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16
) /* MSVC auto aligns
up to 16 bytes
in 64 bit builds */
#define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...)
...
...
external/eigen3/Eigen/StdList
View file @
a394b22a
...
...
@@ -13,7 +13,7 @@
#include "Core"
#include <list>
#if
(defined(_MSC_VER) && defined(_WIN64)
) /* MSVC auto aligns in 64 bit builds */
#if
EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16
) /* MSVC auto aligns
up to 16 bytes
in 64 bit builds */
#define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...)
...
...
external/eigen3/Eigen/StdVector
View file @
a394b22a
...
...
@@ -14,7 +14,7 @@
#include "Core"
#include <vector>
#if
(defined(_MSC_VER) && defined(_WIN64)
) /* MSVC auto aligns in 64 bit builds */
#if
EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16
) /* MSVC auto aligns
up to 16 bytes
in 64 bit builds */
#define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...)
...
...
external/eigen3/Eigen/SuperLUSupport
View file @
a394b22a
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef EIGEN_SUPERLUSUPPORT_MODULE_H
#define EIGEN_SUPERLUSUPPORT_MODULE_H
...
...
@@ -36,6 +43,8 @@ namespace Eigen { struct SluMatrix; }
* - class SuperLU: a supernodal sequential LU factorization.
* - class SuperILU: a supernodal sequential incomplete LU factorization (to be used as a preconditioner for iterative methods).
*
* \warning This wrapper requires at least versions 4.0 of SuperLU. The 3.x versions are not supported.
*
* \warning When including this module, you have to use SUPERLU_EMPTY instead of EMPTY which is no longer defined because it is too polluting.
*
* \code
...
...
@@ -48,12 +57,8 @@ namespace Eigen { struct SluMatrix; }
*
*/
#include "src/misc/Solve.h"
#include "src/misc/SparseSolve.h"
#include "src/SuperLUSupport/SuperLUSupport.h"
#include "src/Core/util/ReenableStupidWarnings.h"
#endif // EIGEN_SUPERLUSUPPORT_MODULE_H
external/eigen3/Eigen/UmfPackSupport
View file @
a394b22a
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef EIGEN_UMFPACKSUPPORT_MODULE_H
#define EIGEN_UMFPACKSUPPORT_MODULE_H
...
...
@@ -26,9 +33,6 @@ extern "C" {
*
*/
#include "src/misc/Solve.h"
#include "src/misc/SparseSolve.h"
#include "src/UmfPackSupport/UmfPackSupport.h"
#include "src/Core/util/ReenableStupidWarnings.h"
...
...
external/eigen3/Eigen/src/CMakeLists.txt
deleted
100644 → 0
View file @
760a0e79
file
(
GLOB Eigen_src_subdirectories
"*"
)
escape_string_as_regex
(
ESCAPED_CMAKE_CURRENT_SOURCE_DIR
"
${
CMAKE_CURRENT_SOURCE_DIR
}
"
)
foreach
(
f
${
Eigen_src_subdirectories
}
)
if
(
NOT f MATCHES
"
\\
.txt"
AND NOT f MATCHES
"
${
ESCAPED_CMAKE_CURRENT_SOURCE_DIR
}
/[.].+"
)
add_subdirectory
(
${
f
}
)
endif
()
endforeach
()
external/eigen3/Eigen/src/Cholesky/CMakeLists.txt
deleted
100644 → 0
View file @
760a0e79
FILE
(
GLOB Eigen_Cholesky_SRCS
"*.h"
)
INSTALL
(
FILES
${
Eigen_Cholesky_SRCS
}
DESTINATION
${
INCLUDE_INSTALL_DIR
}
/Eigen/src/Cholesky COMPONENT Devel
)
external/eigen3/Eigen/src/Cholesky/LDLT.h
View file @
a394b22a
...
...
@@ -13,7 +13,7 @@
#ifndef EIGEN_LDLT_H
#define EIGEN_LDLT_H
namespace
Eigen
{
namespace
Eigen
{
namespace
internal
{
template
<
typename
MatrixType
,
int
UpLo
>
struct
LDLT_Traits
;
...
...
@@ -28,8 +28,8 @@ namespace internal {
*
* \brief Robust Cholesky decomposition of a matrix with pivoting
*
* \param MatrixType the type of the matrix of which to compute the LDL^T Cholesky decomposition
* \param UpLo the triangular part that will be used for the decompositon: Lower (default) or Upper.
* \
t
param
_
MatrixType the type of the matrix of which to compute the LDL^T Cholesky decomposition
* \
t
param
_
UpLo the triangular part that will be used for the decompositon: Lower (default) or Upper.
* The other triangular part won't be read.
*
* Perform a robust Cholesky decomposition of a positive semidefinite or negative semidefinite
...
...
@@ -43,7 +43,9 @@ namespace internal {
* Remember that Cholesky decompositions are not rank-revealing. Also, do not use a Cholesky
* decomposition to determine whether a system of equations has a solution.
*
* \sa MatrixBase::ldlt(), class LLT
* This class supports the \link InplaceDecomposition inplace decomposition \endlink mechanism.
*
* \sa MatrixBase::ldlt(), SelfAdjointView::ldlt(), class LLT
*/
template
<
typename
_MatrixType
,
int
_UpLo
>
class
LDLT
{
...
...
@@ -52,15 +54,15 @@ template<typename _MatrixType, int _UpLo> class LDLT
enum
{
RowsAtCompileTime
=
MatrixType
::
RowsAtCompileTime
,
ColsAtCompileTime
=
MatrixType
::
ColsAtCompileTime
,
Options
=
MatrixType
::
Options
&
~
RowMajorBit
,
// these are the options for the TmpMatrixType, we need a ColMajor matrix here!
MaxRowsAtCompileTime
=
MatrixType
::
MaxRowsAtCompileTime
,
MaxColsAtCompileTime
=
MatrixType
::
MaxColsAtCompileTime
,
UpLo
=
_UpLo
};
typedef
typename
MatrixType
::
Scalar
Scalar
;
typedef
typename
NumTraits
<
typename
MatrixType
::
Scalar
>::
Real
RealScalar
;
typedef
typename
MatrixType
::
Index
Index
;
typedef
Matrix
<
Scalar
,
RowsAtCompileTime
,
1
,
Options
,
MaxRowsAtCompileTime
,
1
>
TmpMatrixType
;
typedef
Eigen
::
Index
Index
;
///< \deprecated since Eigen 3.3
typedef
typename
MatrixType
::
StorageIndex
StorageIndex
;
typedef
Matrix
<
Scalar
,
RowsAtCompileTime
,
1
,
0
,
MaxRowsAtCompileTime
,
1
>
TmpMatrixType
;
typedef
Transpositions
<
RowsAtCompileTime
,
MaxRowsAtCompileTime
>
TranspositionType
;
typedef
PermutationMatrix
<
RowsAtCompileTime
,
MaxRowsAtCompileTime
>
PermutationType
;
...
...
@@ -72,11 +74,11 @@ template<typename _MatrixType, int _UpLo> class LDLT
* The default constructor is useful in cases in which the user intends to
* perform decompositions via LDLT::compute(const MatrixType&).
*/
LDLT
()
:
m_matrix
(),
m_transpositions
(),
LDLT
()
:
m_matrix
(),
m_transpositions
(),
m_sign
(
internal
::
ZeroSign
),
m_isInitialized
(
false
)
m_isInitialized
(
false
)
{}
/** \brief Default Constructor with memory preallocation
...
...
@@ -85,7 +87,7 @@ template<typename _MatrixType, int _UpLo> class LDLT
* according to the specified problem \a size.
* \sa LDLT()
*/
LDLT
(
Index
size
)
explicit
LDLT
(
Index
size
)
:
m_matrix
(
size
,
size
),
m_transpositions
(
size
),
m_temporary
(
size
),
...
...
@@ -96,16 +98,35 @@ template<typename _MatrixType, int _UpLo> class LDLT
/** \brief Constructor with decomposition
*
* This calculates the decomposition for the input \a matrix.
*
* \sa LDLT(Index size)
*/
LDLT
(
const
MatrixType
&
matrix
)
template
<
typename
InputType
>
explicit
LDLT
(
const
EigenBase
<
InputType
>&
matrix
)
:
m_matrix
(
matrix
.
rows
(),
matrix
.
cols
()),
m_transpositions
(
matrix
.
rows
()),
m_temporary
(
matrix
.
rows
()),
m_sign
(
internal
::
ZeroSign
),
m_isInitialized
(
false
)
{
compute
(
matrix
);
compute
(
matrix
.
derived
());
}
/** \brief Constructs a LDLT factorization from a given matrix
*
* This overloaded constructor is provided for \link InplaceDecomposition inplace decomposition \endlink when \c MatrixType is a Eigen::Ref.
*
* \sa LDLT(const EigenBase&)
*/
template
<
typename
InputType
>
explicit
LDLT
(
EigenBase
<
InputType
>&
matrix
)
:
m_matrix
(
matrix
.
derived
()),
m_transpositions
(
matrix
.
rows
()),
m_temporary
(
matrix
.
rows
()),
m_sign
(
internal
::
ZeroSign
),
m_isInitialized
(
false
)
{
compute
(
matrix
.
derived
());
}
/** Clear any existing decomposition
...
...
@@ -151,13 +172,6 @@ template<typename _MatrixType, int _UpLo> class LDLT
eigen_assert
(
m_isInitialized
&&
"LDLT is not initialized."
);
return
m_sign
==
internal
::
PositiveSemiDef
||
m_sign
==
internal
::
ZeroSign
;
}
#ifdef EIGEN2_SUPPORT
inline
bool
isPositiveDefinite
()
const
{
return
isPositive
();
}
#endif
/** \returns true if the matrix is negative (semidefinite) */
inline
bool
isNegative
(
void
)
const
...
...
@@ -173,37 +187,38 @@ template<typename _MatrixType, int _UpLo> class LDLT
* \note_about_checking_solutions
*
* More precisely, this method solves \f$ A x = b \f$ using the decomposition \f$ A = P^T L D L^* P \f$
* by solving the systems \f$ P^T y_1 = b \f$, \f$ L y_2 = y_1 \f$, \f$ D y_3 = y_2 \f$,
* by solving the systems \f$ P^T y_1 = b \f$, \f$ L y_2 = y_1 \f$, \f$ D y_3 = y_2 \f$,
* \f$ L^* y_4 = y_3 \f$ and \f$ P x = y_4 \f$ in succession. If the matrix \f$ A \f$ is singular, then
* \f$ D \f$ will also be singular (all the other matrices are invertible). In that case, the
* least-square solution of \f$ D y_3 = y_2 \f$ is computed. This does not mean that this function
* computes the least-square solution of \f$ A x = b \f$ is \f$ A \f$ is singular.
*
* \sa MatrixBase::ldlt()
* \sa MatrixBase::ldlt()
, SelfAdjointView::ldlt()
*/
template
<
typename
Rhs
>
inline
const
internal
::
solve_retval
<
LDLT
,
Rhs
>
inline
const
Solve
<
LDLT
,
Rhs
>
solve
(
const
MatrixBase
<
Rhs
>&
b
)
const
{
eigen_assert
(
m_isInitialized
&&
"LDLT is not initialized."
);
eigen_assert
(
m_matrix
.
rows
()
==
b
.
rows
()
&&
"LDLT::solve(): invalid number of rows of the right hand side matrix b"
);
return
internal
::
solve_retval
<
LDLT
,
Rhs
>
(
*
this
,
b
.
derived
());
return
Solve
<
LDLT
,
Rhs
>
(
*
this
,
b
.
derived
());
}
#ifdef EIGEN2_SUPPORT
template
<
typename
OtherDerived
,
typename
ResultType
>
bool
solve
(
const
MatrixBase
<
OtherDerived
>&
b
,
ResultType
*
result
)
const
{
*
result
=
this
->
solve
(
b
);
return
true
;
}
#endif
template
<
typename
Derived
>
bool
solveInPlace
(
MatrixBase
<
Derived
>
&
bAndX
)
const
;
LDLT
&
compute
(
const
MatrixType
&
matrix
);
template
<
typename
InputType
>
LDLT
&
compute
(
const
EigenBase
<
InputType
>&
matrix
);
/** \returns an estimate of the reciprocal condition number of the matrix of
* which \c *this is the LDLT decomposition.
*/
RealScalar
rcond
()
const
{
eigen_assert
(
m_isInitialized
&&
"LDLT is not initialized."
);
return
internal
::
rcond_estimate_helper
(
m_l1_norm
,
*
this
);
}
template
<
typename
Derived
>
LDLT
&
rankUpdate
(
const
MatrixBase
<
Derived
>&
w
,
const
RealScalar
&
alpha
=
1
);
...
...
@@ -220,6 +235,13 @@ template<typename _MatrixType, int _UpLo> class LDLT
MatrixType
reconstructedMatrix
()
const
;
/** \returns the adjoint of \c *this, that is, a const reference to the decomposition itself as the underlying matrix is self-adjoint.
*
* This method is provided for compatibility with other matrix decompositions, thus enabling generic code such as:
* \code x = decomposition.adjoint().solve(b) \endcode
*/
const
LDLT
&
adjoint
()
const
{
return
*
this
;
};
inline
Index
rows
()
const
{
return
m_matrix
.
rows
();
}
inline
Index
cols
()
const
{
return
m_matrix
.
cols
();
}
...
...
@@ -231,11 +253,17 @@ template<typename _MatrixType, int _UpLo> class LDLT
ComputationInfo
info
()
const
{
eigen_assert
(
m_isInitialized
&&
"LDLT is not initialized."
);
return
Success
;
return
m_info
;
}
#ifndef EIGEN_PARSED_BY_DOXYGEN
template
<
typename
RhsType
,
typename
DstType
>
EIGEN_DEVICE_FUNC
void
_solve_impl
(
const
RhsType
&
rhs
,
DstType
&
dst
)
const
;
#endif
protected
:
static
void
check_template_parameters
()
{
EIGEN_STATIC_ASSERT_NON_INTEGER
(
Scalar
);
...
...
@@ -248,10 +276,12 @@ template<typename _MatrixType, int _UpLo> class LDLT
* is not stored), and the diagonal entries correspond to D.
*/
MatrixType
m_matrix
;
RealScalar
m_l1_norm
;
TranspositionType
m_transpositions
;
TmpMatrixType
m_temporary
;
internal
::
SignMatrix
m_sign
;
bool
m_isInitialized
;
ComputationInfo
m_info
;
};
namespace
internal
{
...
...
@@ -266,15 +296,17 @@ template<> struct ldlt_inplace<Lower>
using
std
::
abs
;
typedef
typename
MatrixType
::
Scalar
Scalar
;
typedef
typename
MatrixType
::
RealScalar
RealScalar
;
typedef
typename
MatrixType
::
Index
Index
;
typedef
typename
TranspositionType
::
Storage
Index
Index
Type
;
eigen_assert
(
mat
.
rows
()
==
mat
.
cols
());
const
Index
size
=
mat
.
rows
();
bool
found_zero_pivot
=
false
;
bool
ret
=
true
;
if
(
size
<=
1
)
{
transpositions
.
setIdentity
();
if
(
numext
::
real
(
mat
.
coeff
(
0
,
0
))
>
0
)
sign
=
PositiveSemiDef
;
else
if
(
numext
::
real
(
mat
.
coeff
(
0
,
0
))
<
0
)
sign
=
NegativeSemiDef
;
if
(
numext
::
real
(
mat
.
coeff
(
0
,
0
))
>
static_cast
<
RealScalar
>
(
0
)
)
sign
=
PositiveSemiDef
;
else
if
(
numext
::
real
(
mat
.
coeff
(
0
,
0
))
<
static_cast
<
RealScalar
>
(
0
)
)
sign
=
NegativeSemiDef
;
else
sign
=
ZeroSign
;
return
true
;
}
...
...
@@ -286,7 +318,7 @@ template<> struct ldlt_inplace<Lower>
mat
.
diagonal
().
tail
(
size
-
k
).
cwiseAbs
().
maxCoeff
(
&
index_of_biggest_in_corner
);
index_of_biggest_in_corner
+=
k
;
transpositions
.
coeffRef
(
k
)
=
index_of_biggest_in_corner
;
transpositions
.
coeffRef
(
k
)
=
IndexType
(
index_of_biggest_in_corner
)
;
if
(
k
!=
index_of_biggest_in_corner
)
{
// apply the transposition while taking care to consider only
...
...
@@ -295,7 +327,7 @@ template<> struct ldlt_inplace<Lower>
mat
.
row
(
k
).
head
(
k
).
swap
(
mat
.
row
(
index_of_biggest_in_corner
).
head
(
k
));
mat
.
col
(
k
).
tail
(
s
).
swap
(
mat
.
col
(
index_of_biggest_in_corner
).
tail
(
s
));
std
::
swap
(
mat
.
coeffRef
(
k
,
k
),
mat
.
coeffRef
(
index_of_biggest_in_corner
,
index_of_biggest_in_corner
));
for
(
int
i
=
k
+
1
;
i
<
index_of_biggest_in_corner
;
++
i
)
for
(
Index
i
=
k
+
1
;
i
<
index_of_biggest_in_corner
;
++
i
)
{
Scalar
tmp
=
mat
.
coeffRef
(
i
,
k
);
mat
.
coeffRef
(
i
,
k
)
=
numext
::
conj
(
mat
.
coeffRef
(
index_of_biggest_in_corner
,
i
));
...
...
@@ -321,26 +353,44 @@ template<> struct ldlt_inplace<Lower>
if
(
rs
>
0
)
A21
.
noalias
()
-=
A20
*
temp
.
head
(
k
);
}
// In some previous versions of Eigen (e.g., 3.2.1), the scaling was omitted if the pivot
// was smaller than the cutoff value. However, s
o
ince LDLT is not rank-revealing
// we should only make sure we do not introduce INF or NaN values.
// LAPACK also uses 0 as the cutoff value.
// was smaller than the cutoff value. However, since LDLT is not rank-revealing
// we should only make sure
that
we do not introduce INF or NaN values.
//
Remark that
LAPACK also uses 0 as the cutoff value.
RealScalar
realAkk
=
numext
::
real
(
mat
.
coeffRef
(
k
,
k
));
if
((
rs
>
0
)
&&
(
abs
(
realAkk
)
>
RealScalar
(
0
)))
bool
pivot_is_valid
=
(
abs
(
realAkk
)
>
RealScalar
(
0
));
if
(
k
==
0
&&
!
pivot_is_valid
)
{
// The entire diagonal is zero, there is nothing more to do
// except filling the transpositions, and checking whether the matrix is zero.
sign
=
ZeroSign
;
for
(
Index
j
=
0
;
j
<
size
;
++
j
)
{
transpositions
.
coeffRef
(
j
)
=
IndexType
(
j
);
ret
=
ret
&&
(
mat
.
col
(
j
).
tail
(
size
-
j
-
1
).
array
()
==
Scalar
(
0
)).
all
();
}
return
ret
;
}
if
((
rs
>
0
)
&&
pivot_is_valid
)
A21
/=
realAkk
;
if
(
found_zero_pivot
&&
pivot_is_valid
)
ret
=
false
;
// factorization failed
else
if
(
!
pivot_is_valid
)
found_zero_pivot
=
true
;
if
(
sign
==
PositiveSemiDef
)
{
if
(
realAkk
<
0
)
sign
=
Indefinite
;
if
(
realAkk
<
static_cast
<
RealScalar
>
(
0
)
)
sign
=
Indefinite
;
}
else
if
(
sign
==
NegativeSemiDef
)
{
if
(
realAkk
>
0
)
sign
=
Indefinite
;
if
(
realAkk
>
static_cast
<
RealScalar
>
(
0
)
)
sign
=
Indefinite
;
}
else
if
(
sign
==
ZeroSign
)
{
if
(
realAkk
>
0
)
sign
=
PositiveSemiDef
;
else
if
(
realAkk
<
0
)
sign
=
NegativeSemiDef
;
if
(
realAkk
>
static_cast
<
RealScalar
>
(
0
)
)
sign
=
PositiveSemiDef
;
else
if
(
realAkk
<
static_cast
<
RealScalar
>
(
0
)
)
sign
=
NegativeSemiDef
;
}
}
return
true
;
return
ret
;
}
// Reference for the algorithm: Davis and Hager, "Multiple Rank
...
...
@@ -356,7 +406,6 @@ template<> struct ldlt_inplace<Lower>
using
numext
::
isfinite
;
typedef
typename
MatrixType
::
Scalar
Scalar
;
typedef
typename
MatrixType
::
RealScalar
RealScalar
;
typedef
typename
MatrixType
::
Index
Index
;
const
Index
size
=
mat
.
rows
();
eigen_assert
(
mat
.
cols
()
==
size
&&
w
.
size
()
==
size
);
...
...
@@ -420,16 +469,16 @@ template<typename MatrixType> struct LDLT_Traits<MatrixType,Lower>
{
typedef
const
TriangularView
<
const
MatrixType
,
UnitLower
>
MatrixL
;
typedef
const
TriangularView
<
const
typename
MatrixType
::
AdjointReturnType
,
UnitUpper
>
MatrixU
;
static
inline
MatrixL
getL
(
const
MatrixType
&
m
)
{
return
m
;
}
static
inline
MatrixU
getU
(
const
MatrixType
&
m
)
{
return
m
.
adjoint
();
}
static
inline
MatrixL
getL
(
const
MatrixType
&
m
)
{
return
MatrixL
(
m
)
;
}
static
inline
MatrixU
getU
(
const
MatrixType
&
m
)
{
return
MatrixU
(
m
.
adjoint
()
)
;
}
};
template
<
typename
MatrixType
>
struct
LDLT_Traits
<
MatrixType
,
Upper
>
{
typedef
const
TriangularView
<
const
typename
MatrixType
::
AdjointReturnType
,
UnitLower
>
MatrixL
;
typedef
const
TriangularView
<
const
MatrixType
,
UnitUpper
>
MatrixU
;
static
inline
MatrixL
getL
(
const
MatrixType
&
m
)
{
return
m
.
adjoint
();
}
static
inline
MatrixU
getU
(
const
MatrixType
&
m
)
{
return
m
;
}
static
inline
MatrixL
getL
(
const
MatrixType
&
m
)
{
return
MatrixL
(
m
.
adjoint
()
)
;
}
static
inline
MatrixU
getU
(
const
MatrixType
&
m
)
{
return
MatrixU
(
m
)
;
}
};
}
// end namespace internal
...
...
@@ -437,21 +486,35 @@ template<typename MatrixType> struct LDLT_Traits<MatrixType,Upper>
/** Compute / recompute the LDLT decomposition A = L D L^* = U^* D U of \a matrix
*/
template
<
typename
MatrixType
,
int
_UpLo
>
LDLT
<
MatrixType
,
_UpLo
>&
LDLT
<
MatrixType
,
_UpLo
>::
compute
(
const
MatrixType
&
a
)
template
<
typename
InputType
>
LDLT
<
MatrixType
,
_UpLo
>&
LDLT
<
MatrixType
,
_UpLo
>::
compute
(
const
EigenBase
<
InputType
>&
a
)
{
check_template_parameters
();
eigen_assert
(
a
.
rows
()
==
a
.
cols
());
const
Index
size
=
a
.
rows
();
m_matrix
=
a
;
m_matrix
=
a
.
derived
();
// Compute matrix L1 norm = max abs column sum.
m_l1_norm
=
RealScalar
(
0
);
// TODO move this code to SelfAdjointView
for
(
Index
col
=
0
;
col
<
size
;
++
col
)
{
RealScalar
abs_col_sum
;
if
(
_UpLo
==
Lower
)
abs_col_sum
=
m_matrix
.
col
(
col
).
tail
(
size
-
col
).
template
lpNorm
<
1
>()
+
m_matrix
.
row
(
col
).
head
(
col
).
template
lpNorm
<
1
>();
else
abs_col_sum
=
m_matrix
.
col
(
col
).
head
(
col
).
template
lpNorm
<
1
>()
+
m_matrix
.
row
(
col
).
tail
(
size
-
col
).
template
lpNorm
<
1
>();
if
(
abs_col_sum
>
m_l1_norm
)
m_l1_norm
=
abs_col_sum
;
}
m_transpositions
.
resize
(
size
);
m_isInitialized
=
false
;
m_temporary
.
resize
(
size
);
m_sign
=
internal
::
ZeroSign
;
internal
::
ldlt_inplace
<
UpLo
>::
unblocked
(
m_matrix
,
m_transpositions
,
m_temporary
,
m_sign
);
m_info
=
internal
::
ldlt_inplace
<
UpLo
>::
unblocked
(
m_matrix
,
m_transpositions
,
m_temporary
,
m_sign
)
?
Success
:
NumericalIssue
;
m_isInitialized
=
true
;
return
*
this
;
...
...
@@ -466,18 +529,19 @@ template<typename MatrixType, int _UpLo>
template
<
typename
Derived
>
LDLT
<
MatrixType
,
_UpLo
>&
LDLT
<
MatrixType
,
_UpLo
>::
rankUpdate
(
const
MatrixBase
<
Derived
>&
w
,
const
typename
LDLT
<
MatrixType
,
_UpLo
>::
RealScalar
&
sigma
)
{
typedef
typename
TranspositionType
::
StorageIndex
IndexType
;
const
Index
size
=
w
.
rows
();
if
(
m_isInitialized
)
{
eigen_assert
(
m_matrix
.
rows
()
==
size
);
}
else
{
{
m_matrix
.
resize
(
size
,
size
);
m_matrix
.
setZero
();
m_transpositions
.
resize
(
size
);
for
(
Index
i
=
0
;
i
<
size
;
i
++
)
m_transpositions
.
coeffRef
(
i
)
=
i
;
m_transpositions
.
coeffRef
(
i
)
=
IndexType
(
i
)
;
m_temporary
.
resize
(
size
);
m_sign
=
sigma
>=
0
?
internal
::
PositiveSemiDef
:
internal
::
NegativeSemiDef
;
m_isInitialized
=
true
;
...
...
@@ -488,53 +552,45 @@ LDLT<MatrixType,_UpLo>& LDLT<MatrixType,_UpLo>::rankUpdate(const MatrixBase<Deri
return
*
this
;
}
namespace
internal
{
template
<
typename
_MatrixType
,
int
_UpLo
,
typename
Rhs
>
struct
solve_retval
<
LDLT
<
_MatrixType
,
_UpLo
>
,
Rhs
>
:
solve_retval_base
<
LDLT
<
_MatrixType
,
_UpLo
>
,
Rhs
>
#ifndef EIGEN_PARSED_BY_DOXYGEN
template
<
typename
_MatrixType
,
int
_UpLo
>
template
<
typename
RhsType
,
typename
DstType
>
void
LDLT
<
_MatrixType
,
_UpLo
>
::
_solve_impl
(
const
RhsType
&
rhs
,
DstType
&
dst
)
const
{
typedef
LDLT
<
_MatrixType
,
_UpLo
>
LDLTType
;
EIGEN_MAKE_SOLVE_HELPERS
(
LDLTType
,
Rhs
)
template
<
typename
Dest
>
void
evalTo
(
Dest
&
dst
)
const
eigen_assert
(
rhs
.
rows
()
==
rows
());
// dst = P b
dst
=
m_transpositions
*
rhs
;
// dst = L^-1 (P b)
matrixL
().
solveInPlace
(
dst
);
// dst = D^-1 (L^-1 P b)
// more precisely, use pseudo-inverse of D (see bug 241)
using
std
::
abs
;
const
typename
Diagonal
<
const
MatrixType
>::
RealReturnType
vecD
(
vectorD
());
// In some previous versions, tolerance was set to the max of 1/highest and the maximal diagonal entry * epsilon
// as motivated by LAPACK's xGELSS:
// RealScalar tolerance = numext::maxi(vecD.array().abs().maxCoeff() * NumTraits<RealScalar>::epsilon(),RealScalar(1) / NumTraits<RealScalar>::highest());
// However, LDLT is not rank revealing, and so adjusting the tolerance wrt to the highest
// diagonal element is not well justified and leads to numerical issues in some cases.
// Moreover, Lapack's xSYTRS routines use 0 for the tolerance.
RealScalar
tolerance
=
RealScalar
(
1
)
/
NumTraits
<
RealScalar
>::
highest
();
for
(
Index
i
=
0
;
i
<
vecD
.
size
();
++
i
)
{
eigen_assert
(
rhs
().
rows
()
==
dec
().
matrixLDLT
().
rows
());
// dst = P b
dst
=
dec
().
transpositionsP
()
*
rhs
();
// dst = L^-1 (P b)
dec
().
matrixL
().
solveInPlace
(
dst
);
// dst = D^-1 (L^-1 P b)
// more precisely, use pseudo-inverse of D (see bug 241)
using
std
::
abs
;
using
std
::
max
;
typedef
typename
LDLTType
::
MatrixType
MatrixType
;
typedef
typename
LDLTType
::
RealScalar
RealScalar
;
const
typename
Diagonal
<
const
MatrixType
>::
RealReturnType
vectorD
(
dec
().
vectorD
());
// In some previous versions, tolerance was set to the max of 1/highest and the maximal diagonal entry * epsilon
// as motivated by LAPACK's xGELSS:
// RealScalar tolerance = (max)(vectorD.array().abs().maxCoeff() *NumTraits<RealScalar>::epsilon(),RealScalar(1) / NumTraits<RealScalar>::highest());
// However, LDLT is not rank revealing, and so adjusting the tolerance wrt to the highest
// diagonal element is not well justified and to numerical issues in some cases.
// Moreover, Lapack's xSYTRS routines use 0 for the tolerance.
RealScalar
tolerance
=
RealScalar
(
1
)
/
NumTraits
<
RealScalar
>::
highest
();
for
(
Index
i
=
0
;
i
<
vectorD
.
size
();
++
i
)
{
if
(
abs
(
vectorD
(
i
))
>
tolerance
)
dst
.
row
(
i
)
/=
vectorD
(
i
);
else
dst
.
row
(
i
).
setZero
();
}
if
(
abs
(
vecD
(
i
))
>
tolerance
)
dst
.
row
(
i
)
/=
vecD
(
i
);
else
dst
.
row
(
i
).
setZero
();
}
// dst = L^-T (D^-1 L^-1 P b)
dec
().
matrixU
().
solveInPlace
(
dst
);
// dst = L^-T (D^-1 L^-1 P b)
matrixU
().
solveInPlace
(
dst
);
// dst = P^-1 (L^-T D^-1 L^-1 P b) = A^-1 b
dst
=
dec
().
transpositionsP
().
transpose
()
*
dst
;
}
};
// dst = P^-1 (L^-T D^-1 L^-1 P b) = A^-1 b
dst
=
m_transpositions
.
transpose
()
*
dst
;
}
#endif
/** \internal use x = ldlt_object.solve(x);
*
...
...
@@ -588,6 +644,7 @@ MatrixType LDLT<MatrixType,_UpLo>::reconstructedMatrix() const
/** \cholesky_module
* \returns the Cholesky decomposition with full pivoting without square root of \c *this
* \sa MatrixBase::ldlt()
*/
template
<
typename
MatrixType
,
unsigned
int
UpLo
>
inline
const
LDLT
<
typename
SelfAdjointView
<
MatrixType
,
UpLo
>::
PlainObject
,
UpLo
>
...
...
@@ -598,6 +655,7 @@ SelfAdjointView<MatrixType, UpLo>::ldlt() const
/** \cholesky_module
* \returns the Cholesky decomposition with full pivoting without square root of \c *this
* \sa SelfAdjointView::ldlt()
*/
template
<
typename
Derived
>
inline
const
LDLT
<
typename
MatrixBase
<
Derived
>::
PlainObject
>
...
...
external/eigen3/Eigen/src/Cholesky/LLT.h
View file @
a394b22a
...
...
@@ -10,7 +10,7 @@
#ifndef EIGEN_LLT_H
#define EIGEN_LLT_H
namespace
Eigen
{
namespace
Eigen
{
namespace
internal
{
template
<
typename
MatrixType
,
int
UpLo
>
struct
LLT_Traits
;
...
...
@@ -22,8 +22,8 @@ template<typename MatrixType, int UpLo> struct LLT_Traits;
*
* \brief Standard Cholesky decomposition (LL^T) of a matrix and associated features
*
* \param MatrixType the type of the matrix of which we are computing the LL^T Cholesky decomposition
* \param UpLo the triangular part that will be used for the decompositon: Lower (default) or Upper.
* \
t
param
_
MatrixType the type of the matrix of which we are computing the LL^T Cholesky decomposition
* \
t
param
_
UpLo the triangular part that will be used for the decompositon: Lower (default) or Upper.
* The other triangular part won't be read.
*
* This class performs a LL^T Cholesky decomposition of a symmetric, positive definite
...
...
@@ -40,8 +40,10 @@ template<typename MatrixType, int UpLo> struct LLT_Traits;
*
* Example: \include LLT_example.cpp
* Output: \verbinclude LLT_example.out
*
* \sa MatrixBase::llt(), class LDLT
*
* This class supports the \link InplaceDecomposition inplace decomposition \endlink mechanism.
*
* \sa MatrixBase::llt(), SelfAdjointView::llt(), class LDLT
*/
/* HEY THIS DOX IS DISABLED BECAUSE THERE's A BUG EITHER HERE OR IN LDLT ABOUT THAT (OR BOTH)
* Note that during the decomposition, only the upper triangular part of A is considered. Therefore,
...
...
@@ -54,12 +56,12 @@ template<typename _MatrixType, int _UpLo> class LLT
enum
{
RowsAtCompileTime
=
MatrixType
::
RowsAtCompileTime
,
ColsAtCompileTime
=
MatrixType
::
ColsAtCompileTime
,
Options
=
MatrixType
::
Options
,
MaxColsAtCompileTime
=
MatrixType
::
MaxColsAtCompileTime
};
typedef
typename
MatrixType
::
Scalar
Scalar
;
typedef
typename
NumTraits
<
typename
MatrixType
::
Scalar
>::
Real
RealScalar
;
typedef
typename
MatrixType
::
Index
Index
;
typedef
Eigen
::
Index
Index
;
///< \deprecated since Eigen 3.3
typedef
typename
MatrixType
::
StorageIndex
StorageIndex
;
enum
{
PacketSize
=
internal
::
packet_traits
<
Scalar
>::
size
,
...
...
@@ -83,14 +85,30 @@ template<typename _MatrixType, int _UpLo> class LLT
* according to the specified problem \a size.
* \sa LLT()
*/
LLT
(
Index
size
)
:
m_matrix
(
size
,
size
),
explicit
LLT
(
Index
size
)
:
m_matrix
(
size
,
size
),
m_isInitialized
(
false
)
{}
LLT
(
const
MatrixType
&
matrix
)
template
<
typename
InputType
>
explicit
LLT
(
const
EigenBase
<
InputType
>&
matrix
)
:
m_matrix
(
matrix
.
rows
(),
matrix
.
cols
()),
m_isInitialized
(
false
)
{
compute
(
matrix
);
compute
(
matrix
.
derived
());
}
/** \brief Constructs a LDLT factorization from a given matrix
*
* This overloaded constructor is provided for \link InplaceDecomposition inplace decomposition \endlink when
* \c MatrixType is a Eigen::Ref.
*
* \sa LLT(const EigenBase&)
*/
template
<
typename
InputType
>
explicit
LLT
(
EigenBase
<
InputType
>&
matrix
)
:
m_matrix
(
matrix
.
derived
()),
m_isInitialized
(
false
)
{
compute
(
matrix
.
derived
());
}
/** \returns a view of the upper triangular matrix U */
...
...
@@ -115,33 +133,33 @@ template<typename _MatrixType, int _UpLo> class LLT
* Example: \include LLT_solve.cpp
* Output: \verbinclude LLT_solve.out
*
* \sa solveInPlace(), MatrixBase::llt()
* \sa solveInPlace(), MatrixBase::llt()
, SelfAdjointView::llt()
*/
template
<
typename
Rhs
>
inline
const
internal
::
solve_retval
<
LLT
,
Rhs
>
inline
const
Solve
<
LLT
,
Rhs
>
solve
(
const
MatrixBase
<
Rhs
>&
b
)
const
{
eigen_assert
(
m_isInitialized
&&
"LLT is not initialized."
);
eigen_assert
(
m_matrix
.
rows
()
==
b
.
rows
()
&&
"LLT::solve(): invalid number of rows of the right hand side matrix b"
);
return
internal
::
solve_retval
<
LLT
,
Rhs
>
(
*
this
,
b
.
derived
());
return
Solve
<
LLT
,
Rhs
>
(
*
this
,
b
.
derived
());
}
#ifdef EIGEN2_SUPPORT
template
<
typename
OtherDerived
,
typename
ResultType
>
bool
solve
(
const
MatrixBase
<
OtherDerived
>&
b
,
ResultType
*
result
)
const
{
*
result
=
this
->
solve
(
b
);
return
true
;
}
bool
isPositiveDefinite
()
const
{
return
true
;
}
#endif
template
<
typename
Derived
>
void
solveInPlace
(
MatrixBase
<
Derived
>
&
bAndX
)
const
;
LLT
&
compute
(
const
MatrixType
&
matrix
);
template
<
typename
InputType
>
LLT
&
compute
(
const
EigenBase
<
InputType
>&
matrix
);
/** \returns an estimate of the reciprocal condition number of the matrix of
* which \c *this is the Cholesky decomposition.
*/
RealScalar
rcond
()
const
{
eigen_assert
(
m_isInitialized
&&
"LLT is not initialized."
);
eigen_assert
(
m_info
==
Success
&&
"LLT failed because matrix appears to be negative"
);
return
internal
::
rcond_estimate_helper
(
m_l1_norm
,
*
this
);
}
/** \returns the LLT decomposition matrix
*
...
...
@@ -167,24 +185,38 @@ template<typename _MatrixType, int _UpLo> class LLT
return
m_info
;
}
/** \returns the adjoint of \c *this, that is, a const reference to the decomposition itself as the underlying matrix is self-adjoint.
*
* This method is provided for compatibility with other matrix decompositions, thus enabling generic code such as:
* \code x = decomposition.adjoint().solve(b) \endcode
*/
const
LLT
&
adjoint
()
const
{
return
*
this
;
};
inline
Index
rows
()
const
{
return
m_matrix
.
rows
();
}
inline
Index
cols
()
const
{
return
m_matrix
.
cols
();
}
template
<
typename
VectorType
>
LLT
rankUpdate
(
const
VectorType
&
vec
,
const
RealScalar
&
sigma
=
1
);
#ifndef EIGEN_PARSED_BY_DOXYGEN
template
<
typename
RhsType
,
typename
DstType
>
EIGEN_DEVICE_FUNC
void
_solve_impl
(
const
RhsType
&
rhs
,
DstType
&
dst
)
const
;
#endif
protected
:
static
void
check_template_parameters
()
{
EIGEN_STATIC_ASSERT_NON_INTEGER
(
Scalar
);
}
/** \internal
* Used to compute and store L
* The strict upper part is not used and even not initialized.
*/
MatrixType
m_matrix
;
RealScalar
m_l1_norm
;
bool
m_isInitialized
;
ComputationInfo
m_info
;
};
...
...
@@ -194,12 +226,11 @@ namespace internal {
template
<
typename
Scalar
,
int
UpLo
>
struct
llt_inplace
;
template
<
typename
MatrixType
,
typename
VectorType
>
static
typename
MatrixType
::
Index
llt_rank_update_lower
(
MatrixType
&
mat
,
const
VectorType
&
vec
,
const
typename
MatrixType
::
RealScalar
&
sigma
)
static
Index
llt_rank_update_lower
(
MatrixType
&
mat
,
const
VectorType
&
vec
,
const
typename
MatrixType
::
RealScalar
&
sigma
)
{
using
std
::
sqrt
;
typedef
typename
MatrixType
::
Scalar
Scalar
;
typedef
typename
MatrixType
::
RealScalar
RealScalar
;
typedef
typename
MatrixType
::
Index
Index
;
typedef
typename
MatrixType
::
ColXpr
ColXpr
;
typedef
typename
internal
::
remove_all
<
ColXpr
>::
type
ColXprCleaned
;
typedef
typename
ColXprCleaned
::
SegmentReturnType
ColXprSegment
;
...
...
@@ -268,11 +299,10 @@ template<typename Scalar> struct llt_inplace<Scalar, Lower>
{
typedef
typename
NumTraits
<
Scalar
>::
Real
RealScalar
;
template
<
typename
MatrixType
>
static
typename
MatrixType
::
Index
unblocked
(
MatrixType
&
mat
)
static
Index
unblocked
(
MatrixType
&
mat
)
{
using
std
::
sqrt
;
typedef
typename
MatrixType
::
Index
Index
;
eigen_assert
(
mat
.
rows
()
==
mat
.
cols
());
const
Index
size
=
mat
.
rows
();
for
(
Index
k
=
0
;
k
<
size
;
++
k
)
...
...
@@ -295,9 +325,8 @@ template<typename Scalar> struct llt_inplace<Scalar, Lower>
}
template
<
typename
MatrixType
>
static
typename
MatrixType
::
Index
blocked
(
MatrixType
&
m
)
static
Index
blocked
(
MatrixType
&
m
)
{
typedef
typename
MatrixType
::
Index
Index
;
eigen_assert
(
m
.
rows
()
==
m
.
cols
());
Index
size
=
m
.
rows
();
if
(
size
<
32
)
...
...
@@ -322,36 +351,36 @@ template<typename Scalar> struct llt_inplace<Scalar, Lower>
Index
ret
;
if
((
ret
=
unblocked
(
A11
))
>=
0
)
return
k
+
ret
;
if
(
rs
>
0
)
A11
.
adjoint
().
template
triangularView
<
Upper
>().
template
solveInPlace
<
OnTheRight
>(
A21
);
if
(
rs
>
0
)
A22
.
template
selfadjointView
<
Lower
>().
rankUpdate
(
A21
,
-
1
);
// bottleneck
if
(
rs
>
0
)
A22
.
template
selfadjointView
<
Lower
>().
rankUpdate
(
A21
,
typename
NumTraits
<
RealScalar
>::
Literal
(
-
1
)
)
;
// bottleneck
}
return
-
1
;
}
template
<
typename
MatrixType
,
typename
VectorType
>
static
typename
MatrixType
::
Index
rankUpdate
(
MatrixType
&
mat
,
const
VectorType
&
vec
,
const
RealScalar
&
sigma
)
static
Index
rankUpdate
(
MatrixType
&
mat
,
const
VectorType
&
vec
,
const
RealScalar
&
sigma
)
{
return
Eigen
::
internal
::
llt_rank_update_lower
(
mat
,
vec
,
sigma
);
}
};
template
<
typename
Scalar
>
struct
llt_inplace
<
Scalar
,
Upper
>
{
typedef
typename
NumTraits
<
Scalar
>::
Real
RealScalar
;
template
<
typename
MatrixType
>
static
EIGEN_STRONG_INLINE
typename
MatrixType
::
Index
unblocked
(
MatrixType
&
mat
)
static
EIGEN_STRONG_INLINE
Index
unblocked
(
MatrixType
&
mat
)
{
Transpose
<
MatrixType
>
matt
(
mat
);
return
llt_inplace
<
Scalar
,
Lower
>::
unblocked
(
matt
);
}
template
<
typename
MatrixType
>
static
EIGEN_STRONG_INLINE
typename
MatrixType
::
Index
blocked
(
MatrixType
&
mat
)
static
EIGEN_STRONG_INLINE
Index
blocked
(
MatrixType
&
mat
)
{
Transpose
<
MatrixType
>
matt
(
mat
);
return
llt_inplace
<
Scalar
,
Lower
>::
blocked
(
matt
);
}
template
<
typename
MatrixType
,
typename
VectorType
>
static
typename
MatrixType
::
Index
rankUpdate
(
MatrixType
&
mat
,
const
VectorType
&
vec
,
const
RealScalar
&
sigma
)
static
Index
rankUpdate
(
MatrixType
&
mat
,
const
VectorType
&
vec
,
const
RealScalar
&
sigma
)
{
Transpose
<
MatrixType
>
matt
(
mat
);
return
llt_inplace
<
Scalar
,
Lower
>::
rankUpdate
(
matt
,
vec
.
conjugate
(),
sigma
);
...
...
@@ -362,8 +391,8 @@ template<typename MatrixType> struct LLT_Traits<MatrixType,Lower>
{
typedef
const
TriangularView
<
const
MatrixType
,
Lower
>
MatrixL
;
typedef
const
TriangularView
<
const
typename
MatrixType
::
AdjointReturnType
,
Upper
>
MatrixU
;
static
inline
MatrixL
getL
(
const
MatrixType
&
m
)
{
return
m
;
}
static
inline
MatrixU
getU
(
const
MatrixType
&
m
)
{
return
m
.
adjoint
();
}
static
inline
MatrixL
getL
(
const
MatrixType
&
m
)
{
return
MatrixL
(
m
)
;
}
static
inline
MatrixU
getU
(
const
MatrixType
&
m
)
{
return
MatrixU
(
m
.
adjoint
()
)
;
}
static
bool
inplace_decomposition
(
MatrixType
&
m
)
{
return
llt_inplace
<
typename
MatrixType
::
Scalar
,
Lower
>::
blocked
(
m
)
==-
1
;
}
};
...
...
@@ -372,8 +401,8 @@ template<typename MatrixType> struct LLT_Traits<MatrixType,Upper>
{
typedef
const
TriangularView
<
const
typename
MatrixType
::
AdjointReturnType
,
Lower
>
MatrixL
;
typedef
const
TriangularView
<
const
MatrixType
,
Upper
>
MatrixU
;
static
inline
MatrixL
getL
(
const
MatrixType
&
m
)
{
return
m
.
adjoint
();
}
static
inline
MatrixU
getU
(
const
MatrixType
&
m
)
{
return
m
;
}
static
inline
MatrixL
getL
(
const
MatrixType
&
m
)
{
return
MatrixL
(
m
.
adjoint
()
)
;
}
static
inline
MatrixU
getU
(
const
MatrixType
&
m
)
{
return
MatrixU
(
m
)
;
}
static
bool
inplace_decomposition
(
MatrixType
&
m
)
{
return
llt_inplace
<
typename
MatrixType
::
Scalar
,
Upper
>::
blocked
(
m
)
==-
1
;
}
};
...
...
@@ -388,14 +417,28 @@ template<typename MatrixType> struct LLT_Traits<MatrixType,Upper>
* Output: \verbinclude TutorialLinAlgComputeTwice.out
*/
template
<
typename
MatrixType
,
int
_UpLo
>
LLT
<
MatrixType
,
_UpLo
>&
LLT
<
MatrixType
,
_UpLo
>::
compute
(
const
MatrixType
&
a
)
template
<
typename
InputType
>
LLT
<
MatrixType
,
_UpLo
>&
LLT
<
MatrixType
,
_UpLo
>::
compute
(
const
EigenBase
<
InputType
>&
a
)
{
check_template_parameters
();
eigen_assert
(
a
.
rows
()
==
a
.
cols
());
const
Index
size
=
a
.
rows
();
m_matrix
.
resize
(
size
,
size
);
m_matrix
=
a
;
m_matrix
=
a
.
derived
();
// Compute matrix L1 norm = max abs column sum.
m_l1_norm
=
RealScalar
(
0
);
// TODO move this code to SelfAdjointView
for
(
Index
col
=
0
;
col
<
size
;
++
col
)
{
RealScalar
abs_col_sum
;
if
(
_UpLo
==
Lower
)
abs_col_sum
=
m_matrix
.
col
(
col
).
tail
(
size
-
col
).
template
lpNorm
<
1
>()
+
m_matrix
.
row
(
col
).
head
(
col
).
template
lpNorm
<
1
>();
else
abs_col_sum
=
m_matrix
.
col
(
col
).
head
(
col
).
template
lpNorm
<
1
>()
+
m_matrix
.
row
(
col
).
tail
(
size
-
col
).
template
lpNorm
<
1
>();
if
(
abs_col_sum
>
m_l1_norm
)
m_l1_norm
=
abs_col_sum
;
}
m_isInitialized
=
true
;
bool
ok
=
Traits
::
inplace_decomposition
(
m_matrix
);
...
...
@@ -423,33 +466,24 @@ LLT<_MatrixType,_UpLo> LLT<_MatrixType,_UpLo>::rankUpdate(const VectorType& v, c
return
*
this
;
}
namespace
internal
{
template
<
typename
_MatrixType
,
int
UpLo
,
typename
Rhs
>
struct
solve_retval
<
LLT
<
_MatrixType
,
UpLo
>
,
Rhs
>
:
solve_retval_base
<
LLT
<
_MatrixType
,
UpLo
>
,
Rhs
>
{
typedef
LLT
<
_MatrixType
,
UpLo
>
LLTType
;
EIGEN_MAKE_SOLVE_HELPERS
(
LLTType
,
Rhs
)
template
<
typename
Dest
>
void
evalTo
(
Dest
&
dst
)
const
{
dst
=
rhs
();
dec
().
solveInPlace
(
dst
);
}
};
#ifndef EIGEN_PARSED_BY_DOXYGEN
template
<
typename
_MatrixType
,
int
_UpLo
>
template
<
typename
RhsType
,
typename
DstType
>
void
LLT
<
_MatrixType
,
_UpLo
>::
_solve_impl
(
const
RhsType
&
rhs
,
DstType
&
dst
)
const
{
dst
=
rhs
;
solveInPlace
(
dst
);
}
#endif
/** \internal use x = llt_object.solve(x);
*
*
* This is the \em in-place version of solve().
*
* \param bAndX represents both the right-hand side matrix b and result x.
*
* \returns true always! If you need to check for existence of solutions, use another decomposition like LU, QR, or SVD.
*
* This version avoids a copy when the right hand side matrix b is not
* needed anymore.
* This version avoids a copy when the right hand side matrix b is not needed anymore.
*
* \sa LLT::solve(), MatrixBase::llt()
*/
...
...
@@ -475,6 +509,7 @@ MatrixType LLT<MatrixType,_UpLo>::reconstructedMatrix() const
/** \cholesky_module
* \returns the LLT decomposition of \c *this
* \sa SelfAdjointView::llt()
*/
template
<
typename
Derived
>
inline
const
LLT
<
typename
MatrixBase
<
Derived
>::
PlainObject
>
...
...
@@ -485,6 +520,7 @@ MatrixBase<Derived>::llt() const
/** \cholesky_module
* \returns the LLT decomposition of \c *this
* \sa SelfAdjointView::llt()
*/
template
<
typename
MatrixType
,
unsigned
int
UpLo
>
inline
const
LLT
<
typename
SelfAdjointView
<
MatrixType
,
UpLo
>::
PlainObject
,
UpLo
>
...
...
external/eigen3/Eigen/src/Cholesky/LLT_
MKL
.h
→
external/eigen3/Eigen/src/Cholesky/LLT_
LAPACKE
.h
View file @
a394b22a
...
...
@@ -25,41 +25,38 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
********************************************************************************
* Content : Eigen bindings to
Intel(R) MKL
* Content : Eigen bindings to
LAPACKe
* LLt decomposition based on LAPACKE_?potrf function.
********************************************************************************
*/
#ifndef EIGEN_LLT_MKL_H
#define EIGEN_LLT_MKL_H
#include
"Eigen/src/Core/util/MKL_support.h"
#include
<iostream>
#ifndef EIGEN_LLT_LAPACKE_H
#define EIGEN_LLT_LAPACKE_H
namespace
Eigen
{
namespace
internal
{
template
<
typename
Scalar
>
struct
mkl
_llt
;
template
<
typename
Scalar
>
struct
lapacke
_llt
;
#define EIGEN_
MKL
_LLT(EIGTYPE,
MKL
TYPE,
MKL
PREFIX) \
template<> struct
mkl
_llt<EIGTYPE> \
#define EIGEN_
LAPACKE
_LLT(EIGTYPE,
BLAS
TYPE,
LAPACKE_
PREFIX) \
template<> struct
lapacke
_llt<EIGTYPE> \
{ \
template<typename MatrixType> \
static inline
typename MatrixType::
Index potrf(MatrixType& m, char uplo) \
static inline Index potrf(MatrixType& m, char uplo) \
{ \
lapack_int matrix_order; \
lapack_int size, lda, info, StorageOrder; \
EIGTYPE* a; \
eigen_assert(m.rows()==m.cols()); \
/* Set up parameters for ?potrf */
\
size = m.rows(); \
size =
convert_index<lapack_int>(
m.rows()
)
; \
StorageOrder = MatrixType::Flags&RowMajorBit?RowMajor:ColMajor; \
matrix_order = StorageOrder==RowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \
a = &(m.coeffRef(0,0)); \
lda = m.outerStride(); \
lda =
convert_index<lapack_int>(
m.outerStride()
)
; \
\
info = LAPACKE_##
MKL
PREFIX##potrf( matrix_order, uplo, size, (
MKL
TYPE*)a, lda ); \
info = LAPACKE_##
LAPACKE_
PREFIX##potrf( matrix_order, uplo, size, (
BLAS
TYPE*)a, lda ); \
info = (info==0) ? -1 : info>0 ? info-1 : size; \
return info; \
} \
...
...
@@ -67,36 +64,36 @@ template<> struct mkl_llt<EIGTYPE> \
template<> struct llt_inplace<EIGTYPE, Lower> \
{ \
template<typename MatrixType> \
static
typename MatrixType::
Index blocked(MatrixType& m) \
static Index blocked(MatrixType& m) \
{ \
return
mkl
_llt<EIGTYPE>::potrf(m, 'L'); \
return
lapacke
_llt<EIGTYPE>::potrf(m, 'L'); \
} \
template<typename MatrixType, typename VectorType> \
static
typename MatrixType::
Index rankUpdate(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) \
static Index rankUpdate(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) \
{ return Eigen::internal::llt_rank_update_lower(mat, vec, sigma); } \
}; \
template<> struct llt_inplace<EIGTYPE, Upper> \
{ \
template<typename MatrixType> \
static
typename MatrixType::
Index blocked(MatrixType& m) \
static Index blocked(MatrixType& m) \
{ \
return
mkl
_llt<EIGTYPE>::potrf(m, 'U'); \
return
lapacke
_llt<EIGTYPE>::potrf(m, 'U'); \
} \
template<typename MatrixType, typename VectorType> \
static
typename MatrixType::
Index rankUpdate(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) \
static Index rankUpdate(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) \
{ \
Transpose<MatrixType> matt(mat); \
return llt_inplace<EIGTYPE, Lower>::rankUpdate(matt, vec.conjugate(), sigma); \
} \
};
EIGEN_
MKL
_LLT
(
double
,
double
,
d
)
EIGEN_
MKL
_LLT
(
float
,
float
,
s
)
EIGEN_
MKL
_LLT
(
dcomplex
,
MKL_Complex16
,
z
)
EIGEN_
MKL
_LLT
(
scomplex
,
MKL_Complex8
,
c
)
EIGEN_
LAPACKE
_LLT
(
double
,
double
,
d
)
EIGEN_
LAPACKE
_LLT
(
float
,
float
,
s
)
EIGEN_
LAPACKE
_LLT
(
dcomplex
,
lapack_complex_double
,
z
)
EIGEN_
LAPACKE
_LLT
(
scomplex
,
lapack_complex_float
,
c
)
}
// end namespace internal
}
// end namespace Eigen
#endif // EIGEN_LLT_
MKL
_H
#endif // EIGEN_LLT_
LAPACKE
_H
Prev
1
2
3
4
5
6
7
…
10
Next