16 template<
typename MatrixType,
int UpLo>
struct LLT_Traits;
50 template<
typename _MatrixType,
int _UpLo>
class LLT 53 typedef _MatrixType MatrixType;
55 RowsAtCompileTime = MatrixType::RowsAtCompileTime,
56 ColsAtCompileTime = MatrixType::ColsAtCompileTime,
58 MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
62 typedef typename MatrixType::Index Index;
66 AlignmentMask = int(PacketSize)-1,
78 LLT() : m_matrix(), m_isInitialized(false) {}
87 m_isInitialized(false) {}
89 LLT(
const MatrixType& matrix)
90 : m_matrix(matrix.rows(), matrix.cols()),
91 m_isInitialized(
false)
97 inline typename Traits::MatrixU
matrixU()
const 99 eigen_assert(m_isInitialized &&
"LLT is not initialized.");
100 return Traits::getU(m_matrix);
104 inline typename Traits::MatrixL
matrixL()
const 106 eigen_assert(m_isInitialized &&
"LLT is not initialized.");
107 return Traits::getL(m_matrix);
120 template<
typename Rhs>
124 eigen_assert(m_isInitialized &&
"LLT is not initialized.");
125 eigen_assert(m_matrix.rows()==b.rows()
126 &&
"LLT::solve(): invalid number of rows of the right hand side matrix b");
130 #ifdef EIGEN2_SUPPORT 131 template<
typename OtherDerived,
typename ResultType>
134 *result = this->solve(b);
141 template<
typename Derived>
144 LLT& compute(
const MatrixType& matrix);
152 eigen_assert(m_isInitialized &&
"LLT is not initialized.");
156 MatrixType reconstructedMatrix()
const;
166 eigen_assert(m_isInitialized &&
"LLT is not initialized.");
170 inline Index rows()
const {
return m_matrix.rows(); }
171 inline Index cols()
const {
return m_matrix.cols(); }
173 template<
typename VectorType>
174 LLT rankUpdate(
const VectorType& vec,
const RealScalar& sigma = 1);
178 static void check_template_parameters()
180 EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
188 bool m_isInitialized;
196 template<
typename MatrixType,
typename VectorType>
197 static typename MatrixType::Index llt_rank_update_lower(
MatrixType& mat,
const VectorType& vec,
const typename MatrixType::RealScalar& sigma)
201 typedef typename MatrixType::RealScalar RealScalar;
202 typedef typename MatrixType::Index Index;
203 typedef typename MatrixType::ColXpr ColXpr;
205 typedef typename ColXprCleaned::SegmentReturnType ColXprSegment;
207 typedef typename TempVectorType::SegmentReturnType TempVecSegment;
209 Index n = mat.cols();
210 eigen_assert(mat.rows()==n && vec.size()==n);
219 temp = sqrt(sigma) * vec;
221 for(Index i=0; i<n; ++i)
229 ColXprSegment x(mat.col(i).tail(rs));
230 TempVecSegment y(temp.tail(rs));
231 apply_rotation_in_the_plane(x, y, g);
239 for(Index j=0; j<n; ++j)
241 RealScalar Ljj = numext::real(mat.coeff(j,j));
242 RealScalar dj = numext::abs2(Ljj);
243 Scalar wj = temp.coeff(j);
244 RealScalar swj2 = sigma*numext::abs2(wj);
245 RealScalar gamma = dj*beta + swj2;
247 RealScalar x = dj + swj2/beta;
248 if (x<=RealScalar(0))
250 RealScalar nLjj = sqrt(x);
251 mat.coeffRef(j,j) = nLjj;
258 temp.tail(rs) -= (wj/Ljj) * mat.col(j).tail(rs);
260 mat.col(j).tail(rs) = (nLjj/Ljj) * mat.col(j).tail(rs) + (nLjj * sigma*numext::conj(wj)/gamma)*temp.tail(rs);
270 template<
typename MatrixType>
271 static typename MatrixType::Index unblocked(
MatrixType& mat)
274 typedef typename MatrixType::Index Index;
276 eigen_assert(mat.rows()==mat.cols());
277 const Index
size = mat.rows();
278 for(Index k = 0; k <
size; ++k)
286 RealScalar x = numext::real(mat.coeff(k,k));
287 if (k>0) x -= A10.squaredNorm();
288 if (x<=RealScalar(0))
290 mat.coeffRef(k,k) = x = sqrt(x);
291 if (k>0 && rs>0) A21.noalias() -= A20 * A10.adjoint();
297 template<
typename MatrixType>
298 static typename MatrixType::Index blocked(
MatrixType& m)
300 typedef typename MatrixType::Index Index;
301 eigen_assert(m.rows()==m.cols());
302 Index
size = m.rows();
306 Index blockSize = size/8;
307 blockSize = (blockSize/16)*16;
308 blockSize = (std::min)((std::max)(blockSize,Index(8)), Index(128));
310 for (Index k=0; k<
size; k+=blockSize)
316 Index bs = (std::min)(blockSize, size-k);
317 Index rs = size - k - bs;
323 if((ret=unblocked(A11))>=0)
return k+ret;
324 if(rs>0) A11.adjoint().template triangularView<Upper>().
template solveInPlace<OnTheRight>(A21);
325 if(rs>0) A22.template selfadjointView<Lower>().rankUpdate(A21,-1);
330 template<
typename MatrixType,
typename VectorType>
331 static typename MatrixType::Index rankUpdate(
MatrixType& mat,
const VectorType& vec,
const RealScalar& sigma)
333 return Eigen::internal::llt_rank_update_lower(mat, vec, sigma);
341 template<
typename MatrixType>
342 static EIGEN_STRONG_INLINE
typename MatrixType::Index unblocked(
MatrixType& mat)
347 template<
typename MatrixType>
348 static EIGEN_STRONG_INLINE
typename MatrixType::Index blocked(
MatrixType& mat)
353 template<
typename MatrixType,
typename VectorType>
354 static typename MatrixType::Index rankUpdate(
MatrixType& mat,
const VectorType& vec,
const RealScalar& sigma)
365 static inline MatrixL getL(
const MatrixType& m) {
return m; }
366 static inline MatrixU getU(
const MatrixType& m) {
return m.adjoint(); }
367 static bool inplace_decomposition(
MatrixType& m)
375 static inline MatrixL getL(
const MatrixType& m) {
return m.adjoint(); }
376 static inline MatrixU getU(
const MatrixType& m) {
return m; }
377 static bool inplace_decomposition(
MatrixType& m)
390 template<
typename MatrixType,
int _UpLo>
393 check_template_parameters();
395 eigen_assert(a.rows()==a.cols());
396 const Index
size = a.rows();
397 m_matrix.resize(size, size);
400 m_isInitialized =
true;
401 bool ok = Traits::inplace_decomposition(m_matrix);
412 template<
typename _MatrixType,
int _UpLo>
413 template<
typename VectorType>
417 eigen_assert(v.size()==m_matrix.cols());
418 eigen_assert(m_isInitialized);
428 template<
typename _MatrixType,
int UpLo,
typename Rhs>
433 EIGEN_MAKE_SOLVE_HELPERS(LLTType,Rhs)
435 template<
typename Dest>
void evalTo(Dest& dst)
const 438 dec().solveInPlace(dst);
456 template<
typename MatrixType,
int _UpLo>
457 template<
typename Derived>
460 eigen_assert(m_isInitialized &&
"LLT is not initialized.");
461 eigen_assert(m_matrix.rows()==bAndX.rows());
462 matrixL().solveInPlace(bAndX);
463 matrixU().solveInPlace(bAndX);
469 template<
typename MatrixType,
int _UpLo>
472 eigen_assert(m_isInitialized &&
"LLT is not initialized.");
473 return matrixL() * matrixL().adjoint().toDenseMatrix();
479 template<
typename Derived>
489 template<
typename MatrixType,
unsigned int UpLo>
498 #endif // EIGEN_LLT_H Definition: ForwardDeclarations.h:124
void makeGivens(const Scalar &p, const Scalar &q, Scalar *z=0)
Makes *this as a Givens rotation G such that applying to the left of the vector yields: ...
Definition: Jacobi.h:148
MatrixType reconstructedMatrix() const
Definition: LLT.h:470
Expression of the transpose of a matrix.
Definition: Transpose.h:57
LLT(Index size)
Default Constructor with memory preallocation.
Definition: LLT.h:86
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: TestIMU_Common.h:87
Definition: ForwardDeclarations.h:228
Holds information about the various numeric (i.e.
Definition: NumTraits.h:88
Definition: GenericPacketMath.h:71
detail::size< coerce_list< Ts... >> size
Get the size of a list (number of elements.)
Definition: Size.h:56
View matrix as an upper triangular matrix.
Definition: Constants.h:169
Standard Cholesky decomposition (LL^T) of a matrix and associated features.
Definition: LLT.h:50
The provided data did not satisfy the prerequisites.
Definition: Constants.h:378
ComputationInfo info() const
Reports whether previous computation was successful.
Definition: LLT.h:164
Computation was successful.
Definition: Constants.h:376
Traits::MatrixL matrixL() const
Definition: LLT.h:104
Definition: BandTriangularSolver.h:13
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:103
Traits::MatrixU matrixU() const
Definition: LLT.h:97
Base class for triangular part in a matrix.
Definition: TriangularMatrix.h:158
Definition: ForwardDeclarations.h:125
LLT & compute(const MatrixType &matrix)
Computes / recomputes the Cholesky decomposition A = LL^* = U^*U of matrix.
Definition: LLT.h:391
const LLT< PlainObject > llt() const
Definition: LLT.h:481
View matrix as a lower triangular matrix.
Definition: Constants.h:167
const MatrixType & matrixLLT() const
Definition: LLT.h:150
LLT()
Default Constructor.
Definition: LLT.h:78
ComputationInfo
Enum for reporting the status of a computation.
Definition: Constants.h:374
bool isPositiveDefinite(MatrixBase< Derived > const &m)
Definition: TestIMU_UKF.cpp:37
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
const LLT< PlainObject, UpLo > llt() const
Definition: LLT.h:491
Definition: osvr_print_tree.cpp:52
const internal::solve_retval< LLT, Rhs > solve(const MatrixBase< Rhs > &b) const
Definition: LLT.h:122
double Scalar
Common scalar type.
Definition: FlexibleKalmanBase.h:48