10#ifndef EIGEN_SKYLINEINPLACELU_H
11#define EIGEN_SKYLINEINPLACELU_H
24template<
typename MatrixType>
27 typedef typename MatrixType::Scalar
Scalar;
28 typedef typename MatrixType::Index
Index;
98 template<
typename BDerived,
typename XDerived>
100 const int transposed = 0)
const;
118template<
typename MatrixType>
121 const size_t rows = m_lu.rows();
122 const size_t cols = m_lu.cols();
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;
183template<
typename MatrixType>
185 const size_t rows = m_lu.rows();
186 const size_t cols = m_lu.cols();
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)) {
197 const double diag = m_lu.coeffDiag(
col);
199 typename MatrixType::InnerLowerIterator lIt(m_lu,
row);
200 typename MatrixType::InnerUpperIterator uIt(m_lu,
col);
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();
230 m_lu.coeffRefLower(
row,
col) = newCoeff / diag;
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();
249 Scalar newCoeff = m_lu.coeffUpper(rrow,
col) - rowVal.dot(colVal);
255 Scalar newCoeff = m_lu.coeffUpper(rrow,
col);
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);
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;
305template<
typename MatrixType>
306template<
typename BDerived,
typename XDerived>
308 const size_t rows = m_lu.rows();
309 const size_t cols = m_lu.cols();
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;
329 x->coeffRef(
col) =
x->coeff(
col) / m_lu.coeffDiag(
col);
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);
Matrix3f m
Definition AngleAxis_mimic_euler.cpp:1
Array< int, Dynamic, 1 > v
Definition Array_initializer_list_vector_cxx11.cpp:1
int i
Definition BiCGSTAB_step_by_step.cpp:9
#define eigen_assert(x)
Definition Macros.h:1037
int rows
Definition Tutorial_commainit_02.cpp:1
int cols
Definition Tutorial_commainit_02.cpp:1
Scalar * b
Definition benchVecAdd.cpp:17
MatrixXf MatrixType
Definition benchmark-blocking-sizes.cpp:52
A matrix or vector expression mapping an existing array of data.
Definition Map.h:96
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
Inplace LU decomposition of a skyline matrix and associated features.
Definition SkylineInplaceLU.h:25
RealScalar precision() const
Definition SkylineInplaceLU.h:59
int m_flags
Definition SkylineInplaceLU.h:109
void setPrecision(RealScalar v)
Definition SkylineInplaceLU.h:52
void computeRowMajor()
Definition SkylineInplaceLU.h:184
MatrixType::Scalar Scalar
Definition SkylineInplaceLU.h:27
bool solve(const MatrixBase< BDerived > &b, MatrixBase< XDerived > *x, const int transposed=0) const
Definition SkylineInplaceLU.h:307
NumTraits< typenameMatrixType::Scalar >::Real RealScalar
Definition SkylineInplaceLU.h:30
void compute()
Definition SkylineInplaceLU.h:120
int flags() const
Definition SkylineInplaceLU.h:76
bool m_succeeded
Definition SkylineInplaceLU.h:111
void setOrderingMethod(int m)
Definition SkylineInplaceLU.h:80
MatrixType & m_lu
Definition SkylineInplaceLU.h:112
MatrixType::Index Index
Definition SkylineInplaceLU.h:28
int m_status
Definition SkylineInplaceLU.h:110
RealScalar m_precision
Definition SkylineInplaceLU.h:108
bool succeeded(void) const
Definition SkylineInplaceLU.h:103
SkylineInplaceLU(MatrixType &matrix, int flags=0)
Definition SkylineInplaceLU.h:36
int orderingMethod() const
Definition SkylineInplaceLU.h:84
void setFlags(int f)
Definition SkylineInplaceLU.h:71
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition common.h:110
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
Definition gnuplot_common_settings.hh:12
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
Definition gnuplot_common_settings.hh:64
Namespace containing all symbols from the Eigen library.
Definition bench_norm.cpp:85