SparseTriangularView.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) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
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 EIGEN_SPARSE_TRIANGULARVIEW_H
00026 #define EIGEN_SPARSE_TRIANGULARVIEW_H
00027 
00028 namespace internal {
00029   
00030 template<typename MatrixType, int Mode>
00031 struct traits<SparseTriangularView<MatrixType,Mode> >
00032 : public traits<MatrixType>
00033 {};
00034 
00035 } // namespace internal
00036 
00037 template<typename MatrixType, int Mode> class SparseTriangularView
00038   : public SparseMatrixBase<SparseTriangularView<MatrixType,Mode> >
00039 {
00040     enum { SkipFirst = (Mode==Lower && !(MatrixType::Flags&RowMajorBit))
00041                     || (Mode==Upper &&  (MatrixType::Flags&RowMajorBit)) };
00042   public:
00043     
00044     EIGEN_SPARSE_PUBLIC_INTERFACE(SparseTriangularView)
00045 
00046     class InnerIterator;
00047 
00048     inline Index rows() const { return m_matrix.rows(); }
00049     inline Index cols() const { return m_matrix.cols(); }
00050 
00051     typedef typename internal::conditional<internal::must_nest_by_value<MatrixType>::ret,
00052         MatrixType, const MatrixType&>::type MatrixTypeNested;
00053 
00054     inline SparseTriangularView(const MatrixType& matrix) : m_matrix(matrix) {}
00055 
00057     inline const MatrixType& nestedExpression() const { return m_matrix; }
00058 
00059     template<typename OtherDerived>
00060     typename internal::plain_matrix_type_column_major<OtherDerived>::type
00061     solve(const MatrixBase<OtherDerived>& other) const;
00062 
00063     template<typename OtherDerived> void solveInPlace(MatrixBase<OtherDerived>& other) const;
00064     template<typename OtherDerived> void solveInPlace(SparseMatrixBase<OtherDerived>& other) const;
00065 
00066   protected:
00067     MatrixTypeNested m_matrix;
00068 };
00069 
00070 template<typename MatrixType, int Mode>
00071 class SparseTriangularView<MatrixType,Mode>::InnerIterator : public MatrixType::InnerIterator
00072 {
00073     typedef typename MatrixType::InnerIterator Base;
00074   public:
00075 
00076     EIGEN_STRONG_INLINE InnerIterator(const SparseTriangularView& view, Index outer)
00077       : Base(view.nestedExpression(), outer)
00078     {
00079       if(SkipFirst)
00080         while((*this) && this->index()<outer)
00081           ++(*this);
00082     }
00083     inline Index row() const { return Base::row(); }
00084     inline Index col() const { return Base::col(); }
00085 
00086     EIGEN_STRONG_INLINE operator bool() const
00087     {
00088       return SkipFirst ? Base::operator bool() : (Base::operator bool() && this->index() <= this->outer());
00089     }
00090 };
00091 
00092 template<typename Derived>
00093 template<int Mode>
00094 inline const SparseTriangularView<Derived, Mode>
00095 SparseMatrixBase<Derived>::triangularView() const
00096 {
00097   return derived();
00098 }
00099 
00100 #endif // EIGEN_SPARSE_TRIANGULARVIEW_H


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:32:58