Skip to content

Commit

Permalink
Merge pull request HIT-SCIR#135 from endyul/hotfix/VLA
Browse files Browse the repository at this point in the history
VC++ not support VLA
  • Loading branch information
Oneplus committed Aug 26, 2015
2 parents e093f8d + 953bcce commit 7faf223
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/framework/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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) {
Expand Down Expand Up @@ -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; }
Expand All @@ -443,39 +443,39 @@ class ViterbiDecoderWithMarginal : public ViterbiDecoder {
}
row_scale(beta_score, i, scale[i], con);
}

delete[] tmp_row;
}

double row_sum(const math::Mat<double>& mat, int i) const {
double row_sum(const math::Mat<double>& 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<double>& mat, int i, double scale) {
for (int j = 0 ; j < mat.ncols(); ++j) {
void row_scale(math::Mat<double>& 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<double>& 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];
}
return sum;
}

void row_scale(math::Mat<double>& 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;
}
Expand Down

0 comments on commit 7faf223

Please sign in to comment.