10#ifndef EIGEN_SPARSETRIANGULARSOLVER_H
11#define EIGEN_SPARSETRIANGULARSOLVER_H
17template<
typename Lhs,
typename Rhs,
int Mode,
18 int UpLo = (Mode &
Lower)
23 int StorageOrder = int(traits<Lhs>::Flags) &
RowMajorBit>
27template<
typename Lhs,
typename Rhs,
int Mode>
30 typedef typename Rhs::Scalar Scalar;
33 static void run(
const Lhs& lhs, Rhs& other)
36 for(
Index col=0 ; col<other.cols() ; ++col)
38 for(
Index i=0; i<lhs.rows(); ++i)
40 Scalar tmp = other.coeff(i,col);
52 other.coeffRef(i,col) = tmp;
56 other.coeffRef(i,col) = tmp/
lastVal;
64template<
typename Lhs,
typename Rhs,
int Mode>
67 typedef typename Rhs::Scalar Scalar;
70 static void run(
const Lhs& lhs, Rhs& other)
73 for(
Index col=0 ; col<other.cols() ; ++col)
75 for(
Index i=lhs.rows()-1 ; i>=0 ; --i)
77 Scalar tmp = other.coeff(i,col);
80 while(it && it.index()<i)
84 eigen_assert(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;
103template<
typename Lhs,
typename Rhs,
int Mode>
106 typedef typename Rhs::Scalar Scalar;
109 static void run(
const Lhs& lhs, Rhs& other)
112 for(
Index col=0 ; col<other.cols() ; ++col)
114 for(
Index i=0; i<lhs.cols(); ++i)
116 Scalar& tmp = other.coeffRef(i,col);
120 while(it && it.index()<i)
124 eigen_assert(it && it.index()==i);
127 if (it && it.index()==i)
130 other.coeffRef(it.index(), col) -= tmp * it.
value();
138template<
typename Lhs,
typename Rhs,
int Mode>
141 typedef typename Rhs::Scalar Scalar;
144 static void run(
const Lhs& lhs, Rhs& other)
147 for(
Index col=0 ; col<other.cols() ; ++col)
149 for(
Index i=lhs.cols()-1; i>=0; --i)
151 Scalar& tmp = other.coeffRef(i,col);
158 while(it && it.index()!=i)
160 eigen_assert(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
176template<
typename ExpressionType,
unsigned int Mode>
177template<
typename OtherDerived>
180 eigen_assert(derived().cols() == derived().rows() && derived().cols() == other.rows());
185 typedef typename internal::conditional<copy,
186 typename internal::plain_matrix_type_column_major<OtherDerived>::type, OtherDerived&>::type OtherCopy;
187 OtherCopy otherCopy(other.derived());
189 internal::sparse_solve_triangular_selector<ExpressionType, typename internal::remove_reference<OtherCopy>::type, Mode>::run(derived().nestedExpression(), otherCopy);
200template<
typename Lhs,
typename Rhs,
int Mode,
201 int UpLo = (Mode &
Lower)
206 int StorageOrder = int(Lhs::Flags) & (
RowMajorBit)>
210template<
typename Lhs,
typename Rhs,
int Mode,
int UpLo>
213 typedef typename Rhs::Scalar Scalar;
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());
225 for(
Index col=0 ; col<other.cols() ; ++col)
236 for(
Index i=IsLower?0:lhs.cols()-1;
237 IsLower?i<lhs.cols():i>=0;
245 typename Lhs::InnerIterator it(lhs, i);
250 eigen_assert(it.index()==i);
254 ci /= lhs.coeff(i,i);
266 for(; it && it.index()<i; ++it)
281 res.insert(it.index(), col) = it.value();
286 other = res.markAsRValue();
292#ifndef EIGEN_PARSED_BY_DOXYGEN
293template<
typename ExpressionType,
unsigned int Mode>
294template<
typename OtherDerived>
297 eigen_assert(derived().cols() == derived().rows() && derived().cols() == other.rows());
EIGEN_DEVICE_FUNC CoeffReturnType value() const
Definition DenseBase.h:526
EIGEN_DEVICE_FUNC Derived & setZero()
Sets all coefficients in this expression to zero.
Definition CwiseNullaryOp.h:546
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
Definition TriangularMatrix.h:183
Iterator over the nonzero coefficients.
Definition AmbiVector.h:285
@ UnitDiag
Matrix has ones on the diagonal; to be used in combination with #Lower or #Upper.
Definition Constants.h:213
@ ZeroDiag
Matrix has zeros on the diagonal; to be used in combination with #Lower or #Upper.
Definition Constants.h:215
@ Lower
View matrix as a lower triangular matrix.
Definition Constants.h:209
@ Upper
View matrix as an upper triangular matrix.
Definition Constants.h:211
@ ColMajor
Storage order is column major (see TopicStorageOrders).
Definition Constants.h:319
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition Constants.h:66
Namespace containing all symbols from the Eigen library.
Definition LDLT.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
Definition TriangularSolver.h:24
Definition TriangularSolver.h:207
Definition ForwardDeclarations.h:17