23 typedef int StorageIndex;
57 :
public SolverBase<HouseholderQR<_MatrixType> >
61 typedef _MatrixType MatrixType;
67 MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
68 MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
91 m_hCoeffs((
std::min)(rows,cols)),
93 m_isInitialized(
false) {}
107 template<
typename InputType>
109 : m_qr(matrix.rows(), matrix.cols()),
110 m_hCoeffs((
std::min)(matrix.rows(),matrix.cols())),
111 m_temp(matrix.cols()),
112 m_isInitialized(
false)
114 compute(matrix.derived());
125 template<
typename InputType>
128 m_hCoeffs((
std::min)(matrix.rows(),matrix.cols())),
129 m_temp(matrix.cols()),
130 m_isInitialized(
false)
135 #ifdef EIGEN_PARSED_BY_DOXYGEN
150 template<
typename Rhs>
165 eigen_assert(m_isInitialized &&
"HouseholderQR is not initialized.");
174 eigen_assert(m_isInitialized &&
"HouseholderQR is not initialized.");
178 template<
typename InputType>
180 m_qr = matrix.derived();
214 inline Index rows()
const {
return m_qr.rows(); }
215 inline Index cols()
const {
return m_qr.cols(); }
223 #ifndef EIGEN_PARSED_BY_DOXYGEN
224 template<
typename RhsType,
typename DstType>
227 template<
bool Conjugate,
typename RhsType,
typename DstType>
233 static void check_template_parameters()
235 EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
243 bool m_isInitialized;
246template<
typename MatrixType>
250 eigen_assert(m_isInitialized &&
"HouseholderQR is not initialized.");
251 eigen_assert(m_qr.rows() == m_qr.cols() &&
"You can't take the determinant of a non-square matrix!");
252 return abs(m_qr.diagonal().prod());
255template<
typename MatrixType>
258 eigen_assert(m_isInitialized &&
"HouseholderQR is not initialized.");
259 eigen_assert(m_qr.rows() == m_qr.cols() &&
"You can't take the determinant of a non-square matrix!");
260 return m_qr.diagonal().cwiseAbs().array().log().sum();
266template<
typename MatrixQR,
typename HCoeffs>
269 typedef typename MatrixQR::Scalar Scalar;
270 typedef typename MatrixQR::RealScalar RealScalar;
273 Index size = (std::min)(rows,cols);
275 eigen_assert(hCoeffs.size() == size);
285 for(
Index k = 0; k < size; ++k)
287 Index remainingRows = rows - k;
288 Index remainingCols = cols - k - 1;
292 mat.coeffRef(k,k) = beta;
295 mat.bottomRightCorner(remainingRows, remainingCols)
301template<
typename MatrixQR,
typename HCoeffs,
302 typename MatrixQRScalar =
typename MatrixQR::Scalar,
303 bool InnerStrideIsOne = (MatrixQR::InnerStrideAtCompileTime == 1 && HCoeffs::InnerStrideAtCompileTime == 1)>
308 typename MatrixQR::Scalar*
tempData = 0)
310 typedef typename MatrixQR::Scalar Scalar;
315 Index size = (std::min)(rows, cols);
358#ifndef EIGEN_PARSED_BY_DOXYGEN
359template<
typename _MatrixType>
360template<
typename RhsType,
typename DstType>
361void HouseholderQR<_MatrixType>::_solve_impl(
const RhsType &rhs, DstType &dst)
const
363 const Index rank = (std::min)(rows(), cols());
365 typename RhsType::PlainObject c(rhs);
367 c.applyOnTheLeft(householderQ().setLength(rank).
adjoint() );
369 m_qr.topLeftCorner(rank, rank)
370 .template triangularView<Upper>()
371 .solveInPlace(c.topRows(rank));
373 dst.topRows(rank) = c.topRows(rank);
374 dst.bottomRows(cols()-rank).setZero();
377template<
typename _MatrixType>
378template<
bool Conjugate,
typename RhsType,
typename DstType>
379void HouseholderQR<_MatrixType>::_solve_impl_transposed(
const RhsType &rhs, DstType &dst)
const
381 const Index rank = (std::min)(rows(), cols());
383 typename RhsType::PlainObject c(rhs);
385 m_qr.topLeftCorner(rank, rank)
386 .template triangularView<Upper>()
387 .transpose().template conjugateIf<Conjugate>()
388 .solveInPlace(c.topRows(rank));
390 dst.topRows(rank) = c.topRows(rank);
391 dst.bottomRows(rows()-rank).setZero();
393 dst.applyOnTheLeft(householderQ().setLength(rank).
template conjugateIf<!Conjugate>() );
403template<
typename MatrixType>
406 check_template_parameters();
408 Index rows = m_qr.rows();
409 Index cols = m_qr.cols();
410 Index size = (std::min)(rows,cols);
412 m_hCoeffs.resize(size);
418 m_isInitialized =
true;
425template<
typename Derived>
EIGEN_DEVICE_FUNC void resize(Index newSize)
Only plain matrices/arrays, not expressions, may be resized; therefore the only useful resize methods...
Definition DenseBase.h:246
Householder QR decomposition of a matrix.
Definition HouseholderQR.h:58
const HCoeffsType & hCoeffs() const
Definition HouseholderQR.h:221
HouseholderQR(Index rows, Index cols)
Default Constructor with memory preallocation.
Definition HouseholderQR.h:89
void computeInPlace()
Performs the QR factorization of the given matrix matrix.
Definition HouseholderQR.h:404
const MatrixType & matrixQR() const
Definition HouseholderQR.h:172
HouseholderQR(EigenBase< InputType > &matrix)
Constructs a QR factorization from a given matrix.
Definition HouseholderQR.h:126
HouseholderQR()
Default Constructor.
Definition HouseholderQR.h:81
MatrixType::RealScalar absDeterminant() const
Definition HouseholderQR.h:247
MatrixType::RealScalar logAbsDeterminant() const
Definition HouseholderQR.h:256
HouseholderQR(const EigenBase< InputType > &matrix)
Constructs a QR factorization from a given matrix.
Definition HouseholderQR.h:108
HouseholderSequenceType householderQ() const
This method returns an expression of the unitary matrix Q as a sequence of Householder transformation...
Definition HouseholderQR.h:163
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
EIGEN_DEVICE_FUNC void makeHouseholderInPlace(Scalar &tau, RealScalar &beta)
Computes the elementary reflector H such that: where the transformation H is: and the vector v is: ...
Definition Householder.h:43
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EvalReturnType eval() const
Definition DenseBase.h:407
EIGEN_DEVICE_FUNC const AdjointReturnType adjoint() const
Definition Transpose.h:221
EIGEN_DEVICE_FUNC void applyHouseholderOnTheLeft(const EssentialPart &essential, const Scalar &tau, Scalar *workspace)
Apply the elementary reflector H given by with from the left to a vector or matrix.
Definition Householder.h:116
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:180
A base class for matrix decomposition and solvers.
Definition SolverBase.h:69
const Solve< HouseholderQR< _MatrixType >, Rhs > solve(const MatrixBase< Rhs > &b) const
Definition SolverBase.h:106
EIGEN_DEVICE_FUNC HouseholderQR< _MatrixType > & derived()
Definition EigenBase.h:46
@ ColMajor
Storage order is column major (see TopicStorageOrders).
Definition Constants.h:319
@ RowMajor
Storage order is row major (see TopicStorageOrders).
Definition Constants.h:321
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition Constants.h:66
Namespace containing all symbols from the Eigen library.
Definition LDLT.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
Eigen::Index Index
The interface type of indices.
Definition EigenBase.h:39
The type used to identify a matrix expression.
Definition Constants.h:522
The type used to identify a general solver (factored) storage.
Definition Constants.h:513
Definition HouseholderQR.h:305
Definition ForwardDeclarations.h:17