Commit 1bb0669f authored by Dan Povey's avatar Dan Povey
Browse files

trunk: fix in QR algorithm (bad handling of an inf.)

git-svn-id: https://svn.code.sf.net/p/kaldi/code/trunk@4231 5e6a8d80-dfce-4ca6-a32a-6e07a63d50c8
parent a8ad8600
...@@ -86,8 +86,8 @@ void House(MatrixIndexT dim, const Real *x, Real *v, Real *beta) { ...@@ -86,8 +86,8 @@ void House(MatrixIndexT dim, const Real *x, Real *v, Real *beta) {
} else { } else {
cblas_Xscal(dim, inv_v1, v, 1); cblas_Xscal(dim, inv_v1, v, 1);
} }
if (!KALDI_ISFINITE(inv_v1) || !KALDI_ISFINITE(x1)) { if (KALDI_ISNAN(inv_v1)) {
KALDI_ERR << "NaN or inf encountered in HouseBackward"; KALDI_ERR << "NaN encountered in HouseBackward";
} }
} }
} }
...@@ -136,14 +136,14 @@ void HouseBackward(MatrixIndexT dim, const Real *x, Real *v, Real *beta) { ...@@ -136,14 +136,14 @@ void HouseBackward(MatrixIndexT dim, const Real *x, Real *v, Real *beta) {
*beta = 2 * v1sq / (sigma + v1sq); *beta = 2 * v1sq / (sigma + v1sq);
Real inv_v1 = 1.0 / v1; Real inv_v1 = 1.0 / v1;
if (KALDI_ISINF(inv_v1)) { if (KALDI_ISINF(inv_v1)) {
// can happen if v1 is denormal. // can happen if v1 is denormal or zero.
KALDI_ASSERT(v1 == v1 && v1 != 0.0); KALDI_ASSERT(v1 == v1 && v1 != 0.0);
for (MatrixIndexT i = 0; i < dim; i++) v[i] /= v1; for (MatrixIndexT i = 0; i < dim; i++) v[i] /= v1;
} else { } else {
cblas_Xscal(dim, inv_v1, v, 1); cblas_Xscal(dim, inv_v1, v, 1);
} }
if (!KALDI_ISFINITE(inv_v1) || !KALDI_ISFINITE(x1)) { if (KALDI_ISNAN(inv_v1)) {
KALDI_ERR << "NaN or inf encountered in HouseBackward"; KALDI_ERR << "NaN encountered in HouseBackward";
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment