11 #ifndef EIGEN_PARTIALLU_H
12 #define EIGEN_PARTIALLU_H
29 template<
typename T,
typename Derived>
35 template<
typename T,
typename Derived>
76 :
public SolverBase<PartialPivLU<_MatrixType> >
115 template<
typename InputType>
125 template<
typename InputType>
128 template<
typename InputType>
173 template<
typename Rhs>
223 #ifndef EIGEN_PARSED_BY_DOXYGEN
224 template<
typename RhsType,
typename DstType>
240 m_lu.template triangularView<UnitLower>().solveInPlace(dst);
243 m_lu.template triangularView<Upper>().solveInPlace(dst);
246 template<
bool Conjugate,
typename RhsType,
typename DstType>
260 dst =
m_lu.template triangularView<Upper>().adjoint().solve(rhs);
262 m_lu.template triangularView<UnitLower>().adjoint().solveInPlace(dst);
265 dst =
m_lu.template triangularView<Upper>().transpose().solve(rhs);
267 m_lu.template triangularView<UnitLower>().transpose().solveInPlace(dst);
291 template<
typename MatrixType>
295 m_rowsTranspositions(),
298 m_isInitialized(false)
302 template<
typename MatrixType>
306 m_rowsTranspositions(
size),
309 m_isInitialized(false)
313 template<
typename MatrixType>
314 template<
typename InputType>
318 m_rowsTranspositions(
matrix.rows()),
321 m_isInitialized(false)
323 compute(
matrix.derived());
326 template<
typename MatrixType>
327 template<
typename InputType>
331 m_rowsTranspositions(
matrix.rows()),
334 m_isInitialized(false)
342 template<
typename Scalar,
int StorageOrder,
typename PivIndex>
368 typedef typename Scoring::result_type Score;
373 Index first_zero_pivot = -1;
376 Index rrows = rows-k-1;
377 Index rcols = cols-k-1;
379 Index row_of_biggest_in_col;
380 Score biggest_in_corner
381 =
lu.col(k).tail(rows-k).unaryExpr(Scoring()).maxCoeff(&row_of_biggest_in_col);
382 row_of_biggest_in_col += k;
384 row_transpositions[k] = PivIndex(row_of_biggest_in_col);
386 if(biggest_in_corner != Score(0))
388 if(k != row_of_biggest_in_col)
390 lu.row(k).swap(
lu.row(row_of_biggest_in_col));
396 lu.col(k).tail(rrows) /=
lu.coeff(k,k);
398 else if(first_zero_pivot==-1)
402 first_zero_pivot = k;
406 lu.bottomRightCorner(rrows,rcols).noalias() -=
lu.col(k).tail(rrows) *
lu.row(k).tail(rcols);
408 return first_zero_pivot;
444 blockSize = (blockSize/16)*16;
449 Index first_zero_pivot = -1;
453 Index trows = rows - k - bs;
467 PivIndex nb_transpositions_in_panel;
470 Index ret = blocked_lu(trows+bs, bs, &
lu.coeffRef(k,k), luStride,
471 row_transpositions+k, nb_transpositions_in_panel, 16);
472 if(
ret>=0 && first_zero_pivot==-1)
473 first_zero_pivot = k+
ret;
477 for(
Index i=k; i<k+bs; ++i)
479 Index piv = (row_transpositions[i] += internal::convert_index<PivIndex>(k));
480 A_0.row(i).swap(A_0.row(piv));
486 for(
Index i=k;i<k+bs; ++i)
487 A_2.row(i).swap(A_2.row(row_transpositions[i]));
490 A11.template triangularView<UnitLower>().solveInPlace(A12);
492 A22.noalias() -= A21 * A12;
495 return first_zero_pivot;
501 template<
typename MatrixType,
typename TranspositionType>
505 eigen_assert((&row_transpositions.coeffRef(1)-&row_transpositions.coeffRef(0)) == 1);
509 ::blocked_lu(
lu.rows(),
lu.cols(), &
lu.coeffRef(0,0),
lu.outerStride(), &row_transpositions.coeffRef(0),
nb_transpositions);
514 template<
typename MatrixType>
517 check_template_parameters();
522 m_l1_norm = m_lu.cwiseAbs().colwise().sum().maxCoeff();
524 eigen_assert(m_lu.rows() == m_lu.cols() &&
"PartialPivLU is only for square (and moreover invertible) matrices");
527 m_rowsTranspositions.resize(
size);
533 m_p = m_rowsTranspositions;
535 m_isInitialized =
true;
538 template<
typename MatrixType>
541 eigen_assert(m_isInitialized &&
"PartialPivLU is not initialized.");
542 return Scalar(m_det_p) * m_lu.diagonal().prod();
548 template<
typename MatrixType>
551 eigen_assert(m_isInitialized &&
"LU is not initialized.");
553 MatrixType res = m_lu.template triangularView<UnitLower>().toDenseMatrix()
554 * m_lu.template triangularView<Upper>();
557 res = m_p.inverse() * res;
567 template<
typename DstXprType,
typename MatrixType>
587 template<
typename Derived>
588 inline const PartialPivLU<typename MatrixBase<Derived>::PlainObject>
602 template<
typename Derived>
611 #endif // EIGEN_PARTIALLU_H