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>
31 static void run(
const Lhs& lhs, Rhs& other)
33 for(
int col=0 ; col<other.cols() ; ++col)
35 for(
int i=0; i<lhs.rows(); ++i)
37 Scalar tmp = other.coeff(i,col);
40 for(
typename Lhs::InnerIterator it(lhs, i); it; ++it)
43 lastIndex = it.index();
46 tmp -= lastVal * other.coeff(lastIndex,col);
49 other.coeffRef(i,col) = tmp;
52 eigen_assert(lastIndex==i);
53 other.coeffRef(i,col) = tmp/lastVal;
61 template<
typename Lhs,
typename Rhs,
int Mode>
65 static void run(
const Lhs& lhs, Rhs& other)
67 for(
int col=0 ; col<other.cols() ; ++col)
69 for(
int i=lhs.rows()-1 ; i>=0 ; --i)
71 Scalar tmp = other.coeff(i,col);
73 typename Lhs::InnerIterator it(lhs, i);
74 while(it && it.index()<i)
78 eigen_assert(it && it.index()==i);
82 else if (it && it.index() == i)
86 tmp -= it.value() * other.coeff(it.index(),col);
90 other.coeffRef(i,col) = tmp;
92 other.coeffRef(i,col) = tmp/l_ii;
99 template<
typename Lhs,
typename Rhs,
int Mode>
103 static void run(
const Lhs& lhs, Rhs& other)
105 for(
int col=0 ; col<other.cols() ; ++col)
107 for(
int i=0; i<lhs.cols(); ++i)
109 Scalar& tmp = other.coeffRef(i,col);
112 typename Lhs::InnerIterator it(lhs, i);
113 while(it && it.index()<i)
117 eigen_assert(it && it.index()==i);
120 if (it && it.index()==i)
123 other.coeffRef(it.index(), col) -= tmp * it.value();
131 template<
typename Lhs,
typename Rhs,
int Mode>
135 static void run(
const Lhs& lhs, Rhs& other)
137 for(
int col=0 ; col<other.cols() ; ++col)
139 for(
int i=lhs.cols()-1; i>=0; --i)
141 Scalar& tmp = other.coeffRef(i,col);
147 typename Lhs::ReverseInnerIterator it(lhs, i);
148 while(it && it.index()!=i)
150 eigen_assert(it && it.index()==i);
151 other.coeffRef(i,col) /= it.value();
153 typename Lhs::InnerIterator it(lhs, i);
154 for(; it && it.index()<i; ++it)
155 other.coeffRef(it.index(), col) -= tmp * it.value();
164 template<
typename ExpressionType,
int Mode>
165 template<
typename OtherDerived>
168 eigen_assert(m_matrix.cols() == m_matrix.rows() && m_matrix.cols() == other.rows());
175 OtherCopy otherCopy(other.derived());
183 template<
typename ExpressionType,
int Mode>
184 template<
typename OtherDerived>
197 template<
typename Lhs,
typename Rhs,
int Mode,
198 int UpLo = (Mode &
Lower)
203 int StorageOrder = int(Lhs::Flags) & (
RowMajorBit)>
207 template<
typename Lhs,
typename Rhs,
int Mode,
int UpLo>
213 static void run(
const Lhs& lhs, Rhs& other)
215 const bool IsLower = (UpLo==
Lower);
219 Rhs res(other.rows(), other.cols());
220 res.reserve(other.nonZeros());
222 for(
int col=0 ; col<other.cols() ; ++col)
225 tempVector.init(.99);
226 tempVector.setZero();
227 tempVector.restart();
228 for (
typename Rhs::InnerIterator rhsIt(other, col); rhsIt; ++rhsIt)
230 tempVector.coeffRef(rhsIt.index()) = rhsIt.value();
233 for(
int i=IsLower?0:lhs.cols()-1;
234 IsLower?i<lhs.cols():i>=0;
237 tempVector.restart();
238 Scalar& ci = tempVector.coeffRef(i);
242 typename Lhs::InnerIterator it(lhs, i);
247 eigen_assert(it.index()==i);
251 ci /= lhs.coeff(i,i);
253 tempVector.restart();
259 tempVector.coeffRef(it.index()) -= ci * it.value();
263 for(; it && it.index()<i; ++it)
264 tempVector.coeffRef(it.index()) -= ci * it.value();
278 res.insert(it.index(), col) = it.value();
283 other = res.markAsRValue();
289 template<
typename ExpressionType,
int Mode>
290 template<
typename OtherDerived>
293 eigen_assert(m_matrix.cols() == m_matrix.rows() && m_matrix.cols() == other.
rows());
308 #ifdef EIGEN2_SUPPORT 313 template<
typename Derived>
314 template<
typename OtherDerived>
317 this->
template triangular<Flags&(Upper|Lower)>().solveInPlace(other);
321 template<
typename Derived>
322 template<
typename OtherDerived>
327 derived().solveTriangularInPlace(res);
330 #endif // EIGEN2_SUPPORT 334 #endif // EIGEN_SPARSETRIANGULARSOLVER_H Iterator over the nonzero coefficients.
Definition: AmbiVector.h:279
void setBounds(Index start, Index end)
Specifies a sub-vector to work on.
Definition: AmbiVector.h:42
Definition: TriangularSolver.h:24
Definition: TriangularSolver.h:208
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: TestIMU_Common.h:87
Matrix has ones on the diagonal; to be used in combination with Lower or Upper.
Definition: Constants.h:171
Matrix has zeros on the diagonal; to be used in combination with Lower or Upper.
Definition: Constants.h:173
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition: Constants.h:53
Definition: SparseTriangularView.h:25
View matrix as an upper triangular matrix.
Definition: Constants.h:169
Index rows() const
Definition: SparseMatrixBase.h:159
Base class of any sparse matrices or sparse expressions.
Definition: ForwardDeclarations.h:239
Storage order is column major (see TopicStorageOrders).
Definition: Constants.h:264
Definition: BandTriangularSolver.h:13
Storage order is row major (see TopicStorageOrders).
Definition: Constants.h:266
View matrix as a lower triangular matrix.
Definition: Constants.h:167
Definition: TriangularSolver.h:204
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
Definition: AmbiVector.h:23
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Definition: ForwardDeclarations.h:17
double Scalar
Common scalar type.
Definition: FlexibleKalmanBase.h:48