ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
Bitwise.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*----------------------------- File Bitwise.h -----------------------------*/
3/*--------------------------------------------------------------------------*/
49/*--------------------------------------------------------------------------*/
50/*----------------------------- DEFINITIONS --------------------------------*/
51/*--------------------------------------------------------------------------*/
52
53#ifndef __ADS_Bitwise
54 #define __ADS_Bitwise
55/* self-identification: #endif constant */
56
57/*--------------------------------------------------------------------------*/
58/*------------------------------ INCLUDES ----------------------------------*/
59/*--------------------------------------------------------------------------*/
60
61#include "ADS/Contract.h"
62
63#include <cstdint>
64#include <utility>
65
66/*--------------------------------------------------------------------------*/
67/*--------------------------- NAMESPACE ------------------------------------*/
68/*--------------------------------------------------------------------------*/
69
70namespace ADS
71{
72
73using Word = std::uint64_t;
74
92[[nodiscard]] constexpr int sidewaysSum( Word x );
93
106[[nodiscard]] constexpr int ruler( Word x );
107
125[[nodiscard]] constexpr int lambda( Word x );
126
137[[nodiscard]] constexpr Word rightmostOne( Word x );
138
149[[nodiscard]] constexpr Word smearRight( Word x );
150
169[[nodiscard]] constexpr Word reverseBits( Word x );
170
180[[nodiscard]] constexpr Word gray( Word x );
181
195[[nodiscard]] constexpr Word grayInverse( Word g );
196
210[[nodiscard]] constexpr Word nextSameWeight( Word x );
211
232[[nodiscard]] constexpr Word interleave( std::uint32_t x , std::uint32_t y );
233
254[[nodiscard]] constexpr std::pair< std::uint32_t , std::uint32_t >
256
269[[nodiscard]] constexpr bool hasZeroByte( Word x );
270
271/*--------------------------------------------------------------------------*/
272
273} // end( namespace ADS )
274
275/*--------------------------------------------------------------------------*/
276/*-------------------------- IMPLEMENTATION --------------------------------*/
277/*--------------------------------------------------------------------------*/
278
279#include "ADS/combinatorial/impl/Bitwise.tpp"
280
281/*--------------------------------------------------------------------------*/
282
283#endif /* Bitwise.h included */
284
285/*--------------------------------------------------------------------------*/
286/*--------------------------- End File Bitwise.h ---------------------------*/
287/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
constexpr Word interleave(std::uint32_t x, std::uint32_t y)
the Morton code of , the bits of in the even places and those of in the odd ones
constexpr Word reverseBits(Word x)
the bits of in reverse order
constexpr Word gray(Word x)
the Gray code of
constexpr int sidewaysSum(Word x)
the number of 1 bits of ,
constexpr int ruler(Word x)
the number of trailing zeros of ,
constexpr std::pair< std::uint32_t, std::uint32_t > deinterleave(Word z)
the of the Morton code
constexpr Word smearRight(Word x)
with the 0 bits below its rightmost 1 set, 0 if
constexpr Word nextSameWeight(Word x)
the next larger word with as many 1 bits as
constexpr bool hasZeroByte(Word x)
whether one of the 8 bytes of is 0
constexpr Word rightmostOne(Word x)
the rightmost 1 of alone, 0 if
constexpr int lambda(Word x)
the place of the leading 1 of ,
constexpr Word grayInverse(Word g)
the whose Gray code is
Definition ADT.h:96
std::uint64_t Word
a word of 64 bits
Definition Bitwise.h:73