10 #ifndef EIGEN_SKYLINEINPLACELU_H 11 #define EIGEN_SKYLINEINPLACELU_H 24 template<
typename MatrixType>
98 template<
typename BDerived,
typename XDerived>
100 const int transposed = 0)
const;
118 template<
typename MatrixType>
124 eigen_assert(rows == cols &&
"We do not (yet) support rectangular LU.");
125 eigen_assert(!
m_lu.IsRowMajor &&
"LU decomposition does not work with rowMajor Storage");
128 const double pivot =
m_lu.coeffDiag(
row);
132 for (
typename MatrixType::InnerLowerIterator lIt(
m_lu, col); lIt; ++lIt) {
133 lIt.valueRef() /= pivot;
137 typename MatrixType::InnerLowerIterator lIt(
m_lu, col);
138 for (
Index rrow =
row + 1; rrow <
m_lu.rows(); rrow++) {
139 typename MatrixType::InnerUpperIterator uItPivot(
m_lu,
row);
140 typename MatrixType::InnerUpperIterator uIt(
m_lu, rrow);
141 const double coef = lIt.value();
143 uItPivot += (rrow -
row - 1);
146 for (++uItPivot; uIt && uItPivot;) {
147 uIt.valueRef() -= uItPivot.value() * coef;
156 typename MatrixType::InnerLowerIterator lIt3(
m_lu, col);
157 for (
Index rrow =
row + 1; rrow <
m_lu.rows(); rrow++) {
158 typename MatrixType::InnerUpperIterator uItPivot(
m_lu,
row);
159 const double coef = lIt3.value();
163 m_lu.coeffRefLower(rrow, row +
i + 1) -= uItPivot.value() * coef;
169 typename MatrixType::InnerLowerIterator lIt2(
m_lu, col);
170 for (
Index rrow =
row + 1; rrow <
m_lu.rows(); rrow++) {
172 typename MatrixType::InnerUpperIterator uItPivot(
m_lu,
row);
173 typename MatrixType::InnerUpperIterator uIt(
m_lu, rrow);
174 const double coef = lIt2.value();
176 uItPivot += (rrow -
row - 1);
177 m_lu.coeffRefDiag(rrow) -= uItPivot.value() * coef;
183 template<
typename MatrixType>
188 eigen_assert(rows == cols &&
"We do not (yet) support rectangular LU.");
189 eigen_assert(
m_lu.IsRowMajor &&
"You're trying to apply rowMajor decomposition on a ColMajor matrix !");
192 typename MatrixType::InnerLowerIterator llIt(
m_lu,
row);
196 if (
m_lu.coeffExistLower(row,
col)) {
199 typename MatrixType::InnerLowerIterator lIt(
m_lu, row);
200 typename MatrixType::InnerUpperIterator uIt(
m_lu,
col);
206 Index stop = offset > 0 ?
col - lIt.col() :
col - uIt.row();
211 Map<VectorXd > colVal(uIt.valuePtr() + (offset > 0 ? offset : 0), stop);
214 Scalar newCoeff =
m_lu.coeffLower(row,
col) - rowVal.dot(colVal);
222 for (
Index k = 0; k < stop; ++k) {
223 const Scalar tmp = newCoeff;
224 newCoeff = tmp - lIt.value() * uIt.value();
236 typename MatrixType::InnerUpperIterator uuIt(
m_lu, col);
237 for (
Index rrow = uuIt.row(); rrow <
col; rrow++) {
239 typename MatrixType::InnerLowerIterator lIt(
m_lu, rrow);
240 typename MatrixType::InnerUpperIterator uIt(
m_lu, col);
243 Index stop = offset > 0 ? rrow - lIt.col() : rrow - uIt.row();
247 Map<VectorXd > colVal(uIt.valuePtr() + (offset > 0 ? offset : 0), stop);
249 Scalar newCoeff =
m_lu.coeffUpper(rrow, col) - rowVal.dot(colVal);
256 for (
Index k = 0; k < stop; ++k) {
257 const Scalar tmp = newCoeff;
258 newCoeff = tmp - lIt.value() * uIt.value();
264 m_lu.coeffRefUpper(rrow, col) = newCoeff;
269 typename MatrixType::InnerLowerIterator lIt(
m_lu, row);
270 typename MatrixType::InnerUpperIterator uIt(
m_lu, row);
275 Index stop = offset > 0 ? lIt.
size() : uIt.size();
278 Map<VectorXd > colVal(uIt.valuePtr() + (offset > 0 ? offset : 0), stop);
279 Scalar newCoeff =
m_lu.coeffDiag(row) - rowVal.dot(colVal);
286 for (
Index k = 0; k < stop; ++k) {
287 const Scalar tmp = newCoeff;
288 newCoeff = tmp - lIt.value() * uIt.value();
293 m_lu.coeffRefDiag(row) = newCoeff;
305 template<
typename MatrixType>
306 template<
typename BDerived,
typename XDerived>
313 x->coeffRef(
row) = b.coeff(
row);
315 typename MatrixType::InnerLowerIterator lIt(
m_lu,
row);
318 while (lIt.col() <
row) {
320 newVal -= x->coeff(col++) * lIt.
value();
324 x->coeffRef(
row) = newVal;
333 typename MatrixType::InnerUpperIterator uIt(
m_lu,
col);
338 x->coeffRef(uIt.row()) -= x_col * uIt.
value();
345 x->coeffRef(0) = x->coeff(0) /
m_lu.coeffDiag(0);
352 #endif // EIGEN_SKYLINELU_H
Matrix diag(const std::vector< Matrix > &Hs)
EIGEN_DEVICE_FUNC CoeffReturnType value() const
A matrix or vector expression mapping an existing array of data.
void setOrderingMethod(int m)
NumTraits< typename MatrixType::Scalar >::Real RealScalar
SkylineInplaceLU(MatrixType &matrix, int flags=0)
Inplace LU decomposition of a skyline matrix and associated features.
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate offset
Namespace containing all symbols from the Eigen library.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
bool succeeded(void) const
bool solve(const MatrixBase< BDerived > &b, MatrixBase< XDerived > *x, const int transposed=0) const
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
RealScalar precision() const
MatrixType::Scalar Scalar
int orderingMethod() const
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Base class for all dense matrices, vectors, and expressions.
void setPrecision(RealScalar v)