19 template<
typename _MatrixType,
int _UpLo>
struct traits<
LDLT<_MatrixType, _UpLo> >
59 template<
typename _MatrixType,
int _UpLo>
class LDLT 69 MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
70 MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
89 m_isInitialized(false)
99 : m_matrix(size, size),
100 m_transpositions(size),
103 m_isInitialized(false)
112 template<
typename InputType>
114 : m_matrix(matrix.
rows(), matrix.
cols()),
115 m_transpositions(matrix.
rows()),
116 m_temporary(matrix.
rows()),
118 m_isInitialized(false)
129 template<
typename InputType>
131 : m_matrix(matrix.derived()),
132 m_transpositions(matrix.
rows()),
133 m_temporary(matrix.
rows()),
135 m_isInitialized(false)
145 m_isInitialized =
false;
149 inline typename Traits::MatrixU
matrixU()
const 151 eigen_assert(m_isInitialized &&
"LDLT is not initialized.");
152 return Traits::getU(m_matrix);
156 inline typename Traits::MatrixL
matrixL()
const 158 eigen_assert(m_isInitialized &&
"LDLT is not initialized.");
159 return Traits::getL(m_matrix);
166 eigen_assert(m_isInitialized &&
"LDLT is not initialized.");
167 return m_transpositions;
173 eigen_assert(m_isInitialized &&
"LDLT is not initialized.");
174 return m_matrix.diagonal();
180 eigen_assert(m_isInitialized &&
"LDLT is not initialized.");
187 eigen_assert(m_isInitialized &&
"LDLT is not initialized.");
191 #ifdef EIGEN_PARSED_BY_DOXYGEN 207 template<
typename Rhs>
212 template<
typename Derived>
215 template<
typename InputType>
223 eigen_assert(m_isInitialized &&
"LDLT is not initialized.");
227 template <
typename Derived>
236 eigen_assert(m_isInitialized &&
"LDLT is not initialized.");
240 MatrixType reconstructedMatrix()
const;
259 eigen_assert(m_isInitialized &&
"LDLT is not initialized.");
263 #ifndef EIGEN_PARSED_BY_DOXYGEN 264 template<
typename RhsType,
typename DstType>
265 void _solve_impl(
const RhsType &rhs, DstType &dst)
const;
267 template<
bool Conjugate,
typename RhsType,
typename DstType>
268 void _solve_impl_transposed(
const RhsType &rhs, DstType &dst)
const;
299 template<
typename MatrixType,
typename TranspositionType,
typename Workspace>
305 typedef typename TranspositionType::StorageIndex IndexType;
308 bool found_zero_pivot =
false;
313 transpositions.setIdentity();
324 Index index_of_biggest_in_corner;
325 mat.diagonal().tail(size-k).cwiseAbs().maxCoeff(&index_of_biggest_in_corner);
326 index_of_biggest_in_corner += k;
328 transpositions.coeffRef(k) = IndexType(index_of_biggest_in_corner);
329 if(k != index_of_biggest_in_corner)
333 Index s = size-index_of_biggest_in_corner-1;
334 mat.row(k).head(k).swap(mat.row(index_of_biggest_in_corner).head(k));
335 mat.col(k).tail(s).swap(mat.col(index_of_biggest_in_corner).tail(s));
336 std::swap(mat.coeffRef(k,k),mat.coeffRef(index_of_biggest_in_corner,index_of_biggest_in_corner));
337 for(
Index i=k+1;
i<index_of_biggest_in_corner;++
i)
339 Scalar tmp = mat.coeffRef(
i,k);
340 mat.coeffRef(
i,k) =
numext::conj(mat.coeffRef(index_of_biggest_in_corner,
i));
341 mat.coeffRef(index_of_biggest_in_corner,
i) =
numext::conj(tmp);
344 mat.coeffRef(index_of_biggest_in_corner,k) =
numext::conj(mat.coeff(index_of_biggest_in_corner,k));
351 Index rs = size - k - 1;
358 temp.head(k) = mat.diagonal().real().head(k).asDiagonal() * A10.adjoint();
359 mat.coeffRef(k,k) -= (A10 * temp.head(k)).
value();
361 A21.noalias() -= A20 * temp.head(k);
371 if(k==0 && !pivot_is_valid)
378 transpositions.coeffRef(
j) = IndexType(
j);
379 ret = ret && (mat.col(
j).tail(size-
j-1).array()==
Scalar(0)).
all();
384 if((rs>0) && pivot_is_valid)
387 ret = ret && (A21.array()==
Scalar(0)).
all();
389 if(found_zero_pivot && pivot_is_valid) ret =
false;
390 else if(!pivot_is_valid) found_zero_pivot =
true;
393 if (realAkk < static_cast<RealScalar>(0)) sign =
Indefinite;
395 if (realAkk > static_cast<RealScalar>(0)) sign =
Indefinite;
412 template<
typename MatrixType,
typename WDerived>
422 RealScalar
alpha = 1;
433 Scalar wj = w.coeff(
j);
435 RealScalar gamma = dj*alpha + swj2;
437 mat.coeffRef(
j,
j) += swj2/
alpha;
443 w.
tail(rs) -= wj * mat.col(j).tail(rs);
450 template<
typename MatrixType,
typename TranspositionType,
typename Workspace,
typename WType>
454 tmp = transpositions *
w;
462 template<
typename MatrixType,
typename TranspositionType,
typename Workspace>
469 template<
typename MatrixType,
typename TranspositionType,
typename Workspace,
typename WType>
497 template<
typename MatrixType,
int _UpLo>
498 template<
typename InputType>
501 check_template_parameters();
514 abs_col_sum = m_matrix.col(
col).tail(size -
col).template lpNorm<1>() + m_matrix.row(
col).head(
col).template lpNorm<1>();
516 abs_col_sum = m_matrix.col(
col).head(
col).template lpNorm<1>() + m_matrix.row(
col).tail(size -
col).template lpNorm<1>();
517 if (abs_col_sum > m_l1_norm)
518 m_l1_norm = abs_col_sum;
521 m_transpositions.resize(size);
522 m_isInitialized =
false;
523 m_temporary.resize(size);
528 m_isInitialized =
true;
537 template<
typename MatrixType,
int _UpLo>
538 template<
typename Derived>
549 m_matrix.resize(size,size);
551 m_transpositions.resize(size);
553 m_transpositions.coeffRef(
i) = IndexType(
i);
554 m_temporary.resize(size);
556 m_isInitialized =
true;
564 #ifndef EIGEN_PARSED_BY_DOXYGEN 565 template<
typename _MatrixType,
int _UpLo>
566 template<
typename RhsType,
typename DstType>
569 _solve_impl_transposed<true>(rhs, dst);
572 template<
typename _MatrixType,
int _UpLo>
573 template<
bool Conjugate,
typename RhsType,
typename DstType>
577 dst = m_transpositions * rhs;
581 matrixL().template conjugateIf<!Conjugate>().solveInPlace(dst);
596 for (
Index i = 0;
i < vecD.size(); ++
i)
598 if(
abs(vecD(
i)) > tolerance)
599 dst.row(
i) /= vecD(
i);
601 dst.row(
i).setZero();
606 matrixL().transpose().template conjugateIf<Conjugate>().solveInPlace(dst);
610 dst = m_transpositions.transpose() * dst;
627 template<
typename MatrixType,
int _UpLo>
628 template<
typename Derived>
631 eigen_assert(m_isInitialized &&
"LDLT is not initialized.");
634 bAndX = this->solve(bAndX);
642 template<
typename MatrixType,
int _UpLo>
645 eigen_assert(m_isInitialized &&
"LDLT is not initialized.");
651 res = transpositionsP() *
res;
653 res = matrixU() *
res;
655 res = vectorD().real().asDiagonal() *
res;
657 res = matrixL() *
res;
659 res = transpositionsP().transpose() *
res;
668 template<
typename MatrixType,
unsigned int UpLo>
679 template<
typename Derived>
688 #endif // EIGEN_LDLT_H
ComputationInfo info() const
Reports whether previous computation was successful.
Robust Cholesky decomposition of a matrix with pivoting.
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
static void check_template_parameters()
const LDLT< PlainObject, UpLo > ldlt() const
#define EIGEN_STRONG_INLINE
TranspositionType m_transpositions
static bool update(MatrixType &mat, const TranspositionType &transpositions, Workspace &tmp, const WType &w, const typename MatrixType::RealScalar &sigma=1)
static const Eigen::internal::all_t all
LDLT & compute(const EigenBase< InputType > &matrix)
const TranspositionType & transpositionsP() const
internal::traits< LDLT< _MatrixType, _UpLo > >::Scalar Scalar
Traits::MatrixU matrixU() const
void _solve_impl_transposed(const RhsType &rhs, DstType &dst) const
Expression of the transpose of a matrix.
LDLT(Index size)
Default Constructor with memory preallocation.
Matrix< Scalar, RowsAtCompileTime, 1, 0, MaxRowsAtCompileTime, 1 > TmpMatrixType
Namespace containing all symbols from the Eigen library.
LDLT & rankUpdate(const MatrixBase< Derived > &w, const RealScalar &alpha=1)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
static bool updateInPlace(MatrixType &mat, MatrixBase< WDerived > &w, const typename MatrixType::RealScalar &sigma=1)
Decomposition::RealScalar rcond_estimate_helper(typename Decomposition::RealScalar matrix_norm, const Decomposition &dec)
Reciprocal condition number estimator.
Eigen::Index Index
The interface type of indices.
void _solve_impl(const RhsType &rhs, DstType &dst) const
Traits::MatrixL matrixL() const
bool isNegative(void) const
AnnoyingScalar conj(const AnnoyingScalar &x)
Diagonal< const MatrixType > vectorD() const
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
internal::SignMatrix m_sign
static EIGEN_STRONG_INLINE bool update(MatrixType &mat, TranspositionType &transpositions, Workspace &tmp, WType &w, const typename MatrixType::RealScalar &sigma=1)
LDLT()
Default Constructor.
SolverStorage StorageKind
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
LDLT(const EigenBase< InputType > &matrix)
Constructor with decomposition.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool() isfinite(const Eigen::bfloat16 &h)
const TriangularView< const typename MatrixType::AdjointReturnType, UnitLower > MatrixL
EIGEN_DEVICE_FUNC const SignReturnType sign() const
#define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE)
const TriangularView< const MatrixType, UnitLower > MatrixL
Transpositions< RowsAtCompileTime, MaxRowsAtCompileTime > TranspositionType
bool solveInPlace(MatrixBase< Derived > &bAndX) const
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
NumTraits< Scalar >::Real RealScalar
static MatrixL getL(const MatrixType &m)
internal::LDLT_Traits< MatrixType, UpLo > Traits
static MatrixU getU(const MatrixType &m)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE FixedSegmentReturnType< internal::get_fixed_value< NType >::value >::Type tail(NType n)
void swap(GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &a, GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &b)
const LDLT & adjoint() const
const LDLT< PlainObject > ldlt() const
static EIGEN_STRONG_INLINE bool unblocked(MatrixType &mat, TranspositionType &transpositions, Workspace &temp, SignMatrix &sign)
IndicesType::Scalar StorageIndex
TmpMatrixType m_temporary
EIGEN_CONSTEXPR Index size(const T &x)
#define EIGEN_DEVICE_FUNC
static MatrixU getU(const MatrixType &m)
const MatrixType & matrixLDLT() const
Expression of a fixed-size or dynamic-size block.
Expression of a triangular part in a matrix.
MatrixType reconstructedMatrix() const
static const double sigma
const TriangularView< const MatrixType, UnitUpper > MatrixU
const TriangularView< const typename MatrixType::AdjointReturnType, UnitUpper > MatrixU
Expression of a diagonal/subdiagonal/superdiagonal in a matrix.
Pseudo expression representing a solving operation.
EIGEN_DONT_INLINE void compute(Solver &solver, const MatrixType &A)
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
static bool unblocked(MatrixType &mat, TranspositionType &transpositions, Workspace &temp, SignMatrix &sign)
LDLT(EigenBase< InputType > &matrix)
Constructs a LDLT factorization from a given matrix.
A base class for matrix decomposition and solvers.
EIGEN_DEVICE_FUNC bool abs2(bool x)
EIGEN_DEVICE_FUNC Derived & derived()
Base class for all dense matrices, vectors, and expressions.
PermutationMatrix< RowsAtCompileTime, MaxRowsAtCompileTime > PermutationType
static MatrixL getL(const MatrixType &m)