Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ > Class Template Reference

Complete orthogonal decomposition (COD) of a matrix. More...

#include <CompleteOrthogonalDecomposition.h>

+ Inheritance diagram for Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >:

Public Types

enum  { MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime , MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime }
 
typedef MatrixType_ MatrixType
 
typedef SolverBase< CompleteOrthogonalDecompositionBase
 
typedef PermutationIndex_ PermutationIndex
 
typedef internal::plain_diag_type< MatrixType >::type HCoeffsType
 
typedef PermutationMatrix< ColsAtCompileTime, MaxColsAtCompileTime, PermutationIndexPermutationType
 
typedef internal::plain_row_type< MatrixType, Index >::type IntRowVectorType
 
typedef internal::plain_row_type< MatrixType >::type RowVectorType
 
typedef internal::plain_row_type< MatrixType, RealScalar >::type RealRowVectorType
 
typedef HouseholderSequence< MatrixType, internal::remove_all_t< typename HCoeffsType::ConjugateReturnType > > HouseholderSequenceType
 
typedef MatrixType::PlainObject PlainObject
 
- Public Types inherited from Eigen::SolverBase< CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ > >
enum  
 
typedef EigenBase< CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ > > Base
 
typedef internal::traits< CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ > >::Scalar Scalar
 
typedef Scalar CoeffReturnType
 
typedef Transpose< const CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ > > ConstTransposeReturnType
 
typedef std::conditional_t< NumTraits< Scalar >::IsComplex, CwiseUnaryOp< internal::scalar_conjugate_op< Scalar >, const ConstTransposeReturnType >, const ConstTransposeReturnTypeAdjointReturnType
 
- Public Types inherited from Eigen::EigenBase< Derived >
typedef Eigen::Index Index
 The interface type of indices. More...
 
typedef internal::traits< Derived >::StorageKind StorageKind
 

Public Member Functions

 CompleteOrthogonalDecomposition ()
 Default Constructor. More...
 
 CompleteOrthogonalDecomposition (Index rows, Index cols)
 Default Constructor with memory preallocation. More...
 
template<typename InputType >
 CompleteOrthogonalDecomposition (const EigenBase< InputType > &matrix)
 Constructs a complete orthogonal decomposition from a given matrix. More...
 
template<typename InputType >
 CompleteOrthogonalDecomposition (EigenBase< InputType > &matrix)
 Constructs a complete orthogonal decomposition from a given matrix. More...
 
HouseholderSequenceType householderQ (void) const
 
HouseholderSequenceType matrixQ (void) const
 
MatrixType matrixZ () const
 
const MatrixTypematrixQTZ () const
 
const MatrixTypematrixT () const
 
template<typename InputType >
CompleteOrthogonalDecompositioncompute (const EigenBase< InputType > &matrix)
 
const PermutationTypecolsPermutation () const
 
MatrixType::Scalar determinant () const
 
MatrixType::RealScalar absDeterminant () const
 
MatrixType::RealScalar logAbsDeterminant () const
 
MatrixType::Scalar signDeterminant () const
 
Index rank () const
 
Index dimensionOfKernel () const
 
bool isInjective () const
 
bool isSurjective () const
 
bool isInvertible () const
 
const Inverse< CompleteOrthogonalDecompositionpseudoInverse () const
 
Index rows () const
 
Index cols () const
 
const HCoeffsTypehCoeffs () const
 
const HCoeffsTypezCoeffs () const
 
CompleteOrthogonalDecompositionsetThreshold (const RealScalar &threshold)
 
CompleteOrthogonalDecompositionsetThreshold (Default_t)
 
RealScalar threshold () const
 
Index nonzeroPivots () const
 
RealScalar maxPivot () const
 
ComputationInfo info () const
 Reports whether the complete orthogonal decomposition was successful. More...
 
template<typename RhsType , typename DstType >
void _solve_impl (const RhsType &rhs, DstType &dst) const
 
template<bool Conjugate, typename RhsType , typename DstType >
void _solve_impl_transposed (const RhsType &rhs, DstType &dst) const
 
- Public Member Functions inherited from Eigen::SolverBase< CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ > >
 SolverBase ()
 
 ~SolverBase ()
 
const Solve< CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >, Rhs > solve (const MatrixBase< Rhs > &b) const
 
const ConstTransposeReturnType transpose () const
 
const AdjointReturnType adjoint () const
 
constexpr EIGEN_DEVICE_FUNC CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ > & derived ()
 
constexpr EIGEN_DEVICE_FUNC const CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ > & derived () const
 
- Public Member Functions inherited from Eigen::EigenBase< Derived >
constexpr EIGEN_DEVICE_FUNC Derived & derived ()
 
constexpr EIGEN_DEVICE_FUNC const Derived & derived () const
 
EIGEN_DEVICE_FUNC Derived & const_cast_derived () const
 
EIGEN_DEVICE_FUNC const Derived & const_derived () const
 
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows () const EIGEN_NOEXCEPT
 
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index size () const EIGEN_NOEXCEPT
 
template<typename Dest >
EIGEN_DEVICE_FUNC void evalTo (Dest &dst) const
 
