100 template<
typename InputType>
109 template<
typename InputType>
119 template<
typename InputType>
222 #ifdef EIGEN_PARSED_BY_DOXYGEN
242 template<
typename Rhs>
401 eigen_assert(
m_lu.rows() ==
m_lu.cols() &&
"You can't take the inverse of a non-square matrix!");
412 #ifndef EIGEN_PARSED_BY_DOXYGEN
413 template<
typename RhsType,
typename DstType>
414 void _solve_impl(
const RhsType &rhs, DstType &dst)
const;
416 template<
bool Conjugate,
typename RhsType,
typename DstType>
441template<
typename MatrixType>
443 : m_isInitialized(false), m_usePrescribedThreshold(false)
447template<
typename MatrixType>
452 m_rowsTranspositions(rows),
453 m_colsTranspositions(cols),
454 m_isInitialized(false),
455 m_usePrescribedThreshold(false)
459template<
typename MatrixType>
460template<
typename InputType>
462 : m_lu(matrix.rows(), matrix.cols()),
465 m_rowsTranspositions(matrix.rows()),
466 m_colsTranspositions(matrix.cols()),
467 m_isInitialized(false),
468 m_usePrescribedThreshold(false)
473template<
typename MatrixType>
474template<
typename InputType>
476 : m_lu(matrix.derived()),
479 m_rowsTranspositions(matrix.rows()),
480 m_colsTranspositions(matrix.cols()),
481 m_isInitialized(false),
482 m_usePrescribedThreshold(false)
487template<
typename MatrixType>
490 check_template_parameters();
495 m_l1_norm = m_lu.cwiseAbs().colwise().sum().maxCoeff();
498 const Index rows = m_lu.rows();
499 const Index cols = m_lu.cols();
503 m_rowsTranspositions.resize(m_lu.rows());
504 m_colsTranspositions.resize(m_lu.cols());
505 Index number_of_transpositions = 0;
507 m_nonzero_pivots =
size;
508 m_maxpivot = RealScalar(0);
515 Index row_of_biggest_in_corner, col_of_biggest_in_corner;
517 typedef typename Scoring::result_type Score;
518 Score biggest_in_corner;
519 biggest_in_corner = m_lu.bottomRightCorner(rows-k, cols-k)
520 .unaryExpr(Scoring())
521 .maxCoeff(&row_of_biggest_in_corner, &col_of_biggest_in_corner);
522 row_of_biggest_in_corner += k;
523 col_of_biggest_in_corner += k;
525 if(biggest_in_corner==Score(0))
529 m_nonzero_pivots = k;
532 m_rowsTranspositions.coeffRef(i) = internal::convert_index<StorageIndex>(i);
533 m_colsTranspositions.coeffRef(i) = internal::convert_index<StorageIndex>(i);
539 if(abs_pivot > m_maxpivot) m_maxpivot = abs_pivot;
544 m_rowsTranspositions.coeffRef(k) = internal::convert_index<StorageIndex>(row_of_biggest_in_corner);
545 m_colsTranspositions.coeffRef(k) = internal::convert_index<StorageIndex>(col_of_biggest_in_corner);
546 if(k != row_of_biggest_in_corner) {
547 m_lu.row(k).swap(m_lu.row(row_of_biggest_in_corner));
548 ++number_of_transpositions;
550 if(k != col_of_biggest_in_corner) {
551 m_lu.col(k).swap(m_lu.col(col_of_biggest_in_corner));
552 ++number_of_transpositions;
559 m_lu.col(k).tail(rows-k-1) /= m_lu.coeff(k,k);
561 m_lu.block(k+1,k+1,rows-k-1,cols-k-1).noalias() -= m_lu.col(k).tail(rows-k-1) * m_lu.row(k).tail(cols-k-1);
567 m_p.setIdentity(rows);
569 m_p.applyTranspositionOnTheRight(k, m_rowsTranspositions.coeff(k));
571 m_q.setIdentity(cols);
573 m_q.applyTranspositionOnTheRight(k, m_colsTranspositions.coeff(k));
575 m_det_pq = (number_of_transpositions%2) ? -1 : 1;
577 m_isInitialized =
true;
580template<
typename MatrixType>
583 eigen_assert(m_isInitialized &&
"LU is not initialized.");
584 eigen_assert(m_lu.rows() == m_lu.cols() &&
"You can't take the determinant of a non-square matrix!");
585 return Scalar(m_det_pq) *
Scalar(m_lu.diagonal().prod());
591template<
typename MatrixType>
594 eigen_assert(m_isInitialized &&
"LU is not initialized.");
599 res = m_lu.leftCols(smalldim)
600 .template triangularView<UnitLower>().toDenseMatrix()
601 * m_lu.topRows(smalldim)
602 .template triangularView<Upper>().toDenseMatrix();
605 res =
m_p.inverse() * res;
608 res = res * m_q.inverse();
616template<
typename _MatrixType>
623 MatrixType::MaxColsAtCompileTime,
624 MatrixType::MaxRowsAtCompileTime)
627 template<
typename Dest>
void evalTo(Dest& dst)
const
630 const Index cols =
dec().matrixLU().cols(), dimker = cols - rank();
657 RealScalar premultiplied_threshold =
dec().maxPivot() *
dec().threshold();
659 for(
Index i = 0; i <
dec().nonzeroPivots(); ++i)
660 if(
abs(
dec().matrixLU().coeff(i,i)) > premultiplied_threshold)
669 MaxSmallDimAtCompileTime, MatrixType::MaxColsAtCompileTime>
670 m(
dec().matrixLU().
block(0, 0, rank(), cols));
671 for(
Index i = 0; i < rank(); ++i)
673 if(i) m.row(i).head(i).setZero();
674 m.row(i).tail(cols-i) =
dec().matrixLU().row(pivots.
coeff(i)).tail(cols-i);
676 m.block(0, 0, rank(), rank());
677 m.block(0, 0, rank(), rank()).template triangularView<StrictlyLower>().setZero();
678 for(
Index i = 0; i < rank(); ++i)
679 m.col(i).swap(m.col(pivots.
coeff(i)));
684 m.topLeftCorner(rank(), rank())
685 .
template triangularView<Upper>().solveInPlace(
686 m.topRightCorner(rank(), dimker)
690 for(
Index i = rank()-1; i >= 0; --i)
691 m.col(i).swap(m.col(pivots.
coeff(i)));
694 for(
Index i = 0; i < rank(); ++i) dst.row(
dec().permutationQ().indices().coeff(i)) = -m.row(i).tail(dimker);
695 for(
Index i = rank(); i < cols; ++i) dst.row(
dec().permutationQ().indices().coeff(i)).setZero();
696 for(
Index k = 0; k < dimker; ++k) dst.coeffRef(
dec().permutationQ().indices().coeff(rank()+k), k) = Scalar(1);
702template<
typename _MatrixType>
709 MatrixType::MaxColsAtCompileTime,
710 MatrixType::MaxRowsAtCompileTime)
713 template<
typename Dest>
void evalTo(Dest& dst)
const
726 RealScalar premultiplied_threshold =
dec().maxPivot() *
dec().threshold();
728 for(
Index i = 0; i <
dec().nonzeroPivots(); ++i)
729 if(
abs(
dec().matrixLU().coeff(i,i)) > premultiplied_threshold)
733 for(
Index i = 0; i < rank(); ++i)
734 dst.col(i) = originalMatrix().col(
dec().permutationQ().indices().coeff(pivots.
coeff(i)));
742#ifndef EIGEN_PARSED_BY_DOXYGEN
743template<
typename _MatrixType>
744template<
typename RhsType,
typename DstType>
755 const Index rows = this->rows(),
757 nonzero_pivots = this->rank();
760 if(nonzero_pivots == 0)
766 typename RhsType::PlainObject
c(rhs.rows(), rhs.cols());
769 c = permutationP() * rhs;
772 m_lu.topLeftCorner(smalldim,smalldim)
773 .template triangularView<UnitLower>()
774 .solveInPlace(
c.topRows(smalldim));
776 c.bottomRows(rows-cols) -= m_lu.bottomRows(rows-cols) *
c.topRows(cols);
779 m_lu.topLeftCorner(nonzero_pivots, nonzero_pivots)
780 .template triangularView<Upper>()
781 .solveInPlace(
c.topRows(nonzero_pivots));
784 for(
Index i = 0; i < nonzero_pivots; ++i)
785 dst.row(permutationQ().indices().coeff(i)) =
c.row(i);
786 for(
Index i = nonzero_pivots; i < m_lu.cols(); ++i)
787 dst.row(permutationQ().indices().coeff(i)).setZero();
790template<
typename _MatrixType>
791template<
bool Conjugate,
typename RhsType,
typename DstType>
805 const Index rows = this->rows(), cols = this->cols(),
806 nonzero_pivots = this->rank();
809 if(nonzero_pivots == 0)
815 typename RhsType::PlainObject
c(rhs.rows(), rhs.cols());
818 c = permutationQ().inverse() * rhs;
821 m_lu.topLeftCorner(nonzero_pivots, nonzero_pivots)
822 .template triangularView<Upper>()
824 .template conjugateIf<Conjugate>()
825 .solveInPlace(
c.topRows(nonzero_pivots));
828 m_lu.topLeftCorner(smalldim, smalldim)
829 .template triangularView<UnitLower>()
831 .template conjugateIf<Conjugate>()
832 .solveInPlace(
c.topRows(smalldim));
836 for(
Index i = 0; i < smalldim; ++i)
838 for(
Index i = smalldim; i < rows; ++i)
848template<
typename DstXprType,
typename MatrixType>
868template<
typename Derived>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE FixedBlockXpr< internal::get_fixed_value< NRowsType >::value, internal::get_fixed_value< NColsType >::value >::Type block(Index startRow, Index startCol, NRowsType blockRows, NColsType blockCols)
Definition: BlockMethods.h:96
#define EIGEN_MAKE_IMAGE_HELPERS(DecompositionType)
Definition: Image.h:67
#define EIGEN_MAKE_KERNEL_HELPERS(DecompositionType)
Definition: Kernel.h:66
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
Just a side note.
Definition: Macros.h:1274
#define eigen_internal_assert(x)
Definition: Macros.h:1053
#define EIGEN_NOEXCEPT
Definition: Macros.h:1428
#define EIGEN_CONSTEXPR
Definition: Macros.h:797
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:986
#define eigen_assert(x)
Definition: Macros.h:1047
#define EIGEN_SIZE_MIN_PREFER_FIXED(a, b)
Definition: Macros.h:1312
#define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE)
Definition: StaticAssert.h:187
LU decomposition of a matrix with complete pivoting, and related features.
Definition: FullPivLU.h:62
RealScalar m_prescribedThreshold
Definition: FullPivLU.h:436
RealScalar rcond() const
Definition: FullPivLU.h:250
PermutationQType m_q
Definition: FullPivLU.h:431
signed char m_det_pq
Definition: FullPivLU.h:437
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: FullPivLU.h:410
MatrixType reconstructedMatrix() const
Definition: FullPivLU.h:592
_MatrixType MatrixType
Definition: FullPivLU.h:64
bool isSurjective() const
Definition: FullPivLU.h:373
PermutationPType m_p
Definition: FullPivLU.h:430
FullPivLU & setThreshold(Default_t)
Allows to come back to the default behavior, letting Eigen use its default formula for determining th...
Definition: FullPivLU.h:305
MatrixType::PlainObject PlainObject
Definition: FullPivLU.h:77
const internal::kernel_retval< FullPivLU > kernel() const
Definition: FullPivLU.h:190
RealScalar m_maxpivot
Definition: FullPivLU.h:436
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: FullPivLU.h:408
RealScalar m_l1_norm
Definition: FullPivLU.h:435
MatrixType m_lu
Definition: FullPivLU.h:429
Index dimensionOfKernel() const
Definition: FullPivLU.h:347
@ MaxColsAtCompileTime
Definition: FullPivLU.h:71
@ MaxRowsAtCompileTime
Definition: FullPivLU.h:70
Index rank() const
Definition: FullPivLU.h:330
static void check_template_parameters()
Definition: FullPivLU.h:422
internal::traits< MatrixType >::Scalar determinant() const
Definition: FullPivLU.h:581
IntRowVectorType m_colsTranspositions
Definition: FullPivLU.h:433
SolverBase< FullPivLU > Base
Definition: FullPivLU.h:65
internal::plain_row_type< MatrixType, StorageIndex >::type IntRowVectorType
Definition: FullPivLU.h:73
IntColVectorType m_rowsTranspositions
Definition: FullPivLU.h:432
bool m_usePrescribedThreshold
Definition: FullPivLU.h:438
PermutationMatrix< ColsAtCompileTime, MaxColsAtCompileTime > PermutationQType
Definition: FullPivLU.h:75
Index nonzeroPivots() const
Definition: FullPivLU.h:145
bool isInjective() const
Definition: FullPivLU.h:360
void _solve_impl_transposed(const RhsType &rhs, DstType &dst) const
Definition: FullPivLU.h:792
PermutationMatrix< RowsAtCompileTime, MaxRowsAtCompileTime > PermutationPType
Definition: FullPivLU.h:76
FullPivLU & setThreshold(const RealScalar &threshold)
Allows to prescribe a threshold to be used by certain methods, such as rank(), who need to determine ...
Definition: FullPivLU.h:290
EIGEN_DEVICE_FUNC const PermutationPType & permutationP() const
Definition: FullPivLU.h:160
bool m_isInitialized
Definition: FullPivLU.h:438
RealScalar maxPivot() const
Definition: FullPivLU.h:154
const Inverse< FullPivLU > inverse() const
Definition: FullPivLU.h:398
Index m_nonzero_pivots
Definition: FullPivLU.h:434
const MatrixType & matrixLU() const
Definition: FullPivLU.h:132
RealScalar threshold() const
Returns the threshold that will be used by certain methods such as rank().
Definition: FullPivLU.h:315
const PermutationQType & permutationQ() const
Definition: FullPivLU.h:170
void computeInPlace()
Definition: FullPivLU.h:488
FullPivLU & compute(const EigenBase< InputType > &matrix)
Computes the LU decomposition of the given matrix.
Definition: FullPivLU.h:120
const internal::image_retval< FullPivLU > image(const MatrixType &originalMatrix) const
Definition: FullPivLU.h:216
internal::plain_col_type< MatrixType, StorageIndex >::type IntColVectorType
Definition: FullPivLU.h:74
FullPivLU()
Default Constructor.
Definition: FullPivLU.h:442
void _solve_impl(const RhsType &rhs, DstType &dst) const
Definition: FullPivLU.h:745
bool isInvertible() const
Definition: FullPivLU.h:385
Expression of the inverse of another expression.
Definition: Inverse.h:44
EIGEN_DEVICE_FUNC const XprTypeNestedCleaned & nestedExpression() const
Definition: Inverse.h:60
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: Inverse.h:58
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: Inverse.h:57
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:50
const FullPivLU< PlainObject > fullPivLu() const
\lu_module
Definition: FullPivLU.h:870
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:180
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
This is an overloaded version of DenseCoeffsBase<Derived,WriteAccessors>::coeffRef(Index,...
Definition: PlainObjectBase.h:175
InverseReturnType inverse() const
Definition: PermutationMatrix.h:185
const IndicesType & indices() const
const version of indices().
Definition: PermutationMatrix.h:360
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & coeff(Index rowId, Index colId) const
This is an overloaded version of DenseCoeffsBase<Derived,ReadOnlyAccessors>::coeff(Index,...
Definition: PlainObjectBase.h:152
Pseudo expression representing a solving operation.
Definition: Solve.h:63
A base class for matrix decomposition and solvers.
Definition: SolverBase.h:69
internal::traits< FullPivLU< _MatrixType > >::Scalar Scalar
Definition: SolverBase.h:73
const Solve< FullPivLU< _MatrixType >, Rhs > solve(const MatrixBase< Rhs > &b) const
Definition: SolverBase.h:106
UnitType abs(const UnitType x) noexcept
Compute absolute value.
Definition: math.h:721
constexpr common_t< T1, T2 > min(const T1 x, const T2 y) noexcept
Compile-time pairwise minimum function.
Definition: min.hpp:35
EIGEN_CONSTEXPR Index size(const T &x)
Definition: Meta.h:479
Decomposition::RealScalar rcond_estimate_helper(typename Decomposition::RealScalar matrix_norm, const Decomposition &dec)
Reciprocal condition number estimator.
Definition: ConditionEstimator.h:159
Namespace containing all symbols from the Eigen library.
Definition: MatrixExponential.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Default_t
Definition: Constants.h:362
const int Dynamic
This value means that a positive quantity (e.g., a size) is not known at compile-time,...
Definition: Constants.h:22
result
Definition: format.h:2556
Definition: Eigen_Colamd.h:50
static constexpr const mass::kilogram_t m_p(1.672621898e-27)
proton mass.
static constexpr const velocity::meters_per_second_t c(299792458.0)
Speed of light in vacuum.
Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor Matrix...
Definition: EigenBase.h:30
EIGEN_DEVICE_FUNC Derived & derived()
Definition: EigenBase.h:46
The type used to identify a matrix expression.
Definition: Constants.h:522
Holds information about the various numeric (i.e.
Definition: NumTraits.h:233
The type used to identify a general solver (factored) storage.
Definition: Constants.h:513
static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op< typename DstXprType::Scalar, typename MatrixType::Scalar > &)
Definition: FullPivLU.h:853
FullPivLU< MatrixType > LuType
Definition: FullPivLU.h:851
Inverse< LuType > SrcXprType
Definition: FullPivLU.h:852
Definition: AssignEvaluator.h:824
Definition: AssignEvaluator.h:814
Definition: UnaryFunctors.h:72
Definition: AssignmentFunctors.h:21
void evalTo(Dest &dst) const
Definition: FullPivLU.h:713
Definition: ForwardDeclarations.h:141
void evalTo(Dest &dst) const
Definition: FullPivLU.h:627
Definition: ForwardDeclarations.h:139
Definition: UnaryFunctors.h:64
MatrixXpr XprKind
Definition: FullPivLU.h:19
SolverStorage StorageKind
Definition: FullPivLU.h:20
int StorageIndex
Definition: FullPivLU.h:21
Definition: ForwardDeclarations.h:17