11#ifndef EIGEN_SPARSE_TRIANGULARVIEW_H
12#define EIGEN_SPARSE_TRIANGULARVIEW_H
15#include "./InternalHeaderCheck.h"
29template <
typename MatrixType,
unsigned int Mode>
34 SkipLast = !SkipFirst,
35 SkipDiag = (Mode &
ZeroDiag) ? 1 : 0,
36 HasUnitDiag = (Mode &
UnitDiag) ? 1 : 0
50 typedef typename MatrixType::Nested MatrixTypeNested;
51 typedef std::remove_reference_t<MatrixTypeNested> MatrixTypeNestedNonRef;
52 typedef internal::remove_all_t<MatrixTypeNested> MatrixTypeNestedCleaned;
54 template <
typename RhsType,
typename DstType>
55 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void _solve_impl(
const RhsType& rhs, DstType& dst)
const {
56 if (!(internal::is_same<RhsType, DstType>::value && internal::extract_data(dst) == internal::extract_data(rhs)))
58 this->solveInPlace(dst);
62 template <
typename OtherDerived>
66 template <
typename OtherDerived>
72template <
typename ArgType,
unsigned int Mode>
73struct unary_evaluator<
TriangularView<ArgType, Mode>, IteratorBased> : evaluator_base<TriangularView<ArgType, Mode> > {
77 typedef typename XprType::Scalar Scalar;
78 typedef typename XprType::StorageIndex StorageIndex;
79 typedef typename evaluator<ArgType>::InnerIterator EvalIterator;
84 SkipLast = !SkipFirst,
85 SkipDiag = (Mode &
ZeroDiag) ? 1 : 0,
86 HasUnitDiag = (Mode &
UnitDiag) ? 1 : 0
90 enum { CoeffReadCost = evaluator<ArgType>::CoeffReadCost, Flags = XprType::Flags };
92 explicit unary_evaluator(
const XprType& xpr) : m_argImpl(xpr.nestedExpression()), m_arg(xpr.nestedExpression()) {}
94 inline Index nonZerosEstimate()
const {
return m_argImpl.nonZerosEstimate(); }
96 class InnerIterator :
public EvalIterator {
97 typedef EvalIterator Base;
100 EIGEN_STRONG_INLINE InnerIterator(
const unary_evaluator& xprEval, Index outer)
101 : Base(xprEval.m_argImpl, outer),
103 m_containsDiag(Base::outer() < xprEval.m_arg.innerSize()) {
105 while ((*
this) && ((HasUnitDiag || SkipDiag) ? this->index() <= outer : this->index() < outer))
107 if (HasUnitDiag) m_returnOne = m_containsDiag;
108 }
else if (HasUnitDiag && ((!Base::operator
bool()) || Base::index() >= Base::outer())) {
109 if ((!SkipFirst) && Base::operator
bool()) Base::operator++();
110 m_returnOne = m_containsDiag;
114 EIGEN_STRONG_INLINE InnerIterator& operator++() {
115 if (HasUnitDiag && m_returnOne)
119 if (HasUnitDiag && (!SkipFirst) && ((!Base::operator
bool()) || Base::index() >= Base::outer())) {
120 if ((!SkipFirst) && Base::operator
bool()) Base::operator++();
121 m_returnOne = m_containsDiag;
127 EIGEN_STRONG_INLINE
operator bool()
const {
128 if (HasUnitDiag && m_returnOne)
return true;
130 return Base::operator bool();
133 return (Base::operator
bool() && this->index() < this->outer());
135 return (Base::operator
bool() && this->index() <= this->outer());
139 inline Index row()
const {
return (ArgType::Flags & RowMajorBit ? Base::outer() : this->index()); }
140 inline Index col()
const {
return (ArgType::Flags & RowMajorBit ? this->index() : Base::outer()); }
141 inline StorageIndex index()
const {
142 if (HasUnitDiag && m_returnOne)
143 return internal::convert_index<StorageIndex>(Base::outer());
145 return Base::index();
147 inline Scalar value()
const {
148 if (HasUnitDiag && m_returnOne)
151 return Base::value();
163 evaluator<ArgType> m_argImpl;
164 const ArgType& m_arg;
169template <
typename Derived>
171inline const TriangularView<const Derived, Mode> SparseMatrixBase<Derived>::triangularView()
const {
172 return TriangularView<const Derived, Mode>(derived());
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:52
Base class of any sparse matrices or sparse expressions.
Definition SparseMatrixBase.h:30
void solveInPlace(MatrixBase< OtherDerived > &other) const
void solveInPlace(SparseMatrixBase< OtherDerived > &other) const
Expression of a triangular part in a matrix.
Definition TriangularMatrix.h:167
@ UnitDiag
Definition Constants.h:215
@ ZeroDiag
Definition Constants.h:217
@ Lower
Definition Constants.h:211
@ Upper
Definition Constants.h:213
const unsigned int RowMajorBit
Definition Constants.h:70
Namespace containing all symbols from the Eigen library.
Definition Core:137
Definition Constants.h:519