11 #ifndef EIGEN_COLPIVOTINGHOUSEHOLDERQR_H
12 #define EIGEN_COLPIVOTINGHOUSEHOLDERQR_H
19 template<
typename MatrixType_,
typename PermutationIndex_>
struct traits<ColPivHouseholderQR<MatrixType_, PermutationIndex_> >
22 typedef MatrixXpr XprKind;
23 typedef SolverStorage StorageKind;
24 typedef PermutationIndex_ PermutationIndex;
54 :
public SolverBase<ColPivHouseholderQR<MatrixType_, PermutationIndex_> >
68 typedef typename internal::plain_diag_type<MatrixType>::type
HCoeffsType;
70 typedef typename internal::plain_row_type<MatrixType, PermutationIndex>::type
IntRowVectorType;
71 typedef typename internal::plain_row_type<MatrixType>::type
RowVectorType;
128 template <
typename InputType>
140 template <
typename InputType>
146 #ifdef EIGEN_PARSED_BY_DOXYGEN
161 template<
typename Rhs>
195 template<
typename InputType>
262 result += (
abs(
m_qr.coeff(
i,
i)) > premultiplied_threshold);
417 #ifndef EIGEN_PARSED_BY_DOXYGEN
418 template<
typename RhsType,
typename DstType>
419 void _solve_impl(
const RhsType &rhs, DstType &dst)
const;
421 template<
bool Conjugate,
typename RhsType,
typename DstType>
422 void _solve_impl_transposed(
const RhsType &rhs, DstType &dst)
const;
450 eigen_assert(
m_qr.rows() ==
m_qr.cols() &&
"You can't take the determinant of a non-square matrix!");
452 internal::householder_determinant<HCoeffsType, Scalar, NumTraits<Scalar>::IsComplex>::run(
m_hCoeffs, detQ);
456 template<
typename MatrixType,
typename PermutationIndex>
461 eigen_assert(
m_qr.rows() ==
m_qr.cols() &&
"You can't take the determinant of a non-square matrix!");
462 return abs(
m_qr.diagonal().prod());
465 template<
typename MatrixType,
typename PermutationIndex>
469 eigen_assert(
m_qr.rows() ==
m_qr.cols() &&
"You can't take the determinant of a non-square matrix!");
470 return m_qr.diagonal().cwiseAbs().array().log().sum();
479 template<
typename MatrixType,
typename PermutationIndex>
480 template<
typename InputType>
488 template<
typename MatrixType,
typename PermutationIndex>
505 Index number_of_transpositions = 0;
525 Index biggest_col_index;
527 biggest_col_index += k;
536 if(k != biggest_col_index) {
537 m_qr.col(k).swap(
m_qr.col(biggest_col_index));
540 ++number_of_transpositions;
548 m_qr.coeffRef(k,k) = beta;
565 temp = (RealScalar(1) + temp) * (RealScalar(1) - temp);
566 temp = temp < RealScalar(0) ? RealScalar(0) : temp;
569 if (temp2 <= norm_downdate_threshold) {
585 m_det_p = (number_of_transpositions%2) ? -1 : 1;
589 #ifndef EIGEN_PARSED_BY_DOXYGEN
590 template<
typename MatrixType_,
typename PermutationIndex_>
591 template<
typename RhsType,
typename DstType>
596 if(nonzero_pivots == 0)
602 typename RhsType::PlainObject
c(rhs);
606 m_qr.topLeftCorner(nonzero_pivots, nonzero_pivots)
607 .template triangularView<Upper>()
608 .solveInPlace(
c.topRows(nonzero_pivots));
614 template<
typename MatrixType_,
typename PermutationIndex_>
615 template<
bool Conjugate,
typename RhsType,
typename DstType>
616 void ColPivHouseholderQR<MatrixType_, PermutationIndex_>::_solve_impl_transposed(
const RhsType &rhs, DstType &dst)
const
620 if(nonzero_pivots == 0)
628 m_qr.topLeftCorner(nonzero_pivots, nonzero_pivots)
629 .template triangularView<Upper>()
630 .transpose().template conjugateIf<Conjugate>()
631 .solveInPlace(
c.topRows(nonzero_pivots));
633 dst.topRows(nonzero_pivots) =
c.topRows(nonzero_pivots);
634 dst.bottomRows(
rows()-nonzero_pivots).setZero();
636 dst.applyOnTheLeft(
householderQ().setLength(nonzero_pivots).
template conjugateIf<!Conjugate>() );
642 template<
typename DstXprType,
typename MatrixType,
typename PermutationIndex>
645 typedef ColPivHouseholderQR<MatrixType, PermutationIndex> QrType;
646 typedef Inverse<QrType> SrcXprType;
647 static void run(DstXprType &dst,
const SrcXprType &src,
const internal::assign_op<typename DstXprType::Scalar,typename QrType::Scalar> &)
649 dst = src.nestedExpression().solve(MatrixType::Identity(src.rows(), src.cols()));
658 template<
typename MatrixType,
typename PermutationIndex>
670 template<
typename Derived>
671 template<
typename PermutationIndexType>
const AbsReturnType abs() const
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
#define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE)
Matrix< float, 1, Dynamic > MatrixType
Householder rank-revealing QR decomposition of a matrix with column-pivoting.
RealScalar maxPivot() const
internal::plain_row_type< MatrixType >::type RowVectorType
MatrixType::PlainObject PlainObject
bool m_usePrescribedThreshold
const Inverse< ColPivHouseholderQR > inverse() const
internal::plain_diag_type< MatrixType >::type HCoeffsType
RealRowVectorType m_colNormsUpdated
MatrixType::RealScalar absDeterminant() const
RealScalar m_prescribedThreshold
PermutationType m_colsPermutation
internal::plain_row_type< MatrixType, RealScalar >::type RealRowVectorType
bool isSurjective() const
Index nonzeroPivots() const
RealRowVectorType m_colNormsDirect
ColPivHouseholderQR(EigenBase< InputType > &matrix)
Constructs a QR factorization from a given matrix.
ColPivHouseholderQR & setThreshold(const RealScalar &threshold)
PermutationIndex_ PermutationIndex
internal::plain_row_type< MatrixType, PermutationIndex >::type IntRowVectorType
const HCoeffsType & hCoeffs() const
bool isInvertible() const
PermutationMatrix< ColsAtCompileTime, MaxColsAtCompileTime, PermutationIndex > PermutationType
Index dimensionOfKernel() const
HouseholderSequenceType matrixQ() const
SolverBase< ColPivHouseholderQR > Base
ComputationInfo info() const
Reports whether the QR factorization was successful.
const PermutationType & colsPermutation() const
ColPivHouseholderQR()
Default Constructor.
HouseholderSequenceType householderQ() const
const MatrixType & matrixR() const
const Solve< ColPivHouseholderQR, Rhs > solve(const MatrixBase< Rhs > &b) const
ColPivHouseholderQR & compute(const EigenBase< InputType > &matrix)
MatrixType::Scalar determinant() const
void init(Index rows, Index cols)
MatrixType::RealScalar logAbsDeterminant() const
RealScalar threshold() const
ColPivHouseholderQR & setThreshold(Default_t)
ColPivHouseholderQR(Index rows, Index cols)
Default Constructor with memory preallocation.
ColPivHouseholderQR(const EigenBase< InputType > &matrix)
Constructs a QR factorization from a given matrix.
HouseholderSequence< MatrixType, internal::remove_all_t< typename HCoeffsType::ConjugateReturnType > > HouseholderSequenceType
const MatrixType & matrixQR() const
IntRowVectorType m_colsTranspositions
Complete orthogonal decomposition (COD) of a matrix.
NumTraits< Scalar >::Real RealScalar
internal::traits< Derived >::Scalar Scalar
Sequence of Householder reflections acting on subspaces with decreasing size.
Expression of the inverse of another expression.
Base class for all dense matrices, vectors, and expressions.
const ColPivHouseholderQR< PlainObject, PermutationIndex > colPivHouseholderQr() const
Base::PlainObject PlainObject
InverseReturnType transpose() const
void resize(Index newSize)
Derived & applyTranspositionOnTheRight(Index i, Index j)
const IndicesType & indices() const
Pseudo expression representing a solving operation.
A base class for matrix decomposition and solvers.
internal::traits< ColPivHouseholderQR< MatrixType_, PermutationIndex_ > >::Scalar Scalar
ColPivHouseholderQR< MatrixType_, PermutationIndex_ > & derived()
const AdjointReturnType adjoint() const
void swap(scoped_array< T > &a, scoped_array< T > &b)
EIGEN_ALWAYS_INLINE float sqrt(const float &x)
EIGEN_ALWAYS_INLINE T mini(const T &x, const T &y)
bool is_exactly_zero(const X &x)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_abs_op< typename Derived::Scalar >, const Derived > abs(const Eigen::ArrayBase< Derived > &x)
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Eigen::Index Index
The interface type of indices.
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.