Theoretica
Scientific Computing
Loading...
Searching...
No Matches
theoretica::bits Namespace Reference

Operations on bits. More...

Functions

constexpr void mul_uint128 (uint64_t a, uint64_t b, uint64_t &c_low, uint64_t &c_high)
 Multiply two 64-bit unsigned integers and store the result in two 64-bit variables, keeping 128 bits of the result.
 
constexpr uint64_t mix_mum (uint64_t a, uint64_t b)
 MUM bit mixing function, computes the 128-bit product of a and b and the XOR of their high and low 64-bit parts.
 
template<typename UnsignedIntType >
constexpr UnsignedIntType bit_rotate (UnsignedIntType x, unsigned int i)
 Bit rotation of unsigned integer types using shifts.
 
template<typename Vector , enable_vector< Vector > = true>
constexpr void swap_bit_reverse (Vector &x, unsigned int m)
 Swap the elements of a vector pair-wise, by exchanging elements with indices related by bit reversion (e.g.
 

Detailed Description

Operations on bits.

Function Documentation

◆ bit_rotate()

constexpr UnsignedIntType theoretica::bits::bit_rotate ( UnsignedIntType  x,
unsigned int  i 
)
inlineconstexpr

Bit rotation of unsigned integer types using shifts.

Parameters
xThe unsigned integer to rotate the bits of
iThe index of the rotated bits
Returns
The unsigned integer with the given bits rotated

◆ mix_mum()

constexpr uint64_t theoretica::bits::mix_mum ( uint64_t  a,
uint64_t  b 
)
inlineconstexpr

MUM bit mixing function, computes the 128-bit product of a and b and the XOR of their high and low 64-bit parts.

Parameters
aThe first operand
bThe second operand
Returns
The XOR of the high and low bits of the 128-bit product of a and b.

◆ mul_uint128()

constexpr void theoretica::bits::mul_uint128 ( uint64_t  a,
uint64_t  b,
uint64_t c_low,
uint64_t c_high 
)
inlineconstexpr

Multiply two 64-bit unsigned integers and store the result in two 64-bit variables, keeping 128 bits of the result.

Parameters
aThe first number to multiply
bThe second number to multiply
c_lowThe variable to store the lowest 64 bits of the result.
c_highThe variable to store the highest 64 bits of the result.

◆ swap_bit_reverse()

template<typename Vector , enable_vector< Vector > = true>
constexpr void theoretica::bits::swap_bit_reverse ( Vector x,
unsigned int  m 
)
inlineconstexpr

Swap the elements of a vector pair-wise, by exchanging elements with indices related by bit reversion (e.g.

\(110_2\) and \(011_2\)).

Parameters
xThe vector of elements to swap in-place
mThe maximum bit to consider when computing bit reversion