1
// This file is part of Eigen, a lightweight C++ template library
4
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
5
// Copyright (C) 2011 Benoit Jacob <jacob.benoit.1@gmail.com>
7
// Eigen is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU Lesser General Public
9
// License as published by the Free Software Foundation; either
10
// version 3 of the License, or (at your option) any later version.
12
// Alternatively, you can redistribute it and/or
13
// modify it under the terms of the GNU General Public License as
14
// published by the Free Software Foundation; either version 2 of
15
// the License, or (at your option) any later version.
17
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
18
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
20
// GNU General Public License for more details.
22
// You should have received a copy of the GNU Lesser General Public
23
// License and a copy of the GNU General Public License along with
24
// Eigen. If not, see <http://www.gnu.org/licenses/>.
29
template<typename MatrixType>
30
class QR : public HouseholderQR<MatrixType>
34
typedef HouseholderQR<MatrixType> Base;
35
typedef Block<const MatrixType, MatrixType::ColsAtCompileTime, MatrixType::ColsAtCompileTime> MatrixRBlockType;
40
explicit QR(const T& t) : Base(t) {}
42
template<typename OtherDerived, typename ResultType>
43
bool solve(const MatrixBase<OtherDerived>& b, ResultType *result) const
45
*result = static_cast<const Base*>(this)->solve(b);
49
MatrixType matrixQ(void) const {
50
MatrixType ret = MatrixType::Identity(this->rows(), this->cols());
51
ret = this->householderQ() * ret;
55
bool isFullRank() const {
59
const TriangularView<MatrixRBlockType, UpperTriangular>
62
int cols = this->cols();
63
return MatrixRBlockType(this->matrixQR(), 0, 0, cols, cols).template triangularView<UpperTriangular>();
67
/** \return the QR decomposition of \c *this.
71
template<typename Derived>
72
const QR<typename MatrixBase<Derived>::PlainObject>
73
MatrixBase<Derived>::qr() const
75
return QR<PlainObject>(eval());