From bd5b32238f99a979c57a0a5930cc303427a6356a Mon Sep 17 00:00:00 2001 From: Calvin Morrison Date: Tue, 29 Oct 2013 15:09:25 -0400 Subject: use type in memset, add +1 to our matrix width --- src/c/quikr_functions.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/c/quikr_functions.c b/src/c/quikr_functions.c index fd7b99e..60fe676 100644 --- a/src/c/quikr_functions.c +++ b/src/c/quikr_functions.c @@ -181,6 +181,8 @@ struct matrix *load_sensing_matrix(const char *filename) { headers[i] = header+1; + row = memset(row, 0, (width + 1) * sizeof(unsigned long long)); + for(j = 0; j < width; j++) { line = gzgets(fh, line, 32); if(line == NULL || line[0] == '>') { @@ -197,7 +199,7 @@ struct matrix *load_sensing_matrix(const char *filename) { sum += row[j]; } for(j = 1; j < width+1; j++) { - matrix[i*width + j] = ((double)row[j-1]) / sum; + matrix[i*(width+1) + j] = ((double)row[j-1]) / sum; } } -- cgit v1.2.3