ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
BinaryPacking.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*-------------------------- File BinaryPacking.h --------------------------*/
3/*--------------------------------------------------------------------------*/
89/*--------------------------------------------------------------------------*/
90/*----------------------------- DEFINITIONS --------------------------------*/
91/*--------------------------------------------------------------------------*/
92
93#ifndef __ADS_BinaryPacking
94 #define __ADS_BinaryPacking
95/* self-identification: #endif constant */
96
97/*--------------------------------------------------------------------------*/
98/*------------------------------ INCLUDES ----------------------------------*/
99/*--------------------------------------------------------------------------*/
100
101#include "ADS/Contract.h"
102#include "ADS/Simd.h"
103
104#include <algorithm>
105#include <array>
106#include <bit>
107#include <cstddef>
108#include <cstdint>
109#include <cstring>
110#include <memory>
111#include <span>
112#include <utility>
113#include <vector>
114
115// the blocks by the kernels of Highway [see Simd.h], on the machines of
116// little-endian order, unless ADS_BP_SCALAR (or ADS_SIMD_SCALAR, which
117// turns off all the vector branches [see Simd.h]) asks for the scalar code
118#if ADS_SIMD && ! defined( ADS_BP_SCALAR )
119 #define ADS_BP_SIMD 1
120#endif
121
122/*--------------------------------------------------------------------------*/
123/*--------------------------- NAMESPACE ------------------------------------*/
124/*--------------------------------------------------------------------------*/
125
126namespace ADS
127{
128
149[[nodiscard]] inline std::vector< std::uint8_t >
150binaryPack( std::span< const std::uint32_t > x , bool sorted = false );
151
171[[nodiscard]] inline std::vector< std::uint32_t >
172binaryUnpack( std::span< const std::uint8_t > in , std::size_t n ,
173 bool sorted = false );
174
198[[nodiscard]] inline std::vector< std::uint8_t >
199patchedPack( std::span< const std::uint32_t > x , bool sorted = false );
200
221[[nodiscard]] inline std::vector< std::uint32_t >
222patchedUnpack( std::span< const std::uint8_t > in , std::size_t n ,
223 bool sorted = false );
224
225/*--------------------------------------------------------------------------*/
226
227} // end( namespace ADS )
228
229/*--------------------------------------------------------------------------*/
230/*-------------------------- IMPLEMENTATION --------------------------------*/
231/*--------------------------------------------------------------------------*/
232
233#include "ADS/compression/impl/BinaryPacking.tpp"
234
235/*--------------------------------------------------------------------------*/
236
237#endif /* BinaryPacking.h included */
238
239/*--------------------------------------------------------------------------*/
240/*------------------------ End File BinaryPacking.h ------------------------*/
241/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The vector kernels of ADS on Google Highway, with ADS_WITH_HIGHWAY: the loops over arrays that a stru...
std::vector< std::uint8_t > patchedPack(std::span< const std::uint32_t > x, bool sorted=false)
the patched binary packing (PFor) of in blocks of 128 integers, of their differences at a distance o...
std::vector< std::uint8_t > binaryPack(std::span< const std::uint32_t > x, bool sorted=false)
the binary packing of in blocks of 128 integers, of their differences at a distance of 4 if sorted
std::vector< std::uint32_t > patchedUnpack(std::span< const std::uint8_t > in, std::size_t n, bool sorted=false)
the integers of the patched code in, packed with the same sorted
std::vector< std::uint32_t > binaryUnpack(std::span< const std::uint8_t > in, std::size_t n, bool sorted=false)
the integers of the code in, packed with the same sorted
Definition ADT.h:96