@@ -1358,6 +1358,36 @@ template <class uword> bool countstest1() {
13581358 return true ;
13591359}
13601360
1361+ template <class uword > bool countstest2 () {
1362+ size_t data1[]={193 ,261 ,738 ,1484 ,1641 ,1703 ,1858 ,2445 ,3183 ,3385 ,3406 ,4028 ,4139 ,4369 ,6267 ,6692 ,6720 ,6818 ,7165 ,8388 ,8879 ,8898 ,9866 ,10362 ,10465 ,11578 ,11793 ,11871 ,12334 ,12604 ,12814 ,13604 ,14287 ,14699 ,14771 ,14797 ,15041 ,15298 ,16649 ,17620 ,17712 ,18215 ,18576 ,18689 ,18929 ,18971 ,19326 ,19387 ,19397 ,20478 ,20559 ,20590 ,20749 ,21072 ,21830 ,21937 ,22374 ,22547 ,23552 ,23630 ,23727 ,23798 ,23862 ,24770 ,25031 ,25037 ,25669 ,25938 ,26877 ,27972 ,28392 ,29049 ,29170 ,29429 ,30019 ,30504 ,30606 ,30854 ,31325 ,31360 ,31671 ,31960 ,31984 ,32196 ,32483 ,32935 ,33010 ,33163 ,33341 ,33669 ,33822 ,34243 ,35003 ,35334 ,36401 ,37430 ,37472 ,37752 ,38012 ,38374 ,38560 ,38814 ,39011 ,39014 ,39846 ,40441 ,40465 ,40911 ,41103 ,41915 ,42507 ,42942 ,43083 ,43218 ,43748 ,44102 ,44560 ,44607 ,45404 ,45583 ,45587 ,46307 ,46728 ,47239 ,47793 ,47799 ,47913 ,48391 };
1363+ size_t data2[]={58 ,162 ,321 ,326 ,348 ,351 ,361 ,411 ,502 ,605 ,656 ,675 ,765 ,1036 ,1087 ,1213 ,1321 ,1577 ,1818 ,1957 ,2022 ,2290 ,2297 ,2384 ,2397 ,2473 ,2752 ,2805 ,2855 ,2896 ,2961 ,3646 ,3721 ,3866 ,3931 ,4000 ,4121 ,4199 ,4594 ,4634 ,4697 ,4799 ,4876 ,5098 ,5319 ,5454 ,5610 ,5664 ,5851 ,5873 ,5892 ,5986 ,6075 ,6127 ,6270 ,6289 ,6337 ,6354 ,6446 ,6571 ,6817 ,6842 ,6882 ,7394 ,7398 ,7539 ,7677 ,7841 ,7982 ,8106 ,8475 ,8749 ,8769 ,8793 ,8926 ,9015 ,9133 ,9175 ,9207 ,9373 ,9511 ,9663 ,9726 ,9848 ,10154 ,10290 ,10614 ,10675 ,10681 ,10798 ,10868 ,11302 ,11367 ,11396 ,11405 ,11562 ,11626 ,11633 ,11644 ,11721 ,11846 ,11885 ,12322 ,12519 ,12555 ,12591 ,12594 ,12606 ,12618 ,12667 ,12752 ,12820 ,13139 ,13175 ,13252 ,13410 ,13431 ,13534 ,13695 ,13883 ,13982 ,14080 ,14117 ,14142 ,14172 ,14275 ,14362 ,14505 };
1364+ EWAHBoolArray<uword> b1;
1365+ for (size_t k = 0 ; k < sizeof (data1)/sizeof (size_t ); ++k) b1.set (data1[k]);
1366+ EWAHBoolArray<uword> b2;
1367+ for (size_t k = 0 ; k < sizeof (data2)/sizeof (size_t ); ++k) b2.set (data2[k]);
1368+ assert (b1.logicalandcount (b2) == b1.logicaland (b2).numberOfOnes ());
1369+ assert (b1.logicalorcount (b2) == b1.logicalor (b2).numberOfOnes ());
1370+ assert (b1.logicalxorcount (b2) == b1.logicalxor (b2).numberOfOnes ());
1371+ assert (b1.logicalandnotcount (b2) == b1.logicalandnot (b2).numberOfOnes ());
1372+ return true ;
1373+ }
1374+
1375+ template <class uword > bool countstest3 () {
1376+ size_t data1[]={0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,15 ,16 ,17 ,18 ,19 ,20 ,21 ,22 ,23 ,24 ,25 ,26 ,27 ,28 ,29 ,30 ,31 ,32 ,33 ,34 ,35 ,36 ,37 ,38 ,39 ,40 ,41 ,42 ,43 ,44 ,45 ,46 ,47 ,48 ,49 ,50 ,51 ,52 ,53 ,54 ,55 ,56 ,57 ,59 ,60 ,61 ,62 ,63 ,64 ,65 ,66 ,67 ,68 ,69 ,70 ,71 ,72 ,73 ,74 ,75 ,76 ,77 ,78 ,79 ,80 ,81 ,82 ,83 ,84 ,85 ,86 ,87 ,88 ,89 ,90 ,91 ,92 ,93 ,94 ,95 ,96 ,97 ,98 ,99 ,100 ,101 ,102 ,103 ,104 ,105 ,106 ,107 ,108 ,109 ,110 ,111 ,112 ,113 ,114 ,115 ,116 ,117 ,118 ,119 ,120 ,121 ,122 ,123 ,124 ,125 ,126 ,127 ,128 };
1377+ size_t data2[]={31 ,141 ,468 ,692 ,2000 ,2650 ,2715 ,2995 ,3149 ,3337 ,3454 ,3465 ,3848 ,3900 ,4215 ,4388 ,4545 ,4801 ,4911 ,4918 ,5358 ,6020 ,6114 ,6143 ,6659 ,7031 ,7258 ,7631 ,8300 ,9299 ,9416 ,9471 ,9506 ,9541 ,9918 ,10488 ,10616 ,10617 ,10764 ,11199 ,11343 ,11439 ,11455 ,11504 ,11761 ,11901 ,12409 ,12543 ,12619 ,12643 ,12972 ,13488 ,13858 ,14073 ,14185 ,14270 ,14508 ,14994 ,15264 ,15492 ,15497 ,15536 ,15616 ,15897 ,15918 ,16130 ,16498 ,16573 ,16814 ,16832 ,17050 ,17426 ,17443 ,17626 ,17949 ,18122 ,18377 ,18754 ,18810 ,18870 ,18965 ,19110 ,19242 ,19449 ,19870 ,19966 ,20012 ,20068 ,20301 ,20602 ,20854 ,21328 ,22134 ,22362 ,22370 ,22489 ,23324 ,23353 ,24363 ,24689 ,24758 ,24969 ,25104 ,25592 ,25855 ,26111 ,26156 ,26268 ,26372 ,26406 ,26537 ,26703 ,26999 ,27113 ,27116 ,28218 ,28256 ,28282 ,28552 ,28625 ,28679 ,28907 ,29064 ,29303 ,29320 ,29362 ,29388 ,29407 };
1378+ EWAHBoolArray<uword> b1;
1379+ for (size_t k = 0 ; k < sizeof (data1)/sizeof (size_t ); ++k) b1.set (data1[k]);
1380+ EWAHBoolArray<uword> b2;
1381+ for (size_t k = 0 ; k < sizeof (data2)/sizeof (size_t ); ++k) b2.set (data2[k]);
1382+ assert (b1.logicalandcount (b2) == b1.logicaland (b2).numberOfOnes ());
1383+ assert (b1.logicalorcount (b2) == b1.logicalor (b2).numberOfOnes ());
1384+ assert (b1.logicalxorcount (b2) == b1.logicalxor (b2).numberOfOnes ());
1385+ assert (b1.logicalandnotcount (b2) == b1.logicalandnot (b2).numberOfOnes ());
1386+ return true ;
1387+ }
1388+
1389+
1390+
13611391template <class uword > bool arrayinit2d () {
13621392 cout << " [arrayinit2d] checking arrayinit...sizeof(uword)=" << sizeof (uword)
13631393 << endl;
@@ -1377,12 +1407,25 @@ int main(void) {
13771407 if (!funnytest ()) {
13781408 ++failures;
13791409 }
1410+ if (!countstest3<uint16_t >())
1411+ ++failures;
1412+ if (!countstest3<uint32_t >())
1413+ ++failures;
1414+ if (!countstest3<uint64_t >())
1415+ ++failures;
1416+
13801417 if (!countstest1<uint16_t >())
13811418 ++failures;
13821419 if (!countstest1<uint32_t >())
13831420 ++failures;
13841421 if (!countstest1<uint64_t >())
13851422 ++failures;
1423+ if (!countstest2<uint16_t >())
1424+ ++failures;
1425+ if (!countstest2<uint32_t >())
1426+ ++failures;
1427+ if (!countstest3<uint64_t >())
1428+ ++failures;
13861429
13871430 if (!testSerialSize<uint16_t >())
13881431 ++failures;
0 commit comments