11 #ifndef EIGEN_SPARSE_TRIANGULARVIEW_H 12 #define EIGEN_SPARSE_TRIANGULARVIEW_H 25 template<
typename MatrixType,
unsigned int Mode>
class TriangularViewImpl<MatrixType,Mode,
Sparse>
30 SkipLast = !SkipFirst,
32 HasUnitDiag = (Mode&
UnitDiag) ? 1 : 0
44 EIGEN_SPARSE_PUBLIC_INTERFACE(TriangularViewType)
46 typedef typename MatrixType::Nested MatrixTypeNested;
47 typedef typename internal::remove_reference<MatrixTypeNested>::type MatrixTypeNestedNonRef;
48 typedef typename internal::remove_all<MatrixTypeNested>::type MatrixTypeNestedCleaned;
50 template<
typename RhsType,
typename DstType>
52 EIGEN_STRONG_INLINE
void _solve_impl(
const RhsType &rhs, DstType &dst)
const {
53 if(!(internal::is_same<RhsType,DstType>::value && internal::extract_data(dst) == internal::extract_data(rhs)))
55 this->solveInPlace(dst);
65 template<
typename ArgType,
unsigned int Mode>
66 struct unary_evaluator<TriangularView<ArgType,Mode>, IteratorBased>
67 : evaluator_base<TriangularView<ArgType,Mode> >
73 typedef typename XprType::Scalar Scalar;
74 typedef typename XprType::StorageIndex StorageIndex;
75 typedef typename evaluator<ArgType>::InnerIterator EvalIterator;
79 SkipLast = !SkipFirst,
81 HasUnitDiag = (Mode&
UnitDiag) ? 1 : 0
87 CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
88 Flags = XprType::Flags
91 explicit unary_evaluator(
const XprType &xpr) : m_argImpl(xpr.nestedExpression()), m_arg(xpr.nestedExpression()) {}
93 inline Index nonZerosEstimate()
const {
94 return m_argImpl.nonZerosEstimate();
97 class InnerIterator :
public EvalIterator
99 typedef EvalIterator
Base;
102 EIGEN_STRONG_INLINE InnerIterator(
const unary_evaluator& xprEval,
Index outer)
103 : Base(xprEval.m_argImpl,outer), m_returnOne(
false), m_containsDiag(Base::outer()<xprEval.m_arg.innerSize())
107 while((*
this) && ((HasUnitDiag||SkipDiag) ? this->index()<=outer : this->index()<outer))
110 m_returnOne = m_containsDiag;
112 else if(HasUnitDiag && ((!Base::operator
bool()) || Base::index()>=Base::outer()))
114 if((!SkipFirst) && Base::operator
bool())
116 m_returnOne = m_containsDiag;
120 EIGEN_STRONG_INLINE InnerIterator& operator++()
122 if(HasUnitDiag && m_returnOne)
127 if(HasUnitDiag && (!SkipFirst) && ((!Base::operator
bool()) || Base::index()>=Base::outer()))
129 if((!SkipFirst) && Base::operator
bool())
131 m_returnOne = m_containsDiag;
137 EIGEN_STRONG_INLINE
operator bool()
const 139 if(HasUnitDiag && m_returnOne)
141 if(SkipFirst)
return Base::operator bool();
144 if (SkipDiag)
return (Base::operator
bool() && this->index() < this->outer());
145 else return (Base::operator
bool() && this->index() <= this->outer());
151 inline StorageIndex index()
const 153 if(HasUnitDiag && m_returnOne)
return internal::convert_index<StorageIndex>(Base::outer());
154 else return Base::index();
156 inline Scalar value()
const 158 if(HasUnitDiag && m_returnOne)
return Scalar(1);
159 else return Base::value();
170 evaluator<ArgType> m_argImpl;
171 const ArgType& m_arg;
176 template<
typename Derived>
186 #endif // EIGEN_SPARSE_TRIANGULARVIEW_H Namespace containing all symbols from the Eigen library.
Definition: Core:271
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:37
const unsigned int RowMajorBit
Definition: Constants.h:61
Base class of any sparse matrices or sparse expressions.
Definition: ForwardDeclarations.h:281
Definition: Constants.h:204
Definition: Constants.h:208
Definition: Constants.h:494
Definition: Constants.h:206
Definition: Constants.h:210
Definition: Eigen_Colamd.h:50
Expression of a triangular part in a matrix.
Definition: TriangularMatrix.h:186
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48