100 template<
typename InputType>
109 template<
typename InputType>
119 template<
typename InputType>
222 #ifdef EIGEN_PARSED_BY_DOXYGEN
242 template<
typename Rhs>
337 result += (
abs(
m_lu.coeff(
i,
i)) > premultiplied_threshold);
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>
467 m_isInitialized(false),
468 m_usePrescribedThreshold(false)
473template<
typename MatrixType>
474template<
typename InputType>
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();
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;
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;
539 if(abs_pivot > m_maxpivot) m_maxpivot = abs_pivot;
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.");
595 const Index smalldim = (std::min)(m_lu.rows(), m_lu.cols());
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)
659 for(
Index i = 0;
i < dec().nonzeroPivots(); ++
i)
669 MaxSmallDimAtCompileTime, MatrixType::MaxColsAtCompileTime>
670 m(dec().matrixLU().
block(0, 0, rank(),
cols));
673 if(
i)
m.row(
i).head(
i).setZero();
676 m.block(0, 0, rank(), rank());
684 m.topLeftCorner(rank(), rank())
686 m.topRightCorner(rank(),
dimker)
690 for(
Index i = rank()-1;
i >= 0; --
i)
694 for(
Index i = 0;
i < rank(); ++
i)
dst.row(dec().permutationQ().indices().coeff(
i)) = -
m.row(
i).tail(
dimker);
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)
728 for(
Index i = 0;
i < dec().nonzeroPivots(); ++
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>
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));
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>
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));
839 dst.row(invp.
indices().coeff(
i)).setZero();
848template<
typename DstXprType,
typename MatrixType>
855 dst =
src.nestedExpression().solve(MatrixType::Identity(
src.rows(),
src.cols()));
868template<
typename Derived>
869inline const FullPivLU<typename MatrixBase<Derived>::PlainObject>
Matrix3f m
Definition AngleAxis_mimic_euler.cpp:1
int i
Definition BiCGSTAB_step_by_step.cpp:9
#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)
Definition Macros.h:1264
#define eigen_internal_assert(x)
Definition Macros.h:1043
#define EIGEN_NOEXCEPT
Definition Macros.h:1418
#define EIGEN_CONSTEXPR
Definition Macros.h:787
#define EIGEN_DEVICE_FUNC
Definition Macros.h:976
#define eigen_assert(x)
Definition Macros.h:1037
#define EIGEN_SIZE_MIN_PREFER_FIXED(a, b)
Definition Macros.h:1302
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition PartialRedux_count.cpp:3
#define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE)
Definition StaticAssert.h:187
float * p
Definition Tutorial_Map_using.cpp:9
m m block(1, 0, 2, 2)<< 4
int rows
Definition Tutorial_commainit_02.cpp:1
int cols
Definition Tutorial_commainit_02.cpp:1
Scalar Scalar * c
Definition benchVecAdd.cpp:17
Scalar * b
Definition benchVecAdd.cpp:17
Scalar Scalar int size
Definition benchVecAdd.cpp:17
SCALAR Scalar
Definition bench_gemm.cpp:46
NumTraits< Scalar >::Real RealScalar
Definition bench_gemm.cpp:47
MatrixXf MatrixType
Definition benchmark-blocking-sizes.cpp:52
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)
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
@ MaxColsAtCompileTime
Definition FullPivLU.h:71
@ MaxRowsAtCompileTime
Definition FullPivLU.h:70
MatrixType m_lu
Definition FullPivLU.h:429
Index dimensionOfKernel() const
Definition FullPivLU.h:347
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)
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
Definition FullPivLU.h:315
const PermutationQType & permutationQ() const
Definition FullPivLU.h:170
void computeInPlace()
Definition FullPivLU.h:488
FullPivLU & compute(const EigenBase< InputType > &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
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
const FullPivLU< PlainObject > fullPivLu() const
Definition FullPivLU.h:870
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:180
InverseReturnType inverse() const
Definition PermutationMatrix.h:185
Permutation matrix.
Definition PermutationMatrix.h:298
const IndicesType & indices() const
Definition PermutationMatrix.h:360
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
EIGEN_DEVICE_FUNC Derived & derived()
Definition EigenBase.h:46
Definition TensorRef.h:81
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition common.h:110
#define abs(x)
Definition datatypes.h:17
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 bench_norm.cpp:85
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
Definition Constants.h:22
Definition BandTriangularSolver.h:13
internal::nested_eval< T, 1 >::type eval(const T &xpr)
Definition sparse_permutations.cpp:38
Definition EigenBase.h:30
Eigen::Index Index
The interface type of indices.
Definition EigenBase.h:39
Definition Constants.h:522
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition NumTraits.h:233
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 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
MatrixXpr XprKind
Definition FullPivLU.h:19
SolverStorage StorageKind
Definition FullPivLU.h:20
int StorageIndex
Definition FullPivLU.h:21
Definition ForwardDeclarations.h:17