11 #ifndef EIGEN_COLPIVOTINGHOUSEHOLDERQR_H 12 #define EIGEN_COLPIVOTINGHOUSEHOLDERQR_H 37 template<
typename _MatrixType>
class ColPivHouseholderQR
49 typedef typename MatrixType::Scalar
Scalar;
51 typedef typename MatrixType::Index
Index;
139 template<
typename Rhs>
227 result += (
abs(
m_qr.coeff(i,i)) > premultiplied_threshold);
292 (*
this, MatrixType::Identity(
m_qr.rows(),
m_qr.cols()));
398 template<
typename MatrixType>
403 eigen_assert(
m_qr.rows() ==
m_qr.cols() &&
"You can't take the determinant of a non-square matrix!");
404 return abs(
m_qr.diagonal().prod());
407 template<
typename MatrixType>
411 eigen_assert(
m_qr.rows() ==
m_qr.cols() &&
"You can't take the determinant of a non-square matrix!");
412 return m_qr.diagonal().cwiseAbs().array().log().sum();
421 template<
typename MatrixType>
427 Index size = matrix.diagonalSize();
438 Index number_of_transpositions = 0;
449 for(
Index k = 0; k < size; ++k)
452 Index biggest_col_index;
454 biggest_col_index += k;
460 biggest_col_sq_norm =
m_qr.col(biggest_col_index).tail(rows-k).squaredNorm();
463 m_colSqNorms.coeffRef(biggest_col_index) = biggest_col_sq_norm;
470 if(biggest_col_sq_norm < threshold_helper *
RealScalar(rows-k))
474 m_qr.bottomRightCorner(rows-k,cols-k)
475 .template triangularView<StrictlyLower>()
482 if(k != biggest_col_index) {
483 m_qr.col(k).swap(
m_qr.col(biggest_col_index));
485 ++number_of_transpositions;
490 m_qr.col(k).tail(rows-k).makeHouseholderInPlace(
m_hCoeffs.coeffRef(k), beta);
493 m_qr.coeffRef(k,k) = beta;
499 m_qr.bottomRightCorner(rows-k, cols-k-1)
500 .applyHouseholderOnTheLeft(
m_qr.col(k).tail(rows-k-1),
m_hCoeffs.coeffRef(k), &
m_temp.coeffRef(k+1));
510 m_det_pq = (number_of_transpositions%2) ? -1 : 1;
518 template<
typename _MatrixType,
typename Rhs>
524 template<typename Dest>
void evalTo(Dest& dst)
const 529 nonzero_pivots = dec().nonzeroPivots();
531 if(nonzero_pivots == 0)
537 typename Rhs::PlainObject c(rhs());
546 .topLeftCorner(nonzero_pivots, nonzero_pivots)
547 .template triangularView<Upper>()
548 .solveInPlace(c.topRows(nonzero_pivots));
550 for(
Index i = 0; i < nonzero_pivots; ++i) dst.row(dec().
colsPermutation().indices().coeff(i)) = c.row(i);
558 template<
typename MatrixType>
570 template<
typename Derived>
579 #endif // EIGEN_COLPIVOTINGHOUSEHOLDERQR_H PermutationMatrix< ColsAtCompileTime, MaxColsAtCompileTime > PermutationType
const PermutationType & colsPermutation() const
PermutationType::Index PermIndexType
ColPivHouseholderQR & compute(const MatrixType &matrix)
Index nonzeroPivots() const
HouseholderSequence< VectorsType, CoeffsType > householderSequence(const VectorsType &v, const CoeffsType &h)
Convenience function for constructing a Householder sequence.
ColPivHouseholderQR()
Default Constructor.
ColPivHouseholderQR(Index rows, Index cols)
Default Constructor with memory preallocation.
RealRowVectorType m_colSqNorms
const internal::solve_retval< ColPivHouseholderQR, typename MatrixType::IdentityReturnType > inverse() const
RealScalar m_prescribedThreshold
MatrixType::RealScalar logAbsDeterminant() const
bool isInvertible() const
internal::plain_diag_type< MatrixType >::type HCoeffsType
HouseholderSequence< MatrixType, typename internal::remove_all< typename HCoeffsType::ConjugateReturnType >::type > HouseholderSequenceType
Derived & applyTranspositionOnTheRight(Index i, Index j)
PermutationType m_colsPermutation
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
ComputationInfo info() const
Reports whether the QR factorization was succesful.
EIGEN_STRONG_INLINE const CwiseUnaryOp< internal::scalar_abs2_op< Scalar >, const Derived > abs2() const
Sequence of Householder reflections acting on subspaces with decreasing size.
EIGEN_STRONG_INLINE const CwiseUnaryOp< internal::scalar_abs_op< Scalar >, const Derived > abs() const
const internal::solve_retval< ColPivHouseholderQR, Rhs > solve(const MatrixBase< Rhs > &b) const
ColPivHouseholderQR & setThreshold(Default_t)
HouseholderSequenceType matrixQ(void) const
RealScalar threshold() const
internal::plain_row_type< MatrixType >::type RowVectorType
HouseholderSequenceType householderQ(void) const
const MatrixType & matrixR() const
Householder rank-revealing QR decomposition of a matrix with column-pivoting.
const MatrixType & matrixQR() const
MatrixType::Scalar Scalar
const HCoeffsType & hCoeffs() const
bool m_usePrescribedThreshold
Matrix< Scalar, RowsAtCompileTime, RowsAtCompileTime, Options, MaxRowsAtCompileTime, MaxRowsAtCompileTime > MatrixQType
const ColPivHouseholderQR< PlainObject > colPivHouseholderQr() const
internal::traits< Derived >::Index Index
internal::plain_row_type< MatrixType, RealScalar >::type RealRowVectorType
ColPivHouseholderQR & setThreshold(const RealScalar &threshold)
RealScalar maxPivot() const
MatrixType::RealScalar absDeterminant() const
bool isSurjective() const
ColPivHouseholderQR(const MatrixType &matrix)
Constructs a QR factorization from a given matrix.
internal::plain_row_type< MatrixType, Index >::type IntRowVectorType
#define EIGEN_MAKE_SOLVE_HELPERS(DecompositionType, Rhs)
IntRowVectorType m_colsTranspositions
The matrix class, also used for vectors and row-vectors.
Base class for all dense matrices, vectors, and expressions.
Index dimensionOfKernel() const
MatrixType::RealScalar RealScalar