diff options
author | John Hawthorn <john.hawthorn@gmail.com> | 2014-08-30 19:11:55 -0700 |
---|---|---|
committer | John Hawthorn <john.hawthorn@gmail.com> | 2014-08-30 19:48:29 -0700 |
commit | aa98e4a4f0ef111902e6fd0faf24c8daf953330a (patch) | |
tree | fd24254c94684cda9b43f19f905c21bf8b8953bb | |
parent | c8e087f41f467b0f5f32eaef19cd11b7f0f95edb (diff) |
Improve debugging output
-rw-r--r-- | match.c | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -23,9 +23,17 @@ typedef double score_t; #define SCORE_MIN -INFINITY /* print one of the internal matrices */ -void mat_print(score_t *mat, int n, int m){ +void mat_print(score_t *mat, const char *needle, const char *haystack){ + int n = strlen(needle); + int m = strlen(haystack); int i, j; + fprintf(stderr, " "); + for(j = 0; j < m; j++){ + fprintf(stderr, " %c", haystack[j]); + } + fprintf(stderr, "\n"); for(i = 0; i < n; i++){ + fprintf(stderr, " %c |", needle[i]); for(j = 0; j < m; j++){ score_t val = mat[i*m + j]; if(val == SCORE_MIN){ @@ -129,10 +137,10 @@ double calculate_score(const char *needle, const char *haystack, size_t *positio } #if 0 - printf("\"%s\" =~ \"%s\"\n", needle, haystack); - mat_print(&D[0][0], n, m); - mat_print(&M[0][0], n, m); - printf("\n"); + fprintf(stderr, "\"%s\" =~ \"%s\"\n", needle, haystack); + mat_print(&D[0][0], needle, haystack); + mat_print(&M[0][0], needle, haystack); + fprintf(stderr, "\n"); #endif /* backtrace to find the positions of optimal matching */ |