aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2009-10-06 10:24:41 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2009-10-06 10:24:41 +0200
commit4cf73660273fa8c1ea9db4e41bc576f93fd0ccc9 (patch)
tree29be07a3c75f99763b0d2721f55ff23123ac0972
parent904f35d19497b5442a80a30c42d00fc52c22fe36 (diff)
fix compilation in stable norm, move a platform check to the unit tests
-rw-r--r--Eigen/src/Core/StableNorm.h14
-rw-r--r--test/stable_norm.cpp15
2 files changed, 19 insertions, 10 deletions
diff --git a/Eigen/src/Core/StableNorm.h b/Eigen/src/Core/StableNorm.h
index facab9dbd..b4a5d0bfd 100644
--- a/Eigen/src/Core/StableNorm.h
+++ b/Eigen/src/Core/StableNorm.h
@@ -108,21 +108,15 @@ MatrixBase<Derived>::blueNorm() const
iemax = std::numeric_limits<RealScalar>::max_exponent; // maximum exponent
rbig = std::numeric_limits<RealScalar>::max(); // largest floating-point number
- // Check the basic machine-dependent constants.
- if(iemin > 1 - 2*it || 1+it>iemax || (it==2 && ibeta<5)
- || (it<=4 && ibeta <= 3 ) || it<2)
- {
- ei_assert(false && "the algorithm cannot be guaranteed on this computer");
- }
iexp = -((1-iemin)/2);
- b1 = RealScalar(std::pow(double(ibeta),iexp)); // lower boundary of midrange
+ b1 = RealScalar(std::pow<RealScalar>(ibeta,iexp)); // lower boundary of midrange
iexp = (iemax + 1 - it)/2;
- b2 = RealScalar(std::pow(double(ibeta),iexp)); // upper boundary of midrange
+ b2 = RealScalar(std::pow<RealScalar>(ibeta,iexp)); // upper boundary of midrange
iexp = (2-iemin)/2;
- s1m = RealScalar(std::pow(double(ibeta),iexp)); // scaling factor for lower range
+ s1m = RealScalar(std::pow<RealScalar>(ibeta,iexp)); // scaling factor for lower range
iexp = - ((iemax+it)/2);
- s2m = RealScalar(std::pow(double(ibeta),iexp)); // scaling factor for upper range
+ s2m = RealScalar(std::pow<RealScalar>(ibeta,iexp)); // scaling factor for upper range
overfl = rbig*s2m; // overfow boundary for abig
eps = RealScalar(std::pow(double(ibeta), 1-it));
diff --git a/test/stable_norm.cpp b/test/stable_norm.cpp
index 726512ec0..6ce99477d 100644
--- a/test/stable_norm.cpp
+++ b/test/stable_norm.cpp
@@ -33,6 +33,21 @@ template<typename MatrixType> void stable_norm(const MatrixType& m)
typedef typename MatrixType::Scalar Scalar;
typedef typename NumTraits<Scalar>::Real RealScalar;
+ // Check the basic machine-dependent constants.
+ {
+ int nbig, ibeta, it, iemin, iemax, iexp;
+ RealScalar abig, eps;
+
+ ibeta = std::numeric_limits<RealScalar>::radix; // base for floating-point numbers
+ it = std::numeric_limits<RealScalar>::digits; // number of base-beta digits in mantissa
+ iemin = std::numeric_limits<RealScalar>::min_exponent; // minimum exponent
+ iemax = std::numeric_limits<RealScalar>::max_exponent; // maximum exponent
+
+ VERIFY( (!(iemin > 1 - 2*it || 1+it>iemax || (it==2 && ibeta<5) || (it<=4 && ibeta <= 3 ) || it<2))
+ && "the stable norm algorithm cannot be guaranteed on this computer");
+ }
+
+
int rows = m.rows();
int cols = m.cols();