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> >
85 MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
86 MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
115 template<
typename InputType>
125 template<
typename InputType>
128 template<
typename InputType>
143 eigen_assert(m_isInitialized &&
"PartialPivLU is not initialized.");
151 eigen_assert(m_isInitialized &&
"PartialPivLU is not initialized.");
173 template<
typename Rhs>
177 eigen_assert(m_isInitialized &&
"PartialPivLU is not initialized.");
186 eigen_assert(m_isInitialized &&
"PartialPivLU is not initialized.");
199 eigen_assert(m_isInitialized &&
"PartialPivLU is not initialized.");
218 MatrixType reconstructedMatrix()
const;
223 #ifndef EIGEN_PARSED_BY_DOXYGEN 224 template<
typename RhsType,
typename DstType>
237 dst = permutationP() * rhs;
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);
270 dst = permutationP().transpose() * dst;
291 template<
typename MatrixType>
295 m_rowsTranspositions(),
298 m_isInitialized(false)
302 template<
typename MatrixType>
313 template<
typename MatrixType>
314 template<
typename InputType>
326 template<
typename MatrixType>
327 template<
typename InputType>
342 template<
typename Scalar,
int StorageOrder,
typename PivIndex>
368 typedef typename Scoring::result_type Score;
372 nb_transpositions = 0;
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;
428 MapLU lu1(lu_data,StorageOrder==
RowMajor?rows:luStride,StorageOrder==
RowMajor?luStride:cols);
429 MatrixType
lu(lu1,0,0,rows,cols);
436 return unblocked_lu(lu, row_transpositions, nb_transpositions);
444 blockSize = (blockSize/16)*16;
448 nb_transpositions = 0;
449 Index first_zero_pivot = -1;
453 Index trows = rows - k - bs;
454 Index tsize = size - k - bs;
460 BlockType A_0(lu,0,0,rows,k);
461 BlockType A_2(lu,0,k+bs,rows,tsize);
462 BlockType
A11(lu,k,k,bs,bs);
463 BlockType A12(lu,k,k+bs,bs,tsize);
464 BlockType
A21(lu,k+bs,k,trows,bs);
465 BlockType
A22(lu,k+bs,k+bs,trows,tsize);
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;
475 nb_transpositions += nb_transpositions_in_panel;
479 Index piv = (row_transpositions[
i] += internal::convert_index<PivIndex>(k));
480 A_0.row(
i).swap(A_0.row(piv));
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>
524 eigen_assert(
m_lu.rows() ==
m_lu.cols() &&
"PartialPivLU is only for square (and moreover invertible) matrices");
531 m_det_p = (nb_transpositions%2) ? -1 : 1;
538 template<
typename MatrixType>
548 template<
typename MatrixType>
554 *
m_lu.template triangularView<Upper>();
567 template<
typename DstXprType,
typename MatrixType>
587 template<
typename Derived>
602 template<
typename Derived>
611 #endif // EIGEN_PARTIALLU_H
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
Base::PlainObject PlainObject
MatrixType::PlainObject PlainObject
const Inverse< PartialPivLU > inverse() const
PartialPivLU & compute(const EigenBase< InputType > &matrix)
EIGEN_DEVICE_FUNC Index rows() const
void adjoint(const MatrixType &m)
PartialPivLU()
Default Constructor.
internal::traits< PartialPivLU< Matrix< Scalar, Dynamic, Dynamic > > >::Scalar Scalar
Block< MatrixType, Dynamic, Dynamic > BlockType
PartialPivLU< MatrixType > LuType
Map< Matrix< Scalar, Dynamic, Dynamic, StorageOrder > > MapLU
A matrix or vector expression mapping an existing array of data.
static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op< typename DstXprType::Scalar, typename LuType::Scalar > &)
void determinant(const MatrixType &m)
LU decomposition of a matrix with partial pivoting, and related features.
Namespace containing all symbols from the Eigen library.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
EIGEN_DEVICE_FUNC void _solve_impl_transposed(const RhsType &rhs, DstType &dst) const
Transpositions< RowsAtCompileTime, MaxRowsAtCompileTime > TranspositionType
MatrixType::RealScalar RealScalar
Decomposition::RealScalar rcond_estimate_helper(typename Decomposition::RealScalar matrix_norm, const Decomposition &dec)
Reciprocal condition number estimator.
Eigen::Index Index
The interface type of indices.
const unsigned int RowMajorBit
const PartialPivLU< PlainObject > partialPivLu() const
Expression of the inverse of another expression.
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Scalar determinant() const
void partial_lu_inplace(MatrixType &lu, TranspositionType &row_transpositions, typename TranspositionType::StorageIndex &nb_transpositions)
SolverBase< PartialPivLU > Base
const PermutationType & permutationP() const
static void check_template_parameters()
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
EIGEN_DEVICE_FUNC Index cols() const
#define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE)
void resize(Index newSize)
cout<< "Here is the matrix m:"<< endl<< m<< endl;Eigen::FullPivLU< Matrix5x3 > lu(m)
NumTraits< Scalar >::Real RealScalar
A matrix or vector expression mapping an existing expression.
IndicesType::Scalar StorageIndex
InverseReturnType inverse() const
PermutationMatrix< RowsAtCompileTime, MaxRowsAtCompileTime > PermutationType
traits< _MatrixType > BaseTraits
Expression of a fixed-size or dynamic-size block.
SolverStorage StorageKind
static Index unblocked_lu(MatrixType &lu, PivIndex *row_transpositions, PivIndex &nb_transpositions)
Block< MapLU, Dynamic, Dynamic > MatrixType
TranspositionType m_rowsTranspositions
EIGEN_DEVICE_FUNC void _solve_impl(const RhsType &rhs, DstType &dst) const
internal::nested_eval< T, 1 >::type eval(const T &xpr)
Inverse< LuType > SrcXprType
MatrixType reconstructedMatrix() const
Pseudo expression representing a solving operation.
EIGEN_DONT_INLINE void compute(Solver &solver, const MatrixType &A)
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
const MatrixType & matrixLU() const
const Solve< PartialPivLU, Rhs > solve(const MatrixBase< Rhs > &b) const
EIGEN_DEVICE_FUNC const XprTypeNestedCleaned & nestedExpression() const
A base class for matrix decomposition and solvers.
static Index blocked_lu(Index rows, Index cols, Scalar *lu_data, Index luStride, PivIndex *row_transpositions, PivIndex &nb_transpositions, Index maxBlockSize=256)
EIGEN_DEVICE_FUNC Derived & derived()
Base class for all dense matrices, vectors, and expressions.
EIGEN_DEVICE_FUNC Index size() const
const PartialPivLU< PlainObject > lu() const