27 bool complex_real_product_ok =
true;
31 int ibeta, it, iemin, iemax;
33 ibeta = std::numeric_limits<RealScalar>::radix;
34 it = std::numeric_limits<RealScalar>::digits;
35 iemin = std::numeric_limits<RealScalar>::min_exponent;
36 iemax = std::numeric_limits<RealScalar>::max_exponent;
38 VERIFY( (!(iemin > 1 - 2*it || 1+it>iemax || (it==2 && ibeta<5) || (it<=4 && ibeta <= 3 ) || it<2))
39 &&
"the stable norm algorithm cannot be guaranteed on this computer");
41 Scalar
inf = std::numeric_limits<RealScalar>::infinity();
44 complex_real_product_ok =
false;
45 static bool first =
true;
47 std::cerr <<
"WARNING: compiler mess up complex*real product, " << inf <<
" * " << 1.0 <<
" = " << inf*
RealScalar(1) << std::endl;
57 Scalar factor = internal::random<Scalar>();
59 factor = internal::random<Scalar>();
62 factor = internal::random<Scalar>();
64 factor = internal::random<Scalar>();
69 MatrixType vzero = MatrixType::Zero(rows, cols),
70 vrand = MatrixType::Random(rows, cols),
90 RealScalar
size =
static_cast<RealScalar
>(m.size());
120 Index i = internal::random<Index>(0,rows-1);
121 Index j = internal::random<Index>(0,cols-1);
126 v(i,j) = std::numeric_limits<RealScalar>::quiet_NaN();
137 v(i,j) = std::numeric_limits<RealScalar>::infinity();
141 if(complex_real_product_ok){
151 v(i,j) = -std::numeric_limits<RealScalar>::infinity();
155 if(complex_real_product_ok) {
164 Index i2 = internal::random<Index>(0,rows-1);
165 Index j2 = internal::random<Index>(0,cols-1);
167 v(i,j) = -std::numeric_limits<RealScalar>::infinity();
168 v(i2,j2) = std::numeric_limits<RealScalar>::quiet_NaN();
173 if (i2 != i || j2 != j) {
186 vcopy.stableNormalize();
193 VERIFY_IS_APPROX(vbig/big_scaling, (vbig.stableNorm() * vbig.stableNormalized()).
eval()/big_scaling);
198 template<
typename Scalar>
202 Scalar factor = internal::random<Scalar>();
204 factor = internal::random<Scalar>();
207 factor = internal::random<Scalar>();
209 factor = internal::random<Scalar>();
215 nan (std::numeric_limits<RealScalar>::quiet_NaN());
217 Scalar a = internal::random<Scalar>(-1,1);
218 Scalar b = internal::random<Scalar>(-1,1);
#define CALL_SUBTEST_6(FUNC)
#define CALL_SUBTEST_4(FUNC)
#define CALL_SUBTEST_3(FUNC)
EIGEN_DONT_INLINE Scalar zero()
EIGEN_DONT_INLINE T::Scalar hypotNorm(T &v)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
EIGEN_CONSTEXPR Index first(const T &x) EIGEN_NOEXCEPT
#define EIGEN_DONT_INLINE
EIGEN_DONT_INLINE T copy(const T &x)
#define VERIFY_IS_APPROX(a, b)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Abs2ReturnType abs2() const
#define VERIFY_IS_EQUAL(a, b)
#define CALL_SUBTEST_1(FUNC)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Array< int, Dynamic, 1 > v
Array< double, 1, 3 > e(1./3., 0.5, 2.)
EIGEN_DONT_INLINE T::Scalar stableNorm(T &v)
NumTraits< Scalar >::Real RealScalar
#define VERIFY_IS_MUCH_SMALLER_THAN(a, b)
#define CALL_SUBTEST_5(FUNC)
bool isPlusInf(const T &x)
void stable_norm(const MatrixType &m)
#define VERIFY_IS_NOT_APPROX(a, b)
#define CALL_SUBTEST_2(FUNC)
internal::nested_eval< T, 1 >::type eval(const T &xpr)
Jet< T, N > sqrt(const Jet< T, N > &f)
EIGEN_DONT_INLINE T::Scalar blueNorm(T &v)
The matrix class, also used for vectors and row-vectors.
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
EIGEN_DECLARE_TEST(stable_norm)