diff --git a/include/bmat8.hpp b/include/bmat8.hpp index 10eda02e..edc8e554 100644 --- a/include/bmat8.hpp +++ b/include/bmat8.hpp @@ -301,15 +301,10 @@ class BMat8 { //! This method returns the 8 x 8 BMat8 with 1s on the main diagonal. static BMat8 one(size_t dim = 8) { HPCOMBI_ASSERT(dim <= 8); - static std::array const ones = {0x0000000000000000, - 0x8000000000000000, - 0x8040000000000000, - 0x8040200000000000, - 0x8040201000000000, - 0x8040201008000000, - 0x8040201008040000, - 0x8040201008040200, - 0x8040201008040201}; + static std::array const ones = { + 0x0000000000000000, 0x8000000000000000, 0x8040000000000000, + 0x8040200000000000, 0x8040201000000000, 0x8040201008000000, + 0x8040201008040000, 0x8040201008040200, 0x8040201008040201}; return BMat8(ones[dim]); } @@ -328,7 +323,7 @@ class BMat8 { void swap(BMat8 &that) { std::swap(this->_data, that._data); } //! Write \c this on \c os - std::ostream & write(std::ostream &os) const; + std::ostream &write(std::ostream &os) const; #ifdef LIBSEMIGROUPS_DENSEHASHMAP // FIXME do this another way diff --git a/include/bmat8_impl.hpp b/include/bmat8_impl.hpp index 5d848210..2978dd36 100644 --- a/include/bmat8_impl.hpp +++ b/include/bmat8_impl.hpp @@ -156,7 +156,6 @@ inline BMat8 BMat8::transpose() const { return BMat8(x); } - inline BMat8 BMat8::transpose_mask() const { epu8 x = _mm_set_epi64x(_data, _data << 1); uint64_t res = _mm_movemask_epi8(x); @@ -177,35 +176,34 @@ inline BMat8 BMat8::transpose_maskd() const { return BMat8(res); } - -using epu64 = uint64_t __attribute__ ((__vector_size__ (16), __may_alias__)); +using epu64 = uint64_t __attribute__((__vector_size__(16), __may_alias__)); inline void BMat8::transpose2(BMat8 &a, BMat8 &b) { epu64 x = _mm_set_epi64x(a._data, b._data); - epu64 y = (x ^ (x >> 7)) & (epu64 {0xAA00AA00AA00AA, 0xAA00AA00AA00AA}); + epu64 y = (x ^ (x >> 7)) & (epu64{0xAA00AA00AA00AA, 0xAA00AA00AA00AA}); x = x ^ y ^ (y << 7); - y = (x ^ (x >> 14)) & (epu64 {0xCCCC0000CCCC, 0xCCCC0000CCCC}); + y = (x ^ (x >> 14)) & (epu64{0xCCCC0000CCCC, 0xCCCC0000CCCC}); x = x ^ y ^ (y << 14); - y = (x ^ (x >> 28)) & (epu64 {0xF0F0F0F0, 0xF0F0F0F0}); + y = (x ^ (x >> 28)) & (epu64{0xF0F0F0F0, 0xF0F0F0F0}); x = x ^ y ^ (y << 28); a._data = _mm_extract_epi64(x, 1); b._data = _mm_extract_epi64(x, 0); } -static constexpr epu8 rotlow { 7, 0, 1, 2, 3, 4, 5, 6}; -static constexpr epu8 rothigh - { 0, 1, 2, 3, 4, 5, 6, 7,15, 8, 9,10,11,12,13,14}; -static constexpr epu8 rotboth - { 7, 0, 1, 2, 3, 4, 5, 6,15, 8, 9,10,11,12,13,14}; -static constexpr epu8 rot2 - { 6, 7, 0, 1, 2, 3, 4, 5,14,15, 8, 9,10,11,12,13}; +static constexpr epu8 rotlow{7, 0, 1, 2, 3, 4, 5, 6}; +static constexpr epu8 rothigh{0, 1, 2, 3, 4, 5, 6, 7, + 15, 8, 9, 10, 11, 12, 13, 14}; +static constexpr epu8 rotboth{7, 0, 1, 2, 3, 4, 5, 6, + 15, 8, 9, 10, 11, 12, 13, 14}; +static constexpr epu8 rot2{6, 7, 0, 1, 2, 3, 4, 5, + 14, 15, 8, 9, 10, 11, 12, 13}; inline BMat8 BMat8::mult_transpose(BMat8 const &that) const { epu8 x = _mm_set_epi64x(_data, _data); epu8 y = _mm_shuffle_epi8(_mm_set_epi64x(that._data, that._data), rothigh); - epu8 data {}; - epu8 diag {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, - 0x80, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40}; + epu8 data{}; + epu8 diag{0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, + 0x80, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40}; for (int i = 0; i < 4; ++i) { data |= ((x & y) != epu8{}) & diag; y = _mm_shuffle_epi8(y, rot2); @@ -218,7 +216,7 @@ inline epu8 BMat8::row_space_basis_internal() const { epu8 res = remove_dups(revsorted8(_mm_set_epi64x(0, _data))); epu8 rescy = res; // We now compute the union of all the included different rows - epu8 orincl {}; + epu8 orincl{}; for (int i = 0; i < 7; i++) { rescy = permuted(rescy, rotlow); orincl |= ((rescy | res) == res) & rescy; @@ -236,8 +234,8 @@ inline BMat8 BMat8::row_space_basis() const { #endif /* FF */ #define FF 0xff -constexpr std::array masks {{ -// clang-format off +constexpr std::array masks{ + {// clang-format off {FF, 0,FF, 0,FF, 0,FF, 0,FF, 0,FF, 0,FF, 0,FF, 0}, {FF,FF, 1, 1,FF,FF, 1, 1,FF,FF, 1, 1,FF,FF, 1, 1}, {FF,FF,FF,FF, 2, 2, 2, 2,FF,FF,FF,FF, 2, 2, 2, 2}, diff --git a/include/epu.hpp b/include/epu.hpp index a3e13a88..c4f57726 100644 --- a/include/epu.hpp +++ b/include/epu.hpp @@ -44,7 +44,6 @@ #define HPCOMBI_CONSTEXPR_CONSTRUCTOR #endif - namespace HPCombi { /// Unsigned 8 bits int constant. @@ -64,7 +63,6 @@ using xpu8 = uint8_t __attribute__((vector_size(32))); static_assert(alignof(xpu8) == 32, "xpu8 type is not properly aligned by the compiler !"); - namespace { // Implementation detail code /// A handmade C++11 constexpr lambda @@ -136,15 +134,12 @@ uint8_t right_dup_fun(uint8_t i) { return i == 0 ? 0 : i - 1; } HPCOMBI_CONSTEXPR uint8_t complement_fun(uint8_t i) { return 15 - i; } HPCOMBI_CONSTEXPR uint8_t popcount4_fun(uint8_t i) { - return ((i & 1) != 0 ? 1 : 0) - + ((i & 2) != 0 ? 1 : 0) - + ((i & 4) != 0 ? 1 : 0) - + ((i & 8) != 0 ? 1 : 0); + return ((i & 1) != 0 ? 1 : 0) + ((i & 2) != 0 ? 1 : 0) + + ((i & 4) != 0 ? 1 : 0) + ((i & 8) != 0 ? 1 : 0); } } // Anonymous namespace - /// Factory object for various SIMD constants in particular constexpr TPUBuild Epu8; @@ -258,13 +253,12 @@ inline epu8 revsorted8(epu8 a); * @details * @par Algorithm: Uses a 9 stages sorting network #sorting_rounds8 */ -inline epu8 sort_perm(epu8 & a); +inline epu8 sort_perm(epu8 &a); /** Sort \c this and return the sorting permutation * @details * @par Algorithm: Uses a 9 stages sorting network #sorting_rounds8 */ -inline epu8 sort8_perm(epu8 & a); - +inline epu8 sort8_perm(epu8 &a); /** Find if a vector is a permutation of one other * @details @@ -358,7 +352,6 @@ inline epu8 partial_sums_round(epu8); /** @copydoc common_partial_sums */ inline epu8 partial_sums(epu8 v) { return partial_sums_round(v); } - /** @class common_horiz_max * @brief Horizontal sum of a #HPCombi::epu8 * @details @@ -422,7 +415,6 @@ inline epu8 partial_max_round(epu8); /** @copydoc common_partial_max */ inline epu8 partial_max(epu8 v) { return partial_max_round(v); } - /** @class common_horiz_min * @brief Horizontal sum of a #HPCombi::epu8 * @details @@ -486,7 +478,6 @@ inline epu8 partial_min_round(epu8); /** @copydoc common_partial_min */ inline epu8 partial_min(epu8 v) { return partial_min_round(v); } - /** @class common_eval16 * @brief Evaluation of a #HPCombi::epu8 * @details @@ -710,7 +701,7 @@ inline std::ostream &operator<<(std::ostream &stream, HPCombi::epu8 const &a); * - std::hash * - std::less */ -} +} // namespace std #include "epu_impl.hpp" diff --git a/include/epu_impl.hpp b/include/epu_impl.hpp index a7d23318..fbf49b6f 100644 --- a/include/epu_impl.hpp +++ b/include/epu_impl.hpp @@ -92,18 +92,17 @@ inline char less_partial(epu8 a, epu8 b, int k) { : static_cast(a[diff]) - static_cast(b[diff]); } - inline uint64_t first_zero(epu8 v, int bnd) { - return first_mask(v == epu8 {}, bnd); + return first_mask(v == epu8{}, bnd); } inline uint64_t last_zero(epu8 v, int bnd) { - return last_mask(v == epu8 {}, bnd); + return last_mask(v == epu8{}, bnd); } inline uint64_t first_non_zero(epu8 v, int bnd) { - return first_mask(v != epu8 {}, bnd); + return first_mask(v != epu8{}, bnd); } inline uint64_t last_non_zero(epu8 v, int bnd) { - return last_mask(v != epu8 {}, bnd); + return last_mask(v != epu8{}, bnd); } /// Apply a sorting network @@ -180,15 +179,9 @@ constexpr std::array sorting_rounds8 inline bool is_sorted(epu8 a) { return _mm_movemask_epi8(shifted_right(a) > a) == 0; } -inline epu8 sorted(epu8 a) { - return network_sort(a, sorting_rounds); -} -inline epu8 sorted8(epu8 a) { - return network_sort(a, sorting_rounds8); -} -inline epu8 revsorted(epu8 a) { - return network_sort(a, sorting_rounds); -} +inline epu8 sorted(epu8 a) { return network_sort(a, sorting_rounds); } +inline epu8 sorted8(epu8 a) { return network_sort(a, sorting_rounds8); } +inline epu8 revsorted(epu8 a) { return network_sort(a, sorting_rounds); } inline epu8 revsorted8(epu8 a) { return network_sort(a, sorting_rounds8); } @@ -200,7 +193,6 @@ inline epu8 sort8_perm(epu8 &a) { return network_sort_perm(a, sorting_rounds8); } - inline epu8 random_epu8(uint16_t bnd) { epu8 res; std::random_device rd; @@ -219,7 +211,7 @@ inline epu8 remove_dups(epu8 v, uint8_t repl) { } // Gather at the front numbers with (3-i)-th bit not set. -constexpr std::array inverting_rounds {{ +constexpr std::array inverting_rounds{{ // clang-format off // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 epu8 { 0, 1, 2, 3, 8, 9, 10, 11, 4, 5, 6, 7, 12, 13, 14, 15}, @@ -244,14 +236,13 @@ inline epu8 permutation_of(epu8 a, epu8 b) { return res; } - #if defined(FF) #error FF is defined ! #endif /* FF */ #define FF 0xff /// Permutation Round for partial and horizontal sums -constexpr std::array summing_rounds {{ +constexpr std::array summing_rounds{{ // clang-format off // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 epu8 { FF, 0, FF, 2, FF, 4, FF, 6, FF, 8, FF, 10, FF, 12, FF, 14}, @@ -261,7 +252,7 @@ constexpr std::array summing_rounds {{ // clang-format on }}; -constexpr std::array mining_rounds {{ +constexpr std::array mining_rounds{{ // clang-format off // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 epu8 { 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14}, @@ -306,7 +297,6 @@ inline epu8 partial_sums_round(epu8 v) { return v; } - inline uint8_t horiz_max_ref(epu8 v) { uint8_t res = 0; for (size_t i = 0; i < 16; i++) @@ -340,7 +330,6 @@ inline epu8 partial_max_round(epu8 v) { return v; } - inline uint8_t horiz_min_ref(epu8 v) { uint8_t res = 255; for (size_t i = 0; i < 16; i++) @@ -361,7 +350,7 @@ inline epu8 partial_min_ref(epu8 v) { epu8 res; res[0] = v[0]; for (size_t i = 1; i < 16; i++) - res[i] = std::min(res[i - 1], v[i]) ; + res[i] = std::min(res[i - 1], v[i]); return res; } inline epu8 partial_min_gen(epu8 v) { @@ -374,7 +363,6 @@ inline epu8 partial_min_round(epu8 v) { return v; } - inline epu8 eval16_ref(epu8 v) { epu8 res{}; for (size_t i = 0; i < 16; i++) @@ -409,24 +397,22 @@ inline epu8 eval16_popcount(epu8 v) { return res; } - -inline epu8 popcount16(epu8 v){ +inline epu8 popcount16(epu8 v) { return permuted(popcount4, (v & Epu8(0x0f))) + permuted(popcount4, v >> 4); } - inline bool is_partial_transformation(epu8 v, const size_t k) { uint64_t diff = last_diff(v, epu8id, 16); // (forall x in v, x + 1 <= 16) and // (v = Perm16::one() or last diff index < 16) - return (_mm_movemask_epi8(v + Epu8(1) <= Epu8(0x10)) == 0xffff) - && (diff == 16 || diff < k); + return (_mm_movemask_epi8(v + Epu8(1) <= Epu8(0x10)) == 0xffff) && + (diff == 16 || diff < k); } inline bool is_transformation(epu8 v, const size_t k) { uint64_t diff = last_diff(v, epu8id, 16); - return (_mm_movemask_epi8(v < Epu8(0x10)) == 0xffff) - && (diff == 16 || diff < k); + return (_mm_movemask_epi8(v < Epu8(0x10)) == 0xffff) && + (diff == 16 || diff < k); } inline bool is_partial_permutation(epu8 v, const size_t k) { @@ -434,9 +420,9 @@ inline bool is_partial_permutation(epu8 v, const size_t k) { // (forall x in v, x <= 15) and // (forall x < 15, multiplicity x v <= 1 // (v = Perm16::one() or last diff index < 16) - return (_mm_movemask_epi8(v + Epu8(1) <= Epu8(0x10)) == 0xffff) - && (_mm_movemask_epi8(eval16(v) <= Epu8(1)) == 0xffff) - && (diff == 16 || diff < k); + return (_mm_movemask_epi8(v + Epu8(1) <= Epu8(0x10)) == 0xffff) && + (_mm_movemask_epi8(eval16(v) <= Epu8(1)) == 0xffff) && + (diff == 16 || diff < k); } inline bool is_permutation(epu8 v, const size_t k) { @@ -444,9 +430,9 @@ inline bool is_permutation(epu8 v, const size_t k) { // (forall x in v, x in Perm16::one()) and // (forall x in Perm16::one(), x in v) and // (v = Perm16::one() or last diff index < 16) - return _mm_cmpestri(epu8id, 16, v, 16, FIRST_NON_ZERO) == 16 - && _mm_cmpestri(v, 16, epu8id, 16, FIRST_NON_ZERO) == 16 - && (diff == 16 || diff < k); + return _mm_cmpestri(epu8id, 16, v, 16, FIRST_NON_ZERO) == 16 && + _mm_cmpestri(v, 16, epu8id, 16, FIRST_NON_ZERO) == 16 && + (diff == 16 || diff < k); } } // namespace HPCombi diff --git a/include/hpcombi.hpp b/include/hpcombi.hpp index 043bb8b3..89b4743f 100644 --- a/include/hpcombi.hpp +++ b/include/hpcombi.hpp @@ -16,8 +16,8 @@ #ifndef HPCOMBI_HPCOMBI_HPP_INCLUDED #define HPCOMBI_HPCOMBI_HPP_INCLUDED +#include "bmat8.hpp" #include "epu.hpp" #include "perm16.hpp" -#include "bmat8.hpp" #endif // HPCOMBI_HPCOMBI_HPP_INCLUDED diff --git a/include/perm16.hpp b/include/perm16.hpp index 3befac9a..1c35f7e4 100644 --- a/include/perm16.hpp +++ b/include/perm16.hpp @@ -53,7 +53,10 @@ struct alignas(16) PTransf16 : public Vect16 { PTransf16(std::initializer_list il); PTransf16 &operator=(const PTransf16 &) = default; - PTransf16 &operator=(const epu8 &vv) { v = vv; return *this; } + PTransf16 &operator=(const epu8 &vv) { + v = vv; + return *this; + } //! Return whether \c *this is a well constructed object bool validate(size_t k = 16) const { @@ -68,13 +71,13 @@ struct alignas(16) PTransf16 : public Vect16 { } /** Returns a mask for the image of \c *this */ - epu8 image_mask(bool complement=false) const; + epu8 image_mask(bool complement = false) const; /** Returns a bit mask for the image of \c *this */ - uint32_t image_bitset(bool complement=false) const; + uint32_t image_bitset(bool complement = false) const; /** Returns a mask for the domain of \c *this */ - epu8 domain_mask(bool complement=false) const; + epu8 domain_mask(bool complement = false) const; /** Returns a bit mask for the domain of \c *this */ - uint32_t domain_bitset(bool complement=false) const; + uint32_t domain_bitset(bool complement = false) const; /** Returns the partial right identity for \c *this */ PTransf16 right_one() const; @@ -87,9 +90,9 @@ struct alignas(16) PTransf16 : public Vect16 { uint32_t rank() const; /** Returns a mask for the fix point of \c *this */ - epu8 fix_points_mask(bool complement=false) const; + epu8 fix_points_mask(bool complement = false) const; /** Returns a bit mask for the fix point of \c *this */ - uint32_t fix_points_bitset(bool complement=false) const; + uint32_t fix_points_bitset(bool complement = false) const; /** Returns the smallest fix point of \c *this */ uint8_t smallest_fix_point() const; /** Returns the smallest non fix point of \c *this */ @@ -142,7 +145,8 @@ struct PPerm16 : public PTransf16 { HPCOMBI_CONSTEXPR_CONSTRUCTOR PPerm16(const vect v) : PTransf16(v) {} HPCOMBI_CONSTEXPR_CONSTRUCTOR PPerm16(const epu8 x) : PTransf16(x) {} PPerm16(std::vector dom, std::vector rng, - size_t = 0 /* unused */) : PTransf16(dom, rng) {} + size_t = 0 /* unused */) + : PTransf16(dom, rng) {} PPerm16(std::initializer_list il) : PTransf16(il) {} PPerm16 &operator=(const PPerm16 &) = default; @@ -170,7 +174,8 @@ struct PPerm16 : public PTransf16 { * x.inverse() * @endcode * Returns - * @verbatim {0,0xFF,2,1,3,5,6,0xFF,8,9,0xFF,10,12,0xFF,0xFF,0xFF} @endverbatim + * @verbatim {0,0xFF,2,1,3,5,6,0xFF,8,9,0xFF,10,12,0xFF,0xFF,0xFF} + * @endverbatim */ /** @copydoc common_inverse_pperm * @par Algorithm: @@ -201,9 +206,7 @@ struct Perm16 : public Transf16 /* public PPerm : diamond problem */ { Perm16(std::initializer_list il) : Transf16(il) {} //! Return whether \c *this is a well constructed object - bool validate(size_t k = 16) const { - return HPCombi::is_permutation(v, k); - } + bool validate(size_t k = 16) const { return HPCombi::is_permutation(v, k); } // It's not possible to have a static constexpr member of same type as class // being defined (see https://stackoverflow.com/questions/11928089/) @@ -424,7 +427,6 @@ struct Perm16 : public Transf16 /* public PPerm : diamond problem */ { * @f$O(n)@f$ algorithm using length */ bool left_weak_leq(Perm16 other) const; - }; /*****************************************************************************/ @@ -465,9 +467,7 @@ template <> struct hash { template <> struct hash { //! A hash operator for #HPCombi::Perm16 - size_t operator()(const HPCombi::Perm16 &ar) const { - return uint64_t(ar); - } + size_t operator()(const HPCombi::Perm16 &ar) const { return uint64_t(ar); } }; } // namespace std diff --git a/include/perm16_impl.hpp b/include/perm16_impl.hpp index 3e66a6aa..f12fd69c 100644 --- a/include/perm16_impl.hpp +++ b/include/perm16_impl.hpp @@ -22,7 +22,7 @@ #include // lcm until c++17 #else #include "fallback/gcdlcm.hpp" // lcm until c++17 -#endif // HAVE_EXPERIMENTAL_NUMERIC_LCM +#endif // HAVE_EXPERIMENTAL_NUMERIC_LCM namespace HPCombi { @@ -30,14 +30,15 @@ namespace HPCombi { /** Implementation part for inline functions *********************************/ /*****************************************************************************/ -inline PTransf16::PTransf16(std::initializer_list il) : Vect16(epu8id) { +inline PTransf16::PTransf16(std::initializer_list il) + : Vect16(epu8id) { assert(il.size() <= 16); std::copy(il.begin(), il.end(), HPCombi::as_array(v).begin()); } -inline PTransf16::PTransf16(std::vector dom, - std::vector rng, size_t /*unused */) : - Vect16(Epu8(0xFF)) { +inline PTransf16::PTransf16(std::vector dom, std::vector rng, + size_t /*unused */) + : Vect16(Epu8(0xFF)) { assert(dom.size() == rng.size()); assert(dom.size() <= 16); for (size_t i = 0; i < dom.size(); ++i) { @@ -97,12 +98,14 @@ inline uint8_t PTransf16::smallest_moved_point() const { } /** Returns the largest fix point of \c *this */ inline uint8_t PTransf16::largest_fix_point() const { - uint32_t res = fix_points_bitset(false);; + uint32_t res = fix_points_bitset(false); + ; return res == 0 ? 0xFF : _bit_scan_reverse(res); } /** Returns the largest non fix point of \c *this */ inline uint8_t PTransf16::largest_moved_point() const { - uint32_t res = fix_points_bitset(true);; + uint32_t res = fix_points_bitset(true); + ; return res == 0 ? 0xFF : _bit_scan_reverse(res); } /** Returns the number of fix points of \c *this */ diff --git a/include/perm_generic.hpp b/include/perm_generic.hpp index a9fa2125..6f868de0 100644 --- a/include/perm_generic.hpp +++ b/include/perm_generic.hpp @@ -32,7 +32,7 @@ struct PermGeneric : public VectGeneric<_Size, Expo> { static constexpr size_t size() { return _Size; } PermGeneric() = default; - PermGeneric(const vect v) : vect(v) {}; + PermGeneric(const vect v) : vect(v){}; PermGeneric(std::initializer_list il); PermGeneric operator*(const PermGeneric &p) const { @@ -41,7 +41,7 @@ struct PermGeneric : public VectGeneric<_Size, Expo> { static PermGeneric one() { return PermGeneric({}); } static PermGeneric elementary_transposition(uint64_t i); - PermGeneric inverse() const ; + PermGeneric inverse() const; static PermGeneric random(); vect lehmer() const; @@ -50,7 +50,6 @@ struct PermGeneric : public VectGeneric<_Size, Expo> { uint64_t nb_cycles() const; bool left_weak_leq(PermGeneric other) const; - }; /*****************************************************************************/ diff --git a/include/perm_generic_impl.hpp b/include/perm_generic_impl.hpp index 525f5de7..f61e6b30 100644 --- a/include/perm_generic_impl.hpp +++ b/include/perm_generic_impl.hpp @@ -34,16 +34,15 @@ PermGeneric<_Size, Expo>::elementary_transposition(uint64_t i) { } template -PermGeneric<_Size, Expo> -PermGeneric<_Size, Expo>::inverse() const { +PermGeneric<_Size, Expo> PermGeneric<_Size, Expo>::inverse() const { PermGeneric res; - for (uint64_t i = 0; i < _Size; i++) res[this->v[i]] = i; + for (uint64_t i = 0; i < _Size; i++) + res[this->v[i]] = i; return res; } template -PermGeneric<_Size, Expo> -PermGeneric<_Size, Expo>::random() { +PermGeneric<_Size, Expo> PermGeneric<_Size, Expo>::random() { PermGeneric res{{}}; std::random_shuffle(res.v.begin(), res.v.end()); return res; @@ -116,4 +115,3 @@ struct hash> { }; } // namespace std - diff --git a/include/vect16.hpp b/include/vect16.hpp index 06e43181..bded8590 100644 --- a/include/vect16.hpp +++ b/include/vect16.hpp @@ -35,7 +35,10 @@ struct alignas(16) Vect16 { HPCOMBI_CONSTEXPR_CONSTRUCTOR operator epu8() const { return v; } Vect16 &operator=(const Vect16 &) = default; - Vect16 &operator=(const epu8 &vv) { v = vv; return *this; } + Vect16 &operator=(const epu8 &vv) { + v = vv; + return *this; + } array &as_array() { return HPCombi::as_array(v); } const array &as_array() const { return HPCombi::as_array(v); } @@ -79,9 +82,7 @@ struct alignas(16) Vect16 { char less_partial(const Vect16 &b, int k) const { return HPCombi::less_partial(v, b.v, k); }; - Vect16 permuted(const Vect16 &b) const { - return HPCombi::permuted(v, b.v); - } + Vect16 permuted(const Vect16 &b) const { return HPCombi::permuted(v, b.v); } uint8_t sum() const { return HPCombi::horiz_sum(v); } Vect16 partial_sums() const { return HPCombi::partial_sums(v); }; Vect16 eval16() const { return HPCombi::eval16(v); }; @@ -90,8 +91,6 @@ struct alignas(16) Vect16 { bool is_permutation(size_t k) const { return HPCombi::is_permutation(v, k); } - - }; static_assert(std::is_trivial(), "Vect16 is not a trivial class !"); diff --git a/tests/test_bmat8.cpp b/tests/test_bmat8.cpp index b863d9d9..898a8bc6 100644 --- a/tests/test_bmat8.cpp +++ b/tests/test_bmat8.cpp @@ -15,112 +15,113 @@ #define BOOST_TEST_MODULE BMAT8Tests -#include #include +#include #include -#include "epu.hpp" #include "bmat8.hpp" +#include "epu.hpp" #include using namespace HPCombi; -#define EPU8_EQUAL(p1, p2) BOOST_CHECK_PREDICATE(equal, (p1)(p2)) -#define EPU8_NOT_EQUAL(p1, p2) BOOST_CHECK_PREDICATE(boost::not2(equal), (p1)(p2)) +#define EPU8_EQUAL(p1, p2) BOOST_CHECK_PREDICATE(equal, (p1)(p2)) +#define EPU8_NOT_EQUAL(p1, p2) \ + BOOST_CHECK_PREDICATE(boost::not2(equal), (p1)(p2)) -#define TEST_AGREES(type, ref, fun, vct) \ - BOOST_FIXTURE_TEST_CASE(type##_agrees_##fun, Fix) { \ - for (type p : vct) BOOST_TEST(p.fun() == p.ref()); \ +#define TEST_AGREES(type, ref, fun, vct) \ + BOOST_FIXTURE_TEST_CASE(type##_agrees_##fun, Fix) { \ + for (type p : vct) \ + BOOST_TEST(p.fun() == p.ref()); \ } -#define TEST_EPU8_AGREES(type, ref, fun, vct) \ - BOOST_FIXTURE_TEST_CASE(type##_agrees_##fun, Fix) { \ - for (type p : vct) EPU8_EQUAL(p.fun(), p.ref()); \ +#define TEST_EPU8_AGREES(type, ref, fun, vct) \ + BOOST_FIXTURE_TEST_CASE(type##_agrees_##fun, Fix) { \ + for (type p : vct) \ + EPU8_EQUAL(p.fun(), p.ref()); \ } -#define TEST_AGREES2(type, ref, fun, vct) \ - BOOST_FIXTURE_TEST_CASE(type##_agrees_##fun, Fix) { \ - for (type p1 : vct) for (type p2 : vct) \ - BOOST_TEST(p1.fun(p2) == p1.ref(p2)); \ +#define TEST_AGREES2(type, ref, fun, vct) \ + BOOST_FIXTURE_TEST_CASE(type##_agrees_##fun, Fix) { \ + for (type p1 : vct) \ + for (type p2 : vct) \ + BOOST_TEST(p1.fun(p2) == p1.ref(p2)); \ } struct Fix { - Fix() : zero(0), one1(1), one2(0x201), - ones(0xffffffffffffffff), - bm({{0, 0, 0, 1, 0, 0, 1, 1}, - {1, 1, 1, 1, 1, 1, 0, 1}, - {0, 1, 1, 1, 0, 1, 0, 1}, + Fix() + : zero(0), one1(1), one2(0x201), ones(0xffffffffffffffff), + bm({{0, 0, 0, 1, 0, 0, 1, 1}, + {1, 1, 1, 1, 1, 1, 0, 1}, + {0, 1, 1, 1, 0, 1, 0, 1}, + {1, 1, 0, 1, 1, 1, 1, 1}, + {0, 0, 1, 0, 0, 1, 1, 1}, + {1, 1, 0, 0, 0, 0, 0, 1}, + {0, 1, 0, 0, 0, 0, 1, 1}, + {0, 1, 1, 1, 1, 0, 1, 0}}), + bm1({{0, 0, 0, 1, 0, 0, 1, 1}, + {0, 0, 1, 0, 0, 1, 0, 1}, + {1, 1, 0, 0, 1, 1, 0, 1}, + {1, 1, 0, 0, 0, 0, 0, 1}, + {0, 1, 0, 0, 0, 0, 1, 1}, + {0, 1, 0, 1, 1, 1, 1, 1}, + {0, 1, 0, 1, 0, 1, 0, 1}, + {0, 1, 0, 0, 0, 0, 1, 0}}), + bmm1({{1, 1, 0, 1, 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, 1, 1, 1}, {1, 1, 0, 1, 1, 1, 1, 1}, - {0, 0, 1, 0, 0, 1, 1, 1}, - {1, 1, 0, 0, 0, 0, 0, 1}, - {0, 1, 0, 0, 0, 0, 1, 1}, - {0, 1, 1, 1, 1, 0, 1, 0}}), - bm1({{0, 0, 0, 1, 0, 0, 1, 1}, - {0, 0, 1, 0, 0, 1, 0, 1}, - {1, 1, 0, 0, 1, 1, 0, 1}, - {1, 1, 0, 0, 0, 0, 0, 1}, - {0, 1, 0, 0, 0, 0, 1, 1}, - {0, 1, 0, 1, 1, 1, 1, 1}, - {0, 1, 0, 1, 0, 1, 0, 1}, - {0, 1, 0, 0, 0, 0, 1, 0}}), - bmm1({{1, 1, 0, 1, 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, 1, 1, 1}, - {1, 1, 0, 1, 1, 1, 1, 1}, - {0, 1, 1, 1, 0, 1, 1, 1}, - {0, 1, 1, 1, 0, 1, 1, 1}, - {1, 1, 1, 1, 1, 1, 1, 1}}), - bm2({{1, 1}, {0, 1}}), bm2t({{1, 0}, {1, 1}}), - bm3({{0, 0, 0, 1, 0, 0, 1, 1}, - {1, 1, 1, 1, 1, 1, 0, 1}, - {0, 1, 1, 1, 1, 1, 0, 1}, - {1, 1, 0, 1, 1, 1, 1, 1}, - {0, 0, 1, 0, 0, 1, 1, 1}, - {1, 1, 0, 0, 0, 0, 0, 1}, - {0, 1, 0, 0, 0, 0, 1, 1}, - {0, 1, 1, 1, 1, 0, 1, 0}}), - bm3t({{0, 1, 0, 1, 0, 1, 0, 0}, - {0, 1, 1, 1, 0, 1, 1, 1}, - {0, 1, 1, 0, 1, 0, 0, 1}, - {1, 1, 1, 1, 0, 0, 0, 1}, - {0, 1, 1, 1, 0, 0, 0, 1}, - {0, 1, 1, 1, 1, 0, 0, 0}, - {1, 0, 0, 1, 1, 0, 1, 1}, - {1, 1, 1, 1, 1, 1, 1, 0}}), - BMlist({zero, one1, one2, ones, bm, bm1, bmm1, bm2, bm2t, bm3, bm3t}) - { - BOOST_TEST_MESSAGE("setup fixture"); - } + {0, 1, 1, 1, 0, 1, 1, 1}, + {0, 1, 1, 1, 0, 1, 1, 1}, + {1, 1, 1, 1, 1, 1, 1, 1}}), + bm2({{1, 1}, {0, 1}}), bm2t({{1, 0}, {1, 1}}), + bm3({{0, 0, 0, 1, 0, 0, 1, 1}, + {1, 1, 1, 1, 1, 1, 0, 1}, + {0, 1, 1, 1, 1, 1, 0, 1}, + {1, 1, 0, 1, 1, 1, 1, 1}, + {0, 0, 1, 0, 0, 1, 1, 1}, + {1, 1, 0, 0, 0, 0, 0, 1}, + {0, 1, 0, 0, 0, 0, 1, 1}, + {0, 1, 1, 1, 1, 0, 1, 0}}), + bm3t({{0, 1, 0, 1, 0, 1, 0, 0}, + {0, 1, 1, 1, 0, 1, 1, 1}, + {0, 1, 1, 0, 1, 0, 0, 1}, + {1, 1, 1, 1, 0, 0, 0, 1}, + {0, 1, 1, 1, 0, 0, 0, 1}, + {0, 1, 1, 1, 1, 0, 0, 0}, + {1, 0, 0, 1, 1, 0, 1, 1}, + {1, 1, 1, 1, 1, 1, 1, 0}}), + BMlist( + {zero, one1, one2, ones, bm, bm1, bmm1, bm2, bm2t, bm3, bm3t}) { + BOOST_TEST_MESSAGE("setup fixture"); + } ~Fix() { BOOST_TEST_MESSAGE("teardown fixture"); } const BMat8 zero, one1, one2, ones, bm, bm1, bmm1, bm2, bm2t, bm3, bm3t; const std::vector BMlist; }; - //****************************************************************************// BOOST_AUTO_TEST_SUITE(BMat8_test) //****************************************************************************// BOOST_FIXTURE_TEST_CASE(BMat8_one, Fix) { BOOST_TEST(BMat8::one(0) == zero); - BOOST_TEST(BMat8::one(2) == BMat8( - {{1, 0, 0, 0, 0, 0, 0, 0}, - {0, 1, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0}})); - BOOST_TEST(BMat8::one(5) == BMat8( - {{1, 0, 0, 0, 0, 0, 0, 0}, - {0, 1, 0, 0, 0, 0, 0, 0}, - {0, 0, 1, 0, 0, 0, 0, 0}, - {0, 0, 0, 1, 0, 0, 0, 0}, - {0, 0, 0, 0, 1, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0}})); + BOOST_TEST(BMat8::one(2) == BMat8({{1, 0, 0, 0, 0, 0, 0, 0}, + {0, 1, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}})); + BOOST_TEST(BMat8::one(5) == BMat8({{1, 0, 0, 0, 0, 0, 0, 0}, + {0, 1, 0, 0, 0, 0, 0, 0}, + {0, 0, 1, 0, 0, 0, 0, 0}, + {0, 0, 0, 1, 0, 0, 0, 0}, + {0, 0, 0, 0, 1, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}})); BOOST_TEST(BMat8::one(8) == BMat8::one()); } @@ -135,7 +136,6 @@ BOOST_FIXTURE_TEST_CASE(BMat8_transpose, Fix) { TEST_AGREES(BMat8, transpose, transpose_mask, BMlist); TEST_AGREES(BMat8, transpose, transpose_maskd, BMlist); - BOOST_FIXTURE_TEST_CASE(BMat8_transpose2, Fix) { for (auto a : BMlist) { for (auto b : BMlist) { @@ -165,10 +165,8 @@ BOOST_FIXTURE_TEST_CASE(BMat8_mult, Fix) { for (auto b2 : BMlist) for (auto b3 : BMlist) BOOST_TEST((b1 * b2) * b3 == b1 * (b2 * b3)); - } - //****************************************************************************// BOOST_AUTO_TEST_CASE(BMat8_random) { for (size_t d = 1; d < 8; ++d) { @@ -184,14 +182,11 @@ BOOST_AUTO_TEST_CASE(BMat8_random) { //****************************************************************************// BOOST_AUTO_TEST_CASE(BMat8_call_operator) { - std::vector> mat = {{0, 0, 0, 1, 0, 0, 1}, - {0, 1, 1, 1, 0, 1, 0}, - {1, 1, 0, 1, 1, 1, 1}, - {0, 0, 1, 0, 0, 1, 1}, - {1, 1, 0, 0, 0, 0, 0}, - {0, 1, 0, 0, 0, 0, 1}, - {0, 1, 1, 1, 1, 0, 1}}; - BMat8 bm(mat); + std::vector> mat = { + {0, 0, 0, 1, 0, 0, 1}, {0, 1, 1, 1, 0, 1, 0}, {1, 1, 0, 1, 1, 1, 1}, + {0, 0, 1, 0, 0, 1, 1}, {1, 1, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0, 1}, + {0, 1, 1, 1, 1, 0, 1}}; + BMat8 bm(mat); for (size_t i = 0; i < 7; ++i) { for (size_t j = 0; j < 7; ++j) { @@ -204,40 +199,42 @@ BOOST_AUTO_TEST_CASE(BMat8_call_operator) { BOOST_FIXTURE_TEST_CASE(BMat8_operator_insert, Fix) { std::ostringstream oss; oss << bm3; - BOOST_TEST(oss.str() == - "00010011\n" - "11111101\n" - "01111101\n" - "11011111\n" - "00100111\n" - "11000001\n" - "01000011\n" - "01111010\n"); + BOOST_TEST(oss.str() == "00010011\n" + "11111101\n" + "01111101\n" + "11011111\n" + "00100111\n" + "11000001\n" + "01000011\n" + "01111010\n"); std::stringbuf buff; - std::ostream os(&buff); + std::ostream os(&buff); os << BMat8::random(); // Also does not do anything visible } //****************************************************************************// BOOST_FIXTURE_TEST_CASE(BMat8_set, Fix) { BMat8 bs; - bs = bm; bs.set(0, 0, 1); + bs = bm; + bs.set(0, 0, 1); BOOST_TEST(bs != bm); - bs = bm; bs.set(0, 0, 0); + bs = bm; + bs.set(0, 0, 0); BOOST_TEST(bs == bm); - bs = bm; bs.set(2, 4, 1); + bs = bm; + bs.set(2, 4, 1); BOOST_TEST(bs != bm); BOOST_TEST(bs == bm3); for (size_t i = 0; i < 8; ++i) - for (size_t j = 0; j < 8; ++j) - bs.set(i, j, true); + for (size_t j = 0; j < 8; ++j) + bs.set(i, j, true); BOOST_TEST(bs == ones); for (size_t i = 0; i < 8; ++i) - for (size_t j = 0; j < 8; ++j) - bs.set(i, j, false); + for (size_t j = 0; j < 8; ++j) + bs.set(i, j, false); BOOST_TEST(bs == zero); } @@ -295,11 +292,11 @@ BOOST_AUTO_TEST_CASE(BMat8_row_space_basis) { for (size_t i = 0; i < 1000; ++i) { bm = BMat8::random(); - BOOST_TEST(bm.row_space_basis().row_space_basis() == bm.row_space_basis()); + BOOST_TEST(bm.row_space_basis().row_space_basis() == + bm.row_space_basis()); } } - //****************************************************************************// //****************************************************************************// BOOST_AUTO_TEST_CASE(BMat8_col_space_basis) { @@ -344,7 +341,7 @@ BOOST_AUTO_TEST_CASE(BMat8_col_space_basis) { BOOST_TEST(bm3.col_space_basis() == bm4); uint64_t col = 0x8080808080808080; - BMat8 bm5(col); + BMat8 bm5(col); uint64_t data = 0xffffffffffffffff; @@ -355,7 +352,8 @@ BOOST_AUTO_TEST_CASE(BMat8_col_space_basis) { for (size_t i = 0; i < 1000; ++i) { bm = BMat8::random(); - BOOST_TEST(bm.col_space_basis().col_space_basis() == bm.col_space_basis()); + BOOST_TEST(bm.col_space_basis().col_space_basis() == + bm.col_space_basis()); } } @@ -397,14 +395,15 @@ BOOST_FIXTURE_TEST_CASE(BMat8_row_space_included, Fix) { BOOST_TEST(m1.row_space_included(BMat8::one())); BOOST_TEST(m2.row_space_included(BMat8::one())); BOOST_TEST(m3.row_space_included(BMat8::one())); - } TEST_AGREES2(BMat8, row_space_included, row_space_included_ref, BMlist); TEST_AGREES2(BMat8, row_space_included, row_space_included_bitset, BMlist); BOOST_FIXTURE_TEST_CASE(BMat8_row_space_included2, Fix) { - BMat8 a0 = BMat8::one(); BMat8 b0 = BMat8(0); - BMat8 a1 = BMat8(0); BMat8 b1 = BMat8::one(); + BMat8 a0 = BMat8::one(); + BMat8 b0 = BMat8(0); + BMat8 a1 = BMat8(0); + BMat8 b1 = BMat8::one(); auto res = BMat8::row_space_included2(a0, b0, a1, b1); BOOST_TEST(res.first == a0.row_space_included(b0)); @@ -423,14 +422,12 @@ BOOST_FIXTURE_TEST_CASE(BMat8_row_space_included2, Fix) { } } - //****************************************************************************// BOOST_FIXTURE_TEST_CASE(BMat8_row_permuted, Fix) { - BOOST_TEST(bm2.row_permuted(Perm16({1,0})) == - BMat8({{0,1},{1,1}})); - BOOST_TEST(bm2.row_permuted(Perm16({2,1,0})) == - BMat8({{0,0,0},{0,1,0},{1,1,0}})); - BOOST_TEST(bm.row_permuted(Perm16({5,3,1,4,2,0})) == + BOOST_TEST(bm2.row_permuted(Perm16({1, 0})) == BMat8({{0, 1}, {1, 1}})); + BOOST_TEST(bm2.row_permuted(Perm16({2, 1, 0})) == + BMat8({{0, 0, 0}, {0, 1, 0}, {1, 1, 0}})); + BOOST_TEST(bm.row_permuted(Perm16({5, 3, 1, 4, 2, 0})) == BMat8({{1, 1, 0, 0, 0, 0, 0, 1}, {1, 1, 0, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 0, 1}, @@ -439,7 +436,7 @@ BOOST_FIXTURE_TEST_CASE(BMat8_row_permuted, Fix) { {0, 0, 0, 1, 0, 0, 1, 1}, {0, 1, 0, 0, 0, 0, 1, 1}, {0, 1, 1, 1, 1, 0, 1, 0}})); - BOOST_TEST(BMat8::one().row_permuted(Perm16({5,3,1,4,2,0})) == + BOOST_TEST(BMat8::one().row_permuted(Perm16({5, 3, 1, 4, 2, 0})) == BMat8({{0, 0, 0, 0, 0, 1, 0, 0}, {0, 0, 0, 1, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0, 0, 0}, @@ -451,96 +448,87 @@ BOOST_FIXTURE_TEST_CASE(BMat8_row_permuted, Fix) { } BOOST_FIXTURE_TEST_CASE(BMat8_col_permuted, Fix) { - BOOST_TEST(bm2.col_permuted(Perm16({1,0})) == - BMat8({{1,1},{1,0}})); - BOOST_TEST(bm2.col_permuted(Perm16({2,1,0})) == - BMat8({{0,1,1},{0,1,0},{0,0,0}})); - BOOST_TEST(bm.col_permuted( - Perm16({5, 3, 1, 4, 2, 0})) == - BMat8( {{0, 1, 0, 0, 0, 0, 1, 1}, - {1, 1, 1, 1, 1, 1, 0, 1}, - {1, 1, 1, 0, 1, 0, 0, 1}, - {1, 1, 1, 1, 0, 1, 1, 1}, - {1, 0, 0, 0, 1, 0, 1, 1}, - {0, 0, 1, 0, 0, 1, 0, 1}, - {0, 0, 1, 0, 0, 0, 1, 1}, - {0, 1, 1, 1, 1, 0, 1, 0}})); - BOOST_TEST(BMat8::one().col_permuted( - Perm16({4, 1, 3, 0, 2, 6, 5})) == - BMat8({ {0, 0, 0, 1, 0, 0, 0, 0}, - {0, 1, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 1, 0, 0, 0}, - {0, 0, 1, 0, 0, 0, 0, 0}, - {1, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 1, 0}, - {0, 0, 0, 0, 0, 1, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 1}})); + BOOST_TEST(bm2.col_permuted(Perm16({1, 0})) == BMat8({{1, 1}, {1, 0}})); + BOOST_TEST(bm2.col_permuted(Perm16({2, 1, 0})) == + BMat8({{0, 1, 1}, {0, 1, 0}, {0, 0, 0}})); + BOOST_TEST(bm.col_permuted(Perm16({5, 3, 1, 4, 2, 0})) == + BMat8({{0, 1, 0, 0, 0, 0, 1, 1}, + {1, 1, 1, 1, 1, 1, 0, 1}, + {1, 1, 1, 0, 1, 0, 0, 1}, + {1, 1, 1, 1, 0, 1, 1, 1}, + {1, 0, 0, 0, 1, 0, 1, 1}, + {0, 0, 1, 0, 0, 1, 0, 1}, + {0, 0, 1, 0, 0, 0, 1, 1}, + {0, 1, 1, 1, 1, 0, 1, 0}})); + BOOST_TEST(BMat8::one().col_permuted(Perm16({4, 1, 3, 0, 2, 6, 5})) == + BMat8({{0, 0, 0, 1, 0, 0, 0, 0}, + {0, 1, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 1, 0, 0, 0}, + {0, 0, 1, 0, 0, 0, 0, 0}, + {1, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 0}, + {0, 0, 0, 0, 0, 1, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 1}})); } BOOST_FIXTURE_TEST_CASE(BMat8_row_permutation_matrix, Fix) { - BOOST_TEST(BMat8::row_permutation_matrix( - Perm16({1, 0})) == - BMat8({ {0, 1, 0, 0, 0, 0, 0, 0}, - {1, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 1, 0, 0, 0, 0, 0}, - {0, 0, 0, 1, 0, 0, 0, 0}, - {0, 0, 0, 0, 1, 0, 0, 0}, - {0, 0, 0, 0, 0, 1, 0, 0}, - {0, 0, 0, 0, 0, 0, 1, 0}, - {0, 0, 0, 0, 0, 0, 0, 1}})); - BOOST_TEST(BMat8::row_permutation_matrix( - Perm16({1, 3, 4, 0, 2})) == - BMat8({ {0, 1, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 1, 0, 0, 0, 0}, - {0, 0, 0, 0, 1, 0, 0, 0}, - {1, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 1, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 1, 0, 0}, - {0, 0, 0, 0, 0, 0, 1, 0}, - {0, 0, 0, 0, 0, 0, 0, 1}})); - BOOST_TEST(BMat8::row_permutation_matrix( - Perm16({5, 3, 1, 4, 2, 0})) == - BMat8({ {0, 0, 0, 0, 0, 1, 0, 0}, - {0, 0, 0, 1, 0, 0, 0, 0}, - {0, 1, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 1, 0, 0, 0}, - {0, 0, 1, 0, 0, 0, 0, 0}, - {1, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 1, 0}, - {0, 0, 0, 0, 0, 0, 0, 1}})); + BOOST_TEST(BMat8::row_permutation_matrix(Perm16({1, 0})) == + BMat8({{0, 1, 0, 0, 0, 0, 0, 0}, + {1, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 1, 0, 0, 0, 0, 0}, + {0, 0, 0, 1, 0, 0, 0, 0}, + {0, 0, 0, 0, 1, 0, 0, 0}, + {0, 0, 0, 0, 0, 1, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 0}, + {0, 0, 0, 0, 0, 0, 0, 1}})); + BOOST_TEST(BMat8::row_permutation_matrix(Perm16({1, 3, 4, 0, 2})) == + BMat8({{0, 1, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 1, 0, 0, 0, 0}, + {0, 0, 0, 0, 1, 0, 0, 0}, + {1, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 1, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 1, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 0}, + {0, 0, 0, 0, 0, 0, 0, 1}})); + BOOST_TEST(BMat8::row_permutation_matrix(Perm16({5, 3, 1, 4, 2, 0})) == + BMat8({{0, 0, 0, 0, 0, 1, 0, 0}, + {0, 0, 0, 1, 0, 0, 0, 0}, + {0, 1, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 1, 0, 0, 0}, + {0, 0, 1, 0, 0, 0, 0, 0}, + {1, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 0}, + {0, 0, 0, 0, 0, 0, 0, 1}})); } -BOOST_FIXTURE_TEST_CASE(BMat8_col_permutation_matrix, Fix) { - BOOST_TEST(BMat8::col_permutation_matrix( - Perm16({1, 0})) == - BMat8({ {0, 1, 0, 0, 0, 0, 0, 0}, - {1, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 1, 0, 0, 0, 0, 0}, - {0, 0, 0, 1, 0, 0, 0, 0}, - {0, 0, 0, 0, 1, 0, 0, 0}, - {0, 0, 0, 0, 0, 1, 0, 0}, - {0, 0, 0, 0, 0, 0, 1, 0}, - {0, 0, 0, 0, 0, 0, 0, 1}})); - BOOST_TEST(BMat8::col_permutation_matrix( - Perm16({1, 3, 4, 0, 2})) == - BMat8({ {0, 0, 0, 1, 0, 0, 0, 0}, - {1, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 1, 0, 0, 0}, - {0, 1, 0, 0, 0, 0, 0, 0}, - {0, 0, 1, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 1, 0, 0}, - {0, 0, 0, 0, 0, 0, 1, 0}, - {0, 0, 0, 0, 0, 0, 0, 1}})); - BOOST_TEST(BMat8::col_permutation_matrix( - Perm16({5, 3, 1, 4, 2, 0})) == - BMat8({ {0, 0, 0, 0, 0, 1, 0, 0}, - {0, 0, 1, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 1, 0, 0, 0}, - {0, 1, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 1, 0, 0, 0, 0}, - {1, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 1, 0}, - {0, 0, 0, 0, 0, 0, 0, 1}})); +BOOST_FIXTURE_TEST_CASE(BMat8_col_permutation_matrix, Fix) { + BOOST_TEST(BMat8::col_permutation_matrix(Perm16({1, 0})) == + BMat8({{0, 1, 0, 0, 0, 0, 0, 0}, + {1, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 1, 0, 0, 0, 0, 0}, + {0, 0, 0, 1, 0, 0, 0, 0}, + {0, 0, 0, 0, 1, 0, 0, 0}, + {0, 0, 0, 0, 0, 1, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 0}, + {0, 0, 0, 0, 0, 0, 0, 1}})); + BOOST_TEST(BMat8::col_permutation_matrix(Perm16({1, 3, 4, 0, 2})) == + BMat8({{0, 0, 0, 1, 0, 0, 0, 0}, + {1, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 1, 0, 0, 0}, + {0, 1, 0, 0, 0, 0, 0, 0}, + {0, 0, 1, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 1, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 0}, + {0, 0, 0, 0, 0, 0, 0, 1}})); + BOOST_TEST(BMat8::col_permutation_matrix(Perm16({5, 3, 1, 4, 2, 0})) == + BMat8({{0, 0, 0, 0, 0, 1, 0, 0}, + {0, 0, 1, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 1, 0, 0, 0}, + {0, 1, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 1, 0, 0, 0, 0}, + {1, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 0}, + {0, 0, 0, 0, 0, 0, 0, 1}})); } //****************************************************************************// @@ -549,17 +537,15 @@ BOOST_FIXTURE_TEST_CASE(BMat8_nr_rows, Fix) { BOOST_TEST(one1.nr_rows() == 1); BOOST_TEST(one2.nr_rows() == 2); BOOST_TEST(bm.nr_rows() == 8); - BOOST_TEST(BMat8({{1, 0, 1}, - {1, 1, 0}, - {0, 0, 0}}).nr_rows() == 2); + BOOST_TEST(BMat8({{1, 0, 1}, {1, 1, 0}, {0, 0, 0}}).nr_rows() == 2); } //****************************************************************************// BOOST_FIXTURE_TEST_CASE(BMat8_right_perm_action_on_basis_ref, Fix) { BMat8 m1({{1, 1, 0}, {1, 0, 1}, {0, 0, 0}}); BMat8 m2({{0, 0, 0}, {1, 0, 1}, {1, 1, 0}}); - BOOST_TEST(m1.right_perm_action_on_basis_ref(m2) == Perm16({1,0})); - BOOST_TEST(m1.right_perm_action_on_basis(m2) == Perm16({1,0})); + BOOST_TEST(m1.right_perm_action_on_basis_ref(m2) == Perm16({1, 0})); + BOOST_TEST(m1.right_perm_action_on_basis(m2) == Perm16({1, 0})); m1 = BMat8({{1, 1, 0, 1}, {1, 0, 1, 0}, {0, 0, 0, 1}, {0, 0, 0, 0}}); m2 = BMat8({{1, 0, 0, 0}, {0, 1, 0, 1}, {1, 0, 1, 0}, {0, 0, 0, 1}}); @@ -571,21 +557,20 @@ BOOST_FIXTURE_TEST_CASE(BMat8_right_perm_action_on_basis_ref, Fix) { BOOST_TEST(m1.right_perm_action_on_basis_ref(m2) == Perm16::one()); BOOST_TEST(m1.right_perm_action_on_basis(m2) == Perm16::one()); - m1 = BMat8({{0,1,0,0}, {0,0,1,0}, {1,0,0,1}, {0,0,0,0}}); - m2 = BMat8({{1,0,0,1}, {0,0,1,0}, {0,1,0,0}, {0,0,0,1}}); - BOOST_TEST(m1.right_perm_action_on_basis_ref(m2) == Perm16({1,0})); - BOOST_TEST(m1.right_perm_action_on_basis(m2) == Perm16({1,0})); - - m1 = BMat8({{0,0,0,1}, {1,0,0,0}, {0,0,1,0}, {0,1,0,0}}); - m2 = BMat8({{0,1,0,0}, {0,0,1,0}, {1,0,0,0}, {0,0,0,1}}); - BOOST_TEST(m1.right_perm_action_on_basis_ref(m2) == Perm16({0,2,3,1})); - BOOST_TEST(m1.right_perm_action_on_basis(m2) == Perm16({0,2,3,1})); + m1 = BMat8({{0, 1, 0, 0}, {0, 0, 1, 0}, {1, 0, 0, 1}, {0, 0, 0, 0}}); + m2 = BMat8({{1, 0, 0, 1}, {0, 0, 1, 0}, {0, 1, 0, 0}, {0, 0, 0, 1}}); + BOOST_TEST(m1.right_perm_action_on_basis_ref(m2) == Perm16({1, 0})); + BOOST_TEST(m1.right_perm_action_on_basis(m2) == Perm16({1, 0})); + m1 = BMat8({{0, 0, 0, 1}, {1, 0, 0, 0}, {0, 0, 1, 0}, {0, 1, 0, 0}}); + m2 = BMat8({{0, 1, 0, 0}, {0, 0, 1, 0}, {1, 0, 0, 0}, {0, 0, 0, 1}}); + BOOST_TEST(m1.right_perm_action_on_basis_ref(m2) == Perm16({0, 2, 3, 1})); + BOOST_TEST(m1.right_perm_action_on_basis(m2) == Perm16({0, 2, 3, 1})); - m1 = BMat8({{0,0,0,1}, {0,0,1,0}, {0,1,0,0}, {1,0,0,0}}); - m2 = BMat8({{0,1,0,0}, {0,0,0,1}, {1,0,0,0}, {0,0,1,0}}); - BOOST_TEST(m1.right_perm_action_on_basis_ref(m2) == Perm16({2,0,3,1})); - BOOST_TEST(m1.right_perm_action_on_basis(m2) == Perm16({2,0,3,1})); + m1 = BMat8({{0, 0, 0, 1}, {0, 0, 1, 0}, {0, 1, 0, 0}, {1, 0, 0, 0}}); + m2 = BMat8({{0, 1, 0, 0}, {0, 0, 0, 1}, {1, 0, 0, 0}, {0, 0, 1, 0}}); + BOOST_TEST(m1.right_perm_action_on_basis_ref(m2) == Perm16({2, 0, 3, 1})); + BOOST_TEST(m1.right_perm_action_on_basis(m2) == Perm16({2, 0, 3, 1})); } //****************************************************************************// BOOST_AUTO_TEST_SUITE_END() diff --git a/tests/test_epu.cpp b/tests/test_epu.cpp index adef614a..22384fbd 100644 --- a/tests/test_epu.cpp +++ b/tests/test_epu.cpp @@ -15,8 +15,8 @@ #define BOOST_TEST_MODULE EPUTests -#include #include +#include #include #include "epu.hpp" @@ -24,50 +24,47 @@ using namespace HPCombi; -#define EPU8_EQUAL(p1, p2) BOOST_CHECK_PREDICATE(equal, (p1)(p2)) -#define EPU8_NOT_EQUAL(p1, p2) BOOST_CHECK_PREDICATE(boost::not2(equal), (p1)(p2)) +#define EPU8_EQUAL(p1, p2) BOOST_CHECK_PREDICATE(equal, (p1)(p2)) +#define EPU8_NOT_EQUAL(p1, p2) \ + BOOST_CHECK_PREDICATE(boost::not2(equal), (p1)(p2)) -#define TEST_AGREES(ref, fun) \ - BOOST_FIXTURE_TEST_CASE(EPU8_agrees_##fun, Fix) { \ - for (auto x : v) BOOST_TEST(fun(x) == ref(x)); \ +#define TEST_AGREES(ref, fun) \ + BOOST_FIXTURE_TEST_CASE(EPU8_agrees_##fun, Fix) { \ + for (auto x : v) \ + BOOST_TEST(fun(x) == ref(x)); \ } -#define TEST_EPU8_AGREES(ref, fun) \ - BOOST_FIXTURE_TEST_CASE(EPU8_agrees_##fun, Fix) { \ - for (auto x : v) EPU8_EQUAL(fun(x), ref(x)); \ +#define TEST_EPU8_AGREES(ref, fun) \ + BOOST_FIXTURE_TEST_CASE(EPU8_agrees_##fun, Fix) { \ + for (auto x : v) \ + EPU8_EQUAL(fun(x), ref(x)); \ } - struct Fix { - Fix() : zero(Epu8({}, 0)), P01(Epu8({0, 1}, 0)), - P10(Epu8({1, 0}, 0)), P11(Epu8({1, 1}, 0)), - P1(Epu8({}, 1)), - P112(Epu8({1, 1}, 2)), - Pa(epu8{1, 2, 3, 4, 0, 5, 6, 7, 8, 9,10,11,12,13,14,15}), - Pb(epu8{1, 2, 3, 6, 0, 5, 4, 7, 8, 9,10,11,12,15,14,13}), - RP(epu8{ 3, 1, 0,14,15,13, 5,10, 2,11, 6,12, 7, 4, 8, 9}), - Pa1(Epu8({4, 2, 5, 1, 2, 7, 7, 3, 4, 2}, 1)), - Pa2(Epu8({4, 2, 5, 1, 2, 9, 7, 3, 4, 2}, 1)), - P51(Epu8({5,1}, 6)), - Pv(epu8{ 5, 5, 2, 5, 1, 6,12, 4, 0, 3, 2,11,12,13,14,15}), - Pw(epu8{ 5, 5, 2, 9, 1, 6,12, 4, 0, 4, 4, 4,12,13,14,15}), - P5(Epu8({}, 5)), - Pc(Epu8({23, 5, 21, 5, 43, 36}, 7)), - // Elements should be sorted in alphabetic order here - v({zero, P01, epu8id, P10, P11, P1, P112, Pa, Pb, RP, - Pa1, Pa2, P51, Pv, Pw, P5, epu8rev, Pc}), - av({{ 5, 5, 2, 5, 1, 6,12, 4, 0, 3, 2,11,12,13,14,15}}) - { - BOOST_TEST_MESSAGE("setup fixture"); - } + Fix() + : zero(Epu8({}, 0)), P01(Epu8({0, 1}, 0)), P10(Epu8({1, 0}, 0)), + P11(Epu8({1, 1}, 0)), P1(Epu8({}, 1)), P112(Epu8({1, 1}, 2)), + Pa(epu8{1, 2, 3, 4, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}), + Pb(epu8{1, 2, 3, 6, 0, 5, 4, 7, 8, 9, 10, 11, 12, 15, 14, 13}), + RP(epu8{3, 1, 0, 14, 15, 13, 5, 10, 2, 11, 6, 12, 7, 4, 8, 9}), + Pa1(Epu8({4, 2, 5, 1, 2, 7, 7, 3, 4, 2}, 1)), + Pa2(Epu8({4, 2, 5, 1, 2, 9, 7, 3, 4, 2}, 1)), P51(Epu8({5, 1}, 6)), + Pv(epu8{5, 5, 2, 5, 1, 6, 12, 4, 0, 3, 2, 11, 12, 13, 14, 15}), + Pw(epu8{5, 5, 2, 9, 1, 6, 12, 4, 0, 4, 4, 4, 12, 13, 14, 15}), + P5(Epu8({}, 5)), Pc(Epu8({23, 5, 21, 5, 43, 36}, 7)), + // Elements should be sorted in alphabetic order here + v({zero, P01, epu8id, P10, P11, P1, P112, Pa, Pb, RP, Pa1, Pa2, P51, + Pv, Pw, P5, epu8rev, Pc}), + av({{5, 5, 2, 5, 1, 6, 12, 4, 0, 3, 2, 11, 12, 13, 14, 15}}) { + BOOST_TEST_MESSAGE("setup fixture"); + } ~Fix() { BOOST_TEST_MESSAGE("teardown fixture"); } - const epu8 zero, P01, P10, P11, P1, P112, Pa, Pb, RP, - Pa1, Pa2, P51, Pv, Pw, P5, Pc; + const epu8 zero, P01, P10, P11, P1, P112, Pa, Pb, RP, Pa1, Pa2, P51, Pv, Pw, + P5, Pc; const std::vector v; const std::array av; }; - //****************************************************************************// BOOST_AUTO_TEST_SUITE(EPU8_compare) //****************************************************************************// @@ -84,15 +81,16 @@ BOOST_FIXTURE_TEST_CASE(EPU8_first_diff_ref, Fix) { BOOST_TEST(first_diff_ref(Pa1, Pa2, 7) == 5); BOOST_TEST(first_diff_ref(Pa1, Pa2) == 5); BOOST_TEST(first_diff(Pv, Pw) == 3); - for (int i=0; i<16; i++) + for (int i = 0; i < 16; i++) BOOST_TEST(first_diff(Pv, Pw, i) == (i <= 3 ? 16 : 3)); } BOOST_FIXTURE_TEST_CASE(EPU8_first_diff_cmpstr, Fix) { for (auto x : v) { for (auto y : v) { BOOST_TEST(first_diff_cmpstr(x, y) == first_diff_ref(x, y)); - for (int i=0; i<17; i++) - BOOST_TEST(first_diff_cmpstr(x, y, i) == first_diff_ref(x, y, i)); + for (int i = 0; i < 17; i++) + BOOST_TEST(first_diff_cmpstr(x, y, i) == + first_diff_ref(x, y, i)); } } } @@ -100,7 +98,7 @@ BOOST_FIXTURE_TEST_CASE(EPU8_first_diff_mask, Fix) { for (auto x : v) { for (auto y : v) { BOOST_TEST(first_diff_mask(x, y) == first_diff_ref(x, y)); - for (int i=0; i<17; i++) + for (int i = 0; i < 17; i++) BOOST_TEST(first_diff_mask(x, y, i) == first_diff_ref(x, y, i)); } } @@ -121,17 +119,16 @@ BOOST_FIXTURE_TEST_CASE(EPU8_last_diff_ref, Fix) { BOOST_TEST(last_diff_ref(Pa1, Pa2, 6) == 5); BOOST_TEST(last_diff_ref(Pa1, Pa2, 7) == 5); BOOST_TEST(last_diff_ref(Pa1, Pa2) == 5); - const std::array res {{ - 16,16,16,16, 3, 3, 3, 3, 3, 3,9,10,11,11,11,11,11 - }}; - for (int i=0; i<=16; i++) + const std::array res{ + {16, 16, 16, 16, 3, 3, 3, 3, 3, 3, 9, 10, 11, 11, 11, 11, 11}}; + for (int i = 0; i <= 16; i++) BOOST_TEST(last_diff_ref(Pv, Pw, i) == res[i]); } BOOST_FIXTURE_TEST_CASE(EPU8_last_diff_cmpstr, Fix) { for (auto x : v) { for (auto y : v) { BOOST_TEST(last_diff_cmpstr(x, y) == last_diff_ref(x, y)); - for (int i=0; i<17; i++) + for (int i = 0; i < 17; i++) BOOST_TEST(last_diff_cmpstr(x, y, i) == last_diff_ref(x, y, i)); } } @@ -140,13 +137,12 @@ BOOST_FIXTURE_TEST_CASE(EPU8_last_diff_mask, Fix) { for (auto x : v) { for (auto y : v) { BOOST_TEST(last_diff_mask(x, y) == last_diff_ref(x, y)); - for (int i=0; i<17; i++) + for (int i = 0; i < 17; i++) BOOST_TEST(last_diff_mask(x, y, i) == last_diff_ref(x, y, i)); } } } - BOOST_FIXTURE_TEST_CASE(EPU8_is_all_zero, Fix) { BOOST_TEST(is_all_zero(zero)); for (size_t i = 1; i < v.size(); i++) { @@ -170,23 +166,26 @@ BOOST_FIXTURE_TEST_CASE(EPU8_equal, Fix) { BOOST_CHECK_PREDICATE(equal, (a)(b)); BOOST_CHECK_PREDICATE(boost::not2(not_equal), (a)(b)); BOOST_CHECK_PREDICATE(std::equal_to(), (a)(b)); -// For some reason, the following line doesn't compile -// BOOST_CHECK_PREDICATE(boost::not2(std::not_equal_to()), -// (a)(b)); + // For some reason, the following line doesn't compile + // BOOST_CHECK_PREDICATE(boost::not2(std::not_equal_to()), + // (a)(b)); BOOST_CHECK_PREDICATE( [](epu8 a, epu8 b) { return not std::not_equal_to()(a, b); - }, (a)(b)); + }, + (a)(b)); } else { BOOST_CHECK_PREDICATE(boost::not2(equal), (a)(b)); BOOST_CHECK_PREDICATE(not_equal, (a)(b)); BOOST_CHECK_PREDICATE(std::not_equal_to(), (a)(b)); -// For some reason, the following line doesn't compile -// BOOST_CHECK_PREDICATE(boost::not2(std::equal_to()), (a)(b)); + // For some reason, the following line doesn't compile + // BOOST_CHECK_PREDICATE(boost::not2(std::equal_to()), + // (a)(b)); BOOST_CHECK_PREDICATE( [](epu8 a, epu8 b) { return not std::equal_to()(a, b); - }, (a)(b)); + }, + (a)(b)); } } } @@ -196,8 +195,7 @@ BOOST_FIXTURE_TEST_CASE(EPU8_not_equal, Fix) { for (size_t i = 0; i < v.size(); i++) for (size_t j = 0; j < v.size(); j++) if (i == j) - BOOST_CHECK_PREDICATE(boost::not2(not_equal), - (v[i])(v[j])); + BOOST_CHECK_PREDICATE(boost::not2(not_equal), (v[i])(v[j])); else BOOST_CHECK_PREDICATE(not_equal, (v[i])(v[j])); } @@ -214,54 +212,57 @@ BOOST_FIXTURE_TEST_CASE(EPU8_less, Fix) { BOOST_AUTO_TEST_SUITE_END() //****************************************************************************// - //****************************************************************************// BOOST_AUTO_TEST_SUITE(EPU8_permute) //****************************************************************************// BOOST_FIXTURE_TEST_CASE(EPU8_permuted, Fix) { - EPU8_EQUAL(permuted(epu8{ 0, 1, 3, 2, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15}, - epu8{ 3, 2, 5, 1, 4, 0, 6, 7, 8, 9,10,11,12,13,14,15}), - (epu8 { 2, 3, 5, 1, 4, 0, 6, 7, 8, 9,10,11,12,13,14,15})); - EPU8_EQUAL(permuted(epu8{ 3, 2, 5, 1, 4, 0, 6, 7, 8, 9,10,11,12,13,14,15}, - epu8{ 0, 1, 3, 2, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15}), - (epu8 { 3, 2, 1, 5, 4, 0, 6, 7, 8, 9,10,11,12,13,14,15})); - EPU8_EQUAL(permuted(epu8{ 3, 2, 5, 1, 4, 0, 6, 7, 8, 9,10,11,12,13,14,15}, - epu8{ 2, 2, 1, 2, 3, 6,12, 4, 5,16,17,11,12,13,14,15}), - (epu8 { 5, 5, 2, 5, 1, 6,12, 4, 0, 3, 2,11,12,13,14,15})); + EPU8_EQUAL( + permuted(epu8{0, 1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, + epu8{3, 2, 5, 1, 4, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}), + (epu8{2, 3, 5, 1, 4, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15})); + EPU8_EQUAL( + permuted(epu8{3, 2, 5, 1, 4, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, + epu8{0, 1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}), + (epu8{3, 2, 1, 5, 4, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15})); + EPU8_EQUAL( + permuted(epu8{3, 2, 5, 1, 4, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, + epu8{2, 2, 1, 2, 3, 6, 12, 4, 5, 16, 17, 11, 12, 13, 14, 15}), + (epu8{5, 5, 2, 5, 1, 6, 12, 4, 0, 3, 2, 11, 12, 13, 14, 15})); } BOOST_FIXTURE_TEST_CASE(EPU8_shifted_left, Fix) { EPU8_EQUAL(shifted_left(P01), P10); - EPU8_EQUAL(shifted_left(P112), (epu8{1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0})); + EPU8_EQUAL(shifted_left(P112), + (epu8{1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0})); EPU8_EQUAL(shifted_left(Pv), - (epu8{ 5, 2, 5, 1, 6,12, 4, 0, 3, 2,11,12,13,14,15, 0})); + (epu8{5, 2, 5, 1, 6, 12, 4, 0, 3, 2, 11, 12, 13, 14, 15, 0})); } BOOST_FIXTURE_TEST_CASE(EPU8_shifted_right, Fix) { EPU8_EQUAL(shifted_right(P10), P01); - EPU8_EQUAL(shifted_right(P112), Epu8({0,1,1}, 2)); + EPU8_EQUAL(shifted_right(P112), Epu8({0, 1, 1}, 2)); EPU8_EQUAL(shifted_right(Pv), - (epu8{ 0, 5, 5, 2, 5, 1, 6,12, 4, 0, 3, 2,11,12,13,14})); + (epu8{0, 5, 5, 2, 5, 1, 6, 12, 4, 0, 3, 2, 11, 12, 13, 14})); } BOOST_FIXTURE_TEST_CASE(EPU8_reverted, Fix) { EPU8_EQUAL(reverted(epu8id), epu8rev); - for (auto x : v) EPU8_EQUAL(x, reverted(reverted(x))); + for (auto x : v) + EPU8_EQUAL(x, reverted(reverted(x))); } //****************************************************************************// BOOST_AUTO_TEST_SUITE_END() //****************************************************************************// - //****************************************************************************// BOOST_AUTO_TEST_SUITE(EPU8_array) //****************************************************************************// BOOST_FIXTURE_TEST_CASE(EPU8_as_array, Fix) { epu8 x = Epu8({4, 2, 5, 1, 2, 7, 7, 3, 4, 2}, 1); - auto & refx = as_array(x); + auto &refx = as_array(x); refx[2] = 42; EPU8_EQUAL(x, Epu8({4, 2, 42, 1, 2, 7, 7, 3, 4, 2}, 1)); - std::fill(refx.begin()+4, refx.end(), 3); + std::fill(refx.begin() + 4, refx.end(), 3); EPU8_EQUAL(x, Epu8({4, 2, 42, 1}, 3)); BOOST_TEST(av == as_array(Pv)); } @@ -276,70 +277,72 @@ BOOST_FIXTURE_TEST_CASE(EPU8_from_array, Fix) { BOOST_AUTO_TEST_SUITE_END() //****************************************************************************// - //****************************************************************************// BOOST_AUTO_TEST_SUITE(EPU8_sorting) //****************************************************************************// BOOST_FIXTURE_TEST_CASE(EPU8_is_sorted, Fix) { BOOST_TEST(is_sorted(epu8id)); - BOOST_TEST(is_sorted(epu8{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15})); - BOOST_TEST(is_sorted(Epu8({ 0, 1}, 2))); + BOOST_TEST( + is_sorted(epu8{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15})); + BOOST_TEST(is_sorted(Epu8({0, 1}, 2))); BOOST_TEST(is_sorted(Epu8({0}, 1))); BOOST_TEST(is_sorted(Epu8({}, 5))); - BOOST_TEST(not is_sorted(epu8{ 0, 1, 3, 2, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15})); - BOOST_TEST(not is_sorted(Epu8({ 0, 2}, 1))); - BOOST_TEST(not is_sorted(Epu8({ 0, 0, 2}, 1))); + BOOST_TEST(not is_sorted( + epu8{0, 1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15})); + BOOST_TEST(not is_sorted(Epu8({0, 2}, 1))); + BOOST_TEST(not is_sorted(Epu8({0, 0, 2}, 1))); BOOST_TEST(not is_sorted(Epu8({6}, 5))); epu8 x = epu8id; BOOST_TEST(is_sorted(x)); - auto & refx = as_array(x); - while (std::next_permutation(refx.begin(), refx.begin()+9)) { + auto &refx = as_array(x); + while (std::next_permutation(refx.begin(), refx.begin() + 9)) { BOOST_TEST(not is_sorted(x)); } x = epu8id; - while (std::next_permutation(refx.begin()+8, refx.begin()+16)) { + while (std::next_permutation(refx.begin() + 8, refx.begin() + 16)) { BOOST_TEST(not is_sorted(x)); } x = sorted(Pa1); BOOST_TEST(is_sorted(x)); - while (std::next_permutation(refx.begin(), refx.begin()+14)) { + while (std::next_permutation(refx.begin(), refx.begin() + 14)) { BOOST_TEST(not is_sorted(x)); } } BOOST_FIXTURE_TEST_CASE(EPU8_sorted, Fix) { - EPU8_EQUAL(sorted(epu8{ 0, 1, 3, 2, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15}), - epu8id); + EPU8_EQUAL( + sorted(epu8{0, 1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}), + epu8id); for (auto &x : v) BOOST_TEST(is_sorted(sorted(x))); epu8 x = epu8id; BOOST_TEST(is_sorted(x)); - auto & refx = as_array(x); + auto &refx = as_array(x); do { BOOST_TEST(is_sorted(sorted(x))); - } while (std::next_permutation(refx.begin(), refx.begin()+9)); + } while (std::next_permutation(refx.begin(), refx.begin() + 9)); } BOOST_FIXTURE_TEST_CASE(EPU8_revsorted, Fix) { - EPU8_EQUAL(revsorted(epu8{ 0, 1, 3, 2, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15}), - epu8rev); + EPU8_EQUAL( + revsorted(epu8{0, 1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}), + epu8rev); for (auto &x : v) BOOST_TEST(is_sorted(reverted(revsorted(x)))); epu8 x = epu8id; BOOST_TEST(is_sorted(x)); - auto & refx = as_array(x); + auto &refx = as_array(x); do { BOOST_TEST(is_sorted(reverted(revsorted(x)))); - } while (std::next_permutation(refx.begin(), refx.begin()+9)); + } while (std::next_permutation(refx.begin(), refx.begin() + 9)); } BOOST_FIXTURE_TEST_CASE(EPU8_sort_perm, Fix) { - epu8 ve { 2, 1, 3, 2, 4, 1, 1, 4, 2, 0, 1, 2, 1, 3, 4, 0}; + epu8 ve{2, 1, 3, 2, 4, 1, 1, 4, 2, 0, 1, 2, 1, 3, 4, 0}; EPU8_EQUAL(sort_perm(ve), - (epu8{ 9,15, 1, 5, 6,10,12, 3, 0, 8,11, 2,13, 7, 4,14})); - EPU8_EQUAL(ve, - (epu8{ 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 4})); + (epu8{9, 15, 1, 5, 6, 10, 12, 3, 0, 8, 11, 2, 13, 7, 4, 14})); + EPU8_EQUAL(ve, (epu8{0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 4})); for (auto x : v) { epu8 xsort = x; @@ -348,28 +351,24 @@ BOOST_FIXTURE_TEST_CASE(EPU8_sort_perm, Fix) { BOOST_TEST(is_permutation(psort)); EPU8_EQUAL(permuted(x, psort), xsort); } - } BOOST_FIXTURE_TEST_CASE(EPU8_sort8_perm, Fix) { - epu8 ve { 2, 1, 3, 2, 4, 1, 1, 4, 2, 0, 1, 2, 1, 3, 4, 0}; + epu8 ve{2, 1, 3, 2, 4, 1, 1, 4, 2, 0, 1, 2, 1, 3, 4, 0}; EPU8_EQUAL(sort8_perm(ve), - (epu8{ 1, 6, 5, 0, 3, 2, 4, 7, 9,15,10,12, 8,11,13,14})); - EPU8_EQUAL(ve, - (epu8{ 1, 1, 1, 2, 2, 3, 4, 4, 0, 0, 1, 1, 2, 2, 3, 4})); + (epu8{1, 6, 5, 0, 3, 2, 4, 7, 9, 15, 10, 12, 8, 11, 13, 14})); + EPU8_EQUAL(ve, (epu8{1, 1, 1, 2, 2, 3, 4, 4, 0, 0, 1, 1, 2, 2, 3, 4})); for (auto x : v) { epu8 xsort = x; epu8 psort = sort_perm(xsort); - BOOST_TEST(is_sorted(xsort | Epu8({0,0,0,0,0,0,0,0}, 0xFF))); - BOOST_TEST(is_sorted(xsort & Epu8({0,0,0,0,0,0,0,0}, 0xFF))); + BOOST_TEST(is_sorted(xsort | Epu8({0, 0, 0, 0, 0, 0, 0, 0}, 0xFF))); + BOOST_TEST(is_sorted(xsort & Epu8({0, 0, 0, 0, 0, 0, 0, 0}, 0xFF))); BOOST_TEST(is_permutation(psort)); EPU8_EQUAL(permuted(x, psort), xsort); } - } - BOOST_FIXTURE_TEST_CASE(EPU8_permutation_of, Fix) { EPU8_EQUAL(permutation_of(epu8id, epu8id), epu8id); EPU8_EQUAL(permutation_of(Pa, Pa), epu8id); @@ -378,17 +377,17 @@ BOOST_FIXTURE_TEST_CASE(EPU8_permutation_of, Fix) { EPU8_EQUAL(permutation_of(epu8rev, epu8rev), epu8id); EPU8_EQUAL(permutation_of(epu8id, RP), RP); const uint8_t FF = 0xff; - EPU8_EQUAL((permutation_of(Pv, Pv) | -// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15 -// epu8{ 5, 5, 2, 5, 1, 6,12, 4, 0, 3, 2,11,12,13,14,15} - (epu8{FF,FF,FF,FF, 0, 0,FF, 0, 0, 0,FF, 0,FF, 0, 0, 0})), - (epu8 {FF,FF,FF,FF, 4, 5,FF, 7, 8, 9,FF,11,FF,13,14,15})); + EPU8_EQUAL( + (permutation_of(Pv, Pv) | + // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15 + // epu8{ 5, 5, 2, 5, 1, 6,12, 4, 0, 3, 2,11,12,13,14,15} + (epu8{FF, FF, FF, FF, 0, 0, FF, 0, 0, 0, FF, 0, FF, 0, 0, 0})), + (epu8{FF, FF, FF, FF, 4, 5, FF, 7, 8, 9, FF, 11, FF, 13, 14, 15})); } //****************************************************************************// BOOST_AUTO_TEST_SUITE_END() //****************************************************************************// - //****************************************************************************// BOOST_AUTO_TEST_SUITE(EPU8_remove_dups_sum) //****************************************************************************// @@ -396,15 +395,15 @@ BOOST_FIXTURE_TEST_CASE(EPU8_remove_dups, Fix) { EPU8_EQUAL(remove_dups(P1), P10); EPU8_EQUAL(remove_dups(P11), P10); EPU8_EQUAL(remove_dups(sorted(P10)), - (epu8{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1})); + (epu8{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1})); EPU8_EQUAL(remove_dups(sorted(Pv)), - (epu8{ 0, 1, 2, 0, 3, 4, 5, 0, 0, 6,11,12, 0,13,14,15})); + (epu8{0, 1, 2, 0, 3, 4, 5, 0, 0, 6, 11, 12, 0, 13, 14, 15})); EPU8_EQUAL(remove_dups(P1, 1), P1); - EPU8_EQUAL(remove_dups(P11, 1), Epu8({1,1,0},1)); - EPU8_EQUAL(remove_dups(P11, 42), Epu8({1,42,0},42)); + EPU8_EQUAL(remove_dups(P11, 1), Epu8({1, 1, 0}, 1)); + EPU8_EQUAL(remove_dups(P11, 42), Epu8({1, 42, 0}, 42)); EPU8_EQUAL(remove_dups(sorted(P10), 1), P1); EPU8_EQUAL(remove_dups(sorted(Pv), 7), - (epu8{ 7, 1, 2, 7, 3, 4, 5, 7, 7, 6,11,12, 7,13,14,15})); + (epu8{7, 1, 2, 7, 3, 4, 5, 7, 7, 6, 11, 12, 7, 13, 14, 15})); for (auto x : v) { x = sorted(remove_dups(sorted(x))); EPU8_EQUAL(x, sorted(remove_dups(x))); @@ -418,7 +417,6 @@ BOOST_FIXTURE_TEST_CASE(EPU8_remove_dups, Fix) { BOOST_AUTO_TEST_SUITE_END() //****************************************************************************// - //****************************************************************************// BOOST_AUTO_TEST_SUITE(EPU8_horiz_sum) //****************************************************************************// @@ -452,42 +450,46 @@ BOOST_AUTO_TEST_SUITE(EPU8_partial_sums) BOOST_FIXTURE_TEST_CASE(EPU8_partial_sums_ref, Fix) { EPU8_EQUAL(partial_sums_ref(zero), zero); EPU8_EQUAL(partial_sums_ref(P01), Epu8({0}, 1)); - EPU8_EQUAL(partial_sums_ref(epu8id), - (epu8{ 0, 1, 3, 6,10,15,21,28,36,45,55,66,78,91,105,120})); + EPU8_EQUAL(partial_sums_ref(epu8id), (epu8{0, 1, 3, 6, 10, 15, 21, 28, 36, + 45, 55, 66, 78, 91, 105, 120})); EPU8_EQUAL(partial_sums_ref(P10), P1); EPU8_EQUAL(partial_sums_ref(P11), Epu8({1}, 2)); EPU8_EQUAL(partial_sums_ref(P1), epu8id + Epu8({}, 1)); - EPU8_EQUAL(partial_sums_ref(P112), - (epu8{ 1, 2, 4, 6, 8,10,12,14,16,18,20,22,24,26,28,30})); - EPU8_EQUAL(partial_sums_ref(Pa1), - (epu8{ 4, 6,11,12,14,21,28,31,35,37,38,39,40,41,42,43})); - EPU8_EQUAL(partial_sums_ref(Pa2), - (epu8{ 4, 6,11,12,14,23,30,33,37,39,40,41,42,43,44,45})); - EPU8_EQUAL(partial_sums_ref(P51), - (epu8{ 5, 6,12,18,24,30,36,42,48,54,60,66,72,78,84,90})); - EPU8_EQUAL(partial_sums_ref(Pv), - (epu8{ 5,10,12,17,18,24,36,40,40,43,45,56,68,81,95,110})); - EPU8_EQUAL(partial_sums_ref(P5), - (epu8{ 5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80})); + EPU8_EQUAL(partial_sums_ref(P112), (epu8{1, 2, 4, 6, 8, 10, 12, 14, 16, 18, + 20, 22, 24, 26, 28, 30})); + EPU8_EQUAL(partial_sums_ref(Pa1), (epu8{4, 6, 11, 12, 14, 21, 28, 31, 35, + 37, 38, 39, 40, 41, 42, 43})); + EPU8_EQUAL(partial_sums_ref(Pa2), (epu8{4, 6, 11, 12, 14, 23, 30, 33, 37, + 39, 40, 41, 42, 43, 44, 45})); + EPU8_EQUAL(partial_sums_ref(P51), (epu8{5, 6, 12, 18, 24, 30, 36, 42, 48, + 54, 60, 66, 72, 78, 84, 90})); + EPU8_EQUAL(partial_sums_ref(Pv), (epu8{5, 10, 12, 17, 18, 24, 36, 40, 40, + 43, 45, 56, 68, 81, 95, 110})); + EPU8_EQUAL(partial_sums_ref(P5), (epu8{5, 10, 15, 20, 25, 30, 35, 40, 45, + 50, 55, 60, 65, 70, 75, 80})); EPU8_EQUAL(partial_sums_ref(epu8rev), - (epu8{15,29,42,54,65,75,84,92,99,105,110,114,117,119,120,120})); + (epu8{15, 29, 42, 54, 65, 75, 84, 92, 99, 105, 110, 114, 117, + 119, 120, 120})); EPU8_EQUAL(partial_sums_ref(Pc), - (epu8{23,28,49,54,97,133,140,147,154,161,168,175,182,189,196,203})); + (epu8{23, 28, 49, 54, 97, 133, 140, 147, 154, 161, 168, 175, 182, + 189, 196, 203})); } BOOST_FIXTURE_TEST_CASE(EPU8_partial_sum_gen, Fix) { - for (auto x : v) EPU8_EQUAL(partial_sums_gen(x), partial_sums_ref(x)); + for (auto x : v) + EPU8_EQUAL(partial_sums_gen(x), partial_sums_ref(x)); } BOOST_FIXTURE_TEST_CASE(EPU8_partial_sum_round, Fix) { - for (auto x : v) EPU8_EQUAL(partial_sums_round(x), partial_sums_ref(x)); + for (auto x : v) + EPU8_EQUAL(partial_sums_round(x), partial_sums_ref(x)); } BOOST_FIXTURE_TEST_CASE(EPU8_partial_sum, Fix) { - for (auto x : v) EPU8_EQUAL(partial_sums(x), partial_sums_ref(x)); + for (auto x : v) + EPU8_EQUAL(partial_sums(x), partial_sums_ref(x)); } //****************************************************************************// BOOST_AUTO_TEST_SUITE_END() //****************************************************************************// - //****************************************************************************// BOOST_AUTO_TEST_SUITE(EPU8_horiz_max) //****************************************************************************// @@ -529,27 +531,28 @@ BOOST_FIXTURE_TEST_CASE(EPU8_partial_max_ref, Fix) { EPU8_EQUAL(partial_max_ref(Pa1), (Epu8({4, 4, 5, 5, 5}, 7))); EPU8_EQUAL(partial_max_ref(Pa2), (Epu8({4, 4, 5, 5, 5}, 9))); EPU8_EQUAL(partial_max_ref(P51), (Epu8({5, 5}, 6))); - EPU8_EQUAL(partial_max_ref(Pv), - (epu8{ 5, 5, 5, 5, 5, 6,12,12,12,12,12,12,12,13,14,15})); + EPU8_EQUAL(partial_max_ref(Pv), (epu8{5, 5, 5, 5, 5, 6, 12, 12, 12, 12, 12, + 12, 12, 13, 14, 15})); EPU8_EQUAL(partial_max_ref(P5), P5); EPU8_EQUAL(partial_max_ref(epu8rev), Epu8({}, 15)); - EPU8_EQUAL(partial_max_ref(Pc), (Epu8({23,23,23,23}, 43))); - + EPU8_EQUAL(partial_max_ref(Pc), (Epu8({23, 23, 23, 23}, 43))); } BOOST_FIXTURE_TEST_CASE(EPU8_partial_sum_gen, Fix) { - for (auto x : v) EPU8_EQUAL(partial_max_gen(x), partial_max_ref(x)); + for (auto x : v) + EPU8_EQUAL(partial_max_gen(x), partial_max_ref(x)); } BOOST_FIXTURE_TEST_CASE(EPU8_partial_max_round, Fix) { - for (auto x : v) EPU8_EQUAL(partial_max_round(x), partial_max_ref(x)); + for (auto x : v) + EPU8_EQUAL(partial_max_round(x), partial_max_ref(x)); } BOOST_FIXTURE_TEST_CASE(EPU8_partial_max, Fix) { - for (auto x : v) EPU8_EQUAL(partial_max(x), partial_max_ref(x)); + for (auto x : v) + EPU8_EQUAL(partial_max(x), partial_max_ref(x)); } //****************************************************************************// BOOST_AUTO_TEST_SUITE_END() //****************************************************************************// - //****************************************************************************// BOOST_AUTO_TEST_SUITE(EPU8_horiz_min) //****************************************************************************// @@ -591,27 +594,38 @@ BOOST_FIXTURE_TEST_CASE(EPU8_partial_min_ref, Fix) { EPU8_EQUAL(partial_min_ref(Pa1), (Epu8({4, 2, 2}, 1))); EPU8_EQUAL(partial_min_ref(Pa2), (Epu8({4, 2, 2}, 1))); EPU8_EQUAL(partial_min_ref(P51), (Epu8({5}, 1))); - EPU8_EQUAL(partial_min_ref(Pv), - (Epu8({ 5, 5, 2, 2, 1, 1, 1, 1,}, 0))); + EPU8_EQUAL(partial_min_ref(Pv), (Epu8( + { + 5, + 5, + 2, + 2, + 1, + 1, + 1, + 1, + }, + 0))); EPU8_EQUAL(partial_min_ref(P5), P5); EPU8_EQUAL(partial_min_ref(epu8rev), epu8rev); EPU8_EQUAL(partial_min_ref(Pc), (Epu8({23}, 5))); - } BOOST_FIXTURE_TEST_CASE(EPU8_partial_sum_gen, Fix) { - for (auto x : v) EPU8_EQUAL(partial_min_gen(x), partial_min_ref(x)); + for (auto x : v) + EPU8_EQUAL(partial_min_gen(x), partial_min_ref(x)); } BOOST_FIXTURE_TEST_CASE(EPU8_partial_min_round, Fix) { - for (auto x : v) EPU8_EQUAL(partial_min_round(x), partial_min_ref(x)); + for (auto x : v) + EPU8_EQUAL(partial_min_round(x), partial_min_ref(x)); } BOOST_FIXTURE_TEST_CASE(EPU8_partial_min, Fix) { - for (auto x : v) EPU8_EQUAL(partial_min(x), partial_min_ref(x)); + for (auto x : v) + EPU8_EQUAL(partial_min(x), partial_min_ref(x)); } //****************************************************************************// BOOST_AUTO_TEST_SUITE_END() //****************************************************************************// - //****************************************************************************// BOOST_AUTO_TEST_SUITE(EPU8_eval16) //****************************************************************************// @@ -624,13 +638,13 @@ BOOST_FIXTURE_TEST_CASE(EPU8_eval16_ref, Fix) { EPU8_EQUAL(eval16_ref(P1), Epu8({0, 16}, 0)); EPU8_EQUAL(eval16_ref(P112), Epu8({0, 2, 14}, 0)); EPU8_EQUAL(eval16_ref(Pa1), Epu8({0, 7, 3, 1, 2, 1, 0, 2}, 0)); - EPU8_EQUAL(eval16_ref(Pa2), Epu8({ 0, 7, 3, 1, 2, 1, 0, 1, 0, 1}, 0)); - EPU8_EQUAL(eval16_ref(P51), Epu8({ 0, 1, 0, 0, 0, 1,14}, 0)); + EPU8_EQUAL(eval16_ref(Pa2), Epu8({0, 7, 3, 1, 2, 1, 0, 1, 0, 1}, 0)); + EPU8_EQUAL(eval16_ref(P51), Epu8({0, 1, 0, 0, 0, 1, 14}, 0)); EPU8_EQUAL(eval16_ref(Pv), - (epu8{ 1, 1, 2, 1, 1, 3, 1, 0, 0, 0, 0, 1, 2, 1, 1, 1})); - EPU8_EQUAL(eval16_ref(P5), Epu8({ 0, 0, 0, 0, 0, 16}, 0)); + (epu8{1, 1, 2, 1, 1, 3, 1, 0, 0, 0, 0, 1, 2, 1, 1, 1})); + EPU8_EQUAL(eval16_ref(P5), Epu8({0, 0, 0, 0, 0, 16}, 0)); EPU8_EQUAL(eval16_ref(epu8rev), Epu8({}, 1)); - EPU8_EQUAL(eval16_ref(Pc), Epu8({ 0, 0, 0, 0, 0, 2, 0,10}, 0)); + EPU8_EQUAL(eval16_ref(Pc), Epu8({0, 0, 0, 0, 0, 2, 0, 10}, 0)); } TEST_EPU8_AGREES(eval16_ref, eval16_cycle) TEST_EPU8_AGREES(eval16_ref, eval16_popcount) @@ -646,32 +660,31 @@ BOOST_AUTO_TEST_SUITE(EPU8_vector_popcount) //****************************************************************************// BOOST_FIXTURE_TEST_CASE(EPU8_popcount4, Fix) { EPU8_EQUAL(popcount4, - (epu8 { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4})); + (epu8{0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4})); } BOOST_FIXTURE_TEST_CASE(EPU8_popcount, Fix) { EPU8_EQUAL(popcount16(Pv), - (epu8 {2, 2, 1, 2, 1, 2, 2, 1, 0, 2, 1, 3, 2, 3, 3, 4})); + (epu8{2, 2, 1, 2, 1, 2, 2, 1, 0, 2, 1, 3, 2, 3, 3, 4})); EPU8_EQUAL(popcount16(RP), - (epu8 {2, 1, 0, 3, 4, 3, 2, 2, 1, 3, 2, 2, 3, 1, 1, 2})); + (epu8{2, 1, 0, 3, 4, 3, 2, 2, 1, 3, 2, 2, 3, 1, 1, 2})); EPU8_EQUAL(popcount16(RP << 1), - (epu8 {2, 1, 0, 3, 4, 3, 2, 2, 1, 3, 2, 2, 3, 1, 1, 2})); + (epu8{2, 1, 0, 3, 4, 3, 2, 2, 1, 3, 2, 2, 3, 1, 1, 2})); EPU8_EQUAL(popcount16(RP << 2), - (epu8 {2, 1, 0, 3, 4, 3, 2, 2, 1, 3, 2, 2, 3, 1, 1, 2})); - EPU8_EQUAL(popcount16(Epu8({0,1,5,0xff, 0xf0, 0x35}, 0x0f)), - (Epu8({0,1,2,8}, 4))); + (epu8{2, 1, 0, 3, 4, 3, 2, 2, 1, 3, 2, 2, 3, 1, 1, 2})); + EPU8_EQUAL(popcount16(Epu8({0, 1, 5, 0xff, 0xf0, 0x35}, 0x0f)), + (Epu8({0, 1, 2, 8}, 4))); } //****************************************************************************// BOOST_AUTO_TEST_SUITE_END() //****************************************************************************// - //****************************************************************************// BOOST_AUTO_TEST_SUITE(EPU8_random) //****************************************************************************// BOOST_AUTO_TEST_CASE(Random) { - for (int i = 0; i<10 ; i++) { + for (int i = 0; i < 10; i++) { epu8 r = random_epu8(255); EPU8_EQUAL(r, r); } @@ -702,8 +715,10 @@ BOOST_FIXTURE_TEST_CASE(IsPTransf, Fix) { BOOST_TEST(is_partial_transformation(RP)); BOOST_TEST(is_partial_transformation(RP, 16)); BOOST_TEST(not is_partial_transformation(RP, 15)); - BOOST_TEST(is_partial_transformation(Epu8({1,2,1,0xFF,0,5,0xFF,2}, 0))); - BOOST_TEST(not is_partial_transformation(Epu8({1,2,1,0xFF,0,16,0xFF,2}, 0))); + BOOST_TEST( + is_partial_transformation(Epu8({1, 2, 1, 0xFF, 0, 5, 0xFF, 2}, 0))); + BOOST_TEST(not is_partial_transformation( + Epu8({1, 2, 1, 0xFF, 0, 16, 0xFF, 2}, 0))); } BOOST_FIXTURE_TEST_CASE(IsTransf, Fix) { @@ -749,11 +764,13 @@ BOOST_FIXTURE_TEST_CASE(IsPPerm, Fix) { BOOST_TEST(not is_partial_permutation(RP, 15)); BOOST_TEST(is_partial_permutation( - epu8 {1,2,0xFF,0xFF,0,5,0xFF,3,8,9,10,11,12,13,14,15})); + epu8{1, 2, 0xFF, 0xFF, 0, 5, 0xFF, 3, 8, 9, 10, 11, 12, 13, 14, 15})); BOOST_TEST(not is_partial_permutation( - epu8 {1,2,1,0xFF,0,5,0xFF,2,8,9,10,11,12,13,14,15})); - BOOST_TEST(not is_partial_permutation(Epu8({1,2,1,0xFF,0,5,0xFF,2}, 0))); - BOOST_TEST(not is_partial_permutation(Epu8({1,2,1,0xFF,0,16,0xFF,2}, 0))); + epu8{1, 2, 1, 0xFF, 0, 5, 0xFF, 2, 8, 9, 10, 11, 12, 13, 14, 15})); + BOOST_TEST( + not is_partial_permutation(Epu8({1, 2, 1, 0xFF, 0, 5, 0xFF, 2}, 0))); + BOOST_TEST( + not is_partial_permutation(Epu8({1, 2, 1, 0xFF, 0, 16, 0xFF, 2}, 0))); } BOOST_FIXTURE_TEST_CASE(IsPerm, Fix) { diff --git a/tests/test_mincl.cpp b/tests/test_mincl.cpp index 2eb9fc87..13cd63e3 100644 --- a/tests/test_mincl.cpp +++ b/tests/test_mincl.cpp @@ -24,4 +24,3 @@ BOOST_AUTO_TEST_SUITE(MultIncl) BOOST_AUTO_TEST_CASE(MultInclFoo0) { BOOST_CHECK_EQUAL(foo0(), 0); } BOOST_AUTO_TEST_CASE(MultInclFoo1) { BOOST_CHECK_EQUAL(foo1(), 1); } BOOST_AUTO_TEST_SUITE_END() - diff --git a/tests/test_mincl_common.cpp b/tests/test_mincl_common.cpp index 56f74d5d..861dd13b 100644 --- a/tests/test_mincl_common.cpp +++ b/tests/test_mincl_common.cpp @@ -17,7 +17,7 @@ #include "hpcombi.hpp" -#define PPCAT_NX(A, B) A ## B +#define PPCAT_NX(A, B) A##B #define PPCAT(A, B) PPCAT_NX(A, B) int PPCAT(foo, CONST_TO_BE_CHANGED)() { diff --git a/tests/test_perm16.cpp b/tests/test_perm16.cpp index a976887d..cf009bfd 100644 --- a/tests/test_perm16.cpp +++ b/tests/test_perm16.cpp @@ -19,45 +19,48 @@ #include using HPCombi::epu8; -using HPCombi::equal; using HPCombi::Epu8; +using HPCombi::equal; using HPCombi::is_partial_transformation; -using HPCombi::is_transformation; using HPCombi::is_permutation; +using HPCombi::is_transformation; +using HPCombi::Perm16; +using HPCombi::PPerm16; using HPCombi::PTransf16; using HPCombi::Transf16; -using HPCombi::PPerm16; -using HPCombi::Perm16; const uint8_t FF = 0xff; -#define EPU8_EQUAL(p1, p2) BOOST_CHECK_PREDICATE(equal, (p1)(p2)) -#define EPU8_NOT_EQUAL(p1, p2) BOOST_CHECK_PREDICATE(boost::not2(equal), (p1)(p2)) +#define EPU8_EQUAL(p1, p2) BOOST_CHECK_PREDICATE(equal, (p1)(p2)) +#define EPU8_NOT_EQUAL(p1, p2) \ + BOOST_CHECK_PREDICATE(boost::not2(equal), (p1)(p2)) -#define TEST_AGREES(type, ref, fun, vct) \ - BOOST_FIXTURE_TEST_CASE(type##_agrees_##fun, Fix) { \ - for (type p : vct) BOOST_TEST(p.fun() == p.ref()); \ +#define TEST_AGREES(type, ref, fun, vct) \ + BOOST_FIXTURE_TEST_CASE(type##_agrees_##fun, Fix) { \ + for (type p : vct) \ + BOOST_TEST(p.fun() == p.ref()); \ } -#define TEST_EPU8_AGREES(type, ref, fun, vct) \ - BOOST_FIXTURE_TEST_CASE(type##_agrees_##fun, Fix) { \ - for (type p : vct) EPU8_EQUAL(p.fun(), p.ref()); \ +#define TEST_EPU8_AGREES(type, ref, fun, vct) \ + BOOST_FIXTURE_TEST_CASE(type##_agrees_##fun, Fix) { \ + for (type p : vct) \ + EPU8_EQUAL(p.fun(), p.ref()); \ } -std::vector all_perms(uint8_t sz){ - std::vector res {}; +std::vector all_perms(uint8_t sz) { + std::vector res{}; epu8 x = HPCombi::epu8id; res.push_back(x); - auto & refx = HPCombi::as_array(x); - while (std::next_permutation(refx.begin(), refx.begin()+sz)) { + auto &refx = HPCombi::as_array(x); + while (std::next_permutation(refx.begin(), refx.begin() + sz)) { res.push_back(x); } return res; }; std::vector all_pperms(std::vector perms, - std::vector masks){ - std::vector res {}; + std::vector masks) { + std::vector res{}; for (epu8 mask : masks) { for (Perm16 p : perms) { res.push_back(p.v | mask); @@ -67,26 +70,21 @@ std::vector all_pperms(std::vector perms, } struct Fix { - Fix() : zero(Epu8({}, 0)), - P01(Epu8({0, 1}, 0)), - P10(Epu8({1, 0}, 0)), - P11(Epu8({1, 1}, 0)), - P1(Epu8({}, 1)), - RandT({3, 1, 0, 14, 15, 13, 5, 10, 2, 11, 6, 12, 7, 4, 8, 9}), - PPa({1, 2, 3, 4, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}), - PPb({1, 2, 3, 6, 0, 5, 4, 7, 8, 9, 10, 11, 12, 15, 14, 13}), - RandPerm(RandT), - Tlist({zero, P01, P10, P11, P1, RandT, epu8(PPa), epu8(PPb)}), - PlistSmall(all_perms(6)), Plist(all_perms(9)), - PPmasks({ - Epu8(0), Epu8(FF), Epu8({0}, FF), Epu8({0, 0}, FF), - Epu8({0, FF, 0}, FF), Epu8({0, FF, 0}, 0), - Epu8({0, FF, 0, FF, 0, 0, 0, FF, FF}, 0) - }), - PPlist(all_pperms(PlistSmall, PPmasks)) - { - BOOST_TEST_MESSAGE("setup fixture"); - } + Fix() + : zero(Epu8({}, 0)), P01(Epu8({0, 1}, 0)), P10(Epu8({1, 0}, 0)), + P11(Epu8({1, 1}, 0)), P1(Epu8({}, 1)), + RandT({3, 1, 0, 14, 15, 13, 5, 10, 2, 11, 6, 12, 7, 4, 8, 9}), + PPa({1, 2, 3, 4, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}), + PPb({1, 2, 3, 6, 0, 5, 4, 7, 8, 9, 10, 11, 12, 15, 14, 13}), + RandPerm(RandT), + Tlist({zero, P01, P10, P11, P1, RandT, epu8(PPa), epu8(PPb)}), + PlistSmall(all_perms(6)), Plist(all_perms(9)), + PPmasks({Epu8(0), Epu8(FF), Epu8({0}, FF), Epu8({0, 0}, FF), + Epu8({0, FF, 0}, FF), Epu8({0, FF, 0}, 0), + Epu8({0, FF, 0, FF, 0, 0, 0, FF, FF}, 0)}), + PPlist(all_pperms(PlistSmall, PPmasks)) { + BOOST_TEST_MESSAGE("setup fixture"); + } ~Fix() { BOOST_TEST_MESSAGE("teardown fixture"); } const Transf16 zero, P01, P10, P11, P1, RandT; @@ -97,7 +95,6 @@ struct Fix { const std::vector PPlist; }; - //****************************************************************************// BOOST_AUTO_TEST_SUITE(PTransf16_test) //****************************************************************************// @@ -105,168 +102,210 @@ BOOST_AUTO_TEST_SUITE(PTransf16_test) BOOST_AUTO_TEST_CASE(PTransf16_constructor) { const uint8_t FF = 0xff; BOOST_TEST(PTransf16({}) == PTransf16::one()); - BOOST_TEST(PTransf16({0,1,2,3}) == PTransf16::one()); - BOOST_TEST(PTransf16({1,0}) == PTransf16({1,0,2})); - BOOST_TEST(PTransf16({2}) == PTransf16({2,1,2})); + BOOST_TEST(PTransf16({0, 1, 2, 3}) == PTransf16::one()); + BOOST_TEST(PTransf16({1, 0}) == PTransf16({1, 0, 2})); + BOOST_TEST(PTransf16({2}) == PTransf16({2, 1, 2})); BOOST_TEST(PTransf16({4, 5, 0}, {9, 0, 1}) == - PTransf16({ 1,FF,FF,FF, 9, 0,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF})); + PTransf16({1, FF, FF, FF, 9, 0, FF, FF, FF, FF, FF, FF, FF, FF, + FF, FF})); BOOST_TEST(PTransf16({4, 5, 0, 8}, {9, 0, 1, 2}) == - PTransf16({ 1,FF,FF,FF, 9, 0,FF,FF,2,FF,FF,FF,FF,FF,FF,FF})); + PTransf16({1, FF, FF, FF, 9, 0, FF, FF, 2, FF, FF, FF, FF, FF, + FF, FF})); BOOST_TEST(PTransf16({4, 5, 0, 8}, {9, 0, 2, 2}) == - PTransf16({ 2,FF,FF,FF, 9, 0,FF,FF,2,FF,FF,FF,FF,FF,FF,FF})); + PTransf16({2, FF, FF, FF, 9, 0, FF, FF, 2, FF, FF, FF, FF, FF, + FF, FF})); } - BOOST_AUTO_TEST_CASE(PTransf16_hash) { BOOST_TEST(std::hash()(PTransf16::one()) != 0); BOOST_TEST(std::hash()(PTransf16(Epu8(1))) != 0); BOOST_TEST(std::hash()(PTransf16({4, 5, 0}, {9, 0, 1})) != 0); } - BOOST_AUTO_TEST_CASE(PTransf16_image_mask) { EPU8_EQUAL(PTransf16({}).image_mask(), Epu8(FF)); EPU8_EQUAL(PTransf16({}).image_mask(false), Epu8(FF)); EPU8_EQUAL(PTransf16({}).image_mask(true), Epu8(0)); - EPU8_EQUAL(PTransf16({4,4,4,4}).image_mask(), Epu8({0,0,0,0}, FF)); - EPU8_EQUAL(PTransf16({4,4,4,4}).image_mask(false), Epu8({0,0,0,0}, FF)); - EPU8_EQUAL(PTransf16({4,4,4,4}).image_mask(true), Epu8({FF,FF,FF,FF}, 0)); - EPU8_EQUAL(PTransf16(Epu8(1)).image_mask(), Epu8({0,FF}, 0)); - EPU8_EQUAL(PTransf16(Epu8(2)).image_mask(), Epu8({0,0,FF}, 0)); - EPU8_EQUAL(PTransf16(Epu8({2,2,2,0xf},2)).image_mask(), - Epu8({0,0,FF,0,0,0,0,0,0,0,0,0,0,0,0,FF}, 0)); - EPU8_EQUAL(PTransf16(Epu8({0,2,2,0xf,2,2,2,2,5,2}, 2)).image_mask(), - Epu8({FF,0,FF,0,0,FF,0,0,0,0,0,0,0,0,0,FF}, 0)); - EPU8_EQUAL(PTransf16(Epu8({0,2,2,0xf,2,2,2,2,5,2}, 2)).image_mask(false), - Epu8({FF,0,FF,0,0,FF,0,0,0,0,0,0,0,0,0,FF}, 0)); - EPU8_EQUAL(PTransf16(Epu8({0,2,2,0xf,2,2,2,2,5,2}, 2)).image_mask(true), - Epu8({0,FF,0,FF,FF,0,FF,FF,FF,FF,FF,FF,FF,FF,FF,0}, 0)); + EPU8_EQUAL(PTransf16({4, 4, 4, 4}).image_mask(), Epu8({0, 0, 0, 0}, FF)); + EPU8_EQUAL(PTransf16({4, 4, 4, 4}).image_mask(false), + Epu8({0, 0, 0, 0}, FF)); + EPU8_EQUAL(PTransf16({4, 4, 4, 4}).image_mask(true), + Epu8({FF, FF, FF, FF}, 0)); + EPU8_EQUAL(PTransf16(Epu8(1)).image_mask(), Epu8({0, FF}, 0)); + EPU8_EQUAL(PTransf16(Epu8(2)).image_mask(), Epu8({0, 0, FF}, 0)); + EPU8_EQUAL(PTransf16(Epu8({2, 2, 2, 0xf}, 2)).image_mask(), + Epu8({0, 0, FF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FF}, 0)); + EPU8_EQUAL( + PTransf16(Epu8({0, 2, 2, 0xf, 2, 2, 2, 2, 5, 2}, 2)).image_mask(), + Epu8({FF, 0, FF, 0, 0, FF, 0, 0, 0, 0, 0, 0, 0, 0, 0, FF}, 0)); + EPU8_EQUAL( + PTransf16(Epu8({0, 2, 2, 0xf, 2, 2, 2, 2, 5, 2}, 2)).image_mask(false), + Epu8({FF, 0, FF, 0, 0, FF, 0, 0, 0, 0, 0, 0, 0, 0, 0, FF}, 0)); + EPU8_EQUAL( + PTransf16(Epu8({0, 2, 2, 0xf, 2, 2, 2, 2, 5, 2}, 2)).image_mask(true), + Epu8({0, FF, 0, FF, FF, 0, FF, FF, FF, FF, FF, FF, FF, FF, FF, 0}, 0)); } BOOST_AUTO_TEST_CASE(PTransf16_left_one) { BOOST_TEST(PTransf16({}).left_one() == PTransf16::one()); - BOOST_TEST(PTransf16({4,4,4,4}).left_one() == PTransf16({FF,FF,FF,FF})); - BOOST_TEST(PTransf16(Epu8(1)).left_one() == PTransf16(Epu8({FF,1}, FF))); - BOOST_TEST(PTransf16(Epu8(2)).left_one() == PTransf16(Epu8({FF,FF,2}, FF))); - BOOST_TEST(PTransf16(Epu8({2,2,2,0xf},2)).left_one() == - PTransf16({FF,FF,2,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,15})); - BOOST_TEST(PTransf16(Epu8({FF,2,2,0xf},FF)).left_one() == - PTransf16({FF,FF,2,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,15})); - BOOST_TEST(PTransf16(Epu8({0,2,2,0xf,2,2,2,2,5,2}, 2)).left_one() == - PTransf16({0,FF,2,FF,FF,5,FF,FF,FF,FF,FF,FF,FF,FF,FF,15})); - BOOST_TEST(PTransf16(Epu8({0,2,FF,0xf,2,FF,2,FF,5}, FF)).left_one() == - PTransf16({0,FF,2,FF,FF,5,FF,FF,FF,FF,FF,FF,FF,FF,FF,15})); + BOOST_TEST(PTransf16({4, 4, 4, 4}).left_one() == + PTransf16({FF, FF, FF, FF})); + BOOST_TEST(PTransf16(Epu8(1)).left_one() == PTransf16(Epu8({FF, 1}, FF))); + BOOST_TEST(PTransf16(Epu8(2)).left_one() == + PTransf16(Epu8({FF, FF, 2}, FF))); + BOOST_TEST(PTransf16(Epu8({2, 2, 2, 0xf}, 2)).left_one() == + PTransf16({FF, FF, 2, FF, FF, FF, FF, FF, FF, FF, FF, FF, FF, FF, + FF, 15})); + BOOST_TEST(PTransf16(Epu8({FF, 2, 2, 0xf}, FF)).left_one() == + PTransf16({FF, FF, 2, FF, FF, FF, FF, FF, FF, FF, FF, FF, FF, FF, + FF, 15})); + BOOST_TEST( + PTransf16(Epu8({0, 2, 2, 0xf, 2, 2, 2, 2, 5, 2}, 2)).left_one() == + PTransf16( + {0, FF, 2, FF, FF, 5, FF, FF, FF, FF, FF, FF, FF, FF, FF, 15})); + BOOST_TEST( + PTransf16(Epu8({0, 2, FF, 0xf, 2, FF, 2, FF, 5}, FF)).left_one() == + PTransf16( + {0, FF, 2, FF, FF, 5, FF, FF, FF, FF, FF, FF, FF, FF, FF, 15})); } BOOST_AUTO_TEST_CASE(PTransf16_domain_mask) { EPU8_EQUAL(PTransf16({}).domain_mask(), Epu8(FF)); - EPU8_EQUAL(PTransf16({4,4,4,4}).domain_mask(), Epu8(FF)); - EPU8_EQUAL(PTransf16({4,4,4,4}).domain_mask(false), Epu8(FF)); - EPU8_EQUAL(PTransf16({4,4,4,4}).domain_mask(true), Epu8(0)); + EPU8_EQUAL(PTransf16({4, 4, 4, 4}).domain_mask(), Epu8(FF)); + EPU8_EQUAL(PTransf16({4, 4, 4, 4}).domain_mask(false), Epu8(FF)); + EPU8_EQUAL(PTransf16({4, 4, 4, 4}).domain_mask(true), Epu8(0)); EPU8_EQUAL(PTransf16(Epu8(1)).domain_mask(), Epu8(FF)); EPU8_EQUAL(PTransf16(Epu8(2)).domain_mask(), Epu8(FF)); - EPU8_EQUAL(PTransf16(Epu8({2,2,2,0xf}, FF)).domain_mask(), - Epu8({FF,FF,FF,FF}, 0)); - EPU8_EQUAL(PTransf16(Epu8({FF,2,2,0xf},FF)).domain_mask(), + EPU8_EQUAL(PTransf16(Epu8({2, 2, 2, 0xf}, FF)).domain_mask(), + Epu8({FF, FF, FF, FF}, 0)); + EPU8_EQUAL(PTransf16(Epu8({FF, 2, 2, 0xf}, FF)).domain_mask(), Epu8({0, FF, FF, FF}, 0)); - EPU8_EQUAL(PTransf16(Epu8({0,2,FF,0xf,2,FF,2,FF,5}, FF)).domain_mask(), - Epu8({FF,FF,0,FF,FF,0,FF,0,FF},0)); - EPU8_EQUAL(PTransf16(Epu8({0,2,FF,0xf,2,FF,2,FF,5}, FF)).domain_mask(false), - Epu8({FF,FF,0,FF,FF,0,FF,0,FF},0)); - EPU8_EQUAL(PTransf16(Epu8({0,2,FF,0xf,2,FF,2,FF,5}, FF)).domain_mask(true), - Epu8({0,0,FF,0,0,FF, 0,FF,0},FF)); + EPU8_EQUAL( + PTransf16(Epu8({0, 2, FF, 0xf, 2, FF, 2, FF, 5}, FF)).domain_mask(), + Epu8({FF, FF, 0, FF, FF, 0, FF, 0, FF}, 0)); + EPU8_EQUAL(PTransf16(Epu8({0, 2, FF, 0xf, 2, FF, 2, FF, 5}, FF)) + .domain_mask(false), + Epu8({FF, FF, 0, FF, FF, 0, FF, 0, FF}, 0)); + EPU8_EQUAL( + PTransf16(Epu8({0, 2, FF, 0xf, 2, FF, 2, FF, 5}, FF)).domain_mask(true), + Epu8({0, 0, FF, 0, 0, FF, 0, FF, 0}, FF)); } BOOST_AUTO_TEST_CASE(PTransf16_right_one) { BOOST_TEST(PTransf16({}).right_one() == PTransf16::one()); - BOOST_TEST(PTransf16({4,4,4,4}).right_one() == PTransf16::one()); + BOOST_TEST(PTransf16({4, 4, 4, 4}).right_one() == PTransf16::one()); BOOST_TEST(PTransf16(Epu8(1)).right_one() == PTransf16::one()); BOOST_TEST(PTransf16(Epu8(2)).right_one() == PTransf16::one()); - BOOST_TEST(PTransf16(Epu8({2,2,2,0xf}, FF)).right_one() == - PTransf16(Epu8({0,1,2,3}, FF))); - BOOST_TEST(PTransf16(Epu8({FF,2,2,0xf},FF)).right_one() == - PTransf16({FF, 1, 2, 3,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF})); - BOOST_TEST(PTransf16(Epu8({0,2,2,0xf,2,2,2,2,5,2}, 2)).right_one() == - PTransf16::one()); - BOOST_TEST(PTransf16(Epu8({0,2,FF,0xf,2,FF,2,FF,5}, FF)).right_one() == - PTransf16({0,1,FF,3,4,FF, 6,FF,8,FF,FF,FF,FF,FF,FF,FF})); + BOOST_TEST(PTransf16(Epu8({2, 2, 2, 0xf}, FF)).right_one() == + PTransf16(Epu8({0, 1, 2, 3}, FF))); + BOOST_TEST(PTransf16(Epu8({FF, 2, 2, 0xf}, FF)).right_one() == + PTransf16({FF, 1, 2, 3, FF, FF, FF, FF, FF, FF, FF, FF, FF, FF, + FF, FF})); + BOOST_TEST( + PTransf16(Epu8({0, 2, 2, 0xf, 2, 2, 2, 2, 5, 2}, 2)).right_one() == + PTransf16::one()); + BOOST_TEST( + PTransf16(Epu8({0, 2, FF, 0xf, 2, FF, 2, FF, 5}, FF)).right_one() == + PTransf16({0, 1, FF, 3, 4, FF, 6, FF, 8, FF, FF, FF, FF, FF, FF, FF})); } - BOOST_AUTO_TEST_CASE(PTransf16_rank_ref) { BOOST_TEST(PTransf16({}).rank_ref() == 16); - BOOST_TEST(PTransf16({4,4,4,4}).rank() == 12); - BOOST_TEST(PTransf16({1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}).rank_ref() == 1); - BOOST_TEST(PTransf16({2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}).rank_ref() == 1); - BOOST_TEST(PTransf16({2,2,2,0xf,2,2,2,2,2,2,2,2,2,2,2,2}).rank_ref() == 2); - BOOST_TEST(PTransf16({0,2,2,0xf,2,2,2,2,5,2,2,2,2,2,2,2}).rank_ref() == 4); - BOOST_TEST(PTransf16({1,1,1,FF,1,1,FF,1,1,FF,1,FF,1,1,1,1}).rank_ref() == 1); - BOOST_TEST(PTransf16({2,2,2,2,2,FF,2,2,2,FF,2,2,2,FF,2,2}).rank_ref() == 1); - BOOST_TEST(PTransf16({2,2,2,0xf,2,FF,2,2,2,2,2,2,2,2,2,2}).rank_ref() == 2); - BOOST_TEST(PTransf16({0,2,2,0xf,2,2,FF,2,5,2,FF,2,2,2,2,2}).rank_ref() == 4); + BOOST_TEST(PTransf16({4, 4, 4, 4}).rank() == 12); + BOOST_TEST(PTransf16({1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) + .rank_ref() == 1); + BOOST_TEST(PTransf16({2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}) + .rank_ref() == 1); + BOOST_TEST(PTransf16({2, 2, 2, 0xf, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}) + .rank_ref() == 2); + BOOST_TEST(PTransf16({0, 2, 2, 0xf, 2, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2}) + .rank_ref() == 4); + BOOST_TEST(PTransf16({1, 1, 1, FF, 1, 1, FF, 1, 1, FF, 1, FF, 1, 1, 1, 1}) + .rank_ref() == 1); + BOOST_TEST(PTransf16({2, 2, 2, 2, 2, FF, 2, 2, 2, FF, 2, 2, 2, FF, 2, 2}) + .rank_ref() == 1); + BOOST_TEST(PTransf16({2, 2, 2, 0xf, 2, FF, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}) + .rank_ref() == 2); + BOOST_TEST(PTransf16({0, 2, 2, 0xf, 2, 2, FF, 2, 5, 2, FF, 2, 2, 2, 2, 2}) + .rank_ref() == 4); } BOOST_AUTO_TEST_CASE(PTransf16_rank) { BOOST_TEST(PTransf16({}).rank() == 16); - BOOST_TEST(PTransf16({4,4,4,4}).rank() == 12); - BOOST_TEST(PTransf16({1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}).rank() == 1); - BOOST_TEST(PTransf16({2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}).rank() == 1); - BOOST_TEST(PTransf16({2,2,2,0xf,2,2,2,2,2,2,2,2,2,2,2,2}).rank() == 2); - BOOST_TEST(PTransf16({0,2,2,0xf,2,2,2,2,5,2,2,2,2,2,2,2}).rank() == 4); + BOOST_TEST(PTransf16({4, 4, 4, 4}).rank() == 12); + BOOST_TEST( + PTransf16({1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}).rank() == + 1); + BOOST_TEST( + PTransf16({2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}).rank() == + 1); + BOOST_TEST( + PTransf16({2, 2, 2, 0xf, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}).rank() == + 2); + BOOST_TEST( + PTransf16({0, 2, 2, 0xf, 2, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2}).rank() == + 4); } BOOST_AUTO_TEST_CASE(PTransf16_fix_points_mask) { EPU8_EQUAL(PTransf16({}).fix_points_mask(), Epu8(FF)); EPU8_EQUAL(PTransf16({}).fix_points_mask(false), Epu8(FF)); EPU8_EQUAL(PTransf16({}).fix_points_mask(true), Epu8(0)); - EPU8_EQUAL(PTransf16({4,4,4,4}).fix_points_mask(), Epu8({0,0,0,0}, FF)); - EPU8_EQUAL(PTransf16({4,4,4,4}).fix_points_mask(false), Epu8({0,0,0,0}, FF)); - EPU8_EQUAL(PTransf16({4,4,4,4}).fix_points_mask(true), Epu8({FF,FF,FF,FF}, 0)); - EPU8_EQUAL(PTransf16(Epu8(1)).fix_points_mask(), Epu8({0,FF}, 0)); - EPU8_EQUAL(PTransf16(Epu8(2)).fix_points_mask(), Epu8({0,0,FF}, 0)); - EPU8_EQUAL(PTransf16(Epu8({2,2,2,0xf},7)).fix_points_mask(), - Epu8({0,0,FF,0,0,0,0,FF,0,0,0,0,0,0,0,0}, 0)); - EPU8_EQUAL(PTransf16(Epu8({0,2,2,0xf,2,2,2,14,5,2}, 2)).fix_points_mask(), - Epu8({FF,0,FF,0,0,0,0,0,0,0,0,0,0,0,0,0}, 0)); - EPU8_EQUAL(PTransf16(Epu8({0,2,2,0xf,2,2,2,2,8,2}, 14)).fix_points_mask(false), - Epu8({FF,0,FF,0,0,0,0,0,FF,0,0,0,0,0,FF,0}, 0)); - EPU8_EQUAL(PTransf16(Epu8({0,2,2,0xf,2,2,2,2,5,2}, 2)).fix_points_mask(true), - Epu8({0,FF,0},FF)); + EPU8_EQUAL(PTransf16({4, 4, 4, 4}).fix_points_mask(), + Epu8({0, 0, 0, 0}, FF)); + EPU8_EQUAL(PTransf16({4, 4, 4, 4}).fix_points_mask(false), + Epu8({0, 0, 0, 0}, FF)); + EPU8_EQUAL(PTransf16({4, 4, 4, 4}).fix_points_mask(true), + Epu8({FF, FF, FF, FF}, 0)); + EPU8_EQUAL(PTransf16(Epu8(1)).fix_points_mask(), Epu8({0, FF}, 0)); + EPU8_EQUAL(PTransf16(Epu8(2)).fix_points_mask(), Epu8({0, 0, FF}, 0)); + EPU8_EQUAL(PTransf16(Epu8({2, 2, 2, 0xf}, 7)).fix_points_mask(), + Epu8({0, 0, FF, 0, 0, 0, 0, FF, 0, 0, 0, 0, 0, 0, 0, 0}, 0)); + EPU8_EQUAL( + PTransf16(Epu8({0, 2, 2, 0xf, 2, 2, 2, 14, 5, 2}, 2)).fix_points_mask(), + Epu8({FF, 0, FF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0)); + EPU8_EQUAL(PTransf16(Epu8({0, 2, 2, 0xf, 2, 2, 2, 2, 8, 2}, 14)) + .fix_points_mask(false), + Epu8({FF, 0, FF, 0, 0, 0, 0, 0, FF, 0, 0, 0, 0, 0, FF, 0}, 0)); + EPU8_EQUAL(PTransf16(Epu8({0, 2, 2, 0xf, 2, 2, 2, 2, 5, 2}, 2)) + .fix_points_mask(true), + Epu8({0, FF, 0}, FF)); } BOOST_AUTO_TEST_CASE(PTransf16_fix_points_bitset) { BOOST_TEST(PTransf16({}).fix_points_bitset() == 0xFFFF); BOOST_TEST(PTransf16({}).fix_points_bitset(false) == 0xFFFF); BOOST_TEST(PTransf16({}).fix_points_bitset(true) == 0); - BOOST_TEST(PTransf16({4,4,4,4}).fix_points_bitset() == 0xFFF0); - BOOST_TEST(PTransf16({4,4,4,4}).fix_points_bitset(false) == 0xFFF0); - BOOST_TEST(PTransf16({4,4,4,4}).fix_points_bitset(true) == 0x000F); + BOOST_TEST(PTransf16({4, 4, 4, 4}).fix_points_bitset() == 0xFFF0); + BOOST_TEST(PTransf16({4, 4, 4, 4}).fix_points_bitset(false) == 0xFFF0); + BOOST_TEST(PTransf16({4, 4, 4, 4}).fix_points_bitset(true) == 0x000F); BOOST_TEST(PTransf16(Epu8(1)).fix_points_bitset() == 0x0002); - BOOST_TEST(PTransf16(Epu8(2)).fix_points_bitset() == 0x0004); - BOOST_TEST(PTransf16(Epu8({2,2,2,0xf},7)).fix_points_bitset() == 0x0084); - BOOST_TEST(PTransf16(Epu8({0,2,2,0xf,2,2,2,14,5,2}, 2)).fix_points_bitset() - == 0x5); - BOOST_TEST(PTransf16(Epu8({0,2,2,0xf,2,2,2,2,8,2}, 14)).fix_points_bitset(false) - == 0x4105); - BOOST_TEST(PTransf16(Epu8({0,2,2,0xf,2,2,2,2,5,2}, 2)).fix_points_bitset(true) - == 0xFFFA); + BOOST_TEST(PTransf16(Epu8(2)).fix_points_bitset() == 0x0004); + BOOST_TEST(PTransf16(Epu8({2, 2, 2, 0xf}, 7)).fix_points_bitset() == + 0x0084); + BOOST_TEST(PTransf16(Epu8({0, 2, 2, 0xf, 2, 2, 2, 14, 5, 2}, 2)) + .fix_points_bitset() == 0x5); + BOOST_TEST(PTransf16(Epu8({0, 2, 2, 0xf, 2, 2, 2, 2, 8, 2}, 14)) + .fix_points_bitset(false) == 0x4105); + BOOST_TEST(PTransf16(Epu8({0, 2, 2, 0xf, 2, 2, 2, 2, 5, 2}, 2)) + .fix_points_bitset(true) == 0xFFFA); } BOOST_AUTO_TEST_CASE(PTransf16_nb_fix_points) { BOOST_TEST(PTransf16({}).nb_fix_points() == 16); - BOOST_TEST(PTransf16({4,4,4,4}).nb_fix_points() == 12); + BOOST_TEST(PTransf16({4, 4, 4, 4}).nb_fix_points() == 12); BOOST_TEST(PTransf16(Epu8(1)).nb_fix_points() == 1); - BOOST_TEST(PTransf16(Epu8(2)).nb_fix_points() == 1); - BOOST_TEST(PTransf16(Epu8({2,2,2,0xf},7)).nb_fix_points() == 2); - BOOST_TEST(PTransf16(Epu8({0,2,2,0xf,2,2,2,14,5,2}, 2)).nb_fix_points() - == 2); - BOOST_TEST(PTransf16(Epu8({0,2,2,0xf,2,2,2,2,8,2}, 14)).nb_fix_points() - == 4); - + BOOST_TEST(PTransf16(Epu8(2)).nb_fix_points() == 1); + BOOST_TEST(PTransf16(Epu8({2, 2, 2, 0xf}, 7)).nb_fix_points() == 2); + BOOST_TEST( + PTransf16(Epu8({0, 2, 2, 0xf, 2, 2, 2, 14, 5, 2}, 2)).nb_fix_points() == + 2); + BOOST_TEST( + PTransf16(Epu8({0, 2, 2, 0xf, 2, 2, 2, 2, 8, 2}, 14)).nb_fix_points() == + 4); } BOOST_AUTO_TEST_SUITE_END() //****************************************************************************// - //****************************************************************************// BOOST_AUTO_TEST_SUITE(Transf16_test) //****************************************************************************// @@ -298,7 +337,6 @@ BOOST_FIXTURE_TEST_CASE(Transf16_hash, Fix) { BOOST_AUTO_TEST_SUITE_END() //****************************************************************************// - //****************************************************************************// BOOST_AUTO_TEST_SUITE(Perm16_constr) //****************************************************************************// @@ -309,11 +347,10 @@ BOOST_FIXTURE_TEST_CASE(Perm16OperatorUInt64, Fix) { BOOST_TEST(static_cast(PPb) == 0xd7e4f5c0b6a39281); BOOST_TEST(static_cast(RandPerm) == 0x9a854d7fce60b123); - for (auto p : { Perm16::one(), PPa, PPb, RandPerm }) + for (auto p : {Perm16::one(), PPa, PPb, RandPerm}) BOOST_TEST(static_cast(static_cast(p)) == p); } - BOOST_AUTO_TEST_CASE(Perm16TestEq) { BOOST_TEST(Perm16::one() * Perm16::one() == Perm16::one()); } @@ -327,17 +364,18 @@ BOOST_FIXTURE_TEST_CASE(Perm16_hash, Fix) { BOOST_AUTO_TEST_SUITE_END() //****************************************************************************// - //****************************************************************************// BOOST_AUTO_TEST_SUITE(PPerm16_test) //****************************************************************************// BOOST_AUTO_TEST_CASE(PPerm16_constructor) { const uint8_t FF = 0xff; - BOOST_TEST(PPerm16({4, 5, 0}, {9, 0, 1}) == - PPerm16({ 1,FF,FF,FF, 9, 0,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF})); - BOOST_TEST(PPerm16({4, 5, 0, 8}, {9, 0, 1, 2}) == - PPerm16({ 1,FF,FF,FF, 9, 0,FF,FF,2,FF,FF,FF,FF,FF,FF,FF})); + BOOST_TEST( + PPerm16({4, 5, 0}, {9, 0, 1}) == + PPerm16({1, FF, FF, FF, 9, 0, FF, FF, FF, FF, FF, FF, FF, FF, FF, FF})); + BOOST_TEST( + PPerm16({4, 5, 0, 8}, {9, 0, 1, 2}) == + PPerm16({1, FF, FF, FF, 9, 0, FF, FF, 2, FF, FF, FF, FF, FF, FF, FF})); } BOOST_AUTO_TEST_CASE(PPerm16_hash) { @@ -345,21 +383,22 @@ BOOST_AUTO_TEST_CASE(PPerm16_hash) { BOOST_TEST(std::hash()(PPerm16({4, 5, 0}, {9, 0, 1})) != 0); } - BOOST_FIXTURE_TEST_CASE(PPerm16_left_one, Fix) { BOOST_TEST(PPerm16({}).left_one() == PPerm16::one()); - BOOST_TEST(PPerm16({FF,FF,FF,4}).left_one() == PPerm16({FF,FF,FF,FF})); - BOOST_TEST(PPerm16({FF,4,FF,FF}).left_one() == PPerm16({FF,FF,FF,FF})); + BOOST_TEST(PPerm16({FF, FF, FF, 4}).left_one() == + PPerm16({FF, FF, FF, FF})); + BOOST_TEST(PPerm16({FF, 4, FF, FF}).left_one() == + PPerm16({FF, FF, FF, FF})); for (auto pp : PPlist) { BOOST_TEST(pp.left_one() * pp == pp); } } - BOOST_FIXTURE_TEST_CASE(PPerm16_right_one, Fix) { BOOST_TEST(PPerm16({}).right_one() == PPerm16::one()); - BOOST_TEST(PPerm16({FF,FF,FF,4}).right_one() == PPerm16({FF,FF,FF})); - BOOST_TEST(PPerm16({FF,4,FF,FF}).right_one() == PPerm16({FF,1,FF,FF})); + BOOST_TEST(PPerm16({FF, FF, FF, 4}).right_one() == PPerm16({FF, FF, FF})); + BOOST_TEST(PPerm16({FF, 4, FF, FF}).right_one() == + PPerm16({FF, 1, FF, FF})); for (auto pp : PPlist) { BOOST_TEST(pp * pp.right_one() == pp); } @@ -369,7 +408,7 @@ BOOST_FIXTURE_TEST_CASE(PPerm16_right_one, Fix) { BOOST_FIXTURE_TEST_CASE(PPerm16_inverse_ref, Fix) { for (epu8 mask : PPmasks) { for (Perm16 p : Plist) { - PPerm16 pp (p.v | mask); + PPerm16 pp(p.v | mask); PPerm16 pi = pp.inverse_ref(); BOOST_TEST(pp * pi * pp == pp); BOOST_TEST(pi * pp * pi == pi); @@ -382,8 +421,6 @@ TEST_AGREES(PPerm16, inverse_ref, inverse_find, PPlist); BOOST_AUTO_TEST_SUITE_END() //****************************************************************************// - - //****************************************************************************// BOOST_AUTO_TEST_SUITE(Perm16_mathematical_methods) //****************************************************************************// @@ -393,19 +430,19 @@ BOOST_FIXTURE_TEST_CASE(Perm16_fix_points_mask, Fix) { EPU8_EQUAL(Perm16::one().fix_points_mask(), Epu8(FF)); EPU8_EQUAL(PPa.fix_points_mask(), Epu8({0, 0, 0, 0, 0}, FF)); EPU8_EQUAL(PPb.fix_points_mask(), - (epu8{ 0, 0, 0, 0, 0,FF, 0,FF,FF,FF,FF,FF,FF, 0,FF, 0})); - EPU8_EQUAL(RandPerm.fix_points_mask(), Epu8({0,FF}, 0)); + (epu8{0, 0, 0, 0, 0, FF, 0, FF, FF, FF, FF, FF, FF, 0, FF, 0})); + EPU8_EQUAL(RandPerm.fix_points_mask(), Epu8({0, FF}, 0)); EPU8_EQUAL(Perm16::one().fix_points_mask(false), Epu8(FF)); EPU8_EQUAL(PPa.fix_points_mask(false), Epu8({0, 0, 0, 0, 0}, FF)); EPU8_EQUAL(PPb.fix_points_mask(false), - (epu8{ 0, 0, 0, 0, 0,FF, 0,FF,FF,FF,FF,FF,FF, 0,FF, 0})); - EPU8_EQUAL(RandPerm.fix_points_mask(false), Epu8({0,FF}, 0)); + (epu8{0, 0, 0, 0, 0, FF, 0, FF, FF, FF, FF, FF, FF, 0, FF, 0})); + EPU8_EQUAL(RandPerm.fix_points_mask(false), Epu8({0, FF}, 0)); EPU8_EQUAL(Perm16::one().fix_points_mask(true), Epu8(0)); - EPU8_EQUAL(PPa.fix_points_mask(true), Epu8({FF,FF,FF,FF,FF}, 0)); + EPU8_EQUAL(PPa.fix_points_mask(true), Epu8({FF, FF, FF, FF, FF}, 0)); EPU8_EQUAL(PPb.fix_points_mask(true), - (epu8{FF,FF,FF,FF,FF, 0,FF, 0, 0, 0, 0, 0, 0,FF, 0,FF})); + (epu8{FF, FF, FF, FF, FF, 0, FF, 0, 0, 0, 0, 0, 0, FF, 0, FF})); EPU8_EQUAL(RandPerm.fix_points_mask(true), Epu8({FF, 0}, FF)); } @@ -420,7 +457,7 @@ BOOST_FIXTURE_TEST_CASE(Perm16_smallest_moved_point, Fix) { BOOST_TEST(PPa.smallest_moved_point() == 0); BOOST_TEST(PPb.smallest_moved_point() == 0); BOOST_TEST(RandPerm.smallest_moved_point() == 0); - BOOST_TEST(Perm16({0,1,3,2}).smallest_moved_point() == 2); + BOOST_TEST(Perm16({0, 1, 3, 2}).smallest_moved_point() == 2); } BOOST_FIXTURE_TEST_CASE(Perm16_largest_fix_point, Fix) { @@ -434,7 +471,7 @@ BOOST_FIXTURE_TEST_CASE(Perm16_nb_fix_points, Fix) { BOOST_TEST(PPa.nb_fix_points() == 11); BOOST_TEST(PPb.nb_fix_points() == 8); BOOST_TEST(RandPerm.nb_fix_points() == 1); - BOOST_TEST(Perm16({0,1,3,2}).nb_fix_points() == 14); + BOOST_TEST(Perm16({0, 1, 3, 2}).nb_fix_points() == 14); } //****************************************************************************// @@ -458,14 +495,13 @@ TEST_AGREES(Perm16, inverse_ref, inverse_pow, Plist); TEST_AGREES(Perm16, inverse_ref, inverse_cycl, Plist); TEST_AGREES(Perm16, inverse_ref, inverse, Plist); - //****************************************************************************// BOOST_FIXTURE_TEST_CASE(Perm16_lehmer_ref, Fix) { EPU8_EQUAL(Perm16::one().lehmer(), zero); EPU8_EQUAL(PPa.lehmer(), - (epu8 { 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})); + (epu8{1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})); EPU8_EQUAL(PPb.lehmer(), - (epu8 { 1, 1, 1, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0})); + (epu8{1, 1, 1, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0})); } TEST_EPU8_AGREES(Perm16, lehmer_ref, lehmer_arr, Plist); TEST_EPU8_AGREES(Perm16, lehmer_ref, lehmer, Plist); @@ -496,7 +532,6 @@ BOOST_FIXTURE_TEST_CASE(Perm16_nb_cycles_ref, Fix) { } TEST_AGREES(Perm16, nb_cycles_ref, nb_cycles, Plist); - //****************************************************************************// BOOST_FIXTURE_TEST_CASE(Perm16_left_weak_leq_ref, Fix) { BOOST_TEST(Perm16::one().left_weak_leq_ref(Perm16::one())); diff --git a/tests/test_perm_all.cpp b/tests/test_perm_all.cpp index 7a54889c..4fdce0fd 100644 --- a/tests/test_perm_all.cpp +++ b/tests/test_perm_all.cpp @@ -44,10 +44,9 @@ struct Fixture : public IsPermFunctions { using PermType = _PermType; Fixture() - : zero({0}), V01({0, 1}), V10({1, 0}), V11({1, 1}), - V1({}, 1), PPa({1, 2, 3, 4, 0, 5}), - PPb({1, 2, 3, 6, 0, 5}), czero(zero), cV01(V01), - RandPerm({3, 1, 0, 5, 10, 2, 6, 7, 4, 8, 9}), + : zero({0}), V01({0, 1}), V10({1, 0}), V11({1, 1}), V1({}, 1), + PPa({1, 2, 3, 4, 0, 5}), PPb({1, 2, 3, 6, 0, 5}), czero(zero), + cV01(V01), RandPerm({3, 1, 0, 5, 10, 2, 6, 7, 4, 8, 9}), Plist({PPa, PPb, RandPerm}), Vlist({zero, V01, V10, V11, V1, PPa, PPb, RandPerm}) { BOOST_TEST_MESSAGE("setup fixture"); @@ -70,12 +69,9 @@ struct Fixture : public IsPermFunctions { //____________________________________________________________________________// typedef boost::mpl::list< - Fixture, - Fixture>, - Fixture>, - Fixture>, - Fixture>, - Fixture>, + Fixture, Fixture>, + Fixture>, Fixture>, + Fixture>, Fixture>, Fixture>> Fixtures; @@ -85,7 +81,7 @@ BOOST_AUTO_TEST_SUITE(VectType_test) //____________________________________________________________________________// BOOST_FIXTURE_TEST_CASE_TEMPLATE(sizeof_test, F, Fixtures, F) { - BOOST_TEST(sizeof(F::zero) == F::VectType::Size()*sizeof(F::zero[0])); + BOOST_TEST(sizeof(F::zero) == F::VectType::Size() * sizeof(F::zero[0])); } BOOST_FIXTURE_TEST_CASE_TEMPLATE(equal_test, F, Fixtures, F) { @@ -163,47 +159,46 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(operator_less_partial_test, F, Fixtures, F) { BOOST_TEST(F::PPb.less_partial(F::PPa, 5) > 0); } - BOOST_FIXTURE_TEST_CASE_TEMPLATE(first_zero_test, F, Fixtures, F) { - BOOST_TEST(F::zero.first_zero() == 0u); - BOOST_TEST(F::V01.first_zero() == 0u); - BOOST_TEST(F::PPa.first_zero() == 4u); - BOOST_TEST(F::V10.first_zero() == 1u); - BOOST_TEST(F::V1.first_zero() == F::VectType::Size()); - BOOST_TEST(F::V10.first_zero(1) == F::VectType::Size()); - BOOST_TEST(F::PPa.first_zero(5) == 4u); - BOOST_TEST(F::PPa.first_zero(3) == F::VectType::Size()); + BOOST_TEST(F::zero.first_zero() == 0u); + BOOST_TEST(F::V01.first_zero() == 0u); + BOOST_TEST(F::PPa.first_zero() == 4u); + BOOST_TEST(F::V10.first_zero() == 1u); + BOOST_TEST(F::V1.first_zero() == F::VectType::Size()); + BOOST_TEST(F::V10.first_zero(1) == F::VectType::Size()); + BOOST_TEST(F::PPa.first_zero(5) == 4u); + BOOST_TEST(F::PPa.first_zero(3) == F::VectType::Size()); } BOOST_FIXTURE_TEST_CASE_TEMPLATE(last_zero_test, F, Fixtures, F) { - BOOST_TEST(F::zero.last_zero() == F::VectType::Size() - 1); - BOOST_TEST(F::V01.last_zero() == F::VectType::Size() - 1); - BOOST_TEST(F::PPa.last_zero() == 4u); - BOOST_TEST(F::V1.last_zero() == F::VectType::Size()); - BOOST_TEST(F::V01.last_zero(1) == 0u); - BOOST_TEST(F::V10.last_zero(1) == F::VectType::Size()); - BOOST_TEST(F::PPa.last_zero(5) == 4u); - BOOST_TEST(F::PPa.last_zero(3) == F::VectType::Size()); + BOOST_TEST(F::zero.last_zero() == F::VectType::Size() - 1); + BOOST_TEST(F::V01.last_zero() == F::VectType::Size() - 1); + BOOST_TEST(F::PPa.last_zero() == 4u); + BOOST_TEST(F::V1.last_zero() == F::VectType::Size()); + BOOST_TEST(F::V01.last_zero(1) == 0u); + BOOST_TEST(F::V10.last_zero(1) == F::VectType::Size()); + BOOST_TEST(F::PPa.last_zero(5) == 4u); + BOOST_TEST(F::PPa.last_zero(3) == F::VectType::Size()); } BOOST_FIXTURE_TEST_CASE_TEMPLATE(first_non_zero_test, F, Fixtures, F) { - BOOST_TEST(F::zero.first_non_zero() == F::VectType::Size()); - BOOST_TEST(F::V01.first_non_zero() == 1u); - BOOST_TEST(F::PPa.first_non_zero() == 0u); - BOOST_TEST(F::V01.first_non_zero() == 1u); - BOOST_TEST(F::V01.first_non_zero(1) == F::VectType::Size()); - BOOST_TEST(F::PPa.first_non_zero(5) == 0u); - BOOST_TEST(F::PPa.first_non_zero(3) == 0u); + BOOST_TEST(F::zero.first_non_zero() == F::VectType::Size()); + BOOST_TEST(F::V01.first_non_zero() == 1u); + BOOST_TEST(F::PPa.first_non_zero() == 0u); + BOOST_TEST(F::V01.first_non_zero() == 1u); + BOOST_TEST(F::V01.first_non_zero(1) == F::VectType::Size()); + BOOST_TEST(F::PPa.first_non_zero(5) == 0u); + BOOST_TEST(F::PPa.first_non_zero(3) == 0u); } BOOST_FIXTURE_TEST_CASE_TEMPLATE(last_non_zero_test, F, Fixtures, F) { - BOOST_TEST(F::zero.last_non_zero() == F::VectType::Size()); - BOOST_TEST(F::V01.last_non_zero() == 1u); - BOOST_TEST(F::PPa.last_non_zero() == F::VectType::Size() - 1); - BOOST_TEST(F::V01.last_non_zero() == 1u); - BOOST_TEST(F::V01.last_non_zero(1) == F::VectType::Size()); - BOOST_TEST(F::PPa.last_non_zero(5) == 3u); - BOOST_TEST(F::PPa.last_non_zero(3) == 2u); + BOOST_TEST(F::zero.last_non_zero() == F::VectType::Size()); + BOOST_TEST(F::V01.last_non_zero() == 1u); + BOOST_TEST(F::PPa.last_non_zero() == F::VectType::Size() - 1); + BOOST_TEST(F::V01.last_non_zero() == 1u); + BOOST_TEST(F::V01.last_non_zero(1) == F::VectType::Size()); + BOOST_TEST(F::PPa.last_non_zero(5) == 3u); + BOOST_TEST(F::PPa.last_non_zero(3) == 2u); } BOOST_FIXTURE_TEST_CASE_TEMPLATE(permuted_test, F, Fixtures, F) { @@ -266,7 +261,8 @@ template struct PermFixture : public IsPermFunctions<_Perm> { PermFixture() : id(PermType::one()), RandPerm({3, 1, 0, 5, 10, 2, 11, 6, 7, 4, 8, 9}), Plist({id, RandPerm}) { - for (uint64_t i = 0; i < std::min(PermType::size(), 30) - 1; i++) + for (uint64_t i = 0; i < std::min(PermType::size(), 30) - 1; + i++) Plist.push_back(PermType::elementary_transposition(i)); for (uint64_t i = std::max(30, PermType::size() - 20); i < PermType::size() - 1; i++) @@ -285,14 +281,13 @@ template struct PermFixture : public IsPermFunctions<_Perm> { //____________________________________________________________________________// -typedef boost::mpl::list< - PermFixture, - PermFixture>, - PermFixture>, - PermFixture>, - PermFixture>, - PermFixture>, - PermFixture>> +typedef boost::mpl::list, + PermFixture>, + PermFixture>, + PermFixture>, + PermFixture>, + PermFixture>, + PermFixture>> PermFixtures; //____________________________________________________________________________//