10 #ifndef EIGEN_COMPLETEORTHOGONALDECOMPOSITION_H 11 #define EIGEN_COMPLETEORTHOGONALDECOMPOSITION_H 16 template <
typename _MatrixType>
47 template <
typename _MatrixType>
50 typedef _MatrixType MatrixType;
52 RowsAtCompileTime = MatrixType::RowsAtCompileTime,
53 ColsAtCompileTime = MatrixType::ColsAtCompileTime,
54 MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
55 MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
57 typedef typename MatrixType::Scalar Scalar;
58 typedef typename MatrixType::RealScalar RealScalar;
59 typedef typename MatrixType::StorageIndex StorageIndex;
70 typename HCoeffsType::ConjugateReturnType>::type>
71 HouseholderSequenceType;
72 typedef typename MatrixType::PlainObject PlainObject;
75 typedef typename PermutationType::Index PermIndexType;
94 : m_cpqr(rows, cols), m_zCoeffs((
std::min)(rows, cols)), m_temp(cols) {}
112 template <
typename InputType>
114 : m_cpqr(matrix.rows(), matrix.cols()),
115 m_zCoeffs((
std::min)(matrix.rows(), matrix.cols())),
116 m_temp(matrix.cols())
127 template<
typename InputType>
129 : m_cpqr(matrix.derived()),
130 m_zCoeffs((
std::min)(matrix.rows(), matrix.cols())),
131 m_temp(matrix.cols())
146 template <
typename Rhs>
149 eigen_assert(m_cpqr.m_isInitialized &&
150 "CompleteOrthogonalDecomposition is not initialized.");
154 HouseholderSequenceType householderQ(
void)
const;
155 HouseholderSequenceType matrixQ(
void)
const {
return m_cpqr.householderQ(); }
160 MatrixType Z = MatrixType::Identity(m_cpqr.cols(), m_cpqr.cols());
161 applyZAdjointOnTheLeftInPlace(Z);
168 const MatrixType&
matrixQTZ()
const {
return m_cpqr.matrixQR(); }
181 const MatrixType&
matrixT()
const {
return m_cpqr.matrixQR(); }
183 template <
typename InputType>
186 m_cpqr.compute(matrix);
193 return m_cpqr.colsPermutation();
209 typename MatrixType::RealScalar absDeterminant()
const;
224 typename MatrixType::RealScalar logAbsDeterminant()
const;
281 inline Index rows()
const {
return m_cpqr.rows(); }
282 inline Index cols()
const {
return m_cpqr.cols(); }
289 inline const HCoeffsType&
hCoeffs()
const {
return m_cpqr.hCoeffs(); }
296 const HCoeffsType&
zCoeffs()
const {
return m_zCoeffs; }
339 RealScalar
threshold()
const {
return m_cpqr.threshold(); }
353 inline RealScalar
maxPivot()
const {
return m_cpqr.maxPivot(); }
364 eigen_assert(m_cpqr.m_isInitialized &&
"Decomposition is not initialized.");
368 #ifndef EIGEN_PARSED_BY_DOXYGEN 369 template <
typename RhsType,
typename DstType>
370 EIGEN_DEVICE_FUNC
void _solve_impl(
const RhsType& rhs, DstType& dst)
const;
374 static void check_template_parameters() {
375 EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
378 void computeInPlace();
382 template <
typename Rhs>
383 void applyZAdjointOnTheLeftInPlace(Rhs& rhs)
const;
386 HCoeffsType m_zCoeffs;
387 RowVectorType m_temp;
390 template <
typename MatrixType>
391 typename MatrixType::RealScalar
393 return m_cpqr.absDeterminant();
396 template <
typename MatrixType>
397 typename MatrixType::RealScalar
399 return m_cpqr.logAbsDeterminant();
409 template <
typename MatrixType>
412 check_template_parameters();
417 const Index rank = m_cpqr.rank();
418 const Index cols = m_cpqr.cols();
419 const Index rows = m_cpqr.rows();
420 m_zCoeffs.resize((std::min)(rows, cols));
435 for (
Index k = rank - 1; k >= 0; --k) {
440 m_cpqr.m_qr.col(k).head(k + 1).swap(
441 m_cpqr.m_qr.col(rank - 1).head(k + 1));
448 .tail(cols - rank + 1)
449 .makeHouseholderInPlace(m_zCoeffs(k), beta);
450 m_cpqr.m_qr(k, rank - 1) = beta;
453 m_cpqr.m_qr.topRightCorner(k, cols - rank + 1)
454 .applyHouseholderOnTheRight(
455 m_cpqr.m_qr.row(k).tail(cols - rank).transpose(), m_zCoeffs(k),
460 m_cpqr.m_qr.col(k).head(k + 1).swap(
461 m_cpqr.m_qr.col(rank - 1).head(k + 1));
467 template <
typename MatrixType>
468 template <
typename Rhs>
471 const Index cols = this->cols();
472 const Index nrhs = rhs.cols();
473 const Index rank = this->rank();
475 for (
Index k = 0; k < rank; ++k) {
477 rhs.row(k).swap(rhs.row(rank - 1));
479 rhs.middleRows(rank - 1, cols - rank + 1)
480 .applyHouseholderOnTheLeft(
481 matrixQTZ().row(k).tail(cols - rank).adjoint(), zCoeffs()(k),
484 rhs.row(k).swap(rhs.row(rank - 1));
489 #ifndef EIGEN_PARSED_BY_DOXYGEN 490 template <
typename _MatrixType>
491 template <
typename RhsType,
typename DstType>
493 const RhsType& rhs, DstType& dst)
const {
494 eigen_assert(rhs.rows() == this->rows());
496 const Index rank = this->rank();
505 typename RhsType::PlainObject c(rhs);
510 dst.topRows(rank) = matrixT()
511 .topLeftCorner(rank, rank)
512 .template triangularView<Upper>()
513 .solve(c.topRows(rank));
515 const Index cols = this->cols();
519 dst.bottomRows(cols - rank).setZero();
520 applyZAdjointOnTheLeftInPlace(dst);
524 dst = colsPermutation() * dst;
530 template<
typename DstXprType,
typename MatrixType>
537 dst = src.nestedExpression().solve(MatrixType::Identity(src.rows(), src.rows()));
544 template <
typename MatrixType>
547 return m_cpqr.householderQ();
554 template <
typename Derived>
562 #endif // EIGEN_COMPLETEORTHOGONALDECOMPOSITION_H const MatrixType & matrixT() const
Definition: CompleteOrthogonalDecomposition.h:181
CompleteOrthogonalDecomposition()
Default Constructor.
Definition: CompleteOrthogonalDecomposition.h:85
const CompleteOrthogonalDecomposition< PlainObject > completeOrthogonalDecomposition() const
Definition: CompleteOrthogonalDecomposition.h:556
Index rank() const
Definition: CompleteOrthogonalDecomposition.h:233
MatrixType matrixZ() const
Definition: CompleteOrthogonalDecomposition.h:159
const Solve< CompleteOrthogonalDecomposition, Rhs > solve(const MatrixBase< Rhs > &b) const
This method computes the minimum-norm solution X to a least squares problem where A is the matrix of...
Definition: CompleteOrthogonalDecomposition.h:147
CompleteOrthogonalDecomposition(EigenBase< InputType > &matrix)
Constructs a complete orthogonal decomposition from a given matrix.
Definition: CompleteOrthogonalDecomposition.h:128
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:85
Holds information about the various numeric (i.e.
Definition: NumTraits.h:150
MatrixType::RealScalar logAbsDeterminant() const
Definition: CompleteOrthogonalDecomposition.h:398
bool isSurjective() const
Definition: CompleteOrthogonalDecomposition.h:260
bool isInvertible() const
Definition: CompleteOrthogonalDecomposition.h:269
Complete orthogonal decomposition (COD) of a matrix.
Definition: ForwardDeclarations.h:257
HouseholderSequence< VectorsType, CoeffsType > householderSequence(const VectorsType &v, const CoeffsType &h)
\
Definition: HouseholderSequence.h:451
Definition: AssignmentFunctors.h:21
Definition: AssignEvaluator.h:753
Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor Matrix...
Definition: EigenBase.h:28
Definition: AssignEvaluator.h:743
Definition: ForwardDeclarations.h:262
CompleteOrthogonalDecomposition & setThreshold(const RealScalar &threshold)
Allows to prescribe a threshold to be used by certain methods, such as rank(), who need to determine ...
Definition: CompleteOrthogonalDecomposition.h:317
const PermutationType & colsPermutation() const
Definition: CompleteOrthogonalDecomposition.h:192
Expression of the inverse of another expression.
Definition: Inverse.h:43
RealScalar threshold() const
Returns the threshold that will be used by certain methods such as rank().
Definition: CompleteOrthogonalDecomposition.h:339
const MatrixType & matrixQTZ() const
Definition: CompleteOrthogonalDecomposition.h:168
CompleteOrthogonalDecomposition(const EigenBase< InputType > &matrix)
Constructs a complete orthogonal decomposition from a given matrix.
Definition: CompleteOrthogonalDecomposition.h:113
void computeInPlace()
Performs the complete orthogonal decomposition of the given matrix matrix.
Definition: CompleteOrthogonalDecomposition.h:410
void applyZAdjointOnTheLeftInPlace(Rhs &rhs) const
Overwrites rhs with .
Definition: CompleteOrthogonalDecomposition.h:469
Index dimensionOfKernel() const
Definition: CompleteOrthogonalDecomposition.h:242
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
const HCoeffsType & hCoeffs() const
Definition: CompleteOrthogonalDecomposition.h:289
HouseholderSequenceType householderQ(void) const
Definition: CompleteOrthogonalDecomposition.h:546
Computation was successful.
Definition: Constants.h:432
Index nonzeroPivots() const
Definition: CompleteOrthogonalDecomposition.h:348
MatrixType::RealScalar absDeterminant() const
Definition: CompleteOrthogonalDecomposition.h:392
Definition: BandTriangularSolver.h:13
const HCoeffsType & zCoeffs() const
Definition: CompleteOrthogonalDecomposition.h:296
RealScalar maxPivot() const
Definition: CompleteOrthogonalDecomposition.h:353
CompleteOrthogonalDecomposition(Index rows, Index cols)
Default Constructor with memory preallocation.
Definition: CompleteOrthogonalDecomposition.h:93
Pseudo expression representing a solving operation.
Definition: Solve.h:62
CompleteOrthogonalDecomposition & setThreshold(Default_t)
Allows to come back to the default behavior, letting Eigen use its default formula for determining th...
Definition: CompleteOrthogonalDecomposition.h:330
const Inverse< CompleteOrthogonalDecomposition > pseudoInverse() const
Definition: CompleteOrthogonalDecomposition.h:276
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:55
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:178
ComputationInfo
Enum for reporting the status of a computation.
Definition: Constants.h:430
ComputationInfo info() const
Reports whether the complete orthogonal decomposition was succesful.
Definition: CompleteOrthogonalDecomposition.h:363
EIGEN_DEVICE_FUNC Derived & derived()
Definition: EigenBase.h:44
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Definition: ForwardDeclarations.h:17
bool isInjective() const
Definition: CompleteOrthogonalDecomposition.h:251