From 184a2710192950fb62269726243a240ff18294eb Mon Sep 17 00:00:00 2001 From: Determinant Date: Thu, 13 Aug 2015 15:36:09 +0800 Subject: [tnet_to_nerv] add support for matrix of arbitrary size --- htk_io/tools/tnet_to_nerv.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htk_io/tools/tnet_to_nerv.cpp b/htk_io/tools/tnet_to_nerv.cpp index bbfddcf..a779a25 100644 --- a/htk_io/tools/tnet_to_nerv.cpp +++ b/htk_io/tools/tnet_to_nerv.cpp @@ -2,9 +2,10 @@ #include #include #include +#include char token[1024]; char output[1024]; -double mat[4096][4096]; +double **mat; int main(int argc, char **argv) { std::ofstream fout; fout.open(argv[1]); @@ -18,6 +19,9 @@ int main(int argc, char **argv) { scanf("%d %d", &ncol, &nrow); scanf("%s %d %d", token, &ncol, &nrow); printf("%d %d\n", nrow, ncol); + mat = (double **)malloc(nrow * sizeof(double *)); + for (i = 0; i < nrow; i++) + mat[i] = (double *)malloc(ncol * sizeof(double)); for (j = 0; j < ncol; j++) for (i = 0; i < nrow; i++) scanf("%lf", mat[i] + j); @@ -34,7 +38,9 @@ int main(int argc, char **argv) { for (j = 0; j < ncol; j++) fout << mat[i][j] << " "; fout << std::endl; + free(mat[i]); } + free(mat); long length = fout.tellp() - base; fout.seekp(base); sprintf(output, "[%13lu]\n", length); -- cgit v1.2.3-70-g09d2