190 eigen_assert(rows == cols &&
"We do not (yet) support rectangular LU.");
191 eigen_assert(
m_lu.IsRowMajor &&
"You're trying to apply rowMajor decomposition on a ColMajor matrix !");
194 typename MatrixType::InnerLowerIterator llIt(
m_lu, row);
197 for (
Index col = llIt.col(); col < row; col++) {
198 if (
m_lu.coeffExistLower(row, col)) {
199 const double diag =
m_lu.coeffDiag(col);
201 typename MatrixType::InnerLowerIterator lIt(
m_lu, row);
202 typename MatrixType::InnerUpperIterator uIt(
m_lu, col);
205 const Index offset = lIt.col() - uIt.row();
208 Index stop = offset > 0 ?
col - lIt.col() :
col - uIt.row();
212 Map<VectorXd > rowVal(lIt.valuePtr() + (offset > 0 ? 0 : -offset), stop);
213 Map<VectorXd > colVal(uIt.valuePtr() + (offset > 0 ? offset : 0), stop);
216 Scalar newCoeff =
m_lu.coeffLower(row, col) - rowVal.dot(colVal);
224 for (
Index k = 0; k < stop; ++k) {
225 const Scalar tmp = newCoeff;
226 newCoeff = tmp - lIt.value() * uIt.value();
232 m_lu.coeffRefLower(row, col) = newCoeff / diag;
238 typename MatrixType::InnerUpperIterator uuIt(
m_lu, col);
239 for (
Index rrow = uuIt.row(); rrow < col; rrow++) {
241 typename MatrixType::InnerLowerIterator lIt(
m_lu, rrow);
242 typename MatrixType::InnerUpperIterator uIt(
m_lu, col);
243 const Index offset = lIt.col() - uIt.row();
245 Index stop = offset > 0 ? rrow - lIt.col() : rrow - uIt.row();
248 Map<VectorXd > rowVal(lIt.valuePtr() + (offset > 0 ? 0 : -offset), stop);
249 Map<VectorXd > colVal(uIt.valuePtr() + (offset > 0 ? offset : 0), stop);
251 Scalar newCoeff =
m_lu.coeffUpper(rrow, col) - rowVal.dot(colVal);
258 for (
Index k = 0; k < stop; ++k) {
259 const Scalar tmp = newCoeff;
260 newCoeff = tmp - lIt.value() * uIt.value();
266 m_lu.coeffRefUpper(rrow, col) = newCoeff;
271 typename MatrixType::InnerLowerIterator lIt(
m_lu, row);
272 typename MatrixType::InnerUpperIterator uIt(
m_lu, row);
274 const Index offset = lIt.col() - uIt.row();
277 Index stop = offset > 0 ? lIt.size() : uIt.size();
279 Map<VectorXd > rowVal(lIt.valuePtr() + (offset > 0 ? 0 : -offset), stop);
280 Map<VectorXd > colVal(uIt.valuePtr() + (offset > 0 ? offset : 0), stop);
281 Scalar newCoeff =
m_lu.coeffDiag(row) - rowVal.dot(colVal);
288 for (
Index k = 0; k < stop; ++k) {
289 const Scalar tmp = newCoeff;
290 newCoeff = tmp - lIt.value() * uIt.value();
295 m_lu.coeffRefDiag(row) = newCoeff;
MatrixType::Scalar Scalar