1
// This file is part of Eigen, a lightweight C++ template library
4
// Copyright (C) 2011 Benoit Jacob <jacob.benoit.1@gmail.com>
6
// Eigen is free software; you can redistribute it and/or
7
// modify it under the terms of the GNU Lesser General Public
8
// License as published by the Free Software Foundation; either
9
// version 3 of the License, or (at your option) any later version.
11
// Alternatively, you can redistribute it and/or
12
// modify it under the terms of the GNU General Public License as
13
// published by the Free Software Foundation; either version 2 of
14
// the License, or (at your option) any later version.
16
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
17
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
19
// GNU General Public License for more details.
21
// You should have received a copy of the GNU Lesser General Public
22
// License and a copy of the GNU General Public License along with
23
// Eigen. If not, see <http://www.gnu.org/licenses/>.
28
template<typename MatrixType>
29
class LU : public FullPivLU<MatrixType>
33
typedef typename MatrixType::Scalar Scalar;
34
typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
35
typedef Matrix<int, 1, MatrixType::ColsAtCompileTime, MatrixType::Options, 1, MatrixType::MaxColsAtCompileTime> IntRowVectorType;
36
typedef Matrix<int, MatrixType::RowsAtCompileTime, 1, MatrixType::Options, MatrixType::MaxRowsAtCompileTime, 1> IntColVectorType;
37
typedef Matrix<Scalar, 1, MatrixType::ColsAtCompileTime, MatrixType::Options, 1, MatrixType::MaxColsAtCompileTime> RowVectorType;
38
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1, MatrixType::Options, MatrixType::MaxRowsAtCompileTime, 1> ColVectorType;
40
typedef Matrix<typename MatrixType::Scalar,
41
MatrixType::ColsAtCompileTime, // the number of rows in the "kernel matrix" is the number of cols of the original matrix
42
// so that the product "matrix * kernel = zero" makes sense
43
Dynamic, // we don't know at compile-time the dimension of the kernel
45
MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter
46
MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space, whose dimension is the number
47
// of columns of the original matrix
50
typedef Matrix<typename MatrixType::Scalar,
51
MatrixType::RowsAtCompileTime, // the image is a subspace of the destination space, whose dimension is the number
52
// of rows of the original matrix
53
Dynamic, // we don't know at compile time the dimension of the image (the rank)
55
MatrixType::MaxRowsAtCompileTime, // the image matrix will consist of columns from the original matrix,
56
MatrixType::MaxColsAtCompileTime // so it has the same number of rows and at most as many columns.
59
typedef FullPivLU<MatrixType> Base;
63
explicit LU(const T& t) : Base(t), m_originalMatrix(t) {}
65
template<typename OtherDerived, typename ResultType>
66
bool solve(const MatrixBase<OtherDerived>& b, ResultType *result) const
68
*result = static_cast<const Base*>(this)->solve(b);
72
template<typename ResultType>
73
inline void computeInverse(ResultType *result) const
75
solve(MatrixType::Identity(this->rows(), this->cols()), result);
78
template<typename KernelMatrixType>
79
void computeKernel(KernelMatrixType *result) const
81
*result = static_cast<const Base*>(this)->kernel();
84
template<typename ImageMatrixType>
85
void computeImage(ImageMatrixType *result) const
87
*result = static_cast<const Base*>(this)->image(m_originalMatrix);
90
const ImageResultType image() const
92
return static_cast<const Base*>(this)->image(m_originalMatrix);
95
const MatrixType& m_originalMatrix;
98
#if EIGEN2_SUPPORT_STAGE < STAGE20_RESOLVE_API_CONFLICTS
101
* Synonym of partialPivLu().
103
* \return the partial-pivoting LU decomposition of \c *this.
105
* \sa class PartialPivLU
107
template<typename Derived>
108
inline const LU<typename MatrixBase<Derived>::PlainObject>
109
MatrixBase<Derived>::lu() const
111
return LU<PlainObject>(eval());
115
#ifdef EIGEN2_SUPPORT
118
* Synonym of partialPivLu().
120
* \return the partial-pivoting LU decomposition of \c *this.
122
* \sa class PartialPivLU
124
template<typename Derived>
125
inline const LU<typename MatrixBase<Derived>::PlainObject>
126
MatrixBase<Derived>::eigen2_lu() const
128
return LU<PlainObject>(eval());
133
#endif // EIGEN2_LU_H