~choreonoid/choreonoid/debian

« back to all changes in this revision

Viewing changes to thirdparty/eigen3/Eigen/src/Eigen2Support/QR.h

  • Committer: Thomas Moulard
  • Date: 2012-10-23 12:43:24 UTC
  • Revision ID: git-v1:351cf736ad49bc7a9a7b9767dee760a013517a5d
Tags: upstream/1.1.0
ImportedĀ UpstreamĀ versionĀ 1.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// This file is part of Eigen, a lightweight C++ template library
 
2
// for linear algebra.
 
3
//
 
4
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
 
5
// Copyright (C) 2011 Benoit Jacob <jacob.benoit.1@gmail.com>
 
6
//
 
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.
 
11
//
 
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.
 
16
//
 
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.
 
21
//
 
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/>.
 
25
 
 
26
#ifndef EIGEN2_QR_H
 
27
#define EIGEN2_QR_H
 
28
 
 
29
template<typename MatrixType>
 
30
class QR : public HouseholderQR<MatrixType>
 
31
{
 
32
  public:
 
33
 
 
34
    typedef HouseholderQR<MatrixType> Base;
 
35
    typedef Block<const MatrixType, MatrixType::ColsAtCompileTime, MatrixType::ColsAtCompileTime> MatrixRBlockType;
 
36
 
 
37
    QR() : Base() {}
 
38
 
 
39
    template<typename T>
 
40
    explicit QR(const T& t) : Base(t) {}
 
41
 
 
42
    template<typename OtherDerived, typename ResultType>
 
43
    bool solve(const MatrixBase<OtherDerived>& b, ResultType *result) const
 
44
    {
 
45
      *result = static_cast<const Base*>(this)->solve(b);
 
46
      return true;
 
47
    }
 
48
 
 
49
    MatrixType matrixQ(void) const {
 
50
      MatrixType ret = MatrixType::Identity(this->rows(), this->cols());
 
51
      ret = this->householderQ() * ret;
 
52
      return ret;
 
53
    }
 
54
 
 
55
    bool isFullRank() const {
 
56
      return true;
 
57
    }
 
58
    
 
59
    const TriangularView<MatrixRBlockType, UpperTriangular>
 
60
    matrixR(void) const
 
61
    {
 
62
      int cols = this->cols();
 
63
      return MatrixRBlockType(this->matrixQR(), 0, 0, cols, cols).template triangularView<UpperTriangular>();
 
64
    }
 
65
};
 
66
 
 
67
/** \return the QR decomposition of \c *this.
 
68
  *
 
69
  * \sa class QR
 
70
  */
 
71
template<typename Derived>
 
72
const QR<typename MatrixBase<Derived>::PlainObject>
 
73
MatrixBase<Derived>::qr() const
 
74
{
 
75
  return QR<PlainObject>(eval());
 
76
}
 
77
 
 
78
 
 
79
#endif // EIGEN2_QR_H