template<typename Dest >
EIGEN_DEVICE_FUNC void addTo (Dest &dst) const
 
template<typename Dest >
EIGEN_DEVICE_FUNC void subTo (Dest &dst) const
 
template<typename Dest >
EIGEN_DEVICE_FUNC void applyThisOnTheRight (Dest &dst) const
 
template<typename Dest >
EIGEN_DEVICE_FUNC void applyThisOnTheLeft (Dest &dst) const
 
template<typename Device >
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DeviceWrapper< Derived, Device > device (Device &device)
 
template<typename Device >
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DeviceWrapper< const Derived, Device > device (Device &device) const
 

Protected Member Functions

template<bool Transpose_, typename Rhs >
void _check_solve_assertion (const Rhs &b) const
 
void computeInPlace ()
 
template<bool Conjugate, typename Rhs >
void applyZOnTheLeftInPlace (Rhs &rhs) const
 
template<typename Rhs >
void applyZAdjointOnTheLeftInPlace (Rhs &rhs) const
 
- Protected Member Functions inherited from Eigen::SolverBase< CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ > >
void _check_solve_assertion (const Rhs &b) const
 

Protected Attributes

ColPivHouseholderQR< MatrixType, PermutationIndexm_cpqr
 
HCoeffsType m_zCoeffs
 
RowVectorType m_temp
 

Friends

template<typename Derived >
struct internal::solve_assertion
 

Detailed Description

template<typename MatrixType_, typename PermutationIndex_>
class Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >

Complete orthogonal decomposition (COD) of a matrix.

Template Parameters
MatrixType_the type of the matrix of which we are computing the COD.

This class performs a rank-revealing complete orthogonal decomposition of a matrix A into matrices P, Q, T, and Z such that

\[ \mathbf{A} \, \mathbf{P} = \mathbf{Q} \, \begin{bmatrix} \mathbf{T} & \mathbf{0} \\ \mathbf{0} & \mathbf{0} \end{bmatrix} \, \mathbf{Z} \]

by using Householder transformations. Here, P is a permutation matrix, Q and Z are unitary matrices and T an upper triangular matrix of size rank-by-rank. A may be rank deficient.

This class supports the inplace decomposition mechanism.

See also
MatrixBase::completeOrthogonalDecomposition()

Member Typedef Documentation

◆ Base

template<typename MatrixType_ , typename PermutationIndex_ >
typedef SolverBase<CompleteOrthogonalDecomposition> Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::Base

◆ HCoeffsType

template<typename MatrixType_ , typename PermutationIndex_ >
typedef internal::plain_diag_type<MatrixType>::type Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::HCoeffsType

◆ HouseholderSequenceType

template<typename MatrixType_ , typename PermutationIndex_ >
typedef HouseholderSequence<MatrixType, internal::remove_all_t<typename HCoeffsType::ConjugateReturnType> > Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::HouseholderSequenceType

◆ IntRowVectorType

template<typename MatrixType_ , typename PermutationIndex_ >
typedef internal::plain_row_type<MatrixType, Index>::type Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::IntRowVectorType

◆ MatrixType

template<typename MatrixType_ , typename PermutationIndex_ >
typedef MatrixType_ Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::MatrixType

◆ PermutationIndex

template<typename MatrixType_ , typename PermutationIndex_ >
typedef PermutationIndex_ Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::PermutationIndex

◆ PermutationType

template<typename MatrixType_ , typename PermutationIndex_ >
typedef PermutationMatrix<ColsAtCompileTime, MaxColsAtCompileTime, PermutationIndex> Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::PermutationType

◆ PlainObject

template<typename MatrixType_ , typename PermutationIndex_ >
typedef MatrixType::PlainObject Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::PlainObject

◆ RealRowVectorType

template<typename MatrixType_ , typename PermutationIndex_ >
typedef internal::plain_row_type<MatrixType, RealScalar>::type Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::RealRowVectorType

◆ RowVectorType

template<typename MatrixType_ , typename PermutationIndex_ >
typedef internal::plain_row_type<MatrixType>::type Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::RowVectorType

Member Enumeration Documentation

◆ anonymous enum

template<typename MatrixType_ , typename PermutationIndex_ >
anonymous enum
Enumerator
MaxRowsAtCompileTime 
MaxColsAtCompileTime 
63  {
64  MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
65  MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
66  };
@ MaxColsAtCompileTime
Definition: CompleteOrthogonalDecomposition.h:65
@ MaxRowsAtCompileTime
Definition: CompleteOrthogonalDecomposition.h:64

Constructor & Destructor Documentation

◆ CompleteOrthogonalDecomposition() [1/4]

template<typename MatrixType_ , typename PermutationIndex_ >
Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::CompleteOrthogonalDecomposition ( )
inline

Default Constructor.

The default constructor is useful in cases in which the user intends to perform decompositions via CompleteOrthogonalDecomposition::compute(const* MatrixType&).

