11#ifndef EIGEN_PARTIALLU_H
12#define EIGEN_PARTIALLU_H
22 typedef int StorageIndex;
30template<
typename T,
typename Derived>
36template<
typename T,
typename Derived>
77 :
public SolverBase<PartialPivLU<_MatrixType> >
81 typedef _MatrixType MatrixType;
87 MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
88 MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
92 typedef typename MatrixType::PlainObject PlainObject;
117 template<
typename InputType>
127 template<
typename InputType>
130 template<
typename InputType>
132 m_lu = matrix.derived();
145 eigen_assert(m_isInitialized &&
"PartialPivLU is not initialized.");
153 eigen_assert(m_isInitialized &&
"PartialPivLU is not initialized.");
157 #ifdef EIGEN_PARSED_BY_DOXYGEN
175 template<
typename Rhs>
185 eigen_assert(m_isInitialized &&
"PartialPivLU is not initialized.");
186 return internal::rcond_estimate_helper(m_l1_norm, *
this);
198 eigen_assert(m_isInitialized &&
"PartialPivLU is not initialized.");
219 EIGEN_CONSTEXPR
inline Index rows()
const EIGEN_NOEXCEPT {
return m_lu.rows(); }
220 EIGEN_CONSTEXPR
inline Index cols() const EIGEN_NOEXCEPT {
return m_lu.cols(); }
222 #ifndef EIGEN_PARSED_BY_DOXYGEN
223 template<
typename RhsType,
typename DstType>
225 void _solve_impl(
const RhsType &rhs, DstType &dst)
const {
237 m_lu.template triangularView<UnitLower>().solveInPlace(dst);
240 m_lu.template triangularView<Upper>().solveInPlace(dst);
243 template<
bool Conjugate,
typename RhsType,
typename DstType>
245 void _solve_impl_transposed(
const RhsType &rhs, DstType &dst)
const {
253 eigen_assert(rhs.rows() == m_lu.cols());
256 dst = m_lu.template triangularView<Upper>().transpose()
257 .template conjugateIf<Conjugate>().solve(rhs);
259 m_lu.template triangularView<UnitLower>().transpose()
260 .template conjugateIf<Conjugate>().solveInPlace(dst);
268 static void check_template_parameters()
270 EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
277 TranspositionType m_rowsTranspositions;
278 RealScalar m_l1_norm;
280 bool m_isInitialized;
283template<
typename MatrixType>
287 m_rowsTranspositions(),
290 m_isInitialized(
false)
294template<
typename MatrixType>
298 m_rowsTranspositions(size),
301 m_isInitialized(
false)
305template<
typename MatrixType>
306template<
typename InputType>
308 : m_lu(matrix.rows(),matrix.cols()),
310 m_rowsTranspositions(matrix.rows()),
313 m_isInitialized(
false)
315 compute(matrix.derived());
318template<
typename MatrixType>
319template<
typename InputType>
321 : m_lu(matrix.derived()),
323 m_rowsTranspositions(matrix.rows()),
326 m_isInitialized(
false)
334template<
typename Scalar,
int StorageOrder,
typename PivIndex,
int SizeAtCompileTime=Dynamic>
337 static const int UnBlockedBound = 16;
338 static const bool UnBlockedAtCompileTime = SizeAtCompileTime!=
Dynamic && SizeAtCompileTime<=UnBlockedBound;
339 static const int ActualSizeAtCompileTime = UnBlockedAtCompileTime ? SizeAtCompileTime :
Dynamic;
341 static const int RRows = SizeAtCompileTime==2 ? 1 :
Dynamic;
342 static const int RCols = SizeAtCompileTime==2 ? 1 :
Dynamic;
361 typedef typename Scoring::result_type Score;
362 const Index rows = lu.rows();
363 const Index cols = lu.cols();
364 const Index size = (std::min)(rows,cols);
367 const Index endk = UnBlockedAtCompileTime ? size-1 : size;
372 int rrows = internal::convert_index<int>(rows-k-1);
373 int rcols = internal::convert_index<int>(cols-k-1);
404 if(UnBlockedAtCompileTime)
434 const Index size = (std::min)(rows,cols);
437 if(UnBlockedAtCompileTime || size<=UnBlockedBound)
504template<
typename MatrixType,
typename TranspositionType>
508 if (lu.rows() == 0 || lu.cols() == 0) {
517 typename TranspositionType::StorageIndex,
518 EIGEN_SIZE_MIN_PREFER_FIXED(MatrixType::RowsAtCompileTime,MatrixType::ColsAtCompileTime)>
524template<
typename MatrixType>
525void PartialPivLU<MatrixType>::compute()
527 check_template_parameters();
530 eigen_assert(m_lu.rows()<NumTraits<int>::highest());
533 m_l1_norm = m_lu.cwiseAbs().colwise().sum().maxCoeff();
535 m_l1_norm = RealScalar(0);
537 eigen_assert(m_lu.rows() == m_lu.cols() &&
"PartialPivLU is only for square (and moreover invertible) matrices");
538 const Index size = m_lu.rows();
540 m_rowsTranspositions.resize(size);
542 typename TranspositionType::StorageIndex nb_transpositions;
543 internal::partial_lu_inplace(m_lu, m_rowsTranspositions, nb_transpositions);
544 m_det_p = (nb_transpositions%2) ? -1 : 1;
546 m_p = m_rowsTranspositions;
548 m_isInitialized =
true;
551template<
typename MatrixType>
554 eigen_assert(m_isInitialized &&
"PartialPivLU is not initialized.");
555 return Scalar(m_det_p) * m_lu.diagonal().prod();
561template<
typename MatrixType>
564 eigen_assert(m_isInitialized &&
"LU is not initialized.");
570 res = m_p.inverse() * res;
580template<
typename DstXprType,
typename MatrixType>
587 dst =
src.nestedExpression().solve(MatrixType::Identity(
src.rows(),
src.cols()));
600template<
typename Derived>
615template<
typename Derived>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(const DenseBase< OtherDerived > &other)
swaps *this with the expression other.
Definition DenseBase.h:420
EIGEN_DEVICE_FUNC TransposeReturnType transpose()
Definition Transpose.h:182
Expression of the inverse of another expression.
Definition Inverse.h:44
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EvalReturnType eval() const
Definition DenseBase.h:407
NoAlias< Derived, Eigen::MatrixBase > EIGEN_DEVICE_FUNC noalias()
Definition NoAlias.h:102
LU decomposition of a matrix with partial pivoting, and related features.
Definition PartialPivLU.h:78
const Inverse< PartialPivLU > inverse() const
Definition PartialPivLU.h:196
const PermutationType & permutationP() const
Definition PartialPivLU.h:151
RealScalar rcond() const
Definition PartialPivLU.h:183
Scalar determinant() const
Definition PartialPivLU.h:552
PartialPivLU()
Default Constructor.
Definition PartialPivLU.h:284
const MatrixType & matrixLU() const
Definition PartialPivLU.h:143
MatrixType reconstructedMatrix() const
Definition PartialPivLU.h:562
A matrix or vector expression mapping an existing expression.
Definition Ref.h:283
A base class for matrix decomposition and solvers.
Definition SolverBase.h:69
const Solve< PartialPivLU< _MatrixType >, Rhs > solve(const MatrixBase< Rhs > &b) const
Definition SolverBase.h:106
@ ColMajor
Storage order is column major (see TopicStorageOrders).
Definition Constants.h:319
@ RowMajor
Storage order is row major (see TopicStorageOrders).
Definition Constants.h:321
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition Constants.h:66
Namespace containing all symbols from the Eigen library.
Definition LDLT.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
const int Dynamic
This value means that a positive quantity (e.g., a size) is not known at compile-time,...
Definition Constants.h:22
Eigen::Index Index
The interface type of indices.
Definition EigenBase.h:39
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
Definition EigenBase.h:67
The type used to identify a matrix expression.
Definition Constants.h:522
The type used to identify a general solver (factored) storage.
Definition Constants.h:513
Definition AssignEvaluator.h:824
Definition AssignEvaluator.h:814
Definition AssignmentFunctors.h:21
Definition PartialPivLU.h:31
Definition PartialPivLU.h:336
Definition ForwardDeclarations.h:17