summaryrefslogtreecommitdiff
path: root/htk_io
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2015-08-13 15:36:09 +0800
committerDeterminant <[email protected]>2015-08-13 15:36:09 +0800
commit184a2710192950fb62269726243a240ff18294eb (patch)
treed1f05dedece64982ed280b111906b16380739bac /htk_io
parent126433c7ab118e6ca65a3567662cec9509075cef (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.cpp8
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);