84 : m_cpqr(), m_zCoeffs(), m_temp() {}
ColPivHouseholderQR< MatrixType, PermutationIndex > m_cpqr
Definition: CompleteOrthogonalDecomposition.h:421
RowVectorType m_temp
Definition: CompleteOrthogonalDecomposition.h:423
HCoeffsType m_zCoeffs
Definition: CompleteOrthogonalDecomposition.h:422

◆ CompleteOrthogonalDecomposition() [2/4]

template<typename MatrixType_ , typename PermutationIndex_ >
Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::CompleteOrthogonalDecomposition ( Index  rows,
Index  cols 
)
inline

Default Constructor with memory preallocation.

Like the default constructor but with preallocation of the internal data according to the specified problem size.

See also
CompleteOrthogonalDecomposition()
Index cols() const
Definition: CompleteOrthogonalDecomposition.h:302
Index rows() const
Definition: CompleteOrthogonalDecomposition.h:301
#define min(a, b)
Definition: datatypes.h:22

◆ CompleteOrthogonalDecomposition() [3/4]

template<typename MatrixType_ , typename PermutationIndex_ >
template<typename InputType >
Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::CompleteOrthogonalDecomposition ( const EigenBase< InputType > &  matrix)
inlineexplicit

Constructs a complete orthogonal decomposition from a given matrix.

This constructor computes the complete orthogonal decomposition of the matrix matrix by calling the method compute(). The default threshold for rank determination will be used. It is a short cut for:

CompleteOrthogonalDecomposition<MatrixType> cod(matrix.rows(),
matrix.cols());
cod.setThreshold(Default);
cod.compute(matrix);
Eigen::Map< Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor >, 0, Eigen::OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition: common.h:85
@ Default
Definition: Constants.h:361
void cod()
Definition: qr_colpivoting.cpp:17
See also
compute()
113  : m_cpqr(matrix.rows(), matrix.cols()),
114  m_zCoeffs((std::min)(matrix.rows(), matrix.cols())),
115  m_temp(matrix.cols()) {
116  compute(matrix.derived());
117  }
CompleteOrthogonalDecomposition & compute(const EigenBase< InputType > &matrix)
Definition: CompleteOrthogonalDecomposition.h:176

References Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::compute(), and matrix().

◆ CompleteOrthogonalDecomposition() [4/4]

template<typename MatrixType_ , typename PermutationIndex_ >
template<typename InputType >
Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::CompleteOrthogonalDecomposition ( EigenBase< InputType > &  matrix)
inlineexplicit

Constructs a complete orthogonal decomposition from a given matrix.

This overloaded constructor is provided for inplace decomposition when MatrixType is a Eigen::Ref.

See also
CompleteOrthogonalDecomposition(const EigenBase&)
128  : m_cpqr(matrix.derived()), m_zCoeffs((std::min)(matrix.rows(), matrix.cols())), m_temp(matrix.cols()) {
129  computeInPlace();
130  }
void computeInPlace()
Definition: CompleteOrthogonalDecomposition.h:455

References Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::computeInPlace().

Member Function Documentation

◆ _check_solve_assertion()

template<typename MatrixType_ , typename PermutationIndex_ >
template<bool Transpose_, typename Rhs >
void Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::_check_solve_assertion ( const Rhs &  b) const
inlineprotected
400  {
402  eigen_assert(m_cpqr.m_isInitialized && "CompleteOrthogonalDecomposition is not initialized.");
403  eigen_assert((Transpose_ ? derived().cols() : derived().rows()) == b.rows() &&
404  "CompleteOrthogonalDecomposition::solve(): invalid number of rows of the right hand side matrix b");
405  }
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
Definition: Macros.h:922
#define eigen_assert(x)
Definition: Macros.h:910
Scalar * b
Definition: benchVecAdd.cpp:17
bool m_isInitialized
Definition: ColPivHouseholderQR.h:433
constexpr EIGEN_DEVICE_FUNC CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ > & derived()
Definition: EigenBase.h:49

References b, Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::cols(), Eigen::SolverBase< CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ > >::derived(), eigen_assert, EIGEN_ONLY_USED_FOR_DEBUG, Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_cpqr, Eigen::ColPivHouseholderQR< MatrixType_, PermutationIndex_ >::m_isInitialized, and Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::rows().

◆ _solve_impl()

template<typename MatrixType_ , typename PermutationIndex_ >
template<typename RhsType , typename DstType >
void Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::_solve_impl ( const RhsType &  rhs,
DstType &  dst 
) const
545  {
546  const Index rank = this->rank();
547  if (rank == 0) {
548  dst.setZero();
549  return;
550  }
551 
552  // Compute c = Q^* * rhs
553  typename RhsType::PlainObject c(rhs);
554  c.applyOnTheLeft(matrixQ().setLength(rank).adjoint());
555 
556  // Solve T z = c(1:rank, :)
557  dst.topRows(rank) = matrixT().topLeftCorner(rank, rank).template triangularView<Upper>().solve(c.topRows(rank));
558 
559  const Index cols = this->cols();
560  if (rank < cols) {
561  // Compute y = Z^* * [ z ]
562  // [ 0 ]
563  dst.bottomRows(cols - rank).setZero();
565  }
566 
567  // Undo permutation to get x = P^{-1} * y.
568  dst = colsPermutation() * dst;
569 }
void applyZAdjointOnTheLeftInPlace(Rhs &rhs) const
Definition: CompleteOrthogonalDecomposition.h:524
HouseholderSequenceType matrixQ(void) const
Definition: CompleteOrthogonalDecomposition.h:147
const PermutationType & colsPermutation() const
Definition: CompleteOrthogonalDecomposition.h:184
Index rank() const
Definition: CompleteOrthogonalDecomposition.h:253
const MatrixType & matrixT() const
Definition: CompleteOrthogonalDecomposition.h:173
const AdjointReturnType adjoint() const
Definition: SolverBase.h:136
int c
Definition: calibrate.py:100
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:43

