10 #ifndef EIGEN_SPARSETRIANGULARSOLVER_H
11 #define EIGEN_SPARSETRIANGULARSOLVER_H
17 template<
typename Lhs,
typename Rhs,
int Mode,
18 int UpLo = (Mode &
Lower)
27 template<
typename Lhs,
typename Rhs,
int Mode>
38 for(
Index i=0; i<lhs.rows(); ++i)
46 lastIndex = it.index();
49 tmp -= lastVal * other.coeff(lastIndex,
col);
52 other.coeffRef(i,
col) = tmp;
56 other.coeffRef(i,
col) = tmp/lastVal;
64 template<
typename Lhs,
typename Rhs,
int Mode>
75 for(
Index i=lhs.rows()-1 ; i>=0 ; --i)
80 while(it && it.index()<i)
88 else if (it && it.index() == i)
92 tmp -= it.value() * other.coeff(it.index(),
col);
96 else other.coeffRef(i,
col) = tmp/l_ii;
103 template<
typename Lhs,
typename Rhs,
int Mode>
114 for(
Index i=0; i<lhs.cols(); ++i)
120 while(it && it.index()<i)
127 if (it && it.index()==i)
130 other.coeffRef(it.index(),
col) -= tmp * it.value();
138 template<
typename Lhs,
typename Rhs,
int Mode>
149 for(
Index i=lhs.cols()-1; i>=0; --i)
158 while(it && it.index()!=i)
161 other.coeffRef(i,
col) /= it.value();
164 for(; it && it.index()<i; ++it)
165 other.coeffRef(it.index(),
col) -= tmp * it.value();
174 #ifndef EIGEN_PARSED_BY_DOXYGEN
176 template<
typename ExpressionType,
unsigned int Mode>
177 template<
typename OtherDerived>
178 void TriangularViewImpl<ExpressionType,Mode,Sparse>::solveInPlace(MatrixBase<OtherDerived>& other)
const
180 eigen_assert(derived().cols() == derived().rows() && derived().cols() == other.rows());
185 typedef typename internal::conditional<
copy,
187 OtherCopy otherCopy(other.derived());
189 internal::sparse_solve_triangular_selector<ExpressionType, typename internal::remove_reference<OtherCopy>::type, Mode>
::run(derived().nestedExpression(), otherCopy);
200 template<
typename Lhs,
typename Rhs,
int Mode,
201 int UpLo = (Mode &
Lower)
210 template<
typename Lhs,
typename Rhs,
int Mode,
int UpLo>
218 const bool IsLower = (UpLo==
Lower);
222 Rhs res(other.rows(), other.cols());
223 res.reserve(other.nonZeros());
228 tempVector.
init(.99);
231 for (
typename Rhs::InnerIterator rhsIt(other,
col); rhsIt; ++rhsIt)
233 tempVector.
coeffRef(rhsIt.index()) = rhsIt.value();
236 for(
Index i=IsLower?0:lhs.cols()-1;
237 IsLower?i<lhs.cols():i>=0;
245 typename Lhs::InnerIterator it(lhs, i);
254 ci /= lhs.coeff(i,i);
262 tempVector.
coeffRef(it.index()) -= ci * it.value();
266 for(; it && it.index()<i; ++it)
267 tempVector.
coeffRef(it.index()) -= ci * it.value();
281 res.insert(it.index(),
col) = it.value();
286 other = res.markAsRValue();
292 #ifndef EIGEN_PARSED_BY_DOXYGEN
293 template<
typename ExpressionType,
unsigned int Mode>
294 template<
typename OtherDerived>
295 void TriangularViewImpl<ExpressionType,Mode,Sparse>::solveInPlace(SparseMatrixBase<OtherDerived>& other)
const
297 eigen_assert(derived().cols() == derived().rows() && derived().cols() == other.rows());
315 #endif // EIGEN_SPARSETRIANGULARSOLVER_H