| 1 | #ifndef HYPERCUBE_UNIT_TEST_HPP |
| 2 | #define HYPERCUBE_UNIT_TEST_HPP |
| 3 | |
| 4 | #include "Space/Shape/HyperCube.hpp" |
| 5 | #include "util/util_debug.hpp" |
| 6 | |
| 7 | /*! \brief Check if the linearization is correct |
| 8 | * |
| 9 | * \param cmb vector of combination to checl |
| 10 | * |
| 11 | */ |
| 12 | |
| 13 | template<unsigned int dim> void check_lin(std::vector<comb<dim>> cmb) |
| 14 | { |
| 15 | // Check the linearization |
| 16 | for (size_t i = 0 ; i < cmb.size() ; i++) |
| 17 | { |
| 18 | BOOST_REQUIRE_EQUAL(HyperCube<dim>::LinId(cmb[i]),i); |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | /*! \brief Check if the linearization of the permutation is correct |
| 23 | * |
| 24 | * \param cmb vector of combination to checl |
| 25 | * |
| 26 | */ |
| 27 | |
| 28 | template<unsigned int dim> void check_lin_perm(std::vector<comb<dim>> cmb) |
| 29 | { |
| 30 | // Check the linearization |
| 31 | for (size_t i = 0 ; i < cmb.size() ; i++) |
| 32 | { |
| 33 | BOOST_REQUIRE_EQUAL(HyperCube<dim>::LinPerm(cmb[i]),i); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | /*! \brief Check if the combinations are dinstict |
| 38 | * |
| 39 | * \param combs combinations to check |
| 40 | * |
| 41 | */ |
| 42 | |
| 43 | template<unsigned int dim> bool isDinstict(std::vector<comb<dim>> combs) |
| 44 | { |
| 45 | // Check if the combination are dinstinct |
| 46 | |
| 47 | for (size_t i = 0 ; i < combs.size() ; i++) |
| 48 | { |
| 49 | for (size_t j = i+1 ; j < combs.size() ; j++) |
| 50 | { |
| 51 | if (combs[i] == combs[j]) |
| 52 | return false; |
| 53 | } |
| 54 | |
| 55 | } |
| 56 | |
| 57 | return true; |
| 58 | } |
| 59 | |
| 60 | /*! \brief isSubdecomposition check if combs are elements that exist in c as sub-elements |
| 61 | * |
| 62 | * Check if combs are lower dimensional elements of c |
| 63 | * |
| 64 | * \param combs elements to check |
| 65 | * \param c element that must contain all the combs |
| 66 | * |
| 67 | */ |
| 68 | |
| 69 | template<unsigned int dim> bool isSubdecomposition(std::vector<comb<dim>> combs, comb<dim> c) |
| 70 | { |
| 71 | for (size_t i = 0 ; i < combs.size() ; i++) |
| 72 | { |
| 73 | if (c.isSub(combs[i]) == false) |
| 74 | return false; |
| 75 | } |
| 76 | |
| 77 | return true; |
| 78 | } |
| 79 | |
| 80 | template<unsigned int dim> bool isValid(std::vector<comb<dim>> combs) |
| 81 | { |
| 82 | // Check if the combinations are valid |
| 83 | |
| 84 | for (size_t i = 0 ; i < combs.size() ; i++) |
| 85 | { |
| 86 | if (combs[i].isValid() == false) |
| 87 | return false; |
| 88 | } |
| 89 | |
| 90 | return true; |
| 91 | } |
| 92 | |
| 93 | BOOST_AUTO_TEST_SUITE( Hyper_cube ) |
| 94 | |
| 95 | BOOST_AUTO_TEST_CASE( Hyper_cube_comb_use ) |
| 96 | { |
| 97 | { |
| 98 | comb<3> c1({1,2,3}); |
| 99 | comb<3> c2({1,1,1}); |
| 100 | |
| 101 | comb<3> c_ret = c1 - c2; |
| 102 | |
| 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); |
| 106 | } |
| 107 | |
| 108 | { |
| 109 | comb<3> c1({1,2,3}); |
| 110 | comb<3> c2; |
| 111 | c2 = c1 & 0x01; |
| 112 | |
| 113 | BOOST_REQUIRE_EQUAL(c2.c[0],1); |
| 114 | BOOST_REQUIRE_EQUAL(c2.c[1],0); |
| 115 | BOOST_REQUIRE_EQUAL(c2.c[2],1); |
| 116 | } |
| 117 | |
| 118 | { |
| 119 | comb<3> c1({1,2,3}); |
| 120 | comb<3> c2({1,1,1}); |
| 121 | |
| 122 | comb<3> c_ret = c1 + c2; |
| 123 | |
| 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); |
| 127 | } |
| 128 | |
| 129 | { |
| 130 | comb<3> c1({1,2,3}); |
| 131 | |
| 132 | comb<3> c_ret = -c1; |
| 133 | |
| 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); |
| 137 | } |
| 138 | |
| 139 | { |
| 140 | comb<3> c1({-1,1,0}); |
| 141 | |
| 142 | comb<3> c_ret = c1.flip(); |
| 143 | |
| 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); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | BOOST_AUTO_TEST_CASE( Hyper_cube_use) |
| 151 | { |
| 152 | std::cout << "Hyper-cube unit test start" << "\n" ; |
| 153 | // Test Hyper-Cube functionality |
| 154 | |
| 155 | size_t ele[8]; |
| 156 | |
| 157 | //! [Get vertex and edge on a line] |
| 158 | |
| 159 | // Get the number of vertex (elements of dimension 0) of a line (dimension 1) |
| 160 | ele[0] = HyperCube<1>::getNumberOfElements_R(0); |
| 161 | // Get the number of edge (elements of dimension 1) of a line (dimension 1) |
| 162 | ele[1] = HyperCube<1>::getNumberOfElements_R(1); |
| 163 | |
| 164 | // Get combination for each dimensions |
| 165 | std::vector<comb<1>> v_c1_0 = HyperCube<1>::getCombinations_R(0); |
| 166 | |
| 167 | //! [Get vertex and edge on a line] |
| 168 | |
| 169 | // Check |
| 170 | BOOST_REQUIRE_EQUAL(ele[0],2ul); |
| 171 | BOOST_REQUIRE_EQUAL(ele[1],1ul); |
| 172 | |
| 173 | // Fill the expected vector |
| 174 | |
| 175 | comb<1> c[] = {{1},{-1}}; |
| 176 | |
| 177 | // Check the linearization |
| 178 | check_lin(v_c1_0); |
| 179 | |
| 180 | std::vector<comb<1>> v1_st; |
| 181 | HyperCube<1>::BinPermutationsSt(v1_st); |
| 182 | check_lin_perm(v1_st); |
| 183 | |
| 184 | boost_check_array(&c[0],&v_c1_0[0],2); |
| 185 | |
| 186 | //! [Get vertex edge and surfaces of a square] |
| 187 | // Number of vertex |
| 188 | ele[0] = HyperCube<2>::getNumberOfElements_R(0); |
| 189 | // Number of edge |
| 190 | ele[1] = HyperCube<2>::getNumberOfElements_R(1); |
| 191 | // Number of faces |
| 192 | ele[2] = HyperCube<2>::getNumberOfElements_R(2); |
| 193 | |
| 194 | // Get combination for vertex (1,1) (-1,1) (-1,1) (-1,-1) |
| 195 | std::vector<comb<2>> v_c2_0 = HyperCube<2>::getCombinations_R(0); |
| 196 | // Get combination for edges (1,0) (-1,0) (0,1) (0,-1) |
| 197 | std::vector<comb<2>> v_c2_1 = HyperCube<2>::getCombinations_R(1); |
| 198 | |
| 199 | //! [Get vertex edge and surfaces of a square] |
| 200 | |
| 201 | // Check |
| 202 | BOOST_REQUIRE_EQUAL(ele[0],4ul); |
| 203 | BOOST_REQUIRE_EQUAL(ele[1],4ul); |
| 204 | BOOST_REQUIRE_EQUAL(ele[2],1ul); |
| 205 | |
| 206 | // Check combination |
| 207 | |
| 208 | comb<2> c2_0[] = {{1,1},{-1,1},{1,-1},{-1,-1}}; |
| 209 | comb<2> c2_1[] = {{0,1},{0,-1},{1,0},{-1,0}}; |
| 210 | check_lin(v_c2_0); |
| 211 | check_lin(v_c2_1); |
| 212 | |
| 213 | std::vector<comb<2>> v2_st; |
| 214 | HyperCube<2>::BinPermutationsSt(v2_st); |
| 215 | check_lin_perm(v2_st); |
| 216 | |
| 217 | boost_check_array(&c2_0[0],&v_c2_0[0],4); |
| 218 | boost_check_array(&c2_1[0],&v_c2_1[0],4); |
| 219 | |
| 220 | //! [Get vertex edge surfaces and volumes of a cube] |
| 221 | // Number of vertex |
| 222 | ele[0] = HyperCube<3>::getNumberOfElements_R(0); |
| 223 | // Number of edge |
| 224 | ele[1] = HyperCube<3>::getNumberOfElements_R(1); |
| 225 | // Number of faces |
| 226 | ele[2] = HyperCube<3>::getNumberOfElements_R(2); |
| 227 | // Number of Cubes |
| 228 | ele[3] = HyperCube<3>::getNumberOfElements_R(3); |
| 229 | |
| 230 | // Get combination for vertex |
| 231 | std::vector<comb<3>> v_c3_0 = HyperCube<3>::getCombinations_R(0); |
| 232 | // Get combinations for edge |
| 233 | std::vector<comb<3>> v_c3_1 = HyperCube<3>::getCombinations_R(1); |
| 234 | // Get combinations for surfaces |
| 235 | std::vector<comb<3>> v_c3_2 = HyperCube<3>::getCombinations_R(2); |
| 236 | |
| 237 | //! [Get vertex edge surfaces and volumes of a cube] |
| 238 | |
| 239 | // Check |
| 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); |
| 244 | |
| 245 | // Check combination |
| 246 | |
| 247 | comb<3> c3_0[] = {{1,1,1},{-1,1,1},{1,-1,1},{-1,-1,1},{1,1,-1},{-1,1,-1},{1,-1,-1},{-1,-1,-1}}; |
| 248 | comb<3> c3_1[] = {{0,1,1},{0,-1,1},{0,1,-1},{0,-1,-1},{1,0,1},{-1,0,1},{1,0,-1},{-1,0,-1},{1,1,0},{-1,1,0},{1,-1,0},{-1,-1,0}}; |
| 249 | comb<3> c3_2[] = {{{0,0,1}},{{0,0,-1}},{{0,1,0}},{{0,-1,0}},{{1,0,0}},{{-1,0,0}}}; |
| 250 | check_lin(v_c3_0); |
| 251 | check_lin(v_c3_1); |
| 252 | check_lin(v_c3_2); |
| 253 | |
| 254 | std::vector<comb<3>> v3_st; |
| 255 | HyperCube<3>::BinPermutationsSt(v3_st); |
| 256 | check_lin_perm(v3_st); |
| 257 | |
| 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); |
| 261 | |
| 262 | // Tesseract |
| 263 | // Number of vertex |
| 264 | ele[0] = HyperCube<4>::getNumberOfElements_R(0); |
| 265 | // Number of edge |
| 266 | ele[1] = HyperCube<4>::getNumberOfElements_R(1); |
| 267 | // Number of faces |
| 268 | ele[2] = HyperCube<4>::getNumberOfElements_R(2); |
| 269 | // Number of Cubes |
| 270 | ele[3] = HyperCube<4>::getNumberOfElements_R(3); |
| 271 | // Number of Tessaract |
| 272 | ele[4] = HyperCube<4>::getNumberOfElements_R(4); |
| 273 | |
| 274 | // Get combination for each dimensions |
| 275 | std::vector<comb<4>> v_c4_0 = HyperCube<4>::getCombinations_R(0); |
| 276 | std::vector<comb<4>> v_c4_1 = HyperCube<4>::getCombinations_R(1); |
| 277 | std::vector<comb<4>> v_c4_2 = HyperCube<4>::getCombinations_R(2); |
| 278 | std::vector<comb<4>> v_c4_3 = HyperCube<4>::getCombinations_R(3); |
| 279 | check_lin(v_c4_0); |
| 280 | check_lin(v_c4_1); |
| 281 | check_lin(v_c4_2); |
| 282 | check_lin(v_c4_3); |
| 283 | |
| 284 | std::vector<comb<4>> v4_st; |
| 285 | HyperCube<4>::BinPermutationsSt(v4_st); |
| 286 | check_lin_perm(v1_st); |
| 287 | |
| 288 | // Check |
| 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); |
| 294 | |
| 295 | // Penteract |
| 296 | // Number of vertex |
| 297 | ele[0] = HyperCube<5>::getNumberOfElements_R(0); |
| 298 | // Number of edge |
| 299 | ele[1] = HyperCube<5>::getNumberOfElements_R(1); |
| 300 | // Number of faces |
| 301 | ele[2] = HyperCube<5>::getNumberOfElements_R(2); |
| 302 | // Number of Cubes |
| 303 | ele[3] = HyperCube<5>::getNumberOfElements_R(3); |
| 304 | // Number of Tessaract |
| 305 | ele[4] = HyperCube<5>::getNumberOfElements_R(4); |
| 306 | // Number of Penteract |
| 307 | ele[5] = HyperCube<5>::getNumberOfElements_R(5); |
| 308 | |
| 309 | // Get combination for each dimensions |
| 310 | std::vector<comb<5>> v_c5_0 = HyperCube<5>::getCombinations_R(0); |
| 311 | std::vector<comb<5>> v_c5_1 = HyperCube<5>::getCombinations_R(1); |
| 312 | std::vector<comb<5>> v_c5_2 = HyperCube<5>::getCombinations_R(2); |
| 313 | std::vector<comb<5>> v_c5_3 = HyperCube<5>::getCombinations_R(3); |
| 314 | std::vector<comb<5>> v_c5_4 = HyperCube<5>::getCombinations_R(4); |
| 315 | check_lin(v_c5_0); |
| 316 | check_lin(v_c5_1); |
| 317 | check_lin(v_c5_2); |
| 318 | check_lin(v_c5_3); |
| 319 | check_lin(v_c5_4); |
| 320 | |
| 321 | std::vector<comb<5>> v5_st; |
| 322 | HyperCube<5>::BinPermutationsSt(v5_st); |
| 323 | check_lin_perm(v5_st); |
| 324 | |
| 325 | // Check |
| 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); |
| 332 | |
| 333 | |
| 334 | // Test SubHypercube 2D and 3D |
| 335 | |
| 336 | //! [Get the vertices of a square] |
| 337 | std::vector<comb<2>> sc2_0 = HyperCube<2>::getCombinations_R(0); |
| 338 | //! [Get the vertices of a square] |
| 339 | |
| 340 | for (size_t i = 0 ; i < sc2_0.size() ; i++) |
| 341 | { |
| 342 | // Expecting one element equal to c2[i] |
| 343 | //! [Getting the vertex as a sub-hypercube] |
| 344 | std::vector<comb<2>> combs = SubHyperCube<2,0>::getCombinations_R(sc2_0[i],0); |
| 345 | //! [Getting the vertex as a sub-hypercube] |
| 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); |
| 350 | } |
| 351 | |
| 352 | //! [Getting the edge of a square] |
| 353 | std::vector<comb<2>> sc2_1 = HyperCube<2>::getCombinations_R(1); |
| 354 | //! [Getting the edge of a square] |
| 355 | |
| 356 | for (size_t i = 0 ; i < sc2_1.size() ; i++) |
| 357 | { |
| 358 | // Expecting two elements, valid, distinct, sub-decomposition of c2[i] |
| 359 | |
| 360 | //! [Getting the vertex of the line of the original square] |
| 361 | std::vector<comb<2>> combs = SubHyperCube<2,1>::getCombinations_R(sc2_1[i],0); |
| 362 | //! [Getting the vertex of the line of the original square] |
| 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); |
| 367 | |
| 368 | // Expecting one element, valid, distinct, sub-decomposition of c2[i] |
| 369 | //! [Getting the edge(line) of the line of the original square] |
| 370 | combs = SubHyperCube<2,1>::getCombinations_R(sc2_1[i],1); |
| 371 | //! [Getting the edge(line) of the line of the original square] |
| 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); |
| 376 | } |
| 377 | |
| 378 | //! [Getting the square of a square] |
| 379 | std::vector<comb<2>> sc2_2 = HyperCube<2>::getCombinations_R(2); |
| 380 | //! [Getting the square of a square] |
| 381 | |
| 382 | for (size_t i = 0 ; i < sc2_2.size() ; i++) |
| 383 | { |
| 384 | // Expecting two elements, valid, distinct, sub-decomposition of sc2_2[i] |
| 385 | //! [Getting the vertices of the square of the original square] |
| 386 | std::vector<comb<2>> combs = SubHyperCube<2,2>::getCombinations_R(sc2_2[i],0); |
| 387 | //! [Getting the vertices of the square of the original square] |
| 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); |
| 392 | |
| 393 | // Expecting one element, valid, distinct, sub-decomposition of c2[i] |
| 394 | //! [Getting the lines of the square of the original square] |
| 395 | combs = SubHyperCube<2,2>::getCombinations_R(sc2_2[i],1); |
| 396 | //! [Getting the lines of the square of the original square] |
| 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); |
| 401 | |
| 402 | // Expecting one element, valid, distinct, sub-decomposition of c2[i] |
| 403 | //! [Getting the square of the square of the original square] |
| 404 | combs = SubHyperCube<2,2>::getCombinations_R(sc2_2[i],2); |
| 405 | //! [Getting the square of the square of the original square] |
| 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); |
| 410 | } |
| 411 | |
| 412 | ////////////// 3D //////////////// |
| 413 | |
| 414 | //! [Getting the vertices of the cube] |
| 415 | std::vector<comb<3>> sc3_0 = HyperCube<3>::getCombinations_R(0); |
| 416 | //! [Getting the vertices of the cube] |
| 417 | |
| 418 | for (size_t i = 0 ; i < sc3_0.size() ; i++) |
| 419 | { |
| 420 | // Expecting one element equal to sc3[i] |
| 421 | //! [Getting the vertices of the vertices of the cube] |
| 422 | std::vector<comb<3>> combs = SubHyperCube<3,0>::getCombinations_R(sc3_0[i],0); |
| 423 | //! [Getting the vertices of the vertices of the cube] |
| 424 | BOOST_REQUIRE_EQUAL(combs.size(),1ul); |
| 425 | BOOST_REQUIRE_EQUAL(isDinstict(combs),true); |
| 426 | BOOST_REQUIRE_EQUAL(isValid(combs),true); |
| 427 | // BOOST_REQUIRE_EQUAL(isSubdecomposition(combs,sc3_0[i]),true); |
| 428 | } |
| 429 | |
| 430 | //! [Getting the edges of the cube] |
| 431 | std::vector<comb<3>> sc3_1 = HyperCube<3>::getCombinations_R(1); |
| 432 | //! [Getting the edges of the cube] |
| 433 | |
| 434 | for (size_t i = 0 ; i < sc3_1.size() ; i++) |
| 435 | { |
| 436 | // Expecting two elements, valid, distinct, sub-decomposition of sc3[i] |
| 437 | //! [Getting the vertices of the edge of the cube] |
| 438 | std::vector<comb<3>> combs = SubHyperCube<3,1>::getCombinations_R(sc3_1[i],0); |
| 439 | //! [Getting the vertices of the vertices of the cube] |
| 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); |
| 444 | |
| 445 | // Expecting one element, valid, distinct, sub-decomposition of c2[i] |
| 446 | //! [Getting the edges of the edges of the cube] |
| 447 | combs = SubHyperCube<3,1>::getCombinations_R(sc3_1[i],1); |
| 448 | //! [Getting the edges of the edges of the cube] |
| 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); |
| 453 | } |
| 454 | |
| 455 | //! [Getting the surfaces of the cube] |
| 456 | std::vector<comb<3>> sc3_2 = HyperCube<3>::getCombinations_R(2); |
| 457 | //! [Getting the surfaces of the cube] |
| 458 | |
| 459 | for (size_t i = 0 ; i < sc3_2.size() ; i++) |
| 460 | { |
| 461 | // Expecting two elements, valid, distinct, sub-decomposition of sc3_2[i] |
| 462 | //! [Getting the vertices of one surface of the cube] |
| 463 | std::vector<comb<3>> combs = SubHyperCube<3,2>::getCombinations_R(sc3_2[i],0); |
| 464 | //! [Getting the vertices of one surface of the cube] |
| 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); |
| 469 | |
| 470 | // Expecting one element, valid, distinct, sub-decomposition of c2[i] |
| 471 | //! [Getting the edges of the surfaces of the cube] |
| 472 | combs = SubHyperCube<3,2>::getCombinations_R(sc3_2[i],1); |
| 473 | //! [Getting the edges of the surfaces of the cube] |
| 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); |
| 478 | |
| 479 | // Expecting one element, valid, distinct, sub-decomposition of c2[i] |
| 480 | //! [Getting the surfaces of the surfaces of the cube] |
| 481 | combs = SubHyperCube<3,2>::getCombinations_R(sc3_2[i],2); |
| 482 | //! [Getting the surfaces of the surfaces of the cube] |
| 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); |
| 487 | } |
| 488 | |
| 489 | // High dimension test |
| 490 | size_t bc[50]; |
| 491 | |
| 492 | for (size_t i = 0 ; i < 50 ; i++) |
| 493 | {bc[i] = NON_PERIODIC;} |
| 494 | |
| 495 | bc[0] = PERIODIC; |
| 496 | bc[11] = PERIODIC; |
| 497 | bc[17] = PERIODIC; |
| 498 | |
| 499 | std::vector<comb<50>> sc50_2 = HyperCube<50>::getCombinations_R_bc(49,bc); |
| 500 | |
| 501 | BOOST_REQUIRE_EQUAL(sc50_2.size(),6ul); |
| 502 | |
| 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); |
| 506 | |
| 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); |
| 510 | |
| 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); |
| 514 | |
| 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); |
| 518 | |
| 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); |
| 522 | |
| 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); |
| 526 | |
| 527 | std::vector<comb<50>> sc50_3 = HyperCube<50>::getCombinations_R_bc(48,bc); |
| 528 | |
| 529 | BOOST_REQUIRE_EQUAL(sc50_3.size(),12ul); |
| 530 | |
| 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); |
| 534 | |
| 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); |
| 538 | |
| 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); |
| 542 | |
| 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); |
| 546 | |
| 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); |
| 550 | |
| 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); |
| 554 | |
| 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); |
| 558 | |
| 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); |
| 562 | |
| 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); |
| 566 | |
| 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); |
| 570 | |
| 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); |
| 574 | |
| 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); |
| 578 | |
| 579 | std::vector<comb<50>> sc50_4 = HyperCube<50>::getCombinations_R_bc(47,bc); |
| 580 | |
| 581 | BOOST_REQUIRE_EQUAL(sc50_4.size(),8ul); |
| 582 | |
| 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); |
| 586 | |
| 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); |
| 590 | |
| 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); |
| 594 | |
| 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); |
| 598 | |
| 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); |
| 602 | |
| 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); |
| 606 | |
| 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); |
| 610 | |
| 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); |
| 614 | |
| 615 | std::cout << "Hyper-cube unit test end" << "\n" ; |
| 616 | } |
| 617 | |
| 618 | BOOST_AUTO_TEST_SUITE_END() |
| 619 | |
| 620 | #endif |
| 621 | |