References adjoint(), calibrate::c, and cols.

◆ _solve_impl_transposed()

template<typename MatrixType_ , typename PermutationIndex_ >
template<bool Conjugate, typename RhsType , typename DstType >
void Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::_solve_impl_transposed ( const RhsType &  rhs,
DstType &  dst 
) const
574  {
575  const Index rank = this->rank();
576 
577  if (rank == 0) {
578  dst.setZero();
579  return;
580  }
581 
582  typename RhsType::PlainObject c(colsPermutation().transpose() * rhs);
583 
584  if (rank < cols()) {
585  applyZOnTheLeftInPlace<!Conjugate>(c);
586  }
587 
588  matrixT()
589  .topLeftCorner(rank, rank)
590  .template triangularView<Upper>()
591  .transpose()
592  .template conjugateIf<Conjugate>()
593  .solveInPlace(c.topRows(rank));
594 
595  dst.topRows(rank) = c.topRows(rank);
596  dst.bottomRows(rows() - rank).setZero();
597 
598  dst.applyOnTheLeft(householderQ().setLength(rank).template conjugateIf<!Conjugate>());
599 }
HouseholderSequenceType householderQ(void) const
Definition: CompleteOrthogonalDecomposition.h:631
const ConstTransposeReturnType transpose() const
Definition: SolverBase.h:120

References calibrate::c, cols, rows, and anonymous_namespace{skew_symmetric_matrix3.cpp}::transpose().

◆ absDeterminant()

template<typename MatrixType , typename PermutationIndex >
MatrixType::RealScalar Eigen::CompleteOrthogonalDecomposition< MatrixType, PermutationIndex >::absDeterminant
Returns
the absolute value of the determinant of the matrix of which *this is the complete orthogonal decomposition. It has only linear complexity (that is, O(n) where n is the dimension of the square matrix) as the complete orthogonal decomposition has already been computed.
Note
This is only for square matrices.
Warning
a determinant can be very big or small, so for matrices of large enough dimension, there is a risk of overflow/underflow. One way to work around that is to use logAbsDeterminant() instead.
See also
determinant(), logAbsDeterminant(), MatrixBase::determinant()
432  {
433  return m_cpqr.absDeterminant();
434 }
MatrixType::RealScalar absDeterminant() const
Definition: ColPivHouseholderQR.h:449

Referenced by cod().

◆ applyZAdjointOnTheLeftInPlace()

template<typename MatrixType , typename PermutationIndex >
template<typename Rhs >
void Eigen::CompleteOrthogonalDecomposition< MatrixType, PermutationIndex >::applyZAdjointOnTheLeftInPlace ( Rhs &  rhs) const
protected

Overwrites rhs with \( \mathbf{Z}^* * \mathbf{rhs} \).

524  {
525  const Index cols = this->cols();
526  const Index nrhs = rhs.cols();
527  const Index rank = this->rank();
528  Matrix<typename Rhs::Scalar, Dynamic, 1> temp((std::max)(cols, nrhs));
529  for (Index k = 0; k < rank; ++k) {
530  if (k != rank - 1) {
531  rhs.row(k).swap(rhs.row(rank - 1));
532  }
533  rhs.middleRows(rank - 1, cols - rank + 1)
534  .applyHouseholderOnTheLeft(matrixQTZ().row(k).tail(cols - rank).adjoint(), zCoeffs()(k), &temp(0));
535  if (k != rank - 1) {
536  rhs.row(k).swap(rhs.row(rank - 1));
537  }
538  }
539 }
m row(1)
const HCoeffsType & zCoeffs() const
Definition: CompleteOrthogonalDecomposition.h:316
const MatrixType & matrixQTZ() const
Definition: CompleteOrthogonalDecomposition.h:160
#define max(a, b)
Definition: datatypes.h:23
char char char int int * k
Definition: level2_impl.h:374

References adjoint(), cols, k, max, and row().

◆ applyZOnTheLeftInPlace()

template<typename MatrixType , typename PermutationIndex >
template<bool Conjugate, typename Rhs >
void Eigen::CompleteOrthogonalDecomposition< MatrixType, PermutationIndex >::applyZOnTheLeftInPlace ( Rhs &  rhs) const
protected

Overwrites rhs with \( \mathbf{Z} * \mathbf{rhs} \) or \( \mathbf{\overline Z} * \mathbf{rhs} \) if Conjugate is set to true.

