10 #ifndef EIGEN_COMPLETEORTHOGONALDECOMPOSITION_H
11 #define EIGEN_COMPLETEORTHOGONALDECOMPOSITION_H
19 template <
typename MatrixType_,
typename PermutationIndex_>
52 template <
typename MatrixType_,
typename PermutationIndex_>
54 :
public SolverBase<CompleteOrthogonalDecomposition<MatrixType_, PermutationIndex_>> {
59 template <
typename Derived>
111 template <
typename InputType>
126 template <
typename InputType>
132 #ifdef EIGEN_PARSED_BY_DOXYGEN
142 template <
typename Rhs>
153 applyZOnTheLeftInPlace<false>(
Z);
175 template <
typename InputType>
388 #ifndef EIGEN_PARSED_BY_DOXYGEN
389 template <
typename RhsType,
typename DstType>
390 void _solve_impl(
const RhsType& rhs, DstType& dst)
const;
392 template <
bool Conjugate,
typename RhsType,
typename DstType>
399 template <
bool Transpose_,
typename Rhs>
404 "CompleteOrthogonalDecomposition::solve(): invalid number of rows of the right hand side matrix b");
413 template <
bool Conjugate,
typename Rhs>
418 template <
typename Rhs>
426 template <
typename MatrixType,
typename PermutationIndex>
428 return m_cpqr.determinant();
431 template <
typename MatrixType,
typename PermutationIndex>
433 return m_cpqr.absDeterminant();
436 template <
typename MatrixType,
typename PermutationIndex>
439 return m_cpqr.logAbsDeterminant();
442 template <
typename MatrixType,
typename PermutationIndex>
444 return m_cpqr.signDeterminant();
454 template <
typename MatrixType,
typename PermutationIndex>
458 const Index rank = m_cpqr.rank();
476 for (
Index k = rank - 1;
k >= 0; --
k) {
481 m_cpqr.m_qr.col(
k).head(
k + 1).swap(m_cpqr.m_qr.col(rank - 1).head(
k + 1));
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;
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));
496 m_cpqr.m_qr.col(
k).head(
k + 1).swap(m_cpqr.m_qr.col(rank - 1).head(
k + 1));
502 template <
typename MatrixType,
typename PermutationIndex>
503 template <
bool Conjugate,
typename Rhs>
506 const Index nrhs = rhs.cols();
507 const Index rank = this->rank();
509 for (
Index k = rank - 1;
k >= 0; --
k) {
511 rhs.row(
k).swap(rhs.row(rank - 1));
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));
517 rhs.row(
k).swap(rhs.row(rank - 1));
522 template <
typename MatrixType,
typename PermutationIndex>
523 template <
typename Rhs>
526 const Index nrhs = rhs.cols();
527 const Index rank = this->rank();
531 rhs.row(
k).swap(rhs.row(rank - 1));
533 rhs.middleRows(rank - 1,
cols - rank + 1)
534 .applyHouseholderOnTheLeft(matrixQTZ().
row(
k).tail(
cols - rank).
adjoint(), zCoeffs()(
k), &temp(0));
536 rhs.row(
k).swap(rhs.row(rank - 1));
541 #ifndef EIGEN_PARSED_BY_DOXYGEN
542 template <
typename MatrixType_,
typename PermutationIndex_>
543 template <
typename RhsType,
typename DstType>
545 DstType& dst)
const {
546 const Index rank = this->rank();
553 typename RhsType::PlainObject
c(rhs);
554 c.applyOnTheLeft(matrixQ().setLength(rank).
adjoint());
557 dst.topRows(rank) = matrixT().topLeftCorner(rank, rank).template triangularView<Upper>().solve(
c.topRows(rank));
563 dst.bottomRows(
cols - rank).setZero();
564 applyZAdjointOnTheLeftInPlace(dst);
568 dst = colsPermutation() * dst;
571 template <
typename MatrixType_,
typename PermutationIndex_>
572 template <
bool Conjugate,
typename RhsType,
typename DstType>
574 DstType& dst)
const {
575 const Index rank = this->rank();
582 typename RhsType::PlainObject
c(colsPermutation().
transpose() * rhs);
585 applyZOnTheLeftInPlace<!Conjugate>(
c);
589 .topLeftCorner(rank, rank)
590 .template triangularView<Upper>()
592 .template conjugateIf<Conjugate>()
593 .solveInPlace(
c.topRows(rank));
595 dst.topRows(rank) =
c.topRows(rank);
596 dst.bottomRows(
rows() - rank).setZero();
598 dst.applyOnTheLeft(householderQ().setLength(rank).
template conjugateIf<!Conjugate>());
604 template <
typename MatrixType,
typename PermutationIndex>
606 :
traits<typename Transpose<typename MatrixType::PlainObject>::PlainObject> {
610 template <
typename DstXprType,
typename MatrixType,
typename PermutationIndex>
613 typename CompleteOrthogonalDecomposition<MatrixType, PermutationIndex>::Scalar>,
620 CodType::MaxRowsAtCompileTime, CodType::MaxRowsAtCompileTime>
629 template <
typename MatrixType,
typename PermutationIndex>
632 return m_cpqr.householderQ();
639 template <
typename Derived>
640 template <
typename PermutationIndex>
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
Definition: Macros.h:1149
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
Definition: Macros.h:922
#define eigen_assert(x)
Definition: Macros.h:910
#define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE)
Definition: StaticAssert.h:74
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
void adjoint(const MatrixType &m)
Definition: adjoint.cpp:85
Scalar * b
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
NumTraits< Scalar >::Real RealScalar
Definition: bench_gemm.cpp:46
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
RealScalar maxPivot() const
Definition: ColPivHouseholderQR.h:398
Index rows() const
Definition: ColPivHouseholderQR.h:326
Index rank() const
Definition: ColPivHouseholderQR.h:261
bool isSurjective() const
Definition: ColPivHouseholderQR.h:300
Index nonzeroPivots() const
Definition: ColPivHouseholderQR.h:390
bool isInjective() const
Definition: ColPivHouseholderQR.h:288
ColPivHouseholderQR & setThreshold(const RealScalar &threshold)
Definition: ColPivHouseholderQR.h:352
Index cols() const
Definition: ColPivHouseholderQR.h:327
const HCoeffsType & hCoeffs() const
Definition: ColPivHouseholderQR.h:333
bool isInvertible() const
Definition: ColPivHouseholderQR.h:311
Index dimensionOfKernel() const
Definition: ColPivHouseholderQR.h:276
bool m_isInitialized
Definition: ColPivHouseholderQR.h:433
const PermutationType & colsPermutation() const
Definition: ColPivHouseholderQR.h:192
HouseholderSequenceType householderQ() const
Definition: ColPivHouseholderQR.h:656
ColPivHouseholderQR & compute(const EigenBase< InputType > &matrix)
RealScalar threshold() const
Definition: ColPivHouseholderQR.h:375
const MatrixType & matrixQR() const
Definition: ColPivHouseholderQR.h:169
Complete orthogonal decomposition (COD) of a matrix.
Definition: CompleteOrthogonalDecomposition.h:54
internal::plain_diag_type< MatrixType >::type HCoeffsType
Definition: CompleteOrthogonalDecomposition.h:67
MatrixType matrixZ() const
Definition: CompleteOrthogonalDecomposition.h:151
MatrixType_ MatrixType
Definition: CompleteOrthogonalDecomposition.h:56
void applyZAdjointOnTheLeftInPlace(Rhs &rhs) const
Definition: CompleteOrthogonalDecomposition.h:524
CompleteOrthogonalDecomposition()
Default Constructor.
Definition: CompleteOrthogonalDecomposition.h:84
bool isSurjective() const
Definition: CompleteOrthogonalDecomposition.h:280
MatrixType::Scalar signDeterminant() const
Definition: CompleteOrthogonalDecomposition.h:443
Index dimensionOfKernel() const
Definition: CompleteOrthogonalDecomposition.h:262
HouseholderSequenceType matrixQ(void) const
Definition: CompleteOrthogonalDecomposition.h:147
CompleteOrthogonalDecomposition & compute(const EigenBase< InputType > &matrix)
Definition: CompleteOrthogonalDecomposition.h:176
PermutationMatrix< ColsAtCompileTime, MaxColsAtCompileTime, PermutationIndex > PermutationType
Definition: CompleteOrthogonalDecomposition.h:68
CompleteOrthogonalDecomposition(const EigenBase< InputType > &matrix)
Constructs a complete orthogonal decomposition from a given matrix.
Definition: CompleteOrthogonalDecomposition.h:112
CompleteOrthogonalDecomposition(Index rows, Index cols)
Default Constructor with memory preallocation.
Definition: CompleteOrthogonalDecomposition.h:92
CompleteOrthogonalDecomposition & setThreshold(const RealScalar &threshold)
Definition: CompleteOrthogonalDecomposition.h:337
MatrixType::RealScalar absDeterminant() const
Definition: CompleteOrthogonalDecomposition.h:432
const HCoeffsType & zCoeffs() const
Definition: CompleteOrthogonalDecomposition.h:316
void _solve_impl(const RhsType &rhs, DstType &dst) const
Definition: CompleteOrthogonalDecomposition.h:544
Index cols() const
Definition: CompleteOrthogonalDecomposition.h:302
HouseholderSequenceType householderQ(void) const
Definition: CompleteOrthogonalDecomposition.h:631
MatrixType::RealScalar logAbsDeterminant() const
Definition: CompleteOrthogonalDecomposition.h:437
RealScalar threshold() const
Definition: CompleteOrthogonalDecomposition.h:359
ColPivHouseholderQR< MatrixType, PermutationIndex > m_cpqr
Definition: CompleteOrthogonalDecomposition.h:421
RowVectorType m_temp
Definition: CompleteOrthogonalDecomposition.h:423
ComputationInfo info() const
Reports whether the complete orthogonal decomposition was successful.
Definition: CompleteOrthogonalDecomposition.h:383
void _solve_impl_transposed(const RhsType &rhs, DstType &dst) const
Definition: CompleteOrthogonalDecomposition.h:573
const PermutationType & colsPermutation() const
Definition: CompleteOrthogonalDecomposition.h:184
internal::plain_row_type< MatrixType >::type RowVectorType
Definition: CompleteOrthogonalDecomposition.h:70
SolverBase< CompleteOrthogonalDecomposition > Base
Definition: CompleteOrthogonalDecomposition.h:57
internal::plain_row_type< MatrixType, Index >::type IntRowVectorType
Definition: CompleteOrthogonalDecomposition.h:69
bool isInvertible() const
Definition: CompleteOrthogonalDecomposition.h:289
HouseholderSequence< MatrixType, internal::remove_all_t< typename HCoeffsType::ConjugateReturnType > > HouseholderSequenceType
Definition: CompleteOrthogonalDecomposition.h:73
const HCoeffsType & hCoeffs() const
Definition: CompleteOrthogonalDecomposition.h:309
void _check_solve_assertion(const Rhs &b) const
Definition: CompleteOrthogonalDecomposition.h:400
MatrixType::PlainObject PlainObject
Definition: CompleteOrthogonalDecomposition.h:74
internal::plain_row_type< MatrixType, RealScalar >::type RealRowVectorType
Definition: CompleteOrthogonalDecomposition.h:71
bool isInjective() const
Definition: CompleteOrthogonalDecomposition.h:271
Index rows() const
Definition: CompleteOrthogonalDecomposition.h:301
CompleteOrthogonalDecomposition & setThreshold(Default_t)
Definition: CompleteOrthogonalDecomposition.h:350
void applyZOnTheLeftInPlace(Rhs &rhs) const
Definition: CompleteOrthogonalDecomposition.h:504
void computeInPlace()
Definition: CompleteOrthogonalDecomposition.h:455
const MatrixType & matrixQTZ() const
Definition: CompleteOrthogonalDecomposition.h:160
Index nonzeroPivots() const
Definition: CompleteOrthogonalDecomposition.h:368
const Inverse< CompleteOrthogonalDecomposition > pseudoInverse() const
Definition: CompleteOrthogonalDecomposition.h:296
HCoeffsType m_zCoeffs
Definition: CompleteOrthogonalDecomposition.h:422
MatrixType::Scalar determinant() const
Definition: CompleteOrthogonalDecomposition.h:427
Index rank() const
Definition: CompleteOrthogonalDecomposition.h:253
RealScalar maxPivot() const
Definition: CompleteOrthogonalDecomposition.h:373
@ MaxColsAtCompileTime
Definition: CompleteOrthogonalDecomposition.h:65
@ MaxRowsAtCompileTime
Definition: CompleteOrthogonalDecomposition.h:64
const MatrixType & matrixT() const
Definition: CompleteOrthogonalDecomposition.h:173
CompleteOrthogonalDecomposition(EigenBase< InputType > &matrix)
Constructs a complete orthogonal decomposition from a given matrix.
Definition: CompleteOrthogonalDecomposition.h:127
PermutationIndex_ PermutationIndex
Definition: CompleteOrthogonalDecomposition.h:61
Sequence of Householder reflections acting on subspaces with decreasing size.
Definition: HouseholderSequence.h:117
Expression of the inverse of another expression.
Definition: Inverse.h:43
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: Inverse.h:55
EIGEN_DEVICE_FUNC const XprTypeNestedCleaned & nestedExpression() const
Definition: Inverse.h:57
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
const CompleteOrthogonalDecomposition< PlainObject, PermutationIndex > completeOrthogonalDecomposition() const
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
Pseudo expression representing a solving operation.
Definition: Solve.h:62
A base class for matrix decomposition and solvers.
Definition: SolverBase.h:72
constexpr EIGEN_DEVICE_FUNC CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ > & derived()
Definition: EigenBase.h:49
const Solve< CompleteOrthogonalDecomposition< MatrixType_, PermutationIndex_ >, Rhs > solve(const MatrixBase< Rhs > &b) const
Definition: SolverBase.h:106
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
#define min(a, b)
Definition: datatypes.h:22
#define max(a, b)
Definition: datatypes.h:23
ComputationInfo
Definition: Constants.h:438
@ Success
Definition: Constants.h:440
#define Z
Definition: icosphere.cpp:21
Scalar beta
Definition: level2_cplx_impl.h:36
char char char int int * k
Definition: level2_impl.h:374
@ Rhs
Definition: TensorContractionMapper.h:20
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
CleanedUpDerType< DerType >::type() min(const AutoDiffScalar< DerType > &x, const T &y)
Definition: AutoDiffScalar.h:494
Default_t
Definition: Constants.h:361
@ Default
Definition: Constants.h:361
Extend namespace for flags.
Definition: fsi_chan_precond_driver.cc:56
void transpose()
Definition: skew_symmetric_matrix3.cpp:135
int c
Definition: calibrate.py:100
Definition: Eigen_Colamd.h:49
internal::nested_eval< T, 1 >::type eval(const T &xpr)
Definition: sparse_permutations.cpp:47
Definition: EigenBase.h:33
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:43
Definition: Constants.h:534
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217
Definition: Constants.h:525
CompleteOrthogonalDecomposition< MatrixType, PermutationIndex > CodType
Definition: CompleteOrthogonalDecomposition.h:615
Inverse< CodType > SrcXprType
Definition: CompleteOrthogonalDecomposition.h:616
static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op< typename DstXprType::Scalar, typename CodType::Scalar > &)
Definition: CompleteOrthogonalDecomposition.h:617
Definition: AssignEvaluator.h:773
Definition: AssignEvaluator.h:756
Template functor for scalar/packet assignment.
Definition: AssignmentFunctors.h:25
std::conditional_t< is_same< typename traits< ExpressionType >::XprKind, MatrixXpr >::value, MatrixDiagType, ArrayDiagType > type
Definition: XprHelper.h:797
std::conditional_t< is_same< typename traits< ExpressionType >::XprKind, MatrixXpr >::value, MatrixRowType, ArrayRowType > type
Definition: XprHelper.h:768
Definition: SolverBase.h:21
PermutationIndex_ PermutationIndex
Definition: CompleteOrthogonalDecomposition.h:23
MatrixXpr XprKind
Definition: CompleteOrthogonalDecomposition.h:21
SolverStorage StorageKind
Definition: CompleteOrthogonalDecomposition.h:22
Definition: ForwardDeclarations.h:21