add MatrixBase::stableNorm() avoiding over/under-flow

using it in QR reduced the error of Keir test from 1e-12 to 1e-24 but
that's much more expensive !
This commit is contained in:
Gael Guennebaud
2009-01-28 22:11:56 +00:00
parent 42b237b83a
commit 36c8a64923
6 changed files with 46 additions and 6 deletions

View File

@@ -34,10 +34,11 @@ template<typename T> inline T ei_random_amplitude()
else return static_cast<T>(10);
}
template<typename T> inline T ei_hypot(T x, T y)
template<typename T> inline typename NumTraits<T>::Real ei_hypot(T x, T y)
{
T _x = ei_abs(x);
T _y = ei_abs(y);
typedef typename NumTraits<T>::Real RealScalar;
RealScalar _x = ei_abs(x);
RealScalar _y = ei_abs(y);
T p = std::max(_x, _y);
T q = std::min(_x, _y);
T qp = q/p;