FullPivLU.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2006-2009 Benoit Jacob <jacob.benoit.1@gmail.com>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_LU_H
11 #define EIGEN_LU_H
12 
13 #include "./InternalHeaderCheck.h"
14 
15 namespace Eigen {
16 
17 namespace internal {
18 template<typename MatrixType_, typename PermutationIndex_> struct traits<FullPivLU<MatrixType_, PermutationIndex_> >
19  : traits<MatrixType_>
20 {
21  typedef MatrixXpr XprKind;
22  typedef SolverStorage StorageKind;
23  typedef PermutationIndex_ StorageIndex;
24  enum { Flags = 0 };
25 };
26 
27 } // end namespace internal
28 
62 template<typename MatrixType_, typename PermutationIndex_> class FullPivLU
63  : public SolverBase<FullPivLU<MatrixType_, PermutationIndex_> >
64 {
65  public:
66  typedef MatrixType_ MatrixType;
68  friend class SolverBase<FullPivLU>;
69 
71  enum {
72  MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
73  MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
74  };
75  using PermutationIndex = PermutationIndex_;
76  typedef typename internal::plain_row_type<MatrixType, PermutationIndex>::type IntRowVectorType;
77  typedef typename internal::plain_col_type<MatrixType, PermutationIndex>::type IntColVectorType;
81 
88  FullPivLU();
89 
97 
103  template<typename InputType>
104  explicit FullPivLU(const EigenBase<InputType>& matrix);
105 
112  template<typename InputType>
113  explicit FullPivLU(EigenBase<InputType>& matrix);
114 
122  template<typename InputType>
124  m_lu = matrix.derived();
125  computeInPlace();
126  return *this;
127  }
128 
135  inline const MatrixType& matrixLU() const
136  {
137  eigen_assert(m_isInitialized && "LU is not initialized.");
138  return m_lu;
139  }
140 
148  inline Index nonzeroPivots() const
149  {
150  eigen_assert(m_isInitialized && "LU is not initialized.");
151  return m_nonzero_pivots;
152  }
153 
157  RealScalar maxPivot() const { return m_maxpivot; }
158 
164  {
165  eigen_assert(m_isInitialized && "LU is not initialized.");
166  return m_p;
167  }
168 
173  inline const PermutationQType& permutationQ() const
174  {
175  eigen_assert(m_isInitialized && "LU is not initialized.");
176  return m_q;
177  }
178 
193  inline const internal::kernel_retval<FullPivLU> kernel() const
194  {
195  eigen_assert(m_isInitialized && "LU is not initialized.");
196  return internal::kernel_retval<FullPivLU>(*this);
197  }
198 
218  inline const internal::image_retval<FullPivLU>
219  image(const MatrixType& originalMatrix) const
220  {
221  eigen_assert(m_isInitialized && "LU is not initialized.");
222  return internal::image_retval<FullPivLU>(*this, originalMatrix);
223  }
224 
225  #ifdef EIGEN_PARSED_BY_DOXYGEN
245  template<typename Rhs>
246  inline const Solve<FullPivLU, Rhs>
247  solve(const MatrixBase<Rhs>& b) const;
248  #endif
249 
253  inline RealScalar rcond() const
254  {
255  eigen_assert(m_isInitialized && "PartialPivLU is not initialized.");
257  }
258 
274  typename internal::traits<MatrixType>::Scalar determinant() const;
275 
293  FullPivLU& setThreshold(const RealScalar& threshold)
294  {
297  return *this;
298  }
299 
309  {
310  m_usePrescribedThreshold = false;
311  return *this;
312  }
313 
318  RealScalar threshold() const
319  {
322  // this formula comes from experimenting (see "LU precision tuning" thread on the list)
323  // and turns out to be identical to Higham's formula used already in LDLt.
324  : NumTraits<Scalar>::epsilon() * RealScalar(m_lu.diagonalSize());
325  }
326 
333  inline Index rank() const
334  {
335  using std::abs;
336  eigen_assert(m_isInitialized && "LU is not initialized.");
337  RealScalar premultiplied_threshold = abs(m_maxpivot) * threshold();
338  Index result = 0;
339  for(Index i = 0; i < m_nonzero_pivots; ++i)
340  result += (abs(m_lu.coeff(i,i)) > premultiplied_threshold);
341  return result;
342  }
343 
350  inline Index dimensionOfKernel() const
351  {
352  eigen_assert(m_isInitialized && "LU is not initialized.");
353  return cols() - rank();
354  }
355 
363  inline bool isInjective() const
364  {
365  eigen_assert(m_isInitialized && "LU is not initialized.");
366  return rank() == cols();
367  }
368 
376  inline bool isSurjective() const
377  {
378  eigen_assert(m_isInitialized && "LU is not initialized.");
379  return rank() == rows();
380  }
381 
388  inline bool isInvertible() const
389  {
390  eigen_assert(m_isInitialized && "LU is not initialized.");
391  return isInjective() && (m_lu.rows() == m_lu.cols());
392  }
393 
401  inline const Inverse<FullPivLU> inverse() const
402  {
403  eigen_assert(m_isInitialized && "LU is not initialized.");
404  eigen_assert(m_lu.rows() == m_lu.cols() && "You can't take the inverse of a non-square matrix!");
405  return Inverse<FullPivLU>(*this);
406  }
407 
409 
411  inline Index rows() const EIGEN_NOEXCEPT { return m_lu.rows(); }
413  inline Index cols() const EIGEN_NOEXCEPT { return m_lu.cols(); }
414 
415  #ifndef EIGEN_PARSED_BY_DOXYGEN
416  template<typename RhsType, typename DstType>
417  void _solve_impl(const RhsType &rhs, DstType &dst) const;
418 
419  template<bool Conjugate, typename RhsType, typename DstType>
420  void _solve_impl_transposed(const RhsType &rhs, DstType &dst) const;
421  #endif
422 
423  protected:
424 
426 
427  void computeInPlace();
428 
435  RealScalar m_l1_norm;
437  signed char m_det_pq;
439 };
440 
441 template<typename MatrixType, typename PermutationIndex>
443  : m_isInitialized(false), m_usePrescribedThreshold(false)
444 {
445 }
446 
447 template<typename MatrixType, typename PermutationIndex>
449  : m_lu(rows, cols),
450  m_p(rows),
451  m_q(cols),
452  m_rowsTranspositions(rows),
453  m_colsTranspositions(cols),
454  m_isInitialized(false),
455  m_usePrescribedThreshold(false)
456 {
457 }
458 
459 template<typename MatrixType, typename PermutationIndex>
460 template<typename InputType>
462  : m_lu(matrix.rows(), matrix.cols()),
463  m_p(matrix.rows()),
464  m_q(matrix.cols()),
465  m_rowsTranspositions(matrix.rows()),
466  m_colsTranspositions(matrix.cols()),
467  m_isInitialized(false),
468  m_usePrescribedThreshold(false)
469 {
470  compute(matrix.derived());
471 }
472 
473 template<typename MatrixType, typename PermutationIndex>
474 template<typename InputType>
476  : m_lu(matrix.derived()),
477  m_p(matrix.rows()),
478  m_q(matrix.cols()),
479  m_rowsTranspositions(matrix.rows()),
480  m_colsTranspositions(matrix.cols()),
481  m_isInitialized(false),
482  m_usePrescribedThreshold(false)
483 {
484  computeInPlace();
485 }
486 
487 template<typename MatrixType, typename PermutationIndex>
489 {
491 
492  m_l1_norm = m_lu.cwiseAbs().colwise().sum().maxCoeff();
493 
494  const Index size = m_lu.diagonalSize();
495  const Index rows = m_lu.rows();
496  const Index cols = m_lu.cols();
497 
498  // will store the transpositions, before we accumulate them at the end.
499  // can't accumulate on-the-fly because that will be done in reverse order for the rows.
500  m_rowsTranspositions.resize(m_lu.rows());
501  m_colsTranspositions.resize(m_lu.cols());
502  Index number_of_transpositions = 0; // number of NONTRIVIAL transpositions, i.e. m_rowsTranspositions[i]!=i
503 
504  m_nonzero_pivots = size; // the generic case is that in which all pivots are nonzero (invertible case)
505  m_maxpivot = RealScalar(0);
506 
507  for(Index k = 0; k < size; ++k)
508  {
509  // First, we need to find the pivot.
510 
511  // biggest coefficient in the remaining bottom-right corner (starting at row k, col k)
512  Index row_of_biggest_in_corner, col_of_biggest_in_corner;
513  typedef internal::scalar_score_coeff_op<Scalar> Scoring;
514  typedef typename Scoring::result_type Score;
515  Score biggest_in_corner;
516  biggest_in_corner = m_lu.bottomRightCorner(rows-k, cols-k)
517  .unaryExpr(Scoring())
518  .maxCoeff(&row_of_biggest_in_corner, &col_of_biggest_in_corner);
519  row_of_biggest_in_corner += k; // correct the values! since they were computed in the corner,
520  col_of_biggest_in_corner += k; // need to add k to them.
521 
522  if(numext::is_exactly_zero(biggest_in_corner))
523  {
524  // before exiting, make sure to initialize the still uninitialized transpositions
525  // in a sane state without destroying what we already have.
526  m_nonzero_pivots = k;
527  for(Index i = k; i < size; ++i)
528  {
529  m_rowsTranspositions.coeffRef(i) = internal::convert_index<StorageIndex>(i);
530  m_colsTranspositions.coeffRef(i) = internal::convert_index<StorageIndex>(i);
531  }
532  break;
533  }
534 
535  RealScalar abs_pivot = internal::abs_knowing_score<Scalar>()(m_lu(row_of_biggest_in_corner, col_of_biggest_in_corner), biggest_in_corner);
536  if(abs_pivot > m_maxpivot) m_maxpivot = abs_pivot;
537 
538  // Now that we've found the pivot, we need to apply the row/col swaps to
539  // bring it to the location (k,k).
540 
541  m_rowsTranspositions.coeffRef(k) = internal::convert_index<StorageIndex>(row_of_biggest_in_corner);
542  m_colsTranspositions.coeffRef(k) = internal::convert_index<StorageIndex>(col_of_biggest_in_corner);
543  if(k != row_of_biggest_in_corner) {
544  m_lu.row(k).swap(m_lu.row(row_of_biggest_in_corner));
545  ++number_of_transpositions;
546  }
547  if(k != col_of_biggest_in_corner) {
548  m_lu.col(k).swap(m_lu.col(col_of_biggest_in_corner));
549  ++number_of_transpositions;
550  }
551 
552  // Now that the pivot is at the right location, we update the remaining
553  // bottom-right corner by Gaussian elimination.
554 
555  if(k<rows-1)
556  m_lu.col(k).tail(rows-k-1) /= m_lu.coeff(k,k);
557  if(k<size-1)
558  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);
559  }
560 
561  // the main loop is over, we still have to accumulate the transpositions to find the
562  // permutations P and Q
563 
564  m_p.setIdentity(rows);
565  for(Index k = size-1; k >= 0; --k)
566  m_p.applyTranspositionOnTheRight(k, m_rowsTranspositions.coeff(k));
567 
568  m_q.setIdentity(cols);
569  for(Index k = 0; k < size; ++k)
570  m_q.applyTranspositionOnTheRight(k, m_colsTranspositions.coeff(k));
571 
572  m_det_pq = (number_of_transpositions%2) ? -1 : 1;
573 
574  m_isInitialized = true;
575 }
576 
577 template<typename MatrixType, typename PermutationIndex>
578 typename internal::traits<MatrixType>::Scalar FullPivLU<MatrixType, PermutationIndex>::determinant() const
579 {
580  eigen_assert(m_isInitialized && "LU is not initialized.");
581  eigen_assert(m_lu.rows() == m_lu.cols() && "You can't take the determinant of a non-square matrix!");
582  return Scalar(m_det_pq) * Scalar(m_lu.diagonal().prod());
583 }
584 
588 template<typename MatrixType, typename PermutationIndex>
590 {
591  eigen_assert(m_isInitialized && "LU is not initialized.");
592  const Index smalldim = (std::min)(m_lu.rows(), m_lu.cols());
593  // LU
594  MatrixType res(m_lu.rows(),m_lu.cols());
595  // FIXME the .toDenseMatrix() should not be needed...
596  res = m_lu.leftCols(smalldim)
597  .template triangularView<UnitLower>().toDenseMatrix()
598  * m_lu.topRows(smalldim)
599  .template triangularView<Upper>().toDenseMatrix();
600 
601  // P^{-1}(LU)
602  res = m_p.inverse() * res;
603 
604  // (P^{-1}LU)Q^{-1}
605  res = res * m_q.inverse();
606 
607  return res;
608 }
609 
610 
612 namespace internal {
613 template<typename MatrixType_, typename PermutationIndex_>
614 struct kernel_retval<FullPivLU<MatrixType_, PermutationIndex_> >
615  : kernel_retval_base<FullPivLU<MatrixType_, PermutationIndex_> >
616 {
617  using DecompositionType = FullPivLU<MatrixType_, PermutationIndex_>;
618  EIGEN_MAKE_KERNEL_HELPERS(DecompositionType)
619 
620  enum { MaxSmallDimAtCompileTime = min_size_prefer_fixed(
621  MatrixType::MaxColsAtCompileTime,
622  MatrixType::MaxRowsAtCompileTime)
623  };
624 
625  template<typename Dest> void evalTo(Dest& dst) const
626  {
627  using std::abs;
628  const Index cols = dec().matrixLU().cols(), dimker = cols - rank();
629  if(dimker == 0)
630  {
631  // The Kernel is just {0}, so it doesn't have a basis properly speaking, but let's
632  // avoid crashing/asserting as that depends on floating point calculations. Let's
633  // just return a single column vector filled with zeros.
634  dst.setZero();
635  return;
636  }
637 
638  /* Let us use the following lemma:
639  *
640  * Lemma: If the matrix A has the LU decomposition PAQ = LU,
641  * then Ker A = Q(Ker U).
642  *
643  * Proof: trivial: just keep in mind that P, Q, L are invertible.
644  */
645 
646  /* Thus, all we need to do is to compute Ker U, and then apply Q.
647  *
648  * U is upper triangular, with eigenvalues sorted so that any zeros appear at the end.
649  * Thus, the diagonal of U ends with exactly
650  * dimKer zero's. Let us use that to construct dimKer linearly
651  * independent vectors in Ker U.
652  */
653 
654  Matrix<Index, Dynamic, 1, 0, MaxSmallDimAtCompileTime, 1> pivots(rank());
655  RealScalar premultiplied_threshold = dec().maxPivot() * dec().threshold();
656  Index p = 0;
657  for(Index i = 0; i < dec().nonzeroPivots(); ++i)
658  if(abs(dec().matrixLU().coeff(i,i)) > premultiplied_threshold)
659  pivots.coeffRef(p++) = i;
660  eigen_internal_assert(p == rank());
661 
662  // we construct a temporaty trapezoid matrix m, by taking the U matrix and
663  // permuting the rows and cols to bring the nonnegligible pivots to the top of
664  // the main diagonal. We need that to be able to apply our triangular solvers.
665  // FIXME when we get triangularView-for-rectangular-matrices, this can be simplified
666  Matrix<typename MatrixType::Scalar, Dynamic, Dynamic, MatrixType::Options,
667  MaxSmallDimAtCompileTime, MatrixType::MaxColsAtCompileTime>
668  m(dec().matrixLU().block(0, 0, rank(), cols));
669  for(Index i = 0; i < rank(); ++i)
670  {
671  if(i) m.row(i).head(i).setZero();
672  m.row(i).tail(cols-i) = dec().matrixLU().row(pivots.coeff(i)).tail(cols-i);
673  }
674  m.block(0, 0, rank(), rank());
675  m.block(0, 0, rank(), rank()).template triangularView<StrictlyLower>().setZero();
676  for(Index i = 0; i < rank(); ++i)
677  m.col(i).swap(m.col(pivots.coeff(i)));
678 
679  // ok, we have our trapezoid matrix, we can apply the triangular solver.
680  // notice that the math behind this suggests that we should apply this to the
681  // negative of the RHS, but for performance we just put the negative sign elsewhere, see below.
682  m.topLeftCorner(rank(), rank())
683  .template triangularView<Upper>().solveInPlace(
684  m.topRightCorner(rank(), dimker)
685  );
686 
687  // now we must undo the column permutation that we had applied!
688  for(Index i = rank()-1; i >= 0; --i)
689  m.col(i).swap(m.col(pivots.coeff(i)));
690 
691  // see the negative sign in the next line, that's what we were talking about above.
692  for(Index i = 0; i < rank(); ++i) dst.row(dec().permutationQ().indices().coeff(i)) = -m.row(i).tail(dimker);
693  for(Index i = rank(); i < cols; ++i) dst.row(dec().permutationQ().indices().coeff(i)).setZero();
694  for(Index k = 0; k < dimker; ++k) dst.coeffRef(dec().permutationQ().indices().coeff(rank()+k), k) = Scalar(1);
695  }
696 };
697 
698 
700 template<typename MatrixType_, typename PermutationIndex_>
701 struct image_retval<FullPivLU<MatrixType_, PermutationIndex_> >
702  : image_retval_base<FullPivLU<MatrixType_, PermutationIndex_> >
703 {
704  using DecompositionType = FullPivLU<MatrixType_, PermutationIndex_>;
705  EIGEN_MAKE_IMAGE_HELPERS(DecompositionType)
706 
707  enum { MaxSmallDimAtCompileTime = min_size_prefer_fixed(
708  MatrixType::MaxColsAtCompileTime,
709  MatrixType::MaxRowsAtCompileTime)
710  };
711 
712  template<typename Dest> void evalTo(Dest& dst) const
713  {
714  using std::abs;
715  if(rank() == 0)
716  {
717  // The Image is just {0}, so it doesn't have a basis properly speaking, but let's
718  // avoid crashing/asserting as that depends on floating point calculations. Let's
719  // just return a single column vector filled with zeros.
720  dst.setZero();
721  return;
722  }
723 
724  Matrix<Index, Dynamic, 1, 0, MaxSmallDimAtCompileTime, 1> pivots(rank());
725  RealScalar premultiplied_threshold = dec().maxPivot() * dec().threshold();
726  Index p = 0;
727  for(Index i = 0; i < dec().nonzeroPivots(); ++i)
728  if(abs(dec().matrixLU().coeff(i,i)) > premultiplied_threshold)
729  pivots.coeffRef(p++) = i;
730  eigen_internal_assert(p == rank());
731 
732  for(Index i = 0; i < rank(); ++i)
733  dst.col(i) = originalMatrix().col(dec().permutationQ().indices().coeff(pivots.coeff(i)));
734  }
735 };
736 
737 
739 } // end namespace internal
740 
741 #ifndef EIGEN_PARSED_BY_DOXYGEN
742 template<typename MatrixType_, typename PermutationIndex_>
743 template<typename RhsType, typename DstType>
744 void FullPivLU<MatrixType_, PermutationIndex_>::_solve_impl(const RhsType &rhs, DstType &dst) const
745 {
746  /* The decomposition PAQ = LU can be rewritten as A = P^{-1} L U Q^{-1}.
747  * So we proceed as follows:
748  * Step 1: compute c = P * rhs.
749  * Step 2: replace c by the solution x to Lx = c. Exists because L is invertible.
750  * Step 3: replace c by the solution x to Ux = c. May or may not exist.
751  * Step 4: result = Q * c;
752  */
753 
754  const Index rows = this->rows(),
755  cols = this->cols(),
756  nonzero_pivots = this->rank();
757  const Index smalldim = (std::min)(rows, cols);
758 
759  if(nonzero_pivots == 0)
760  {
761  dst.setZero();
762  return;
763  }
764 
765  typename RhsType::PlainObject c(rhs.rows(), rhs.cols());
766 
767  // Step 1
768  c = permutationP() * rhs;
769 
770  // Step 2
771  m_lu.topLeftCorner(smalldim,smalldim)
772  .template triangularView<UnitLower>()
773  .solveInPlace(c.topRows(smalldim));
774  if(rows>cols)
775  c.bottomRows(rows-cols) -= m_lu.bottomRows(rows-cols) * c.topRows(cols);
776 
777  // Step 3
778  m_lu.topLeftCorner(nonzero_pivots, nonzero_pivots)
779  .template triangularView<Upper>()
780  .solveInPlace(c.topRows(nonzero_pivots));
781 
782  // Step 4
783  for(Index i = 0; i < nonzero_pivots; ++i)
784  dst.row(permutationQ().indices().coeff(i)) = c.row(i);
785  for(Index i = nonzero_pivots; i < m_lu.cols(); ++i)
786  dst.row(permutationQ().indices().coeff(i)).setZero();
787 }
788 
789 template<typename MatrixType_, typename PermutationIndex_>
790 template<bool Conjugate, typename RhsType, typename DstType>
791 void FullPivLU<MatrixType_, PermutationIndex_>::_solve_impl_transposed(const RhsType &rhs, DstType &dst) const
792 {
793  /* The decomposition PAQ = LU can be rewritten as A = P^{-1} L U Q^{-1},
794  * and since permutations are real and unitary, we can write this
795  * as A^T = Q U^T L^T P,
796  * So we proceed as follows:
797  * Step 1: compute c = Q^T rhs.
798  * Step 2: replace c by the solution x to U^T x = c. May or may not exist.
799  * Step 3: replace c by the solution x to L^T x = c.
800  * Step 4: result = P^T c.
801  * If Conjugate is true, replace "^T" by "^*" above.
802  */
803 
804  const Index rows = this->rows(), cols = this->cols(),
805  nonzero_pivots = this->rank();
806  const Index smalldim = (std::min)(rows, cols);
807 
808  if(nonzero_pivots == 0)
809  {
810  dst.setZero();
811  return;
812  }
813 
814  typename RhsType::PlainObject c(rhs.rows(), rhs.cols());
815 
816  // Step 1
817  c = permutationQ().inverse() * rhs;
818 
819  // Step 2
820  m_lu.topLeftCorner(nonzero_pivots, nonzero_pivots)
821  .template triangularView<Upper>()
822  .transpose()
823  .template conjugateIf<Conjugate>()
824  .solveInPlace(c.topRows(nonzero_pivots));
825 
826  // Step 3
827  m_lu.topLeftCorner(smalldim, smalldim)
828  .template triangularView<UnitLower>()
829  .transpose()
830  .template conjugateIf<Conjugate>()
831  .solveInPlace(c.topRows(smalldim));
832 
833  // Step 4
834  PermutationPType invp = permutationP().inverse().eval();
835  for(Index i = 0; i < smalldim; ++i)
836  dst.row(invp.indices().coeff(i)) = c.row(i);
837  for(Index i = smalldim; i < rows; ++i)
838  dst.row(invp.indices().coeff(i)).setZero();
839 }
840 
841 #endif
842 
843 namespace internal {
844 
845 
846 
847 template<typename DstXprType, typename MatrixType, typename PermutationIndex>
848 struct Assignment<DstXprType, Inverse<FullPivLU<MatrixType, PermutationIndex> >, internal::assign_op<typename DstXprType::Scalar,typename FullPivLU<MatrixType, PermutationIndex>::Scalar>, Dense2Dense>
849 {
850  typedef FullPivLU<MatrixType, PermutationIndex> LuType;
851  typedef Inverse<LuType> SrcXprType;
852  static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<typename DstXprType::Scalar,typename MatrixType::Scalar> &)
853  {
854  dst = src.nestedExpression().solve(MatrixType::Identity(src.rows(), src.cols()));
855  }
856 };
857 } // end namespace internal
858 
859 
867 template<typename Derived>
868 template<typename PermutationIndex>
869 inline const FullPivLU<typename MatrixBase<Derived>::PlainObject, PermutationIndex>
871 {
873 }
874 
875 } // end namespace Eigen
876 
877 #endif // EIGEN_LU_H
Matrix3f m
const AbsReturnType abs() const
Array< int, 3, 1 > b
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<...,... >::Type block(Index startRow, Index startCol, NRowsType blockRows, NColsType blockCols)
Definition: BlockMethods.h:96
Array33i c
#define EIGEN_MAKE_IMAGE_HELPERS(DecompositionType)
Definition: Image.h:69
#define EIGEN_MAKE_KERNEL_HELPERS(DecompositionType)
Definition: Kernel.h:68
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
Definition: Macros.h:1149
#define eigen_internal_assert(x)
Definition: Macros.h:908
#define EIGEN_NOEXCEPT
Definition: Macros.h:1260
#define EIGEN_CONSTEXPR
Definition: Macros.h:747
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:883
#define eigen_assert(x)
Definition: Macros.h:902
v setZero(3)
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
#define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE)
Definition: StaticAssert.h:81
float * p
Matrix< float, 1, Dynamic > MatrixType
TransposeReturnType transpose()
Definition: Transpose.h:184
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:61
LU decomposition of a matrix with complete pivoting, and related features.
Definition: FullPivLU.h:64
IntColVectorType m_rowsTranspositions
Definition: FullPivLU.h:432
internal::plain_row_type< MatrixType, PermutationIndex >::type IntRowVectorType
Definition: FullPivLU.h:76
FullPivLU & setThreshold(const RealScalar &threshold)
Definition: FullPivLU.h:293
bool isInjective() const
Definition: FullPivLU.h:363
bool isInvertible() const
Definition: FullPivLU.h:388
internal::traits< MatrixType >::Scalar determinant() const
Definition: FullPivLU.h:578
internal::plain_col_type< MatrixType, PermutationIndex >::type IntColVectorType
Definition: FullPivLU.h:77
MatrixType m_lu
Definition: FullPivLU.h:429
RealScalar rcond() const
Definition: FullPivLU.h:253
IntRowVectorType m_colsTranspositions
Definition: FullPivLU.h:433
void computeInPlace()
Definition: FullPivLU.h:488
MatrixType_ MatrixType
Definition: FullPivLU.h:66
Index nonzeroPivots() const
Definition: FullPivLU.h:148
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: FullPivLU.h:411
RealScalar m_l1_norm
Definition: FullPivLU.h:435
bool m_usePrescribedThreshold
Definition: FullPivLU.h:438
MatrixType::PlainObject PlainObject
Definition: FullPivLU.h:80
signed char m_det_pq
Definition: FullPivLU.h:437
MatrixType reconstructedMatrix() const
Definition: FullPivLU.h:589
const MatrixType & matrixLU() const
Definition: FullPivLU.h:135
const Inverse< FullPivLU > inverse() const
Definition: FullPivLU.h:401
const PermutationPType & permutationP() const
Definition: FullPivLU.h:163
bool m_isInitialized
Definition: FullPivLU.h:438
Index m_nonzero_pivots
Definition: FullPivLU.h:434
FullPivLU & compute(const EigenBase< InputType > &matrix)
Definition: FullPivLU.h:123
RealScalar maxPivot() const
Definition: FullPivLU.h:157
Index rank() const
Definition: FullPivLU.h:333
PermutationIndex_ PermutationIndex
Definition: FullPivLU.h:75
FullPivLU & setThreshold(Default_t)
Definition: FullPivLU.h:308
RealScalar m_prescribedThreshold
Definition: FullPivLU.h:436
SolverBase< FullPivLU > Base
Definition: FullPivLU.h:67
RealScalar m_maxpivot
Definition: FullPivLU.h:436
PermutationMatrix< ColsAtCompileTime, MaxColsAtCompileTime, PermutationIndex > PermutationQType
Definition: FullPivLU.h:78
bool isSurjective() const
Definition: FullPivLU.h:376
const internal::image_retval< FullPivLU > image(const MatrixType &originalMatrix) const
Definition: FullPivLU.h:219
RealScalar threshold() const
Definition: FullPivLU.h:318
const internal::kernel_retval< FullPivLU > kernel() const
Definition: FullPivLU.h:193
PermutationMatrix< RowsAtCompileTime, MaxRowsAtCompileTime, PermutationIndex > PermutationPType
Definition: FullPivLU.h:79
PermutationPType m_p
Definition: FullPivLU.h:430
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: FullPivLU.h:413
const PermutationQType & permutationQ() const
Definition: FullPivLU.h:173
PermutationQType m_q
Definition: FullPivLU.h:431
Index dimensionOfKernel() const
Definition: FullPivLU.h:350
const Solve< FullPivLU, Rhs > solve(const MatrixBase< Rhs > &b) const
FullPivLU()
Default Constructor.
Definition: FullPivLU.h:442
Expression of the inverse of another expression.
Definition: Inverse.h:46
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
const FullPivLU< PlainObject, PermutationIndex > fullPivLu() const
Base::PlainObject PlainObject
Definition: Matrix.h:194
Derived & setZero(Index size)
Pseudo expression representing a solving operation.
Definition: Solve.h:65
A base class for matrix decomposition and solvers.
Definition: SolverBase.h:71
internal::traits< FullPivLU< MatrixType_, PermutationIndex_ > >::Scalar Scalar
Definition: SolverBase.h:75
bfloat16() min(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:684
constexpr int min_size_prefer_fixed(A a, B b)
Definition: Meta.h:553
Decomposition::RealScalar rcond_estimate_helper(typename Decomposition::RealScalar matrix_norm, const Decomposition &dec)
Reciprocal condition number estimator.
bool is_exactly_zero(const X &x)
Definition: Meta.h:475
: InteropHeaders
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
Default_t
Definition: Constants.h:364
const int Dynamic
Definition: Constants.h:24
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_abs_op< typename Derived::Scalar >, const Derived > abs(const Eigen::ArrayBase< Derived > &x)
Derived & derived()
Definition: EigenBase.h:48
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:41
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:231