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
bool isSurjective() const
PermutationType::Index PermIndexType
ColPivHouseholderQR & compute(const MatrixType &matrix)
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
RealScalar m_prescribedThreshold
const internal::solve_retval< ColPivHouseholderQR, typename MatrixType::IdentityReturnType > inverse() const
const HCoeffsType & hCoeffs() const
const ColPivHouseholderQR< PlainObject > colPivHouseholderQr() 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. ...
HouseholderSequenceType householderQ(void) const
ComputationInfo info() const
Reports whether the QR factorization was succesful.
Sequence of Householder reflections acting on subspaces with decreasing size.
RealScalar maxPivot() const
ColPivHouseholderQR & setThreshold(Default_t)
internal::plain_row_type< MatrixType >::type RowVectorType
Householder rank-revealing QR decomposition of a matrix with column-pivoting.
const MatrixType & matrixR() const
MatrixType::Scalar Scalar
HouseholderSequenceType matrixQ(void) const
bool m_usePrescribedThreshold
const internal::solve_retval< ColPivHouseholderQR, Rhs > solve(const MatrixBase< Rhs > &b) const
Matrix< Scalar, RowsAtCompileTime, RowsAtCompileTime, Options, MaxRowsAtCompileTime, MaxRowsAtCompileTime > MatrixQType
internal::traits< Derived >::Index Index
bool isInvertible() const
internal::plain_row_type< MatrixType, RealScalar >::type RealRowVectorType
MatrixType::RealScalar absDeterminant() const
ColPivHouseholderQR & setThreshold(const RealScalar &threshold)
RealScalar threshold() const
ColPivHouseholderQR(const MatrixType &matrix)
Constructs a QR factorization from a given matrix.
EIGEN_STRONG_INLINE const CwiseUnaryOp< internal::scalar_abs_op< Scalar >, const Derived > abs() const
MatrixType::RealScalar logAbsDeterminant() const
Index dimensionOfKernel() const
internal::plain_row_type< MatrixType, Index >::type IntRowVectorType
Index nonzeroPivots() const
#define EIGEN_MAKE_SOLVE_HELPERS(DecompositionType, Rhs)
IntRowVectorType m_colsTranspositions
EIGEN_STRONG_INLINE const CwiseUnaryOp< internal::scalar_abs2_op< Scalar >, const Derived > abs2() const
The matrix class, also used for vectors and row-vectors.
const MatrixType & matrixQR() const
const PermutationType & colsPermutation() const
Base class for all dense matrices, vectors, and expressions.
MatrixType::RealScalar RealScalar