16#ifndef EIGEN_SVDBASE_H
17#define EIGEN_SVDBASE_H
67 template<
typename Derived_>
71 typedef typename MatrixType::Scalar
Scalar;
89 Derived&
derived() {
return *
static_cast<Derived*
>(
this); }
90 const Derived&
derived()
const {
return *
static_cast<const Derived*
>(
this); }
215 #ifdef EIGEN_PARSED_BY_DOXYGEN
225 template<
typename Rhs>
242 #ifndef EIGEN_PARSED_BY_DOXYGEN
243 template<
typename RhsType,
typename DstType>
246 template<
bool Conjugate,
typename RhsType,
typename DstType>
261 template<
bool Transpose_,
typename Rhs>
265 eigen_assert(
computeU() &&
computeV() &&
"SVDBase::solve(): Both unitaries U and V are required to be computed (thin unitaries suffice).");
266 eigen_assert((Transpose_?
cols():
rows())==
b.rows() &&
"SVDBase::solve(): invalid number of rows of the right hand side matrix b");
305#ifndef EIGEN_PARSED_BY_DOXYGEN
306template<
typename Derived>
307template<
typename RhsType,
typename DstType>
314 Index l_rank = rank();
315 tmp.noalias() = m_matrixU.leftCols(l_rank).adjoint() * rhs;
316 tmp = m_singularValues.head(l_rank).asDiagonal().inverse() * tmp;
317 dst = m_matrixV.leftCols(l_rank) * tmp;
320template<
typename Derived>
321template<
bool Conjugate,
typename RhsType,
typename DstType>
328 Index l_rank = rank();
330 tmp.noalias() = m_matrixV.leftCols(l_rank).transpose().template conjugateIf<Conjugate>() * rhs;
331 tmp = m_singularValues.head(l_rank).asDiagonal().inverse() * tmp;
332 dst = m_matrixU.template conjugateIf<!Conjugate>().leftCols(l_rank) * tmp;
336template<
typename MatrixType>
344 computationOptions == m_computationOptions)
352 m_isInitialized =
false;
353 m_isAllocated =
true;
354 m_computationOptions = computationOptions;
355 m_computeFullU = (computationOptions &
ComputeFullU) != 0;
356 m_computeThinU = (computationOptions &
ComputeThinU) != 0;
357 m_computeFullV = (computationOptions &
ComputeFullV) != 0;
358 m_computeThinV = (computationOptions &
ComputeThinV) != 0;
359 eigen_assert(!(m_computeFullU && m_computeThinU) &&
"SVDBase: you can't ask for both full and thin U");
360 eigen_assert(!(m_computeFullV && m_computeThinV) &&
"SVDBase: you can't ask for both full and thin V");
362 "SVDBase: thin U and V are only available when your matrix has a dynamic number of columns.");
364 m_diagSize = (
std::min)(m_rows, m_cols);
365 m_singularValues.resize(m_diagSize);
367 m_matrixU.resize(m_rows, m_computeFullU ? m_rows : m_computeThinU ? m_diagSize : 0);
369 m_matrixV.resize(m_cols, m_computeFullV ? m_cols : m_computeThinV ? m_diagSize : 0);
#define EIGEN_SIZE_MIN_PREFER_DYNAMIC(a, b)
Definition: Macros.h:1304
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:986
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
Definition: Macros.h:1059
#define eigen_assert(x)
Definition: Macros.h:1047
#define EIGEN_IMPLIES(a, b)
Definition: Macros.h:1325
#define EIGEN_SIZE_MIN_PREFER_FIXED(a, b)
Definition: Macros.h:1312
#define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE)
Definition: StaticAssert.h:187
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:50
Base class of SVD algorithms.
Definition: SVDBase.h:64
void _solve_impl_transposed(const RhsType &rhs, DstType &dst) const
Definition: SVDBase.h:322
void _check_solve_assertion(const Rhs &b) const
Definition: SVDBase.h:262
Index cols() const
Definition: SVDBase.h:213
Derived & setThreshold(const RealScalar &threshold)
Allows to prescribe a threshold to be used by certain methods, such as rank() and solve(),...
Definition: SVDBase.h:173
internal::plain_diag_type< MatrixType, RealScalar >::type SingularValuesType
Definition: SVDBase.h:87
bool m_usePrescribedThreshold
Definition: SVDBase.h:276
bool m_computeFullV
Definition: SVDBase.h:278
Index rank() const
Definition: SVDBase.h:148
NumTraits< typenameMatrixType::Scalar >::Real RealScalar
Definition: SVDBase.h:72
ComputationInfo m_info
Definition: SVDBase.h:275
bool m_computeThinU
Definition: SVDBase.h:277
Derived & derived()
Definition: SVDBase.h:89
EIGEN_DEVICE_FUNC ComputationInfo info() const
Reports whether previous computation was successful.
Definition: SVDBase.h:236
bool computeV() const
Definition: SVDBase.h:210
Eigen::Index Index
Definition: SVDBase.h:74
bool m_isInitialized
Definition: SVDBase.h:276
Index m_cols
Definition: SVDBase.h:280
unsigned int m_computationOptions
Definition: SVDBase.h:279
MatrixVType m_matrixV
Definition: SVDBase.h:273
Index m_diagSize
Definition: SVDBase.h:280
bool computeU() const
Definition: SVDBase.h:208
bool allocate(Index rows, Index cols, unsigned int computationOptions)
Definition: SVDBase.h:337
Derived & setThreshold(Default_t)
Allows to come back to the default behavior, letting Eigen use its default formula for determining th...
Definition: SVDBase.h:188
RealScalar threshold() const
Returns the threshold that will be used by certain methods such as rank().
Definition: SVDBase.h:198
MatrixType::Scalar Scalar
Definition: SVDBase.h:71
Index m_rows
Definition: SVDBase.h:280
@ MatrixOptions
Definition: SVDBase.h:82
@ ColsAtCompileTime
Definition: SVDBase.h:77
@ DiagSizeAtCompileTime
Definition: SVDBase.h:78
@ MaxRowsAtCompileTime
Definition: SVDBase.h:79
@ MaxDiagSizeAtCompileTime
Definition: SVDBase.h:81
@ MaxColsAtCompileTime
Definition: SVDBase.h:80
@ RowsAtCompileTime
Definition: SVDBase.h:76
Index m_nonzeroSingularValues
Definition: SVDBase.h:280
Index rows() const
Definition: SVDBase.h:212
Matrix< Scalar, RowsAtCompileTime, RowsAtCompileTime, MatrixOptions, MaxRowsAtCompileTime, MaxRowsAtCompileTime > MatrixUType
Definition: SVDBase.h:85
SingularValuesType m_singularValues
Definition: SVDBase.h:274
const Derived & derived() const
Definition: SVDBase.h:90
RealScalar m_prescribedThreshold
Definition: SVDBase.h:281
SVDBase()
Default Constructor.
Definition: SVDBase.h:287
void _solve_impl(const RhsType &rhs, DstType &dst) const
Definition: SVDBase.h:308
const SingularValuesType & singularValues() const
Definition: SVDBase.h:129
bool m_computeThinV
Definition: SVDBase.h:278
const MatrixUType & matrixU() const
Definition: SVDBase.h:101
bool m_computeFullU
Definition: SVDBase.h:277
Eigen::internal::traits< SVDBase >::StorageIndex StorageIndex
Definition: SVDBase.h:73
static void check_template_parameters()
Definition: SVDBase.h:252
internal::traits< Derived >::MatrixType MatrixType
Definition: SVDBase.h:70
const MatrixVType & matrixV() const
Definition: SVDBase.h:117
MatrixUType m_matrixU
Definition: SVDBase.h:272
Matrix< Scalar, ColsAtCompileTime, ColsAtCompileTime, MatrixOptions, MaxColsAtCompileTime, MaxColsAtCompileTime > MatrixVType
Definition: SVDBase.h:86
void _check_compute_assertions() const
Definition: SVDBase.h:257
bool m_isAllocated
Definition: SVDBase.h:276
Index nonzeroSingularValues() const
Definition: SVDBase.h:136
Pseudo expression representing a solving operation.
Definition: Solve.h:63
A base class for matrix decomposition and solvers.
Definition: SolverBase.h:69
const Solve< SVDBase< Derived >, Rhs > solve(const MatrixBase< Rhs > &b) const
Definition: SolverBase.h:106
UnitType abs(const UnitType x) noexcept
Compute absolute value.
Definition: math.h:721
ComputationInfo
Enum for reporting the status of a computation.
Definition: Constants.h:440
@ Success
Computation was successful.
Definition: Constants.h:442
@ ComputeFullV
Used in JacobiSVD to indicate that the square matrix V is to be computed.
Definition: Constants.h:397
@ ComputeThinV
Used in JacobiSVD to indicate that the thin matrix V is to be computed.
Definition: Constants.h:399
@ ComputeFullU
Used in JacobiSVD to indicate that the square matrix U is to be computed.
Definition: Constants.h:393
@ ComputeThinU
Used in JacobiSVD to indicate that the thin matrix U is to be computed.
Definition: Constants.h:395
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: MatrixExponential.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Default_t
Definition: Constants.h:362
const int Dynamic
This value means that a positive quantity (e.g., a size) is not known at compile-time,...
Definition: Constants.h:22
Definition: Eigen_Colamd.h:50
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:39
T Real
Definition: NumTraits.h:164
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
Definition: SolverBase.h:18
SolverStorage StorageKind
Definition: SVDBase.h:26
MatrixXpr XprKind
Definition: SVDBase.h:25
int StorageIndex
Definition: SVDBase.h:27
Definition: ForwardDeclarations.h:17