diff --git a/.mailmap b/.mailmap index 3602a18..8efc266 100644 --- a/.mailmap +++ b/.mailmap @@ -1,3 +1,5 @@ +Victorin Brunel Victorin +Victorin Brunel Victorin Brunel <83453511+Victorin-Brunel@users.noreply.github.com> Reinis Cirpons reiniscirpons Reinis Cirpons Reinis Cirpons <43414125+reiniscirpons@users.noreply.github.com> Joe Edwards Joe Edwards <80713360+Joseph-Edwards@users.noreply.github.com> diff --git a/CMakeLists.txt b/CMakeLists.txt index 980e5a2..902a62e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,8 +27,8 @@ project(HPCombi) set(DESCRIPTION "High Performance Combinatorics in C++ using vector instructions" CACHE STRING "Project description.") set(VERSION_MAJOR 1 CACHE STRING "Project major version number.") -set(VERSION_MINOR 0 CACHE STRING "Project minor version number.") -set(VERSION_PATCH 3 CACHE STRING "Project patch version number.") +set(VERSION_MINOR 1 CACHE STRING "Project minor version number.") +set(VERSION_PATCH 0 CACHE STRING "Project patch version number.") mark_as_advanced(VERSION_MAJOR VERSION_MINOR VERSION_PATCH) message(STATUS "**** Build type = ${CMAKE_BUILD_TYPE}") diff --git a/README.md b/README.md index 1523342..09f7945 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # HPCombi -High Performance Combinatorics in C++ using vector instructions v1.0.3 +High Performance Combinatorics in C++ using vector instructions v1.1.0 HPCombi is a C++17 header-only library using the SSE and AVX instruction sets, and some equivalents, for very fast manipulation of small combinatorial objects @@ -22,6 +22,8 @@ other processors too. ## Contributors +- Victorin Brunel : wrote the + BMat16 code - Reinis Cirpons : CI - Jean-Baptiste Rouquier : improvements to the doc - Joe Edwards : improvements to the CI diff --git a/etc/make-lint.sh b/etc/make-lint.sh new file mode 100755 index 0000000..9805dd5 --- /dev/null +++ b/etc/make-lint.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +if [[ $# -ne 0 ]]; then + bold "error expected 0 arguments, got $#!" + exit 1 +fi + +exit_code=0 + +cpplint --repository='include' include/hpcombi/*.hpp || ((exit_code = 1)) + +exit $exit_code diff --git a/include/hpcombi/bmat16.hpp b/include/hpcombi/bmat16.hpp index 7773236..0825221 100644 --- a/include/hpcombi/bmat16.hpp +++ b/include/hpcombi/bmat16.hpp @@ -24,18 +24,15 @@ #ifndef HPCOMBI_BMAT16_HPP_ #define HPCOMBI_BMAT16_HPP_ -#include // for array -#include // for bitset -#include // for size_t -#include // for uint64_t, uint8_t -#include // for hash, __scalar_hash -#include // for ostream -#include // for hash -#include // for pair, swap -#include // for vector - -#include "debug.hpp" // for HPCOMBI_ASSERT -#include "bmat8.hpp" +#include // for array +#include // for size_t +#include // for uint64_t, uint8_t +#include // for ostream +#include // for pair, swap +#include // for vector + +#include "bmat8.hpp" // for BMat8 +#include "debug.hpp" // for HPCOMBI_ASSERT #include "simde/x86/avx2.h" @@ -51,13 +48,11 @@ xpu64 to_line(xpu64 vect); //! Converting storage type from rows to blocks of a xpu64 //! representing a 16x16 matrix (used in BMat16). -//! -//! Each 64 bit unsigned int represents one of the four +//! +//! Each 64 bit unsigned int represents one of the four //! 8x8 matrix that make up a 16x16 when quartered. xpu64 to_block(xpu64 vect); - - //! Class for fast boolean matrices of dimension up to 16 x 16 //! //! The methods for these small matrices over the boolean semiring @@ -77,17 +72,17 @@ class BMat16 { //! A constructor. //! //! This constructor initializes a matrix with a 256-bit register - //! The rows are equal to the 16 chunks, of 16 bits each, + //! The rows are equal to the 16 chunks, of 16 bits each, //! of the binary representation of the matrix. - explicit BMat16(xpu64 mat) noexcept : - _data{mat} {} + explicit BMat16(xpu64 mat) noexcept : _data{mat} {} //! A constructor. //! //! This constructor initializes a matrix with 4 64 bits unsigned int //! Each uint represents one of the four quarter (8x8 matrix). - explicit BMat16(uint64_t n0, uint64_t n1, uint64_t n2, uint64_t n3) noexcept; - + explicit BMat16(uint64_t n0, uint64_t n1, uint64_t n2, + uint64_t n3) noexcept; + //! A constructor. //! //! This constructor initializes a matrix where the rows of the matrix @@ -162,7 +157,7 @@ class BMat16 { //! //! This method perform the bitwise operator on the matrices and //! returns the result as a BMat16. - BMat16 operator|(BMat16 const& that) const noexcept { + BMat16 operator|(BMat16 const &that) const noexcept { return BMat16(_data | that._data); } @@ -189,8 +184,8 @@ class BMat16 { //! Returns the matrix product of \c this and \p that //! //! This method returns the standard matrix product (over the - //! boolean semiring) of two BMat16 objects. - //! It comes down to 8 products of 8x8 matrices, + //! boolean semiring) of two BMat16 objects. + //! It comes down to 8 products of 8x8 matrices, //! which make up a 16x16 when we cut it into 4. BMat16 mult_4bmat8(BMat16 const &that) const noexcept; @@ -206,16 +201,17 @@ class BMat16 { //! Returns the matrix product of \c this and \p that //! //! This method returns the standard matrix product (over the - //! boolean semiring) of two BMat16 objects. It performs the most naive approach - //! by simply iterating through all entries using the access operator of BMat16 - BMat16 mult_naive(BMat16 const& that) const noexcept; + //! boolean semiring) of two BMat16 objects. It performs the most naive + //! approach by simply iterating through all entries using the access + //! operator of BMat16 + BMat16 mult_naive(BMat16 const &that) const noexcept; //! Returns the matrix product of \c this and \p that //! //! This method returns the standard matrix product (over the - //! boolean semiring) of two BMat16 objects. It performs the most naive approach - //! by simply iterating through all entries using array conversion. - BMat16 mult_naive_array(BMat16 const& that) const noexcept; + //! boolean semiring) of two BMat16 objects. It performs the most naive + //! approach by simply iterating through all entries using array conversion. + BMat16 mult_naive_array(BMat16 const &that) const noexcept; //! Returns the number of non-zero rows of \c this size_t nr_rows() const noexcept; @@ -229,9 +225,17 @@ class BMat16 { //! This method returns the 16 x 16 BMat16 with 1s on the main diagonal. static BMat16 one(size_t dim = 16) noexcept { HPCOMBI_ASSERT(dim <= 16); - static std::array const ones = { - 0, 1, 0x201, 0x40201, 0x8040201, 0x1008040201, 0x201008040201, 0x40201008040201, 0x8040201008040201}; - return BMat16(ones[dim >= 8 ? 8 : dim], 0, 0, ones[dim >= 8 ? dim - 8 : 0]); + static std::array const ones = {0, + 1, + 0x201, + 0x40201, + 0x8040201, + 0x1008040201, + 0x201008040201, + 0x40201008040201, + 0x8040201008040201}; + return BMat16(ones[dim >= 8 ? 8 : dim], 0, 0, + ones[dim >= 8 ? dim - 8 : 0]); } //! Returns a random BMat16 @@ -253,14 +257,12 @@ class BMat16 { // Not noexcept std::ostream &write(std::ostream &os) const; - private: xpu64 _data; - }; } // namespace HPCombi #include "bmat16_impl.hpp" -#endif \ No newline at end of file +#endif // HPCOMBI_BMAT16_HPP_ diff --git a/include/hpcombi/bmat16_impl.hpp b/include/hpcombi/bmat16_impl.hpp index ad0d956..146d0af 100644 --- a/include/hpcombi/bmat16_impl.hpp +++ b/include/hpcombi/bmat16_impl.hpp @@ -22,6 +22,8 @@ // This file contains an implementation of fast boolean matrices up to // dimension 16 x 16. +// NOLINT(build/header_guard) + namespace HPCombi { static_assert(std::is_trivial(), "BMat16 is not a trivial class!"); diff --git a/include/hpcombi/bmat8.hpp b/include/hpcombi/bmat8.hpp index d8aef35..ebb9e91 100644 --- a/include/hpcombi/bmat8.hpp +++ b/include/hpcombi/bmat8.hpp @@ -3,7 +3,7 @@ // Copyright (C) 2018-2024 James Mitchell // // Copyright (C) 2018-2024 Florent Hivert , // // // -// This file is part of HP-Combi // +// This file is part of HP-Combi // // // // HP-Combi is free software: you can redistribute it and/or modify it // // under the terms of the GNU General Public License as published by the // @@ -155,7 +155,7 @@ class BMat8 { //! //! This method perform the bitwise operator on the matrices and //! returns the result as a BMat8 - BMat8 operator|(BMat8 const& that) const noexcept { + BMat8 operator|(BMat8 const &that) const noexcept { return BMat8(to_int() | that.to_int()); } @@ -209,16 +209,17 @@ class BMat8 { //! Returns the matrix product of \c this and \p that //! //! This method returns the standard matrix product (over the - //! boolean semiring) of two BMat8 objects. It performs the most naive approach - //! by simply iterating through all entries using the access operator of BMat8 - BMat8 mult_naive(BMat8 const& that) const noexcept; + //! boolean semiring) of two BMat8 objects. It performs the most naive + //! approach by simply iterating through all entries using the access + //! operator of BMat8 + BMat8 mult_naive(BMat8 const &that) const noexcept; //! Returns the matrix product of \c this and \p that //! //! This method returns the standard matrix product (over the - //! boolean semiring) of two BMat8 objects. It performs the most naive approach - //! by simply iterating through all entries using array conversion. - BMat8 mult_naive_array(BMat8 const& that) const noexcept; + //! boolean semiring) of two BMat8 objects. It performs the most naive + //! approach by simply iterating through all entries using array conversion. + BMat8 mult_naive_array(BMat8 const &that) const noexcept; //! Returns a canonical basis of the row space of \c this //! diff --git a/include/hpcombi/bmat8_impl.hpp b/include/hpcombi/bmat8_impl.hpp index af80bc2..1456294 100644 --- a/include/hpcombi/bmat8_impl.hpp +++ b/include/hpcombi/bmat8_impl.hpp @@ -118,7 +118,8 @@ inline std::array, 8> BMat8::to_array() const noexcept { uint64_t a = to_int(); std::array, 8> res; for (int i = 0; i < 64; i++) { - res[7 - i/8][7 - i%8] = a % 2; a >>= 1; + res[7 - i / 8][7 - i % 8] = a % 2; + a >>= 1; } return res; } @@ -150,7 +151,8 @@ inline BMat8 BMat8::random() { } inline BMat8 BMat8::random(size_t const dim) { - // TO DO : Instead of nulling all the cols/rows one by one, one could do that at once with the proper mask + // TODO : Instead of nulling all the cols/rows one by one, one could do + // that at once with the proper mask HPCOMBI_ASSERT(0 < dim && dim <= 8); BMat8 bm = BMat8::random(); for (size_t i = dim; i < 8; ++i) { @@ -257,7 +259,8 @@ inline BMat8 BMat8::mult_naive(BMat8 const &that) const noexcept { } inline BMat8 BMat8::mult_naive_array(BMat8 const &that) const noexcept { - std::array, 8> tab1 = to_array(), tab2 = that.to_array(); + std::array, 8> tab1 = to_array(), + tab2 = that.to_array(); uint64_t a = 0; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) {