10 #ifndef EIGEN_SPARSETRIANGULARSOLVER_H 11 #define EIGEN_SPARSETRIANGULARSOLVER_H 17 template<
typename Lhs,
typename Rhs,
int Mode,
18 int UpLo = (Mode &
Lower)
23 int StorageOrder = int(traits<Lhs>::Flags) &
RowMajorBit>
27 template<
typename Lhs,
typename Rhs,
int Mode>
33 static void run(
const Lhs& lhs, Rhs& other)
38 for(
Index i=0; i<lhs.rows(); ++i)
40 Scalar tmp = other.coeff(i,
col);
43 for(LhsIterator it(lhsEval, i); it; ++it)
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>
70 static void run(
const Lhs& lhs, Rhs& other)
75 for(
Index i=lhs.rows()-1 ; i>=0 ; --i)
77 Scalar tmp = other.coeff(i,
col);
79 LhsIterator it(lhsEval, i);
80 while(it && it.index()<i)
88 else if (it && it.index() == i)
92 tmp -= it.value() * other.coeff(it.index(),
col);
95 if (Mode & UnitDiag) other.coeffRef(i,
col) = tmp;
96 else other.coeffRef(i,
col) = tmp/l_ii;
103 template<
typename Lhs,
typename Rhs,
int Mode>
109 static void run(
const Lhs& lhs, Rhs& other)
111 LhsEval lhsEval(lhs);
114 for(
Index i=0; i<lhs.cols(); ++i)
116 Scalar& tmp = other.coeffRef(i,
col);
119 LhsIterator it(lhsEval, 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>
144 static void run(
const Lhs& lhs, Rhs& other)
146 LhsEval lhsEval(lhs);
149 for(
Index i=lhs.cols()-1; i>=0; --i)
151 Scalar& tmp = other.coeffRef(i,
col);
157 LhsIterator it(lhsEval, i);
158 while(it && it.index()!=i)
161 other.coeffRef(i,
col) /= it.value();
163 LhsIterator it(lhsEval, i);
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>
180 eigen_assert(derived().cols() == derived().rows() && derived().cols() == other.rows());
187 OtherCopy otherCopy(other.derived());
200 template<
typename Lhs,
typename Rhs,
int Mode,
201 int UpLo = (Mode &
Lower)
206 int StorageOrder = int(Lhs::Flags) & (
RowMajorBit)>
210 template<
typename Lhs,
typename Rhs,
int Mode,
int UpLo>
216 static void run(
const Lhs& lhs, Rhs& other)
218 const bool IsLower = (UpLo==
Lower);
222 Rhs res(other.rows(), other.cols());
223 res.reserve(other.nonZeros());
228 tempVector.init(.99);
229 tempVector.setZero();
230 tempVector.restart();
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;
240 tempVector.restart();
241 Scalar& ci = tempVector.coeffRef(i);
245 typename Lhs::InnerIterator it(lhs, i);
254 ci /= lhs.coeff(i,i);
256 tempVector.restart();
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>
297 eigen_assert(derived().cols() == derived().rows() && derived().cols() == other.
rows());
315 #endif // EIGEN_SPARSETRIANGULARSOLVER_H
static void run(const Lhs &lhs, Rhs &other)
evaluator< Lhs >::InnerIterator LhsIterator
void setBounds(Index start, Index end)
const unsigned int RowMajorBit
promote_index_type< typename traits< Lhs >::StorageIndex, typename traits< Rhs >::StorageIndex >::type StorageIndex
EIGEN_DEVICE_FUNC ColXpr col(Index i)
This is the const version of col().
static void run(const Lhs &lhs, Rhs &other)
Base class of any sparse matrices or sparse expressions.
static void run(const Lhs &lhs, Rhs &other)
static void run(const Lhs &lhs, Rhs &other)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
evaluator< Lhs >::InnerIterator LhsIterator
const Derived & derived() const
evaluator< Lhs >::InnerIterator LhsIterator
The matrix class, also used for vectors and row-vectors.
void run(Expr &expr, Dev &dev)
Base class for all dense matrices, vectors, and expressions.
evaluator< Lhs >::InnerIterator LhsIterator
static void run(const Lhs &lhs, Rhs &other)