504  {
505  const Index cols = this->cols();
506  const Index nrhs = rhs.cols();
507  const Index rank = this->rank();
508  Matrix<typename Rhs::Scalar, Dynamic, 1> temp((std::max)(cols, nrhs));
509  for (Index k = rank - 1; k >= 0; --k) {
510  if (k != rank - 1) {
511  rhs.row(k).swap(rhs.row(rank - 1));
512  }
513  rhs.middleRows(rank - 1, cols - rank + 1)
514  .applyHouseholderOnTheLeft(matrixQTZ().row(k).tail(cols - rank).transpose().template conjugateIf<!Conjugate>(),
515  zCoeffs().template conjugateIf<Conjugate>()(k), &temp(0));
516  if (k != rank - 1) {
517  rhs.row(k).swap(rhs.row(rank - 1));
518  }
519  }
520 }

References cols, k, max, row(), and anonymous_namespace{skew_symmetric_matrix3.cpp}::transpose().

◆ cols()

◆ colsPermutation()

template<typename MatrixType_ , typename PermutationIndex_ >
const PermutationType& Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::colsPermutation ( ) const
inline
Returns
a const reference to the column permutation matrix
184 { return m_cpqr.colsPermutation(); }
const PermutationType & colsPermutation() const
Definition: ColPivHouseholderQR.h:192

References Eigen::ColPivHouseholderQR< MatrixType_, PermutationIndex_ >::colsPermutation(), and Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_cpqr.

◆ compute()

template<typename MatrixType_ , typename PermutationIndex_ >
template<typename InputType >
CompleteOrthogonalDecomposition& Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::compute ( const EigenBase< InputType > &  matrix)
inline

◆ computeInPlace()

template<typename MatrixType , typename PermutationIndex >
void Eigen::CompleteOrthogonalDecomposition< MatrixType, PermutationIndex >::computeInPlace
protected

Performs the complete orthogonal decomposition of the given matrix matrix. The result of the factorization is stored into *this, and a reference to *this is returned.

See also
class CompleteOrthogonalDecomposition, CompleteOrthogonalDecomposition(const MatrixType&)
455  {
456  eigen_assert(m_cpqr.cols() <= NumTraits<PermutationIndex>::highest());
457 
458  const Index rank = m_cpqr.rank();
459  const Index cols = m_cpqr.cols();
460  const Index rows = m_cpqr.rows();
461  m_zCoeffs.resize((std::min)(rows, cols));
462  m_temp.resize(cols);
463 
464  if (rank < cols) {
465  // We have reduced the (permuted) matrix to the form
466  // [R11 R12]
467  // [ 0 R22]
468  // where R11 is r-by-r (r = rank) upper triangular, R12 is
469  // r-by-(n-r), and R22 is empty or the norm of R22 is negligible.
470  // We now compute the complete orthogonal decomposition by applying
471  // Householder transformations from the right to the upper trapezoidal
472  // matrix X = [R11 R12] to zero out R12 and obtain the factorization
473  // [R11 R12] = [T11 0] * Z, where T11 is r-by-r upper triangular and
474  // Z = Z(0) * Z(1) ... Z(r-1) is an n-by-n orthogonal matrix.
475  // We store the data representing Z in R12 and m_zCoeffs.
476  for (Index k = rank - 1; k >= 0; --k) {
477  if (k != rank - 1) {
478  // Given the API for Householder reflectors, it is more convenient if
479  // we swap the leading parts of columns k and r-1 (zero-based) to form
480  // the matrix X_k = [X(0:k, k), X(0:k, r:n)]
481  m_cpqr.m_qr.col(k).head(k + 1).swap(m_cpqr.m_qr.col(rank - 1).head(k + 1));
482  }
483  // Construct Householder reflector Z(k) to zero out the last row of X_k,
484  // i.e. choose Z(k) such that
485  // [X(k, k), X(k, r:n)] * Z(k) = [beta, 0, .., 0].
487  m_cpqr.m_qr.row(k).tail(cols - rank + 1).makeHouseholderInPlace(m_zCoeffs(k), beta);
488  m_cpqr.m_qr(k, rank - 1) = beta;
489  if (k > 0) {
490  // Apply Z(k) to the first k rows of X_k
491  m_cpqr.m_qr.topRightCorner(k, cols - rank + 1)
492  .applyHouseholderOnTheRight(m_cpqr.m_qr.row(k).tail(cols - rank).adjoint(), m_zCoeffs(k), &m_temp(0));
493  }
494  if (k != rank - 1) {
495  // Swap X(0:k,k) back to its proper location.
496  m_cpqr.m_qr.col(k).head(k + 1).swap(m_cpqr.m_qr.col(rank - 1).head(k + 1));
497  }
498  }
499  }
500 }
NumTraits< Scalar >::Real RealScalar
Definition: bench_gemm.cpp:46
Index rows() const
Definition: ColPivHouseholderQR.h:326
Index rank() const
Definition: ColPivHouseholderQR.h:261
MatrixType m_qr
Definition: ColPivHouseholderQR.h:426
Scalar beta
Definition: level2_cplx_impl.h:36

