diff --git a/Eigen/src/Core/StableNorm.h b/Eigen/src/Core/StableNorm.h index f702fd8e2..f9cd01b7e 100644 --- a/Eigen/src/Core/StableNorm.h +++ b/Eigen/src/Core/StableNorm.h @@ -157,6 +157,7 @@ inline typename NumTraits::Scalar>::Real MatrixBase::stableNorm() const { using std::sqrt; + using std::abs; const Index blockSize = 4096; RealScalar scale(0); RealScalar invScale(1); @@ -167,6 +168,10 @@ MatrixBase::stableNorm() const typedef typename internal::conditional, Aligned>, typename Base::ConstSegmentReturnType>::type SegmentWrapper; Index n = size(); + + if(n==1) + return abs(this->coeff(0)); + Index bi = internal::first_aligned(derived()); if (bi>0) internal::stable_norm_kernel(this->head(bi), ssq, scale, invScale);