10#ifndef EIGEN_CONDITIONESTIMATOR_H
11#define EIGEN_CONDITIONESTIMATOR_H
17template <
typename Vector,
typename RealVector,
bool IsComplex>
19 static inline Vector run(
const Vector& v) {
22 .
select(Vector::Ones(v.size()), v.cwiseQuotient(
v_abs));
27template <
typename Vector>
29 static inline Vector run(
const Vector& v) {
30 return (v.array() <
static_cast<typename Vector::RealScalar
>(0))
31 .select(-Vector::Ones(v.size()), Vector::Ones(v.size()));
55template <
typename Decomposition>
56typename Decomposition::RealScalar rcond_invmatrix_L1_norm_estimate(
const Decomposition& dec)
58 typedef typename Decomposition::MatrixType MatrixType;
59 typedef typename Decomposition::Scalar Scalar;
60 typedef typename Decomposition::RealScalar RealScalar;
65 eigen_assert(dec.rows() == dec.cols());
66 const Index n = dec.rows();
71#ifdef __INTEL_COMPILER
73 #pragma warning ( disable : 2259 )
75 Vector v = dec.solve(Vector::Ones(n) / Scalar(n));
76#ifdef __INTEL_COMPILER
84 RealScalar lower_bound = v.template
lpNorm<1>();
96 for (
int k = 0; k < 4; ++k)
111 v = dec.solve(Vector::Unit(n, v_max_abs_index));
112 lower_bound = v.template lpNorm<1>();
113 if (lower_bound <= old_lower_bound) {
118 old_sign_vector = sign_vector;
120 old_v_max_abs_index = v_max_abs_index;
121 old_lower_bound = lower_bound;
133 Scalar alternating_sign(RealScalar(1));
134 for (
Index i = 0; i < n; ++i) {
136 v[i] = alternating_sign *
static_cast<RealScalar
>(RealScalar(1) + (RealScalar(i) / (RealScalar(n - 1))));
137 alternating_sign = -alternating_sign;
140 const RealScalar alternate_lower_bound = (2 * v.template lpNorm<1>()) / (3 * RealScalar(n));
141 return numext::maxi(lower_bound, alternate_lower_bound);
157template <
typename Decomposition>
158typename Decomposition::RealScalar
159rcond_estimate_helper(
typename Decomposition::RealScalar matrix_norm,
const Decomposition& dec)
161 typedef typename Decomposition::RealScalar RealScalar;
162 eigen_assert(dec.rows() == dec.cols());
163 if (dec.rows() == 0)
return NumTraits<RealScalar>::infinity();
164 if (matrix_norm == RealScalar(0))
return RealScalar(0);
165 if (dec.rows() == 1)
return RealScalar(1);
166 const RealScalar inverse_matrix_norm = rcond_invmatrix_L1_norm_estimate(dec);
167 return (inverse_matrix_norm == RealScalar(0) ? RealScalar(0)
168 : (RealScalar(1) / inverse_matrix_norm) / matrix_norm);
EIGEN_DEVICE_FUNC const Select< Derived, ThenDerived, ElseDerived > select(const DenseBase< ThenDerived > &thenMatrix, const DenseBase< ElseDerived > &elseMatrix) const
Definition Select.h:126
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ArrayWrapper< Derived > array()
Definition MatrixBase.h:313
EIGEN_DEVICE_FUNC const AdjointReturnType adjoint() const
Definition Transpose.h:221
Namespace containing all symbols from the Eigen library.
Definition LDLT.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
Holds information about the various numeric (i.e.
Definition NumTraits.h:236
Definition ConditionEstimator.h:18