References beta, cols, eigen_assert, k, min, and rows.

Referenced by Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::CompleteOrthogonalDecomposition(), and Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::compute().

◆ determinant()

template<typename MatrixType , typename PermutationIndex >
MatrixType::Scalar Eigen::CompleteOrthogonalDecomposition< MatrixType, PermutationIndex >::determinant
Returns
the determinant of the matrix of which *this is the complete orthogonal decomposition. It has only linear complexity (that is, O(n) where n is the dimension of the square matrix) as the complete orthogonal decomposition has already been computed.
Note
This is only for square matrices.
Warning
a determinant can be very big or small, so for matrices of large enough dimension, there is a risk of overflow/underflow. One way to work around that is to use logAbsDeterminant() instead.
See also
absDeterminant(), logAbsDeterminant(), MatrixBase::determinant()
427  {
428  return m_cpqr.determinant();
429 }
MatrixType::Scalar determinant() const
Definition: ColPivHouseholderQR.h:440

Referenced by cod().

◆ dimensionOfKernel()

template<typename MatrixType_ , typename PermutationIndex_ >
Index Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::dimensionOfKernel ( ) const
inline
Returns
the dimension of the kernel of the matrix of which *this is the complete orthogonal decomposition.
Note
This method has to determine which pivots should be considered nonzero. For that, it uses the threshold value that you can control by calling setThreshold(const RealScalar&).
262 { return m_cpqr.dimensionOfKernel(); }
Index dimensionOfKernel() const
Definition: ColPivHouseholderQR.h:276

References Eigen::ColPivHouseholderQR< MatrixType_, PermutationIndex_ >::dimensionOfKernel(), and Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_cpqr.

◆ hCoeffs()

template<typename MatrixType_ , typename PermutationIndex_ >
const HCoeffsType& Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::hCoeffs ( ) const
inline
Returns
a const reference to the vector of Householder coefficients used to represent the factor Q.

For advanced uses only.

309 { return m_cpqr.hCoeffs(); }
const HCoeffsType & hCoeffs() const
Definition: ColPivHouseholderQR.h:333

References Eigen::ColPivHouseholderQR< MatrixType_, PermutationIndex_ >::hCoeffs(), and Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_cpqr.

◆ householderQ()

template<typename MatrixType , typename PermutationIndex >
CompleteOrthogonalDecomposition< MatrixType, PermutationIndex >::HouseholderSequenceType Eigen::CompleteOrthogonalDecomposition< MatrixType, PermutationIndex >::householderQ ( void  ) const
Returns
the matrix Q as a sequence of householder transformations
631  {
632  return m_cpqr.householderQ();
633 }
HouseholderSequenceType householderQ() const
Definition: ColPivHouseholderQR.h:656

Referenced by cod().

◆ info()

template<typename MatrixType_ , typename PermutationIndex_ >
ComputationInfo Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::info ( ) const
inline

Reports whether the complete orthogonal decomposition was successful.

Note
This function always returns Success. It is provided for compatibility with other factorization routines.
Returns
Success
383  {
384  eigen_assert(m_cpqr.m_isInitialized && "Decomposition is not initialized.");
385  return Success;
386  }
@ Success
Definition: Constants.h:440

References eigen_assert, Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_cpqr, Eigen::ColPivHouseholderQR< MatrixType_, PermutationIndex_ >::m_isInitialized, and Eigen::Success.

◆ isInjective()

template<typename MatrixType_ , typename PermutationIndex_ >
bool Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::isInjective ( ) const
inline
Returns
true if the matrix of which *this is the decomposition represents an injective linear map, i.e. has trivial kernel; false otherwise.
Note
This method has to determine which pivots should be considered nonzero. For that, it uses the threshold value that you can control by calling setThreshold(const RealScalar&).
271 { return m_cpqr.isInjective(); }
bool isInjective() const
Definition: ColPivHouseholderQR.h:288

References Eigen::ColPivHouseholderQR< MatrixType_, PermutationIndex_ >::isInjective(), and Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_cpqr.

◆ isInvertible()

template<typename MatrixType_ , typename PermutationIndex_ >
bool Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::isInvertible ( ) const
inline
Returns
true if the matrix of which *this is the complete orthogonal decomposition is invertible.
Note
This method has to determine which pivots should be considered nonzero. For that, it uses the threshold value that you can control by calling setThreshold(const RealScalar&).
289 { return m_cpqr.isInvertible(); }
bool isInvertible() const
Definition: ColPivHouseholderQR.h:311

References Eigen::ColPivHouseholderQR< MatrixType_, PermutationIndex_ >::isInvertible(), and Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_cpqr.

◆ isSurjective()

template<typename MatrixType_ , typename PermutationIndex_ >
bool Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::isSurjective ( ) const
inline
Returns
true if the matrix of which *this is the decomposition represents a surjective linear map; false otherwise.
Note
This method has to determine which pivots should be considered nonzero. For that, it uses the threshold value that you can control by calling setThreshold(const RealScalar&).
280 { return m_cpqr.isSurjective(); }
bool isSurjective() const
Definition: ColPivHouseholderQR.h:300

