diff options
author | Determinant <[email protected]> | 2015-08-13 15:36:09 +0800 |
---|---|---|
committer | Determinant <[email protected]> | 2015-08-13 15:36:09 +0800 |
commit | 184a2710192950fb62269726243a240ff18294eb (patch) | |
tree | d1f05dedece64982ed280b111906b16380739bac /htk_io | |
parent | 126433c7ab118e6ca65a3567662cec9509075cef (diff) |
[tnet_to_nerv] add support for matrix of arbitrary size
Diffstat (limited to 'htk_io')
-rw-r--r-- | htk_io/tools/tnet_to_nerv.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
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 <fstream> #include <string> #include <cstring> +#include <cstdlib> 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); |