diff --git a/src/framework/decoder.h b/src/framework/decoder.h index c2efcb06c..59723d977 100644 --- a/src/framework/decoder.h +++ b/src/framework/decoder.h @@ -369,7 +369,7 @@ class ViterbiDecoderWithMarginal : public ViterbiDecoder { beta_score[L-1][j] = scale[L-1]; } - double tmp_row[T]; + double * tmp_row = new double[T]; for (int i = L - 2; i >= 0; --i) { for (size_t nt = 0; nt < T; ++nt) { tmp_row[nt] = beta_score[i+1][nt] * exp_emit[i+1][nt]; @@ -381,7 +381,7 @@ class ViterbiDecoderWithMarginal : public ViterbiDecoder { } row_scale(beta_score, i, scale[i]); } - + delete[] tmp_row; } void calc_alpha_score(const ViterbiDecodeConstrain& con) { @@ -428,7 +428,7 @@ class ViterbiDecoderWithMarginal : public ViterbiDecoder { beta_score[L-1][j] = scale[L-1]; } - double tmp_row[T]; + double * tmp_row = new double[T]; for (int i = L - 2; i >= 0; --i) { for (size_t nt = 0; nt < T; ++nt) { if (!con.can_emit(i+1, nt)) { continue; } @@ -443,28 +443,28 @@ class ViterbiDecoderWithMarginal : public ViterbiDecoder { } row_scale(beta_score, i, scale[i], con); } - + delete[] tmp_row; } - double row_sum(const math::Mat& mat, int i) const { + double row_sum(const math::Mat& mat, size_t i) const { double sum = 0.; - for (int j = 0; j < mat.ncols(); ++j) { + for (size_t j = 0; j < mat.ncols(); ++j) { sum += mat[i][j]; } return sum; } - void row_scale(math::Mat& mat, int i, double scale) { - for (int j = 0 ; j < mat.ncols(); ++j) { + void row_scale(math::Mat& mat, size_t i, double scale) { + for (size_t j = 0 ; j < mat.ncols(); ++j) { mat[i][j] *= scale; } } double row_sum(const math::Mat& mat, - int i, + size_t i, const ViterbiDecodeConstrain& con) const { double sum = 0.; - for (int j = 0; j < mat.ncols(); ++j) { + for (size_t j = 0; j < mat.ncols(); ++j) { if (!con.can_emit(i, j)) { continue; } sum += mat[i][j]; } @@ -472,10 +472,10 @@ class ViterbiDecoderWithMarginal : public ViterbiDecoder { } void row_scale(math::Mat& mat, - int i, + size_t i, double scale, const ViterbiDecodeConstrain& con) { - for (int j = 0 ; j < mat.ncols(); ++j) { + for (size_t j = 0 ; j < mat.ncols(); ++j) { if (!con.can_emit(i, j)) { continue; } mat[i][j] *= scale; }