References Eigen::ColPivHouseholderQR< MatrixType_, PermutationIndex_ >::isSurjective(), and Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_cpqr.

◆ logAbsDeterminant()

template<typename MatrixType , typename PermutationIndex >
MatrixType::RealScalar Eigen::CompleteOrthogonalDecomposition< MatrixType, PermutationIndex >::logAbsDeterminant
Returns
the natural log of the absolute value of the determinant of the matrix of which *this is the complete orthogonal decomposition. It has only linear complexity (that is, O(n) where n is the dimension of the square matrix) as the complete orthogonal decomposition has already been computed.
Note
This is only for square matrices.
This method is useful to work around the risk of overflow/underflow that's inherent to determinant computation.
See also
determinant(), absDeterminant(), MatrixBase::determinant()
438  {
439  return m_cpqr.logAbsDeterminant();
440 }
MatrixType::RealScalar logAbsDeterminant() const
Definition: ColPivHouseholderQR.h:457

Referenced by cod().

◆ matrixQ()

template<typename MatrixType_ , typename PermutationIndex_ >
HouseholderSequenceType Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::matrixQ ( void  ) const
inline

◆ matrixQTZ()

template<typename MatrixType_ , typename PermutationIndex_ >
const MatrixType& Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::matrixQTZ ( ) const
inline
Returns
a reference to the matrix where the complete orthogonal decomposition is stored
160 { return m_cpqr.matrixQR(); }
const MatrixType & matrixQR() const
Definition: ColPivHouseholderQR.h:169

References Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_cpqr, and Eigen::ColPivHouseholderQR< MatrixType_, PermutationIndex_ >::matrixQR().

◆ matrixT()

template<typename MatrixType_ , typename PermutationIndex_ >
const MatrixType& Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::matrixT ( ) const
inline
Returns
a reference to the matrix where the complete orthogonal decomposition is stored.
Warning
The strict lower part and
cols() - rank()
right columns of this matrix contains internal values. Only the upper triangular part should be referenced. To get it, use
matrixT().template triangularView<Upper>()
For rank-deficient matrices, use
matrixT().topLeftCorner(rank(), rank()).template triangularView<Upper>()
173 { return m_cpqr.matrixQR(); }

References Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_cpqr, and Eigen::ColPivHouseholderQR< MatrixType_, PermutationIndex_ >::matrixQR().

◆ matrixZ()

template<typename MatrixType_ , typename PermutationIndex_ >
MatrixType Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::matrixZ ( ) const
inline
Returns
the matrix Z.
151  {
152  MatrixType Z = MatrixType::Identity(m_cpqr.cols(), m_cpqr.cols());
153  applyZOnTheLeftInPlace<false>(Z);
154  return Z;
155  }
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
#define Z
Definition: icosphere.cpp:21

References Eigen::ColPivHouseholderQR< MatrixType_, PermutationIndex_ >::cols(), Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_cpqr, and Z.

◆ maxPivot()

template<typename MatrixType_ , typename PermutationIndex_ >
RealScalar Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::maxPivot ( ) const
inline
Returns
the absolute value of the biggest pivot, i.e. the biggest diagonal coefficient of R.
373 { return m_cpqr.maxPivot(); }
RealScalar maxPivot() const
Definition: ColPivHouseholderQR.h:398

References Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_cpqr, and Eigen::ColPivHouseholderQR< MatrixType_, PermutationIndex_ >::maxPivot().

◆ nonzeroPivots()

template<typename MatrixType_ , typename PermutationIndex_ >
Index Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::nonzeroPivots ( ) const
inline
Returns
the number of nonzero pivots in the complete orthogonal decomposition. Here nonzero is meant in the exact sense, not in a fuzzy sense. So that notion isn't really intrinsically interesting, but it is still useful when implementing algorithms.
See also
rank()
368 { return m_cpqr.nonzeroPivots(); }
Index nonzeroPivots() const
Definition: ColPivHouseholderQR.h:390

References Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_cpqr, and Eigen::ColPivHouseholderQR< MatrixType_, PermutationIndex_ >::nonzeroPivots().

◆ pseudoInverse()

template<typename MatrixType_ , typename PermutationIndex_ >
const Inverse<CompleteOrthogonalDecomposition> Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::pseudoInverse ( ) const
inline
Returns
the pseudo-inverse of the matrix of which *this is the complete orthogonal decomposition.
Warning
: Do not compute this->pseudoInverse()*rhs to solve a linear systems. It is more efficient and numerically stable to call this->solve(rhs).
296  {
297  eigen_assert(m_cpqr.m_isInitialized && "CompleteOrthogonalDecomposition is not initialized.");
298  return Inverse<CompleteOrthogonalDecomposition>(*this);
299  }

References eigen_assert, Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_cpqr, and Eigen::ColPivHouseholderQR< MatrixType_, PermutationIndex_ >::m_isInitialized.

◆ rank()

