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>
33 static void run(
const Lhs& lhs, Rhs& other)
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;
64template<
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)
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;
103template<
typename Lhs,
typename Rhs,
int Mode>
109 static void run(
const Lhs& lhs, Rhs& other)
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();
138template<
typename Lhs,
typename Rhs,
int Mode>
144 static void run(
const Lhs& lhs, Rhs& other)
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
176template<
typename ExpressionType,
unsigned int Mode>
177template<
typename OtherDerived>
178void 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());
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>
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);
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
293template<
typename ExpressionType,
unsigned int Mode>
294template<
typename OtherDerived>
295void TriangularViewImpl<ExpressionType,Mode,Sparse>::solveInPlace(SparseMatrixBase<OtherDerived>& other)
const
297 eigen_assert(derived().cols() == derived().rows() && derived().cols() == other.rows());
306 internal::sparse_solve_triangular_sparse_selector<ExpressionType, OtherDerived, Mode>::run(derived().nestedExpression(), other.derived());
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ColXpr col(Index i)
This is the const version of col().
Definition: BlockMethods.h:1097
#define eigen_assert(x)
Definition: Macros.h:1047
Iterator over the nonzero coefficients.
Definition: AmbiVector.h:285
Definition: AmbiVector.h:24
void restart()
Must be called whenever we might perform a write access with an index smaller than the previous one.
Definition: AmbiVector.h:164
void init(double estimatedDensity)
Definition: AmbiVector.h:138
void setBounds(Index start, Index end)
Specifies a sub-vector to work on.
Definition: AmbiVector.h:42
Scalar & coeffRef(Index i)
Definition: AmbiVector.h:187
void setZero()
Set all coefficients of current subvector to zero.
Definition: AmbiVector.h:171
type
Definition: core.h:575
@ 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
@ RowMajor
Storage order is row major (see TopicStorageOrders).
Definition: Constants.h:321
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: Core:141
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
OutputIterator copy(const RangeT &range, OutputIterator out)
Definition: ranges.h:26
Definition: Eigen_Colamd.h:50
Matrix< typename traits< T >::Scalar, Rows, Cols,(MaxRows==1 &&MaxCols!=1) ? RowMajor :ColMajor, MaxRows, MaxCols > type
Definition: XprHelper.h:391
evaluator< Lhs >::InnerIterator LhsIterator
Definition: TriangularSolver.h:108
static void run(const Lhs &lhs, Rhs &other)
Definition: TriangularSolver.h:109
evaluator< Lhs > LhsEval
Definition: TriangularSolver.h:107
Rhs::Scalar Scalar
Definition: TriangularSolver.h:106
Rhs::Scalar Scalar
Definition: TriangularSolver.h:30
evaluator< Lhs > LhsEval
Definition: TriangularSolver.h:31
static void run(const Lhs &lhs, Rhs &other)
Definition: TriangularSolver.h:33
evaluator< Lhs >::InnerIterator LhsIterator
Definition: TriangularSolver.h:32
Rhs::Scalar Scalar
Definition: TriangularSolver.h:141
static void run(const Lhs &lhs, Rhs &other)
Definition: TriangularSolver.h:144
evaluator< Lhs > LhsEval
Definition: TriangularSolver.h:142
evaluator< Lhs >::InnerIterator LhsIterator
Definition: TriangularSolver.h:143
evaluator< Lhs >::InnerIterator LhsIterator
Definition: TriangularSolver.h:69
Rhs::Scalar Scalar
Definition: TriangularSolver.h:67
evaluator< Lhs > LhsEval
Definition: TriangularSolver.h:68
static void run(const Lhs &lhs, Rhs &other)
Definition: TriangularSolver.h:70
Definition: TriangularSolver.h:24
Definition: TriangularSolver.h:212
Rhs::Scalar Scalar
Definition: TriangularSolver.h:213
promote_index_type< typenametraits< Lhs >::StorageIndex, typenametraits< Rhs >::StorageIndex >::type StorageIndex
Definition: TriangularSolver.h:215
static void run(const Lhs &lhs, Rhs &other)
Definition: TriangularSolver.h:216
Definition: TriangularSolver.h:207
Definition: ForwardDeclarations.h:17