40 using namespace nvbio;
44 template <
typename CompStream>
49 if (uncomp_stream[i] != comp_stream[i])
51 fprintf(stderr,
" error at %u : found %u, expected %u\n", i,
uint32( comp_stream[i] ),
uint32( uncomp_stream[i] ));
58 template <
typename CompStream>
63 if (uncomp_stream[i] != *comp_stream)
65 fprintf(stderr,
" forward iterator error at %u : found %u, expected %u\n", i,
uint32( *comp_stream ),
uint32( uncomp_stream[i] ));
80 Stream
stream( base_stream );
82 fprintf(stderr,
"2-bit stream test... started\n");
87 stream.set( 0,
uint8(3) );
88 uncomp_stream[0] =
uint8(3);
93 stream.set( 2,
uint8(2) );
94 uncomp_stream[2] =
uint8(2);
99 stream.set( 16,
uint8(3) );
100 uncomp_stream[16] =
uint8(3);
105 stream.set( 17,
uint8(1) );
106 uncomp_stream[17] =
uint8(1);
112 for (
uint32 i = 0; i < 1000; ++i)
115 const uint32 s = rand() % 4;
117 uncomp_stream[j] = s;
123 Stream::iterator it = stream.begin();
124 for (
uint32 i = 0; i < 1000; ++i)
127 const uint32 s = rand() % 4;
129 uncomp_stream[j] = s;
135 std::swap( *uncomp_stream, *(uncomp_stream+1) );
136 std::swap( *stream.begin(), *(stream.begin()+1) );
147 CachedPackedStream cached_stream( cached_base_stream );
150 if (uncomp_stream[i] != cached_stream[i])
152 fprintf(stderr,
" error at %u : found %u, expected %u\n", i,
uint32( cached_stream[i] ),
uint32( uncomp_stream[i] ));
166 saisxx( stream.begin(), SA, 6, 4 );
174 fprintf(stderr,
" wrong suffix tree for \"BANANA\"\n");
175 for (
uint32 i = 0; i < 6; ++i)
176 fprintf(stderr,
"%u : %u\n", i, SA[i]);
180 Stream bwt_stream( base_bwt_stream );
182 saisxx_bwt( stream.begin(), bwt_stream.begin(), SA, 6, 4 );
184 for (
uint32 i = 0; i < 6; ++i)
186 const uint8 c = bwt_stream[i];
194 if (strcmp( bwt,
"ANNBAA" ) != 0)
196 fprintf(stderr,
" wrong bwt: expected \"ANNBAA\", got \"%s\"\n", bwt);
200 fprintf(stderr,
"2-bit stream test... done\n");
204 uint8 uncomp_stream[4*
LEN] = { 0u };
206 fprintf(stderr,
"4-bit uint32-stream test... started\n");
213 uncomp_stream[9] =
uint8(5);
218 uncomp_stream[10] =
uint8(15);
223 for (
uint32 i = 0; i < 1000; ++i)
226 const uint32 s = rand() % 16;
228 uncomp_stream[j] = s;
245 if (
check_stream( uncomp_stream, cached_stream ) ==
false)
248 fprintf(stderr,
"4-bit uint32-stream test... done\n");
251 uint4 base_stream[
LEN] = { { 0u } };
252 uint8 uncomp_stream[4*
LEN] = { 0u };
254 fprintf(stderr,
"4-bit uint4-stream test... started\n");
261 uncomp_stream[9] =
uint8(5);
266 uncomp_stream[10] =
uint8(15);
271 for (
uint32 i = 0; i < 1000; ++i)
274 const uint32 s = rand() % 16;
276 uncomp_stream[j] = s;
293 if (
check_stream( uncomp_stream, cached_stream ) ==
false)
296 fprintf(stderr,
"4-bit uint4-stream test... done\n");
300 uint8 uncomp_stream[3*
LEN] = { 0u };
302 fprintf(stderr,
"3-bit uint32-stream test... started\n");
309 uncomp_stream[9] =
uint8(5);
314 uncomp_stream[10] =
uint8(7);
319 for (
uint32 i = 0; i < 1000; ++i)
322 const uint32 s = rand() % 8;
324 uncomp_stream[j] = s;
335 fprintf(stderr,
"3-bit uint32-stream test... done\n");
339 uint8 uncomp_stream[2*
LEN] = { 0u };
341 fprintf(stderr,
"2-bit byte-stream test... started\n");
348 uncomp_stream[9] =
uint8(3);
353 uncomp_stream[10] =
uint8(2);
358 for (
uint32 i = 0; i < 1000; ++i)
361 const uint32 s = rand() % 4;
363 uncomp_stream[j] = s;
378 fprintf(stderr,
"2-bit byte-stream test... done\n");
381 uint4 base_stream[
LEN] = { { 0u } };
382 uint8 uncomp_stream[4*
LEN] = { 0u };
384 fprintf(stderr,
"2-bit uint4-stream test... started\n");
391 uncomp_stream[9] =
uint8(3);
396 uncomp_stream[10] =
uint8(2);
401 for (
uint32 i = 0; i < 1000; ++i)
404 const uint32 s = rand() % 4;
406 uncomp_stream[j] = s;
417 fprintf(stderr,
"2-bit uint4-stream test... done\n");