1#ifndef HYPERCUBE_UNIT_TEST_HPP
2#define HYPERCUBE_UNIT_TEST_HPP
4#include "Space/Shape/HyperCube.hpp"
5#include "util/util_debug.hpp"
13template<
unsigned int dim>
void check_lin(std::vector<
comb<dim>> cmb)
16 for (
size_t i = 0 ; i < cmb.size() ; i++)
28template<
unsigned int dim>
void check_lin_perm(std::vector<
comb<dim>> cmb)
31 for (
size_t i = 0 ; i < cmb.size() ; i++)
43template<
unsigned int dim>
bool isDinstict(std::vector<
comb<dim>> combs)
47 for (
size_t i = 0 ; i < combs.size() ; i++)
49 for (
size_t j = i+1 ; j < combs.size() ; j++)
51 if (combs[i] == combs[j])
69template<
unsigned int dim>
bool isSubdecomposition(std::vector<
comb<dim>> combs,
comb<dim> c)
71 for (
size_t i = 0 ; i < combs.size() ; i++)
73 if (c.
isSub(combs[i]) ==
false)
80template<
unsigned int dim>
bool isValid(std::vector<
comb<dim>> combs)
84 for (
size_t i = 0 ; i < combs.size() ; i++)
86 if (combs[i].isValid() ==
false)
93BOOST_AUTO_TEST_SUITE( Hyper_cube )
95BOOST_AUTO_TEST_CASE( Hyper_cube_comb_use )
103 BOOST_REQUIRE_EQUAL(c_ret.
c[0],2);
104 BOOST_REQUIRE_EQUAL(c_ret.
c[1],1);
105 BOOST_REQUIRE_EQUAL(c_ret.
c[2],0);
113 BOOST_REQUIRE_EQUAL(c2.c[0],1);
114 BOOST_REQUIRE_EQUAL(c2.c[1],0);
115 BOOST_REQUIRE_EQUAL(c2.c[2],1);
124 BOOST_REQUIRE_EQUAL(c_ret.
c[0],4);
125 BOOST_REQUIRE_EQUAL(c_ret.
c[1],3);
126 BOOST_REQUIRE_EQUAL(c_ret.
c[2],2);
134 BOOST_REQUIRE_EQUAL(c_ret.
c[0],-3);
135 BOOST_REQUIRE_EQUAL(c_ret.
c[1],-2);
136 BOOST_REQUIRE_EQUAL(c_ret.
c[2],-1);
140 comb<3> c1({(char)-1,(
char)1,(char)0});
144 BOOST_REQUIRE_EQUAL(c_ret.
c[0],0);
145 BOOST_REQUIRE_EQUAL(c_ret.
c[1],-1);
146 BOOST_REQUIRE_EQUAL(c_ret.
c[2],-1);
150BOOST_AUTO_TEST_CASE( Hyper_cube_use)
152 std::cout <<
"Hyper-cube unit test start" <<
"\n";
170 BOOST_REQUIRE_EQUAL(
ele[0],2ul);
171 BOOST_REQUIRE_EQUAL(
ele[1],1ul);
175 comb<1> c[] = {{(char)1},{(char)-1}};
180 std::vector<comb<1>> v1_st;
182 check_lin_perm(v1_st);
184 boost_check_array(&c[0],&v_c1_0[0],2);
202 BOOST_REQUIRE_EQUAL(
ele[0],4ul);
203 BOOST_REQUIRE_EQUAL(
ele[1],4ul);
204 BOOST_REQUIRE_EQUAL(
ele[2],1ul);
208 comb<2> c2_0[] = {{(char)1,(
char)1},{(char)-1,(
char)1},{(char)1,(
char)-1},{(char)-1,(
char)-1}};
209 comb<2> c2_1[] = {{(char)0,(
char)1},{(char)0,(
char)-1},{(char)1,(
char)0},{(char)-1,(
char)0}};
213 std::vector<comb<2>> v2_st;
215 check_lin_perm(v2_st);
217 boost_check_array(&c2_0[0],&v_c2_0[0],4);
218 boost_check_array(&c2_1[0],&v_c2_1[0],4);
240 BOOST_REQUIRE_EQUAL(
ele[0],8ul);
241 BOOST_REQUIRE_EQUAL(
ele[1],12ul);
242 BOOST_REQUIRE_EQUAL(
ele[2],6ul);
243 BOOST_REQUIRE_EQUAL(
ele[3],1ul);
247 comb<3> c3_0[] = {{(char)1,(
char)1,(char)1},{(char)-1,(
char)1,(char)1},{(char)1,(
char)-1,(char)1},{(char)-1,(
char)-1,(char)1},{(char)1,(
char)1,(char)-1},{(char)-1,(
char)1,(char)-1},{(char)1,(
char)-1,(char)-1},{(char)-1,(
char)-1,(char)-1}};
248 comb<3> c3_1[] = {{(char)0,(
char)1,(char)1},{(char)0,(
char)-1,(char)1},{(char)0,(
char)1,(char)-1},{(char)0,(
char)-1,(char)-1},{(char)1,(
char)0,(char)1},{(char)-1,(
char)0,(char)1},{(char)1,(
char)0,(char)-1},{(char)-1,(
char)0,(char)-1},{(char)1,(
char)1,(char)0},{(char)-1,(
char)1,(char)0},{(char)1,(
char)-1,(char)0},{(char)-1,(
char)-1,(char)0}};
249 comb<3> c3_2[] = {{{(char)0,(
char)0,(char)1}},{{(char)0,(
char)0,(char)-1}},{{(char)0,(
char)1,(char)0}},{{(char)0,(
char)-1,(char)0}},{{(char)1,(
char)0,(char)0}},{{(char)-1,(
char)0,(char)0}}};
254 std::vector<comb<3>> v3_st;
256 check_lin_perm(v3_st);
258 boost_check_array(&c3_0[0],&v_c3_0[0],8);
259 boost_check_array(&c3_1[0],&v_c3_1[0],12);
260 boost_check_array(&c3_2[0],&v_c3_2[0],6);
284 std::vector<comb<4>> v4_st;
286 check_lin_perm(v1_st);
289 BOOST_REQUIRE_EQUAL(
ele[0],16ul);
290 BOOST_REQUIRE_EQUAL(
ele[1],32ul);
291 BOOST_REQUIRE_EQUAL(
ele[2],24ul);
292 BOOST_REQUIRE_EQUAL(
ele[3],8ul);
293 BOOST_REQUIRE_EQUAL(
ele[4],1ul);
321 std::vector<comb<5>> v5_st;
323 check_lin_perm(v5_st);
326 BOOST_REQUIRE_EQUAL(
ele[0],32ul);
327 BOOST_REQUIRE_EQUAL(
ele[1],80ul);
328 BOOST_REQUIRE_EQUAL(
ele[2],80ul);
329 BOOST_REQUIRE_EQUAL(
ele[3],40ul);
330 BOOST_REQUIRE_EQUAL(
ele[4],10ul);
331 BOOST_REQUIRE_EQUAL(
ele[5],1ul);
340 for (
size_t i = 0 ; i < sc2_0.size() ; i++)
346 BOOST_REQUIRE_EQUAL(combs.size(),1ul);
347 BOOST_REQUIRE_EQUAL(isDinstict(combs),
true);
348 BOOST_REQUIRE_EQUAL(isValid(combs),
true);
349 BOOST_REQUIRE_EQUAL(isSubdecomposition(combs,sc2_0[i]),
true);
356 for (
size_t i = 0 ; i < sc2_1.size() ; i++)
363 BOOST_REQUIRE_EQUAL(combs.size(),2ul);
364 BOOST_REQUIRE_EQUAL(isDinstict(combs),
true);
365 BOOST_REQUIRE_EQUAL(isValid(combs),
true);
366 BOOST_REQUIRE_EQUAL(isSubdecomposition(combs,sc2_1[i]),
true);
372 BOOST_REQUIRE_EQUAL(combs.size(),1ul);
373 BOOST_REQUIRE_EQUAL(isDinstict(combs),
true);
374 BOOST_REQUIRE_EQUAL(isValid(combs),
true);
375 BOOST_REQUIRE_EQUAL(isSubdecomposition(combs,sc2_1[i]),
true);
382 for (
size_t i = 0 ; i < sc2_2.size() ; i++)
388 BOOST_REQUIRE_EQUAL(combs.size(),4ul);
389 BOOST_REQUIRE_EQUAL(isDinstict(combs),
true);
390 BOOST_REQUIRE_EQUAL(isValid(combs),
true);
391 BOOST_REQUIRE_EQUAL(isSubdecomposition(combs,sc2_2[i]),
true);
397 BOOST_REQUIRE_EQUAL(combs.size(),4ul);
398 BOOST_REQUIRE_EQUAL(isDinstict(combs),
true);
399 BOOST_REQUIRE_EQUAL(isValid(combs),
true);
400 BOOST_REQUIRE_EQUAL(isSubdecomposition(combs,sc2_2[i]),
true);
406 BOOST_REQUIRE_EQUAL(combs.size(),1ul);
407 BOOST_REQUIRE_EQUAL(isDinstict(combs),
true);
408 BOOST_REQUIRE_EQUAL(isValid(combs),
true);
409 BOOST_REQUIRE_EQUAL(isSubdecomposition(combs,sc2_2[i]),
true);
418 for (
size_t i = 0 ; i < sc3_0.size() ; i++)
424 BOOST_REQUIRE_EQUAL(combs.size(),1ul);
425 BOOST_REQUIRE_EQUAL(isDinstict(combs),
true);
426 BOOST_REQUIRE_EQUAL(isValid(combs),
true);
434 for (
size_t i = 0 ; i < sc3_1.size() ; i++)
440 BOOST_REQUIRE_EQUAL(combs.size(),2ul);
441 BOOST_REQUIRE_EQUAL(isDinstict(combs),
true);
442 BOOST_REQUIRE_EQUAL(isValid(combs),
true);
443 BOOST_REQUIRE_EQUAL(isSubdecomposition(combs,sc3_1[i]),
true);
449 BOOST_REQUIRE_EQUAL(combs.size(),1ul);
450 BOOST_REQUIRE_EQUAL(isDinstict(combs),
true);
451 BOOST_REQUIRE_EQUAL(isValid(combs),
true);
452 BOOST_REQUIRE_EQUAL(isSubdecomposition(combs,sc3_1[i]),
true);
459 for (
size_t i = 0 ; i < sc3_2.size() ; i++)
465 BOOST_REQUIRE_EQUAL(combs.size(),4ul);
466 BOOST_REQUIRE_EQUAL(isDinstict(combs),
true);
467 BOOST_REQUIRE_EQUAL(isValid(combs),
true);
468 BOOST_REQUIRE_EQUAL(isSubdecomposition(combs,sc3_2[i]),
true);
474 BOOST_REQUIRE_EQUAL(combs.size(),4ul);
475 BOOST_REQUIRE_EQUAL(isDinstict(combs),
true);
476 BOOST_REQUIRE_EQUAL(isValid(combs),
true);
477 BOOST_REQUIRE_EQUAL(isSubdecomposition(combs,sc3_2[i]),
true);
483 BOOST_REQUIRE_EQUAL(combs.size(),1ul);
484 BOOST_REQUIRE_EQUAL(isDinstict(combs),
true);
485 BOOST_REQUIRE_EQUAL(isValid(combs),
true);
486 BOOST_REQUIRE_EQUAL(isSubdecomposition(combs,sc3_2[i]),
true);
492 for (
size_t i = 0 ; i < 50 ; i++)
493 {bc[i] = NON_PERIODIC;}
501 BOOST_REQUIRE_EQUAL(sc50_2.size(),6ul);
503 BOOST_REQUIRE_EQUAL(sc50_2[0].c[0],1);
504 BOOST_REQUIRE_EQUAL(sc50_2[0].c[11],0);
505 BOOST_REQUIRE_EQUAL(sc50_2[0].c[17],0);
507 BOOST_REQUIRE_EQUAL(sc50_2[1].c[0],-1);
508 BOOST_REQUIRE_EQUAL(sc50_2[1].c[11],0);
509 BOOST_REQUIRE_EQUAL(sc50_2[1].c[17],0);
511 BOOST_REQUIRE_EQUAL(sc50_2[2].c[0],0);
512 BOOST_REQUIRE_EQUAL(sc50_2[2].c[11],1);
513 BOOST_REQUIRE_EQUAL(sc50_2[2].c[17],0);
515 BOOST_REQUIRE_EQUAL(sc50_2[3].c[0],0);
516 BOOST_REQUIRE_EQUAL(sc50_2[3].c[11],-1);
517 BOOST_REQUIRE_EQUAL(sc50_2[3].c[17],0);
519 BOOST_REQUIRE_EQUAL(sc50_2[4].c[0],0);
520 BOOST_REQUIRE_EQUAL(sc50_2[4].c[11],0);
521 BOOST_REQUIRE_EQUAL(sc50_2[4].c[17],1);
523 BOOST_REQUIRE_EQUAL(sc50_2[5].c[0],0);
524 BOOST_REQUIRE_EQUAL(sc50_2[5].c[11],0);
525 BOOST_REQUIRE_EQUAL(sc50_2[5].c[17],-1);
529 BOOST_REQUIRE_EQUAL(sc50_3.size(),12ul);
531 BOOST_REQUIRE_EQUAL(sc50_3[0].c[0],1);
532 BOOST_REQUIRE_EQUAL(sc50_3[0].c[11],1);
533 BOOST_REQUIRE_EQUAL(sc50_3[0].c[17],0);
535 BOOST_REQUIRE_EQUAL(sc50_3[1].c[0],1);
536 BOOST_REQUIRE_EQUAL(sc50_3[1].c[11],-1);
537 BOOST_REQUIRE_EQUAL(sc50_3[1].c[17],0);
539 BOOST_REQUIRE_EQUAL(sc50_3[2].c[0],-1);
540 BOOST_REQUIRE_EQUAL(sc50_3[2].c[11],1);
541 BOOST_REQUIRE_EQUAL(sc50_3[2].c[17],0);
543 BOOST_REQUIRE_EQUAL(sc50_3[3].c[0],-1);
544 BOOST_REQUIRE_EQUAL(sc50_3[3].c[11],-1);
545 BOOST_REQUIRE_EQUAL(sc50_3[3].c[17],0);
547 BOOST_REQUIRE_EQUAL(sc50_3[4].c[0],1);
548 BOOST_REQUIRE_EQUAL(sc50_3[4].c[11],0);
549 BOOST_REQUIRE_EQUAL(sc50_3[4].c[17],1);
551 BOOST_REQUIRE_EQUAL(sc50_3[5].c[0],1);
552 BOOST_REQUIRE_EQUAL(sc50_3[5].c[11],0);
553 BOOST_REQUIRE_EQUAL(sc50_3[5].c[17],-1);
555 BOOST_REQUIRE_EQUAL(sc50_3[6].c[0],-1);
556 BOOST_REQUIRE_EQUAL(sc50_3[6].c[11],0);
557 BOOST_REQUIRE_EQUAL(sc50_3[6].c[17],1);
559 BOOST_REQUIRE_EQUAL(sc50_3[7].c[0],-1);
560 BOOST_REQUIRE_EQUAL(sc50_3[7].c[11],0);
561 BOOST_REQUIRE_EQUAL(sc50_3[7].c[17],-1);
563 BOOST_REQUIRE_EQUAL(sc50_3[8].c[0],0);
564 BOOST_REQUIRE_EQUAL(sc50_3[8].c[11],1);
565 BOOST_REQUIRE_EQUAL(sc50_3[8].c[17],1);
567 BOOST_REQUIRE_EQUAL(sc50_3[9].c[0],0);
568 BOOST_REQUIRE_EQUAL(sc50_3[9].c[11],1);
569 BOOST_REQUIRE_EQUAL(sc50_3[9].c[17],-1);
571 BOOST_REQUIRE_EQUAL(sc50_3[10].c[0],0);
572 BOOST_REQUIRE_EQUAL(sc50_3[10].c[11],-1);
573 BOOST_REQUIRE_EQUAL(sc50_3[10].c[17],1);
575 BOOST_REQUIRE_EQUAL(sc50_3[11].c[0],0);
576 BOOST_REQUIRE_EQUAL(sc50_3[11].c[11],-1);
577 BOOST_REQUIRE_EQUAL(sc50_3[11].c[17],-1);
581 BOOST_REQUIRE_EQUAL(sc50_4.size(),8ul);
583 BOOST_REQUIRE_EQUAL(sc50_4[0].c[0],1);
584 BOOST_REQUIRE_EQUAL(sc50_4[0].c[11],1);
585 BOOST_REQUIRE_EQUAL(sc50_4[0].c[17],1);
587 BOOST_REQUIRE_EQUAL(sc50_4[1].c[0],1);
588 BOOST_REQUIRE_EQUAL(sc50_4[1].c[11],1);
589 BOOST_REQUIRE_EQUAL(sc50_4[1].c[17],-1);
591 BOOST_REQUIRE_EQUAL(sc50_4[2].c[0],1);
592 BOOST_REQUIRE_EQUAL(sc50_4[2].c[11],-1);
593 BOOST_REQUIRE_EQUAL(sc50_4[2].c[17],1);
595 BOOST_REQUIRE_EQUAL(sc50_4[3].c[0],1);
596 BOOST_REQUIRE_EQUAL(sc50_4[3].c[11],-1);
597 BOOST_REQUIRE_EQUAL(sc50_4[3].c[17],-1);
599 BOOST_REQUIRE_EQUAL(sc50_4[4].c[0],-1);
600 BOOST_REQUIRE_EQUAL(sc50_4[4].c[11],1);
601 BOOST_REQUIRE_EQUAL(sc50_4[4].c[17],1);
603 BOOST_REQUIRE_EQUAL(sc50_4[5].c[0],-1);
604 BOOST_REQUIRE_EQUAL(sc50_4[5].c[11],1);
605 BOOST_REQUIRE_EQUAL(sc50_4[5].c[17],-1);
607 BOOST_REQUIRE_EQUAL(sc50_4[6].c[0],-1);
608 BOOST_REQUIRE_EQUAL(sc50_4[6].c[11],-1);
609 BOOST_REQUIRE_EQUAL(sc50_4[6].c[17],1);
611 BOOST_REQUIRE_EQUAL(sc50_4[7].c[0],-1);
612 BOOST_REQUIRE_EQUAL(sc50_4[7].c[11],-1);
613 BOOST_REQUIRE_EQUAL(sc50_4[7].c[17],-1);
615 std::cout <<
"Hyper-cube unit test end" <<
"\n";
618BOOST_AUTO_TEST_SUITE_END()
This class calculate elements of the hyper-cube.
static std::vector< comb< dim > > getCombinations_R(size_t d)
static void BinPermutationsSt(std::vector< comb< dim > > &v)
Binary permutations.
static size_t getNumberOfElements_R(size_t d)
Get the number of Elements of dimension d.
static std::vector< comb< dim > > getCombinations_R_bc(size_t d, const size_t(&bc)[dim])
static std::vector< comb< dim > > getCombinations_R(comb< dim > c, int d)
Position of the element of dimension d in the hyper-cube of dimension dim.
bool isSub(comb< dim > cmb)
Check if the combination is a sub-element.
signed char c[dim]
Array that store the combination.