Fix stableNorm when input is zero-sized.

This commit is contained in:
Antonio Sanchez
2024-01-16 08:50:26 -08:00
parent c29a410116
commit b2814d53a7
2 changed files with 11 additions and 0 deletions

View File

@@ -55,6 +55,10 @@ typename MatrixType::RealScalar stable_norm_impl(const MatrixType& mat) {
RealScalar invScale(1);
RealScalar ssq(0); // sum of squares
if (mat.size() == 0) {
return RealScalar(0);
}
stable_norm_kernel(mat, ssq, scale, invScale);
return scale * sqrt(ssq);
}