Skip to content

Commit 99cb0a3

Browse files
author
David Cock
committed
* Histogram test
1 parent 4baddf1 commit 99cb0a3

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

.hgignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ test/*.capacity
1414
test/*.cm
1515
test/*.plot
1616
test/*.sim
17+
test/*.hist_test
1718
sample_error
1819
channel_hist
1920
log
@@ -24,3 +25,4 @@ smooth
2425
drop_samples
2526
row_average
2627
test_sparse
28+
test_hist

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ row_average: row_average.o ${SPARSE_OBJS}
106106

107107
TEST_MATRICES=matrix1
108108

109+
HIST_TEST=matrix1
110+
109111
ifdef BIGMEM
110112
# This matrix requires 2.5GB of memory to build, and roughly 2*ncores GB
111113
# to simulate
@@ -117,6 +119,9 @@ TEST_TARGETS= \
117119
$(patsubst %,test/%.capacity,${TEST_MATRICES}) \
118120
$(patsubst %,test/%.sim,${TEST_MATRICES})
119121

122+
HIST_TEST_TARGETS= \
123+
$(patsubst %,test/%.hist_test,${HIST_TEST})
124+
120125
%.cm: %.samples.xz channel_matrix
121126
xzcat $< | ./channel_matrix $@
122127

@@ -129,7 +134,10 @@ TEST_TARGETS= \
129134
%.sim: %.cm sample_error
130135
./sample_error $< 100 10 1e-3 1 0 1 > $@
131136

132-
test: ${TEST_TARGETS} test_sparse
137+
%.hist_test: %.samples.xz test_hist
138+
xzcat $< | ./test_hist > $@
139+
140+
test: ${TEST_TARGETS} ${HIST_TEST_TARGETS} test_sparse
133141
./test_sparse
134142

135143
###

test_hist.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ main(int argc, char *argv[]) {
5656

5757
printf(" done.\n");
5858

59+
if(!bsc_check(H, 1)) abort();
60+
5961
bsc_stats(H);
6062

6163
col= malloc(H->end_row * sizeof(int));
@@ -64,19 +66,21 @@ main(int argc, char *argv[]) {
6466
exit(EXIT_FAILURE);
6567
}
6668

67-
printf("Recounting all entries...\n");
69+
printf("Recounting all entries...");
6870
fflush(stdout);
6971

7072
for(c= 0; c < H->end_col; c++) {
7173
size_t i;
72-
if(c != 0 && c % 10 == 0)
73-
printf("%d/%d\n", c, H->end_col);
7474
bzero(col, H->end_row * sizeof(int));
7575
if(H->end_rows[c] <= H->start_rows[c]) continue;
7676
for(i= 0; i < nread; i++) {
77-
if(data[i].c == c) col[data[i].r]++;
77+
if(data[i].c == c) {
78+
assert(H->start_rows[c] <= data[i].r);
79+
assert(data[i].r < H->end_rows[c]);
80+
col[data[i].r]++;
81+
}
7882
}
79-
for(r= H->start_rows[c]; r < H->end_rows[c]; r++) {
83+
for(r= H->start_rows[c]; r < H->end_rows[c] && r < H->end_row; r++) {
8084
int ri= r - H->start_rows[c];
8185

8286
if(col[r] != H->entries[c][ri]) {

0 commit comments

Comments
 (0)