10 #ifndef EIGEN_CONDITIONESTIMATOR_H
11 #define EIGEN_CONDITIONESTIMATOR_H
19 template <
typename Vector,
typename RealVector,
bool IsComplex>
20 struct rcond_compute_sign {
22 const RealVector v_abs =
v.cwiseAbs();
29 template <
typename Vector>
57 template <
typename Decomposition>
61 typedef typename Decomposition::Scalar Scalar;
62 typedef typename Decomposition::RealScalar RealScalar;
63 typedef typename internal::plain_col_type<MatrixType>::type
Vector;
64 typedef typename internal::plain_col_type<MatrixType, RealScalar>::type RealVector;
68 const Index n = dec.rows();
73 #ifdef __INTEL_COMPILER
75 #pragma warning ( disable : 2259 )
78 #ifdef __INTEL_COMPILER
86 RealScalar lower_bound =
v.template lpNorm<1>();
93 RealScalar old_lower_bound = lower_bound;
96 Index v_max_abs_index = -1;
97 Index old_v_max_abs_index = v_max_abs_index;
98 for (
int k = 0; k < 4; ++k)
100 sign_vector = internal::rcond_compute_sign<Vector, RealVector, is_complex>::run(
v);
101 if (k > 0 && !is_complex && sign_vector == old_sign_vector) {
106 v = dec.adjoint().solve(sign_vector);
107 v.real().cwiseAbs().maxCoeff(&v_max_abs_index);
108 if (v_max_abs_index == old_v_max_abs_index) {
114 lower_bound =
v.template lpNorm<1>();
115 if (lower_bound <= old_lower_bound) {
120 old_sign_vector = sign_vector;
122 old_v_max_abs_index = v_max_abs_index;
123 old_lower_bound = lower_bound;
135 Scalar alternating_sign(RealScalar(1));
138 v[
i] = alternating_sign *
static_cast<RealScalar
>(RealScalar(1) + (RealScalar(
i) / (RealScalar(
n - 1))));
139 alternating_sign = -alternating_sign;
142 const RealScalar alternate_lower_bound = (2 *
v.template lpNorm<1>()) / (3 * RealScalar(
n));
143 return numext::maxi(lower_bound, alternate_lower_bound);
159 template <
typename Decomposition>
160 typename Decomposition::RealScalar
163 typedef typename Decomposition::RealScalar RealScalar;
167 if (dec.rows() == 1)
return RealScalar(1);
170 : (RealScalar(1) / inverse_matrix_norm) / matrix_norm);
Array< int, Dynamic, 1 > v
Matrix< float, 1, Dynamic > MatrixType
static const ConstantReturnType Ones()
static const BasisReturnType Unit(Index size, Index i)
The matrix class, also used for vectors and row-vectors.
NumTraits< Scalar >::Real RealScalar
Matrix< Type, Size, 1 > Vector
[c++11] SizeĆ1 vector of type Type.
Decomposition::RealScalar rcond_invmatrix_L1_norm_estimate(const Decomposition &dec)
Decomposition::RealScalar rcond_estimate_helper(typename Decomposition::RealScalar matrix_norm, const Decomposition &dec)
Reciprocal condition number estimator.
EIGEN_ALWAYS_INLINE T maxi(const T &x, const T &y)
bool is_exactly_zero(const X &x)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.