10#ifndef EIGEN_COMPLETEORTHOGONALDECOMPOSITION_H
11#define EIGEN_COMPLETEORTHOGONALDECOMPOSITION_H
16template <
typename _MatrixType>
51 :
public SolverBase<CompleteOrthogonalDecomposition<_MatrixType> >
57 template<
typename Derived>
117 template <
typename InputType>
132 template<
typename InputType>
141 #ifdef EIGEN_PARSED_BY_DOXYGEN
151 template <
typename Rhs>
163 applyZOnTheLeftInPlace<false>(Z);
185 template <
typename InputType>
371#ifndef EIGEN_PARSED_BY_DOXYGEN
372 template <
typename RhsType,
typename DstType>
373 void _solve_impl(
const RhsType& rhs, DstType& dst)
const;
375 template<
bool Conjugate,
typename RhsType,
typename DstType>
384 template<
bool Transpose_,
typename Rhs>
388 eigen_assert((Transpose_?
derived().
cols():
derived().
rows())==
b.rows() &&
"CompleteOrthogonalDecomposition::solve(): invalid number of rows of the right hand side matrix b");
397 template <
bool Conjugate,
typename Rhs>
402 template <
typename Rhs>
410template <
typename MatrixType>
411typename MatrixType::RealScalar
413 return m_cpqr.absDeterminant();
416template <
typename MatrixType>
417typename MatrixType::RealScalar
419 return m_cpqr.logAbsDeterminant();
429template <
typename MatrixType>
432 check_template_parameters();
437 const Index rank = m_cpqr.rank();
438 const Index cols = m_cpqr.cols();
439 const Index rows = m_cpqr.rows();
440 m_zCoeffs.resize((
std::min)(rows, cols));
455 for (
Index k = rank - 1; k >= 0; --k) {
460 m_cpqr.m_qr.col(k).head(k + 1).swap(
461 m_cpqr.m_qr.col(rank - 1).head(k + 1));
468 .tail(cols - rank + 1)
469 .makeHouseholderInPlace(m_zCoeffs(k),
beta);
470 m_cpqr.m_qr(k, rank - 1) =
beta;
473 m_cpqr.m_qr.topRightCorner(k, cols - rank + 1)
474 .applyHouseholderOnTheRight(
475 m_cpqr.m_qr.row(k).tail(cols - rank).adjoint(), m_zCoeffs(k),
480 m_cpqr.m_qr.col(k).head(k + 1).swap(
481 m_cpqr.m_qr.col(rank - 1).head(k + 1));
487template <
typename MatrixType>
488template <
bool Conjugate,
typename Rhs>
491 const Index cols = this->cols();
492 const Index nrhs = rhs.cols();
493 const Index rank = this->rank();
495 for (
Index k = rank-1; k >= 0; --k) {
497 rhs.row(k).swap(rhs.row(rank - 1));
499 rhs.middleRows(rank - 1, cols - rank + 1)
500 .applyHouseholderOnTheLeft(
501 matrixQTZ().
row(k).
tail(cols - rank).transpose().
template conjugateIf<!Conjugate>(), zCoeffs().
template conjugateIf<Conjugate>()(k),
504 rhs.row(k).swap(rhs.row(rank - 1));
509template <
typename MatrixType>
510template <
typename Rhs>
513 const Index cols = this->cols();
514 const Index nrhs = rhs.cols();
515 const Index rank = this->rank();
517 for (
Index k = 0; k < rank; ++k) {
519 rhs.row(k).swap(rhs.row(rank - 1));
521 rhs.middleRows(rank - 1, cols - rank + 1)
522 .applyHouseholderOnTheLeft(
523 matrixQTZ().
row(k).
tail(cols - rank).adjoint(), zCoeffs()(k),
526 rhs.row(k).swap(rhs.row(rank - 1));
531#ifndef EIGEN_PARSED_BY_DOXYGEN
532template <
typename _MatrixType>
533template <
typename RhsType,
typename DstType>
535 const RhsType& rhs, DstType& dst)
const {
536 const Index rank = this->rank();
543 typename RhsType::PlainObject
c(rhs);
544 c.applyOnTheLeft(matrixQ().setLength(rank).adjoint());
547 dst.topRows(rank) = matrixT()
548 .topLeftCorner(rank, rank)
549 .template triangularView<Upper>()
550 .solve(
c.topRows(rank));
552 const Index cols = this->cols();
556 dst.bottomRows(cols - rank).setZero();
557 applyZAdjointOnTheLeftInPlace(dst);
561 dst = colsPermutation() * dst;
564template<
typename _MatrixType>
565template<
bool Conjugate,
typename RhsType,
typename DstType>
568 const Index rank = this->rank();
575 typename RhsType::PlainObject
c(colsPermutation().transpose()*rhs);
578 applyZOnTheLeftInPlace<!Conjugate>(
c);
581 matrixT().topLeftCorner(rank, rank)
582 .template triangularView<Upper>()
583 .transpose().template conjugateIf<Conjugate>()
584 .solveInPlace(
c.topRows(rank));
586 dst.topRows(rank) =
c.topRows(rank);
587 dst.bottomRows(rows()-rank).setZero();
589 dst.applyOnTheLeft(householderQ().setLength(rank).
template conjugateIf<!Conjugate>() );
595template<
typename MatrixType>
597 :
traits<typename Transpose<typename MatrixType::PlainObject>::PlainObject>
602template<
typename DstXprType,
typename MatrixType>
617template <
typename MatrixType>
620 return m_cpqr.householderQ();
627template <
typename Derived>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE FixedSegmentReturnType< internal::get_fixed_value< NType >::value >::Type tail(NType n)
Definition: BlockMethods.h:1257
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE RowXpr row(Index i)
This is the const version of row(). */.
Definition: BlockMethods.h:1118
internal::conditional< NumTraits< Scalar >::IsComplex, constCwiseUnaryOp< internal::scalar_conjugate_op< Scalar >, constDerived >, constDerived & >::type ConjugateReturnType
Definition: CommonCwiseUnaryOps.h:19
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
Just a side note.
Definition: Macros.h:1274
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
Definition: Macros.h:1059
#define eigen_assert(x)
Definition: Macros.h:1047
#define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE)
Definition: StaticAssert.h:187
constexpr common_return_t< T1, T2 > beta(const T1 a, const T2 b) noexcept
Compile-time beta function.
Definition: beta.hpp:36
bool isInjective() const
Definition: ColPivHouseholderQR.h:285
const HCoeffsType & hCoeffs() const
Definition: ColPivHouseholderQR.h:334
HouseholderSequenceType householderQ() const
Definition: ColPivHouseholderQR.h:655
Index rank() const
Definition: ColPivHouseholderQR.h:255
bool m_isInitialized
Definition: ColPivHouseholderQR.h:443
Index cols() const
Definition: ColPivHouseholderQR.h:328
RealScalar threshold() const
Returns the threshold that will be used by certain methods such as rank().
Definition: ColPivHouseholderQR.h:378
Index nonzeroPivots() const
Definition: ColPivHouseholderQR.h:394
Index rows() const
Definition: ColPivHouseholderQR.h:327
const PermutationType & colsPermutation() const
Definition: ColPivHouseholderQR.h:214
Index dimensionOfKernel() const
Definition: ColPivHouseholderQR.h:272
bool isSurjective() const
Definition: ColPivHouseholderQR.h:298
bool isInvertible() const
Definition: ColPivHouseholderQR.h:310
RealScalar maxPivot() const
Definition: ColPivHouseholderQR.h:403
ColPivHouseholderQR & setThreshold(const RealScalar &threshold)
Allows to prescribe a threshold to be used by certain methods, such as rank(), who need to determine ...
Definition: ColPivHouseholderQR.h:353
const MatrixType & matrixQR() const
Definition: ColPivHouseholderQR.h:189
ColPivHouseholderQR & compute(const EigenBase< InputType > &matrix)
Complete orthogonal decomposition (COD) of a matrix.
Definition: CompleteOrthogonalDecomposition.h:52
CompleteOrthogonalDecomposition(EigenBase< InputType > &matrix)
Constructs a complete orthogonal decomposition from a given matrix.
Definition: CompleteOrthogonalDecomposition.h:133
void applyZAdjointOnTheLeftInPlace(Rhs &rhs) const
Overwrites rhs with .
Definition: CompleteOrthogonalDecomposition.h:511
const Inverse< CompleteOrthogonalDecomposition > pseudoInverse() const
Definition: CompleteOrthogonalDecomposition.h:278
const HCoeffsType & zCoeffs() const
Definition: CompleteOrthogonalDecomposition.h:299
HouseholderSequenceType matrixQ(void) const
Definition: CompleteOrthogonalDecomposition.h:157
ComputationInfo info() const
Reports whether the complete orthogonal decomposition was successful.
Definition: CompleteOrthogonalDecomposition.h:366
bool isInjective() const
Definition: CompleteOrthogonalDecomposition.h:253
CompleteOrthogonalDecomposition & compute(const EigenBase< InputType > &matrix)
Definition: CompleteOrthogonalDecomposition.h:186
RealScalar threshold() const
Returns the threshold that will be used by certain methods such as rank().
Definition: CompleteOrthogonalDecomposition.h:342
CompleteOrthogonalDecomposition & setThreshold(Default_t)
Allows to come back to the default behavior, letting Eigen use its default formula for determining th...
Definition: CompleteOrthogonalDecomposition.h:333
Index cols() const
Definition: CompleteOrthogonalDecomposition.h:285
MatrixType matrixZ() const
Definition: CompleteOrthogonalDecomposition.h:161
MatrixType::PlainObject PlainObject
Definition: CompleteOrthogonalDecomposition.h:77
bool isSurjective() const
Definition: CompleteOrthogonalDecomposition.h:262
RealScalar maxPivot() const
Definition: CompleteOrthogonalDecomposition.h:356
static void check_template_parameters()
Definition: CompleteOrthogonalDecomposition.h:380
@ MaxRowsAtCompileTime
Definition: CompleteOrthogonalDecomposition.h:62
@ MaxColsAtCompileTime
Definition: CompleteOrthogonalDecomposition.h:63
void _solve_impl(const RhsType &rhs, DstType &dst) const
Definition: CompleteOrthogonalDecomposition.h:534
internal::plain_row_type< MatrixType >::type RowVectorType
Definition: CompleteOrthogonalDecomposition.h:70
CompleteOrthogonalDecomposition()
Default Constructor.
Definition: CompleteOrthogonalDecomposition.h:90
bool isInvertible() const
Definition: CompleteOrthogonalDecomposition.h:271
ColPivHouseholderQR< MatrixType > m_cpqr
Definition: CompleteOrthogonalDecomposition.h:405
internal::plain_row_type< MatrixType, Index >::type IntRowVectorType
Definition: CompleteOrthogonalDecomposition.h:69
HCoeffsType m_zCoeffs
Definition: CompleteOrthogonalDecomposition.h:406
SolverBase< CompleteOrthogonalDecomposition > Base
Definition: CompleteOrthogonalDecomposition.h:55
_MatrixType MatrixType
Definition: CompleteOrthogonalDecomposition.h:54
const MatrixType & matrixQTZ() const
Definition: CompleteOrthogonalDecomposition.h:170
RowVectorType m_temp
Definition: CompleteOrthogonalDecomposition.h:407
HouseholderSequence< MatrixType, typename internal::remove_all< typename HCoeffsType::ConjugateReturnType >::type > HouseholderSequenceType
Definition: CompleteOrthogonalDecomposition.h:76
void _solve_impl_transposed(const RhsType &rhs, DstType &dst) const
Definition: CompleteOrthogonalDecomposition.h:566
internal::plain_row_type< MatrixType, RealScalar >::type RealRowVectorType
Definition: CompleteOrthogonalDecomposition.h:72
CompleteOrthogonalDecomposition(Index rows, Index cols)
Default Constructor with memory preallocation.
Definition: CompleteOrthogonalDecomposition.h:98
const PermutationType & colsPermutation() const
Definition: CompleteOrthogonalDecomposition.h:194
const MatrixType & matrixT() const
Definition: CompleteOrthogonalDecomposition.h:183
MatrixType::RealScalar absDeterminant() const
Definition: CompleteOrthogonalDecomposition.h:412
const HCoeffsType & hCoeffs() const
Definition: CompleteOrthogonalDecomposition.h:292
HouseholderSequenceType householderQ(void) const
Definition: CompleteOrthogonalDecomposition.h:619
Index dimensionOfKernel() const
Definition: CompleteOrthogonalDecomposition.h:244
internal::plain_diag_type< MatrixType >::type HCoeffsType
Definition: CompleteOrthogonalDecomposition.h:65
MatrixType::RealScalar logAbsDeterminant() const
Definition: CompleteOrthogonalDecomposition.h:418
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:320
void computeInPlace()
Performs the complete orthogonal decomposition of the given matrix matrix.
Definition: CompleteOrthogonalDecomposition.h:430
Index rows() const
Definition: CompleteOrthogonalDecomposition.h:284
PermutationMatrix< ColsAtCompileTime, MaxColsAtCompileTime > PermutationType
Definition: CompleteOrthogonalDecomposition.h:67
void _check_solve_assertion(const Rhs &b) const
Definition: CompleteOrthogonalDecomposition.h:385
Index rank() const
Definition: CompleteOrthogonalDecomposition.h:235
Index nonzeroPivots() const
Definition: CompleteOrthogonalDecomposition.h:351
CompleteOrthogonalDecomposition(const EigenBase< InputType > &matrix)
Constructs a complete orthogonal decomposition from a given matrix.
Definition: CompleteOrthogonalDecomposition.h:118
void applyZOnTheLeftInPlace(Rhs &rhs) const
Overwrites rhs with or if Conjugate is set to true.
Definition: CompleteOrthogonalDecomposition.h:489
\householder_module
Definition: HouseholderSequence.h:121
Expression of the inverse of another expression.
Definition: Inverse.h:44
EIGEN_DEVICE_FUNC const XprTypeNestedCleaned & nestedExpression() const
Definition: Inverse.h:60
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: Inverse.h:58
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:50
const CompleteOrthogonalDecomposition< PlainObject > completeOrthogonalDecomposition() const
Definition: CompleteOrthogonalDecomposition.h:629
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:180
Pseudo expression representing a solving operation.
Definition: Solve.h:63
A base class for matrix decomposition and solvers.
Definition: SolverBase.h:69
internal::traits< CompleteOrthogonalDecomposition< _MatrixType > >::Scalar Scalar
Definition: SolverBase.h:73
const Solve< CompleteOrthogonalDecomposition< _MatrixType >, Rhs > solve(const MatrixBase< Rhs > &b) const
Definition: SolverBase.h:106
EIGEN_DEVICE_FUNC CompleteOrthogonalDecomposition< _MatrixType > & derived()
Definition: EigenBase.h:46
type
Definition: core.h:575
ComputationInfo
Enum for reporting the status of a computation.
Definition: Constants.h:440
@ Success
Computation was successful.
Definition: Constants.h:442
constexpr common_t< T1, T2 > max(const T1 x, const T2 y) noexcept
Compile-time pairwise maximum function.
Definition: max.hpp:35
constexpr common_t< T1, T2 > min(const T1 x, const T2 y) noexcept
Compile-time pairwise minimum function.
Definition: min.hpp:35
Namespace containing all symbols from the Eigen library.
Definition: Core:141
Default_t
Definition: Constants.h:362
@ Default
Definition: Constants.h:362
Definition: Eigen_Colamd.h:50
Definition: BFloat16.h:88
static constexpr const velocity::meters_per_second_t c(299792458.0)
Speed of light in vacuum.
Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor Matrix...
Definition: EigenBase.h:30
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:39
EIGEN_DEVICE_FUNC Derived & derived()
Definition: EigenBase.h:46
The type used to identify a matrix expression.
Definition: Constants.h:522
Holds information about the various numeric (i.e.
Definition: NumTraits.h:233
The type used to identify a general solver (factored) storage.
Definition: Constants.h:513
Inverse< CodType > SrcXprType
Definition: CompleteOrthogonalDecomposition.h:606
CompleteOrthogonalDecomposition< MatrixType > CodType
Definition: CompleteOrthogonalDecomposition.h:605
static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op< typename DstXprType::Scalar, typename CodType::Scalar > &)
Definition: CompleteOrthogonalDecomposition.h:607
Definition: AssignEvaluator.h:824
Definition: AssignEvaluator.h:814
Definition: AssignmentFunctors.h:21
Definition: SolverBase.h:18
SolverStorage StorageKind
Definition: CompleteOrthogonalDecomposition.h:20
int StorageIndex
Definition: CompleteOrthogonalDecomposition.h:21
MatrixXpr XprKind
Definition: CompleteOrthogonalDecomposition.h:19
Definition: ForwardDeclarations.h:17