20 template<
typename MatrixType_>
struct traits<HouseholderQR<MatrixType_> >
23 typedef MatrixXpr XprKind;
24 typedef SolverStorage StorageKind;
25 typedef int StorageIndex;
59 :
public SolverBase<HouseholderQR<MatrixType_> >
73 typedef typename internal::plain_diag_type<MatrixType>::type
HCoeffsType;
74 typedef typename internal::plain_row_type<MatrixType>::type
RowVectorType;
109 template<
typename InputType>
127 template<
typename InputType>
137 #ifdef EIGEN_PARSED_BY_DOXYGEN
152 template<
typename Rhs>
180 template<
typename InputType>
240 #ifndef EIGEN_PARSED_BY_DOXYGEN
241 template<
typename RhsType,
typename DstType>
242 void _solve_impl(
const RhsType &rhs, DstType &dst)
const;
244 template<
bool Conjugate,
typename RhsType,
typename DstType>
245 void _solve_impl_transposed(
const RhsType &rhs, DstType &dst)
const;
263 template<
typename HCoeffs,
typename Scalar,
bool IsComplex>
264 struct householder_determinant
282 template<
typename HCoeffs,
typename Scalar>
283 struct householder_determinant<HCoeffs,
Scalar, false>
287 bool negated =
false;
301 template<
typename MatrixType>
305 eigen_assert(
m_qr.rows() ==
m_qr.cols() &&
"You can't take the determinant of a non-square matrix!");
307 internal::householder_determinant<HCoeffsType, Scalar, NumTraits<Scalar>::IsComplex>::run(
m_hCoeffs, detQ);
308 return m_qr.diagonal().prod() * detQ;
311 template<
typename MatrixType>
316 eigen_assert(
m_qr.rows() ==
m_qr.cols() &&
"You can't take the determinant of a non-square matrix!");
317 return abs(
m_qr.diagonal().prod());
320 template<
typename MatrixType>
324 eigen_assert(
m_qr.rows() ==
m_qr.cols() &&
"You can't take the determinant of a non-square matrix!");
325 return m_qr.diagonal().cwiseAbs().array().log().sum();
331 template<
typename MatrixQR,
typename HCoeffs>
334 typedef typename MatrixQR::Scalar
Scalar;
335 typedef typename MatrixQR::RealScalar RealScalar;
347 tempData = tempVector.data();
356 mat.col(k).tail(remainingRows).makeHouseholderInPlace(
hCoeffs.coeffRef(k), beta);
357 mat.coeffRef(k,k) = beta;
360 mat.bottomRightCorner(remainingRows, remainingCols)
361 .applyHouseholderOnTheLeft(
mat.col(k).tail(remainingRows-1),
hCoeffs.coeffRef(k), tempData+k+1);
374 template <
typename MatrixQR,
typename HCoeffs,
typename VectorQR>
378 typedef typename MatrixQR::RealScalar RealScalar;
388 mat.col(k) = newColumn;
394 .applyHouseholderOnTheLeft(
mat.col(
i).tail(remainingRows - 1),
hCoeffs.coeffRef(
i), tempData +
i + 1);
398 mat.col(k).tail(
rows - k).makeHouseholderInPlace(
hCoeffs.coeffRef(k), beta);
399 mat.coeffRef(k, k) = beta;
403 template<
typename MatrixQR,
typename HCoeffs,
404 typename MatrixQRScalar =
typename MatrixQR::Scalar,
405 bool InnerStrideIsOne = (MatrixQR::InnerStrideAtCompileTime == 1 && HCoeffs::InnerStrideAtCompileTime == 1)>
406 struct householder_qr_inplace_blocked
409 static void run(MatrixQR&
mat, HCoeffs&
hCoeffs,
Index maxBlockSize=32,
410 typename MatrixQR::Scalar* tempData = 0)
412 typedef typename MatrixQR::Scalar
Scalar;
424 tempData = tempVector.data();
430 for (k = 0; k <
size; k += blockSize)
444 BlockType A11_21 =
mat.block(k,k,brows,bs);
445 Block<HCoeffs,Dynamic,1> hCoeffsSegment =
hCoeffs.segment(k,bs);
451 BlockType A21_22 =
mat.block(k,k+bs,brows,tcols);
460 #ifndef EIGEN_PARSED_BY_DOXYGEN
461 template<
typename MatrixType_>
462 template<
typename RhsType,
typename DstType>
463 void HouseholderQR<MatrixType_>::_solve_impl(
const RhsType &rhs, DstType &dst)
const
467 typename RhsType::PlainObject
c(rhs);
471 m_qr.topLeftCorner(rank, rank)
472 .template triangularView<Upper>()
473 .solveInPlace(
c.topRows(rank));
475 dst.topRows(rank) =
c.topRows(rank);
476 dst.bottomRows(
cols()-rank).setZero();
479 template<
typename MatrixType_>
480 template<
bool Conjugate,
typename RhsType,
typename DstType>
481 void HouseholderQR<MatrixType_>::_solve_impl_transposed(
const RhsType &rhs, DstType &dst)
const
485 typename RhsType::PlainObject
c(rhs);
487 m_qr.topLeftCorner(rank, rank)
488 .template triangularView<Upper>()
489 .transpose().template conjugateIf<Conjugate>()
490 .solveInPlace(
c.topRows(rank));
492 dst.topRows(rank) =
c.topRows(rank);
493 dst.bottomRows(
rows()-rank).setZero();
495 dst.applyOnTheLeft(
householderQ().setLength(rank).
template conjugateIf<!Conjugate>() );
505 template<
typename MatrixType>
516 internal::householder_qr_inplace_blocked<MatrixType, HCoeffsType>::run(
m_qr,
m_hCoeffs, 48,
m_temp.data());
525 template<
typename Derived>
const AbsReturnType abs() const
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
#define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE)
Expression of a fixed-size or dynamic-size block.
NumTraits< Scalar >::Real RealScalar
internal::traits< Derived >::Scalar Scalar
Householder QR decomposition of a matrix.
HouseholderQR(Index rows, Index cols)
Default Constructor with memory preallocation.
HouseholderQR(EigenBase< InputType > &matrix)
Constructs a QR factorization from a given matrix.
const Solve< HouseholderQR, Rhs > solve(const MatrixBase< Rhs > &b) const
HouseholderSequence< MatrixType, internal::remove_all_t< typename HCoeffsType::ConjugateReturnType > > HouseholderSequenceType
HouseholderQR(const EigenBase< InputType > &matrix)
Constructs a QR factorization from a given matrix.
MatrixType::Scalar determinant() const
const HCoeffsType & hCoeffs() const
internal::plain_diag_type< MatrixType >::type HCoeffsType
HouseholderSequenceType householderQ() const
HouseholderQR()
Default Constructor.
MatrixType::RealScalar absDeterminant() const
const MatrixType & matrixQR() const
HouseholderQR & compute(const EigenBase< InputType > &matrix)
SolverBase< HouseholderQR > Base
internal::plain_row_type< MatrixType >::type RowVectorType
MatrixType::RealScalar logAbsDeterminant() const
Sequence of Householder reflections acting on subspaces with decreasing size.
Base class for all dense matrices, vectors, and expressions.
const HouseholderQR< PlainObject > householderQr() const
The matrix class, also used for vectors and row-vectors.
constexpr void resize(Index rows, Index cols)
Pseudo expression representing a solving operation.
A base class for matrix decomposition and solvers.
internal::traits< HouseholderQR< MatrixType_ > >::Scalar Scalar
HouseholderQR< MatrixType_ > & derived()
const AdjointReturnType adjoint() const
const unsigned int RowMajorBit
bfloat16() min(const bfloat16 &a, const bfloat16 &b)
void householder_qr_inplace_unblocked(MatrixQR &mat, HCoeffs &hCoeffs, typename MatrixQR::Scalar *tempData=0)
void householder_qr_inplace_update(MatrixQR &mat, HCoeffs &hCoeffs, const VectorQR &newColumn, typename MatrixQR::Index k, typename MatrixQR::Scalar *tempData)
void apply_block_householder_on_the_left(MatrixType &mat, const VectorsType &vectors, const CoeffsType &hCoeffs, bool forward)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_conjugate_op< typename Derived::Scalar >, const Derived > conj(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_abs_op< typename Derived::Scalar >, const Derived > abs(const Eigen::ArrayBase< Derived > &x)
Eigen::Index Index
The interface type of indices.
EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT