Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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 }
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