1
// This file is part of Eigen, a lightweight C++ template library
4
// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
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/>.
25
#ifndef EIGEN_SPARSE_TRIANGULARVIEW_H
26
#define EIGEN_SPARSE_TRIANGULARVIEW_H
30
template<typename MatrixType, int Mode>
31
struct traits<SparseTriangularView<MatrixType,Mode> >
32
: public traits<MatrixType>
35
} // namespace internal
37
template<typename MatrixType, int Mode> class SparseTriangularView
38
: public SparseMatrixBase<SparseTriangularView<MatrixType,Mode> >
40
enum { SkipFirst = (Mode==Lower && !(MatrixType::Flags&RowMajorBit))
41
|| (Mode==Upper && (MatrixType::Flags&RowMajorBit)) };
44
EIGEN_SPARSE_PUBLIC_INTERFACE(SparseTriangularView)
48
inline Index rows() const { return m_matrix.rows(); }
49
inline Index cols() const { return m_matrix.cols(); }
51
typedef typename internal::conditional<internal::must_nest_by_value<MatrixType>::ret,
52
MatrixType, const MatrixType&>::type MatrixTypeNested;
54
inline SparseTriangularView(const MatrixType& matrix) : m_matrix(matrix) {}
57
inline const MatrixType& nestedExpression() const { return m_matrix; }
59
template<typename OtherDerived>
60
typename internal::plain_matrix_type_column_major<OtherDerived>::type
61
solve(const MatrixBase<OtherDerived>& other) const;
63
template<typename OtherDerived> void solveInPlace(MatrixBase<OtherDerived>& other) const;
64
template<typename OtherDerived> void solveInPlace(SparseMatrixBase<OtherDerived>& other) const;
67
MatrixTypeNested m_matrix;
70
template<typename MatrixType, int Mode>
71
class SparseTriangularView<MatrixType,Mode>::InnerIterator : public MatrixType::InnerIterator
73
typedef typename MatrixType::InnerIterator Base;
76
EIGEN_STRONG_INLINE InnerIterator(const SparseTriangularView& view, Index outer)
77
: Base(view.nestedExpression(), outer)
80
while((*this) && this->index()<outer)
83
inline Index row() const { return Base::row(); }
84
inline Index col() const { return Base::col(); }
86
EIGEN_STRONG_INLINE operator bool() const
88
return SkipFirst ? Base::operator bool() : (Base::operator bool() && this->index() <= this->outer());
92
template<typename Derived>
94
inline const SparseTriangularView<Derived, Mode>
95
SparseMatrixBase<Derived>::triangularView() const
100
#endif // EIGEN_SPARSE_TRIANGULARVIEW_H