LU.h
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2011 Benoit Jacob <jacob.benoit.1@gmail.com>
00005 //
00006 // Eigen is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 3 of the License, or (at your option) any later version.
00010 //
00011 // Alternatively, you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License as
00013 // published by the Free Software Foundation; either version 2 of
00014 // the License, or (at your option) any later version.
00015 //
00016 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
00017 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00018 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
00019 // GNU General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License and a copy of the GNU General Public License along with
00023 // Eigen. If not, see <http://www.gnu.org/licenses/>.
00024 
00025 #ifndef EIGEN2_LU_H
00026 #define EIGEN2_LU_H
00027 
00028 template<typename MatrixType>
00029 class LU : public FullPivLU<MatrixType>
00030 {
00031   public:
00032 
00033     typedef typename MatrixType::Scalar Scalar;
00034     typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
00035     typedef Matrix<int, 1, MatrixType::ColsAtCompileTime, MatrixType::Options, 1, MatrixType::MaxColsAtCompileTime> IntRowVectorType;
00036     typedef Matrix<int, MatrixType::RowsAtCompileTime, 1, MatrixType::Options, MatrixType::MaxRowsAtCompileTime, 1> IntColVectorType;
00037     typedef Matrix<Scalar, 1, MatrixType::ColsAtCompileTime, MatrixType::Options, 1, MatrixType::MaxColsAtCompileTime> RowVectorType;
00038     typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1, MatrixType::Options, MatrixType::MaxRowsAtCompileTime, 1> ColVectorType;
00039 
00040     typedef Matrix<typename MatrixType::Scalar,
00041                   MatrixType::ColsAtCompileTime, // the number of rows in the "kernel matrix" is the number of cols of the original matrix
00042                                                  // so that the product "matrix * kernel = zero" makes sense
00043                   Dynamic,                       // we don't know at compile-time the dimension of the kernel
00044                   MatrixType::Options,
00045                   MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter
00046                   MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space, whose dimension is the number
00047                                                    // of columns of the original matrix
00048     > KernelResultType;
00049 
00050     typedef Matrix<typename MatrixType::Scalar,
00051                    MatrixType::RowsAtCompileTime, // the image is a subspace of the destination space, whose dimension is the number
00052                                                   // of rows of the original matrix
00053                    Dynamic,                       // we don't know at compile time the dimension of the image (the rank)
00054                    MatrixType::Options,
00055                    MatrixType::MaxRowsAtCompileTime, // the image matrix will consist of columns from the original matrix,
00056                    MatrixType::MaxColsAtCompileTime  // so it has the same number of rows and at most as many columns.
00057     > ImageResultType;
00058 
00059     typedef FullPivLU<MatrixType> Base;
00060     LU() : Base() {}
00061 
00062     template<typename T>
00063     explicit LU(const T& t) : Base(t), m_originalMatrix(t) {}
00064 
00065     template<typename OtherDerived, typename ResultType>
00066     bool solve(const MatrixBase<OtherDerived>& b, ResultType *result) const
00067     {
00068       *result = static_cast<const Base*>(this)->solve(b);
00069       return true;
00070     }
00071 
00072     template<typename ResultType>
00073     inline void computeInverse(ResultType *result) const
00074     {
00075       solve(MatrixType::Identity(this->rows(), this->cols()), result);
00076     }
00077     
00078     template<typename KernelMatrixType>
00079     void computeKernel(KernelMatrixType *result) const
00080     {
00081       *result = static_cast<const Base*>(this)->kernel();
00082     }
00083     
00084     template<typename ImageMatrixType>
00085     void computeImage(ImageMatrixType *result) const
00086     {
00087       *result = static_cast<const Base*>(this)->image(m_originalMatrix);
00088     }
00089     
00090     const ImageResultType image() const
00091     {
00092       return static_cast<const Base*>(this)->image(m_originalMatrix);
00093     }
00094     
00095     const MatrixType& m_originalMatrix;
00096 };
00097 
00098 #if EIGEN2_SUPPORT_STAGE < STAGE20_RESOLVE_API_CONFLICTS
00099 
00107 template<typename Derived>
00108 inline const LU<typename MatrixBase<Derived>::PlainObject>
00109 MatrixBase<Derived>::lu() const
00110 {
00111   return LU<PlainObject>(eval());
00112 }
00113 #endif
00114 
00115 #ifdef EIGEN2_SUPPORT
00116 
00124 template<typename Derived>
00125 inline const LU<typename MatrixBase<Derived>::PlainObject>
00126 MatrixBase<Derived>::eigen2_lu() const
00127 {
00128   return LU<PlainObject>(eval());
00129 }
00130 #endif
00131 
00132 
00133 #endif // EIGEN2_LU_H


libicr
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:32:59