template<typename MatrixType_ , typename PermutationIndex_ >
Index Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::rank ( ) const
inline
Returns
the rank of the matrix of which *this is the complete orthogonal decomposition.
Note
This method has to determine which pivots should be considered nonzero. For that, it uses the threshold value that you can control by calling setThreshold(const RealScalar&).
253 { return m_cpqr.rank(); }

References Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_cpqr, and Eigen::ColPivHouseholderQR< MatrixType_, PermutationIndex_ >::rank().

◆ rows()

◆ setThreshold() [1/2]

template<typename MatrixType_ , typename PermutationIndex_ >
CompleteOrthogonalDecomposition& Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::setThreshold ( const RealScalar threshold)
inline

Allows to prescribe a threshold to be used by certain methods, such as rank(), who need to determine when pivots are to be considered nonzero. Most be called before calling compute().

When it needs to get the threshold value, Eigen calls threshold(). By default, this uses a formula to automatically determine a reasonable threshold. Once you have called the present method setThreshold(const RealScalar&), your value is used instead.

Parameters
thresholdThe new value to use as the threshold.

A pivot will be considered nonzero if its absolute value is strictly greater than \( \vert pivot \vert \leqslant threshold \times \vert maxpivot \vert \) where maxpivot is the biggest pivot.

If you want to come back to the default behavior, call setThreshold(Default_t)

337  {
339  return *this;
340  }
ColPivHouseholderQR & setThreshold(const RealScalar &threshold)
Definition: ColPivHouseholderQR.h:352
RealScalar threshold() const
Definition: CompleteOrthogonalDecomposition.h:359

References Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_cpqr, Eigen::ColPivHouseholderQR< MatrixType_, PermutationIndex_ >::setThreshold(), and Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::threshold().

◆ setThreshold() [2/2]

template<typename MatrixType_ , typename PermutationIndex_ >
CompleteOrthogonalDecomposition& Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::setThreshold ( Default_t  )
inline

Allows to come back to the default behavior, letting Eigen use its default formula for determining the threshold.

You should pass the special object Eigen::Default as parameter here.

qr.setThreshold(Eigen::Default);
HouseholderQR< MatrixXf > qr(A)

See the documentation of setThreshold(const RealScalar&).

350  {
352  return *this;
353  }

References Eigen::Default, Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_cpqr, and Eigen::ColPivHouseholderQR< MatrixType_, PermutationIndex_ >::setThreshold().

◆ signDeterminant()

template<typename MatrixType , typename PermutationIndex >
MatrixType::Scalar Eigen::CompleteOrthogonalDecomposition< MatrixType, PermutationIndex >::signDeterminant
Returns
the sign of the determinant of the matrix of which *this is the complete orthogonal decomposition. It has only linear complexity (that is, O(n) where n is the dimension of the square matrix) as the complete orthogonal decomposition has already been computed.
Note
This is only for square matrices.
This method is useful to work around the risk of overflow/underflow that's inherent to determinant computation.
See also
determinant(), absDeterminant(), logAbsDeterminant(), MatrixBase::determinant()
443  {
444  return m_cpqr.signDeterminant();
445 }
MatrixType::Scalar signDeterminant() const
Definition: ColPivHouseholderQR.h:464

Referenced by cod().

◆ threshold()

template<typename MatrixType_ , typename PermutationIndex_ >
RealScalar Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::threshold ( ) const
inline

Returns the threshold that will be used by certain methods such as rank().

See the documentation of setThreshold(const RealScalar&).

359 { return m_cpqr.threshold(); }
RealScalar threshold() const
Definition: ColPivHouseholderQR.h:375

References Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_cpqr, and Eigen::ColPivHouseholderQR< MatrixType_, PermutationIndex_ >::threshold().

Referenced by Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::setThreshold().

◆ zCoeffs()

template<typename MatrixType_ , typename PermutationIndex_ >
const HCoeffsType& Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::zCoeffs ( ) const
inline
Returns
a const reference to the vector of Householder coefficients used to represent the factor Z.

For advanced uses only.

316 { return m_zCoeffs; }

References Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_zCoeffs.

Friends And Related Function Documentation

◆ internal::solve_assertion

template<typename MatrixType_ , typename PermutationIndex_ >
template<typename Derived >
friend struct internal::solve_assertion
friend

Member Data Documentation

◆ m_cpqr

template<typename MatrixType_ , typename PermutationIndex_ >
ColPivHouseholderQR<MatrixType, PermutationIndex> Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_cpqr
protected

Referenced by Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::_check_solve_assertion(), Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::cols(), Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::colsPermutation(), Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::compute(), Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::dimensionOfKernel(), Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::hCoeffs(), Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::info(), Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::isInjective(), Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::isInvertible(), Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::isSurjective(), Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::matrixQ(), Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::matrixQTZ(), Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::matrixT(), Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::matrixZ(), Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::maxPivot(), Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::nonzeroPivots(), Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::pseudoInverse(), Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::rank(), Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::rows(), Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::setThreshold(), and Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::threshold().

◆ m_temp

template<typename MatrixType_ , typename PermutationIndex_ >
RowVectorType Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_temp
protected

◆ m_zCoeffs

template<typename MatrixType_ , typename PermutationIndex_ >
HCoeffsType Eigen::CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >::m_zCoeffs
protected

The documentation for this class was generated from the following files: