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

@@ -292,6 +292,18 @@ inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real MatrixBase<
return ei_sqrt(squaredNorm());
}
/** \returns the \em l2 norm of \c *this using a numerically more stable
* algorithm.
*
* \sa norm(), dot(), squaredNorm()
*/
template<typename Derived>
inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real
MatrixBase<Derived>::stableNorm() const
{
return this->cwise().abs().redux(ei_scalar_hypot_op<RealScalar>());
}
/** \returns an expression of the quotient of *this by its own norm.
*
* \only_for_vectors