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 // This Source Code Form is subject to the terms of the Mozilla
00007 // Public License v. 2.0. If a copy of the MPL was not distributed
00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00009 
00010 #ifndef EIGEN2_LU_H
00011 #define EIGEN2_LU_H
00012 
00013 namespace Eigen { 
00014 
00015 template<typename MatrixType>
00016 class LU : public FullPivLU<MatrixType>
00017 {
00018   public:
00019 
00020     typedef typename MatrixType::Scalar Scalar;
00021     typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
00022     typedef Matrix<int, 1, MatrixType::ColsAtCompileTime, MatrixType::Options, 1, MatrixType::MaxColsAtCompileTime> IntRowVectorType;
00023     typedef Matrix<int, MatrixType::RowsAtCompileTime, 1, MatrixType::Options, MatrixType::MaxRowsAtCompileTime, 1> IntColVectorType;
00024     typedef Matrix<Scalar, 1, MatrixType::ColsAtCompileTime, MatrixType::Options, 1, MatrixType::MaxColsAtCompileTime> RowVectorType;
00025     typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1, MatrixType::Options, MatrixType::MaxRowsAtCompileTime, 1> ColVectorType;
00026 
00027     typedef Matrix<typename MatrixType::Scalar,
00028                   MatrixType::ColsAtCompileTime, // the number of rows in the "kernel matrix" is the number of cols of the original matrix
00029                                                  // so that the product "matrix * kernel = zero" makes sense
00030                   Dynamic,                       // we don't know at compile-time the dimension of the kernel
00031                   MatrixType::Options,
00032                   MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter
00033                   MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space, whose dimension is the number
00034                                                    // of columns of the original matrix
00035     > KernelResultType;
00036 
00037     typedef Matrix<typename MatrixType::Scalar,
00038                    MatrixType::RowsAtCompileTime, // the image is a subspace of the destination space, whose dimension is the number
00039                                                   // of rows of the original matrix
00040                    Dynamic,                       // we don't know at compile time the dimension of the image (the rank)
00041                    MatrixType::Options,
00042                    MatrixType::MaxRowsAtCompileTime, // the image matrix will consist of columns from the original matrix,
00043                    MatrixType::MaxColsAtCompileTime  // so it has the same number of rows and at most as many columns.
00044     > ImageResultType;
00045 
00046     typedef FullPivLU<MatrixType> Base;
00047 
00048     template<typename T>
00049     explicit LU(const T& t) : Base(t), m_originalMatrix(t) {}
00050 
00051     template<typename OtherDerived, typename ResultType>
00052     bool solve(const MatrixBase<OtherDerived>& b, ResultType *result) const
00053     {
00054       *result = static_cast<const Base*>(this)->solve(b);
00055       return true;
00056     }
00057 
00058     template<typename ResultType>
00059     inline void computeInverse(ResultType *result) const
00060     {
00061       solve(MatrixType::Identity(this->rows(), this->cols()), result);
00062     }
00063     
00064     template<typename KernelMatrixType>
00065     void computeKernel(KernelMatrixType *result) const
00066     {
00067       *result = static_cast<const Base*>(this)->kernel();
00068     }
00069     
00070     template<typename ImageMatrixType>
00071     void computeImage(ImageMatrixType *result) const
00072     {
00073       *result = static_cast<const Base*>(this)->image(m_originalMatrix);
00074     }
00075     
00076     const ImageResultType image() const
00077     {
00078       return static_cast<const Base*>(this)->image(m_originalMatrix);
00079     }
00080     
00081     const MatrixType& m_originalMatrix;
00082 };
00083 
00084 #if EIGEN2_SUPPORT_STAGE < STAGE20_RESOLVE_API_CONFLICTS
00085 
00093 template<typename Derived>
00094 inline const LU<typename MatrixBase<Derived>::PlainObject>
00095 MatrixBase<Derived>::lu() const
00096 {
00097   return LU<PlainObject>(eval());
00098 }
00099 #endif
00100 
00101 #ifdef EIGEN2_SUPPORT
00102 
00110 template<typename Derived>
00111 inline const LU<typename MatrixBase<Derived>::PlainObject>
00112 MatrixBase<Derived>::eigen2_lu() const
00113 {
00114   return LU<PlainObject>(eval());
00115 }
00116 #endif
00117 
00118 } // end namespace Eigen
00119 
00120 #endif // EIGEN2_LU_H


win_eigen
Author(s): Daniel Stonier
autogenerated on Wed Sep 16 2015 07:11:09