46 typedef _MatrixType MatrixType;
48 RowsAtCompileTime = MatrixType::RowsAtCompileTime,
49 ColsAtCompileTime = MatrixType::ColsAtCompileTime,
50 Options = MatrixType::Options,
51 MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
52 MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
54 typedef typename MatrixType::Scalar Scalar;
55 typedef typename MatrixType::RealScalar RealScalar;
57 typedef typename MatrixType::StorageIndex StorageIndex;
79 m_hCoeffs((
std::min)(rows,cols)),
81 m_isInitialized(
false) {}
95 template<
typename InputType>
97 : m_qr(matrix.rows(), matrix.cols()),
98 m_hCoeffs((
std::min)(matrix.rows(),matrix.cols())),
99 m_temp(matrix.cols()),
100 m_isInitialized(
false)
102 compute(matrix.derived());
122 template<
typename Rhs>
126 eigen_assert(m_isInitialized &&
"HouseholderQR is not initialized.");
140 eigen_assert(m_isInitialized &&
"HouseholderQR is not initialized.");
149 eigen_assert(m_isInitialized &&
"HouseholderQR is not initialized.");
153 template<
typename InputType>
185 inline Index rows()
const {
return m_qr.rows(); }
186 inline Index cols()
const {
return m_qr.cols(); }
194 #ifndef EIGEN_PARSED_BY_DOXYGEN
195 template<
typename RhsType,
typename DstType>
202 static void check_template_parameters()
204 EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
208 HCoeffsType m_hCoeffs;
209 RowVectorType m_temp;
210 bool m_isInitialized;
213template<
typename MatrixType>
217 eigen_assert(m_isInitialized &&
"HouseholderQR is not initialized.");
218 eigen_assert(m_qr.rows() == m_qr.cols() &&
"You can't take the determinant of a non-square matrix!");
219 return abs(m_qr.diagonal().prod());
222template<
typename MatrixType>
225 eigen_assert(m_isInitialized &&
"HouseholderQR is not initialized.");
226 eigen_assert(m_qr.rows() == m_qr.cols() &&
"You can't take the determinant of a non-square matrix!");
227 return m_qr.diagonal().cwiseAbs().array().log().sum();
233template<
typename MatrixQR,
typename HCoeffs>
236 typedef typename MatrixQR::Scalar Scalar;
237 typedef typename MatrixQR::RealScalar RealScalar;
238 Index rows =
mat.rows();
239 Index cols =
mat.cols();
240 Index size = (std::min)(rows,cols);
242 eigen_assert(hCoeffs.size() == size);
252 for(Index k = 0; k < size; ++k)
254 Index remainingRows = rows - k;
255 Index remainingCols = cols - k - 1;
258 mat.col(k).tail(remainingRows).makeHouseholderInPlace(hCoeffs.coeffRef(k), beta);
259 mat.coeffRef(k,k) = beta;
262 mat.bottomRightCorner(remainingRows, remainingCols)
263 .applyHouseholderOnTheLeft(mat.col(k).tail(remainingRows-1), hCoeffs.coeffRef(k), tempData+k+1);
268template<
typename MatrixQR,
typename HCoeffs,
269 typename MatrixQRScalar =
typename MatrixQR::Scalar,
270 bool InnerStrideIsOne = (MatrixQR::InnerStrideAtCompileTime == 1 && HCoeffs::InnerStrideAtCompileTime == 1)>
275 typename MatrixQR::Scalar*
tempData = 0)
277 typedef typename MatrixQR::Scalar Scalar;
280 Index rows =
mat.rows();
281 Index cols =
mat.cols();
282 Index size = (std::min)(rows, cols);
299 Index
brows = rows-k;
325#ifndef EIGEN_PARSED_BY_DOXYGEN
326template<
typename _MatrixType>
327template<
typename RhsType,
typename DstType>
330 const Index rank = (std::min)(rows(), cols());
331 eigen_assert(rhs.rows() == rows());
333 typename RhsType::PlainObject c(rhs);
336 c.applyOnTheLeft(householderSequence(
338 m_hCoeffs.head(rank)).transpose()
341 m_qr.topLeftCorner(rank, rank)
343 .solveInPlace(c.topRows(rank));
345 dst.topRows(rank) = c.topRows(rank);
346 dst.bottomRows(cols()-rank).setZero();
356template<
typename MatrixType>
357template<
typename InputType>
360 check_template_parameters();
362 Index rows = matrix.rows();
363 Index cols = matrix.cols();
364 Index size = (std::min)(rows,cols);
366 m_qr = matrix.derived();
367 m_hCoeffs.resize(size);
373 m_isInitialized =
true;
382template<
typename Derived>
Householder QR decomposition of a matrix.
Definition HouseholderQR.h:43
const HCoeffsType & hCoeffs() const
Definition HouseholderQR.h:192
HouseholderQR(Index rows, Index cols)
Default Constructor with memory preallocation.
Definition HouseholderQR.h:77
const MatrixType & matrixQR() const
Definition HouseholderQR.h:147
const Solve< HouseholderQR, Rhs > solve(const MatrixBase< Rhs > &b) const
This method finds a solution x to the equation Ax=b, where A is the matrix of which *this is the QR d...
Definition HouseholderQR.h:124
HouseholderQR()
Default Constructor.
Definition HouseholderQR.h:69
MatrixType::RealScalar absDeterminant() const
Definition HouseholderQR.h:214
MatrixType::RealScalar logAbsDeterminant() const
Definition HouseholderQR.h:223
HouseholderQR(const EigenBase< InputType > &matrix)
Constructs a QR factorization from a given matrix.
Definition HouseholderQR.h:96
HouseholderSequenceType householderQ() const
This method returns an expression of the unitary matrix Q as a sequence of Householder transformation...
Definition HouseholderQR.h:138
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:180
Pseudo expression representing a solving operation.
Definition Solve.h:63
@ ColMajor
Storage order is column major (see TopicStorageOrders).
Definition Constants.h:320
@ RowMajor
Storage order is row major (see TopicStorageOrders).
Definition Constants.h:322
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition Constants.h:61
Definition HouseholderQR.h:272