MOTION  0.01
Framework for mixed-protocol multi-party computation
Public Member Functions | Static Public Member Functions | Friends | Related Functions | List of all members
encrypto::motion::BitVector< Allocator > Class Template Reference

Class representing a series of bits and providing single bit access. More...

#include <bit_vector.h>

Public Member Functions

 BitVector () noexcept
 
 BitVector (BitVector &&bit_vector) noexcept
 
 BitVector (const BitVector &bit_vector) noexcept
 
BitVector< Allocator > & operator= (const BitVector< Allocator > &other) noexcept
 
BitVector< Allocator > & operator= (BitVector< Allocator > &&other) noexcept
 
template<typename OtherAllocator >
 BitVector (const BitVector< OtherAllocator > &bit_vector) noexcept
 Copy from a BitVector with different allocator. More...
 
template<typename OtherAllocator >
BitVector< Allocator > & operator= (const BitVector< OtherAllocator > &other) noexcept
 Copy-assign from BitVector with different allocator. More...
 
 BitVector (const std::vector< bool > &data)
 Initialize from a std::vector<bool>. More...
 
 BitVector (const std::vector< bool > &data, std::size_t number_of_bits)
 Initialize from a std::vector<bool>. More...
 
 BitVector (std::size_t number_of_bits, bool value=false) noexcept
 Construct a BitVector with exactly number_of_bits bits set to value. More...
 
 BitVector (const unsigned char *buffer, std::size_t bits)
 Initialize BitVector from buffer. More...
 
 BitVector (const std::byte *buffer, std::size_t bits)
 Initialize BitVector from buffer. More...
 
template<typename OtherAllocator >
 BitVector (const std::vector< std::byte, OtherAllocator > &data, std::size_t number_of_bits)
 Initialize by copying content of std::vector. More...
 
 BitVector (std::vector< std::byte, Allocator > &&data, std::size_t number_of_bits)
 Initialize by moving content of std::vector (requires same allocator). More...
 
bool Empty () const
 Check if BitVector is empty. More...
 
auto GetSize () const noexcept
 Get size of BitVector. More...
 
const auto & GetData () const noexcept
 Get const reference to content of BitVector. More...
 
auto & GetMutableData () noexcept
 Get reference to content of BitVector. More...
 
void Assign (const BitVector &other) noexcept
 Copy-assign other BitVector. More...
 
void Assign (BitVector &&other) noexcept
 Move-assign other BitVector. More...
 
void Set (bool value) noexcept
 Sets or unsets all bits in the BitVector. More...
 
void Set (bool value, std::size_t position)
 Sets or unsets the bit at position in the BitVector. More...
 
bool Get (std::size_t position) const
 Get bit at given position. More...
 
void Resize (std::size_t number_of_bits, bool zero_fill=false) noexcept
 Resize BitVector to size number_of_bits. New bits are uninitialized by default. More...
 
void Reserve (std::size_t number_of_bits)
 Reserves new space for BitVector, so that it can contain at least number_of_bits bits. More...
 
void Append (bool bit) noexcept
 Appends a bit to BitVector. More...
 
void Append (const BitVector< Allocator > &other) noexcept
 Appends another BitVector to BitVector. More...
 
void Append (BitVector &&other) noexcept
 Appends another BitVector to BitVector. More...
 
void Append (const BitSpan &other)
 Appends a BitSpan to BitVector. More...
 
void Append (BitSpan &&other)
 Appends a BitSpan to BitVector. More...
 
void Append (const std::byte *pointer, const std::size_t append_bit_size) noexcept
 Appends append_bit_size bytes starting from pointer to BitVector. More...
 
void Copy (const std::size_t dest_from, const std::size_t dest_to, const BitVector &other)
 copies the first (dest_to - dest_from) bits from other to the bits [dest_from, dest_to) in this. More...
 
void Copy (const std::size_t dest_from, const BitVector &other)
 copies other to this[dest_from...dest_from+GetSize()]. More...
 
BitVector Subset (std::size_t from, std::size_t to) const
 Returns a new BitVector containing the bits of this BitVector between positions from and to. More...
 
std::string AsString () const noexcept
 Returns a string representation of this BitVector. More...
 
void Clear () noexcept
 Clear this Bitvector. More...
 
void Invert ()
 In-place bit-wise invert. More...
 
bool operator[] (std::size_t position) const
 Get bit at given position in the BitVector. More...
 
BitVector operator~ () const
 Return an inverted copy of this BitVector. More...
 
template<typename OtherAllocator >
BitVector operator& (const BitVector< OtherAllocator > &other) const noexcept
 Perform AND operation between every bit of two BitVectors. More...
 
BitVector operator& (const BitSpan &other) const noexcept
 Perform AND operation between every bit of a BitVector and a BitSpan. More...
 
template<typename OtherAllocator >
BitVector operator^ (const BitVector< OtherAllocator > &other) const noexcept
 Perform XOR operation between every bit of two BitVectors. More...
 
BitVector operator^ (const BitSpan &other) const noexcept
 Perform XOR operation between every bit of a BitVector and a BitSpan. More...
 
template<typename OtherAllocator >
BitVector operator| (const BitVector< OtherAllocator > &other) const noexcept
 Perform OR operation between every bit of two BitVectors. More...
 
BitVector operator| (const BitSpan &other) const noexcept
 Perform OR operation between every bit of a BitVector and a BitSpan. More...
 
template<typename OtherAllocator >
bool operator!= (const BitVector< OtherAllocator > &other) const noexcept
 Compares two BitVectors for inequality. More...
 
bool operator!= (const BitSpan &other) const noexcept
 Compares a BitVector and a BitSpan for inequality. More...
 
template<typename OtherAllocator >
bool operator== (const BitVector< OtherAllocator > &other) const noexcept
 Compares two BitVectors for equality. More...
 
bool operator== (const BitSpan &other) const noexcept
 Compares a BitVector and a BitSpan for equality. More...
 
template<typename OtherAllocator >
BitVectoroperator&= (const BitVector< OtherAllocator > &other) noexcept
 Perform AND-assign operation between every bit of this and the other BitVector. More...
 
BitVectoroperator&= (const BitSpan &other) noexcept
 Perform AND-assign operation between every bit of this and a BitSpan. More...
 
template<typename OtherAllocator >
BitVectoroperator^= (const BitVector< OtherAllocator > &other) noexcept
 Perform XOR-assign operation between every bit of this and the other BitVector. More...
 
BitVectoroperator^= (const BitSpan &other) noexcept
 Perform XOR-assign operation between every bit of this and a BitSpan. More...
 
template<typename OtherAllocator >
BitVectoroperator|= (const BitVector< OtherAllocator > &other) noexcept
 Perform OR-assign operation between every bit of this and the other BitVector. More...
 
BitVectoroperator|= (const BitSpan &other) noexcept
 Perform OR-assign operation between every bit of this and a BitSpan. More...
 
template<typename OtherAllocator >
BitVector< Allocator > operator& (const BitVector< OtherAllocator > &other) const noexcept
 
template<typename OtherAllocator >
BitVector< Allocator > operator^ (const BitVector< OtherAllocator > &other) const noexcept
 
template<typename OtherAllocator >
BitVector< Allocator > operator| (const BitVector< OtherAllocator > &other) const noexcept
 
template<typename OtherAllocator >
BitVector< Allocator > & operator&= (const BitVector< OtherAllocator > &other) noexcept
 
template<typename OtherAllocator >
BitVector< Allocator > & operator^= (const BitVector< OtherAllocator > &other) noexcept
 
template<typename OtherAllocator >
BitVector< Allocator > & operator|= (const BitVector< OtherAllocator > &other) noexcept
 

Static Public Member Functions

static BitVector SecureRandom (const std::size_t size) noexcept
 Returns a random BitVector. More...
 
static BitVector RandomSeeded (const std::size_t size, const std::size_t seed=0) noexcept
 Returns a random BitVector using an input seed. Internally uses Mersenne twister, do not use as cryptographic randomness! More...
 
static bool OrReduceBitVector (const BitVector &bit_vector)
 Performs OR operation between all bits in BitVector. More...
 
static BitVector OrBitVectors (const std::vector< BitVector > &bit_vectors)
 Performs OR operation between all BitVectors in bit_vectors. More...
 
static bool AndReduceBitVector (const BitVector &bit_vector)
 Performs AND operation between all bits in BitVector. More...
 
static BitVector AndBitVectors (const std::vector< BitVector > &bit_vectors)
 Performs AND operation between all BitVectors in bit_vectors. More...
 
static std::vector< BitVectorAndBitVectors (const std::vector< BitVector > &a, const std::vector< BitVector > &b)
 Performs AND operation between every BitVector in a and b. More...
 
static std::vector< BitVectorAndBitVectors (const std::vector< std::vector< BitVector >> &bit_vectors)
 Performs AndBitVectors operation between all vectors of BitVector in bit_vectors. More...
 
static bool XorReduceBitVector (const BitVector &bit_vector)
 Performs XOR operation between all bits in BitVector. More...
 
static BitVector XorBitVectors (const std::vector< BitVector > &bit_vectors)
 Performs XOR operation between all BitVectors in bit_vectors. More...
 
static std::vector< BitVectorXorBitVectors (const std::vector< BitVector > &a, const std::vector< BitVector > &b)
 Performs XOR operation between every BitVector in a and b. More...
 
static std::vector< BitVectorXorBitVectors (const std::vector< std::vector< BitVector >> &bit_vectors)
 Performs XorBitVectors operation between all vectors of BitVector in bit_vectors. More...
 
static bool IsEqualSizeDimensions (const std::vector< BitVector > &bit_vectors)
 Check if all Bitvectors in bit_vectors are of equal dimension. More...
 
static constexpr bool IsAligned () noexcept
 Returns true if Allocator is aligned allocator. More...
 

Friends

template<typename OtherAllocator >
class BitVector
 
class BitSpan
 

Related Functions

(Note that these are not member functions.)

template<typename T , typename = std::enable_if_t<std::is_floating_point_v<T> || std::is_unsigned_v<T>>, typename Allocator = std::allocator<std::byte>>
std::vector< BitVector< Allocator > > ToInput (T value)
 Converts a value of an unsigned integer type or a floating point type to a vector of BitVector. More...
 
template<typename UnsignedIntegralType , typename = std::enable_if_t<std::is_unsigned_v<UnsignedIntegralType>>, typename Allocator = std::allocator<std::byte>>
std::vector< UnsignedIntegralType > ToVectorOutput (std::vector< BitVector< Allocator >> bit_vectors)
 Converts a vector of UnsignedIntegralType to a vector of BitVectors. More...
 

Detailed Description

template<typename Allocator = std::allocator<std::byte>>
class encrypto::motion::BitVector< Allocator >

Class representing a series of bits and providing single bit access.

Constructor & Destructor Documentation

◆ BitVector() [1/11]

template<typename Allocator = std::allocator<std::byte>>
encrypto::motion::BitVector< Allocator >::BitVector ( )
inlinenoexcept

◆ BitVector() [2/11]

template<typename Allocator = std::allocator<std::byte>>
encrypto::motion::BitVector< Allocator >::BitVector ( BitVector< Allocator > &&  bit_vector)
inlinenoexcept

◆ BitVector() [3/11]

template<typename Allocator = std::allocator<std::byte>>
encrypto::motion::BitVector< Allocator >::BitVector ( const BitVector< Allocator > &  bit_vector)
inlinenoexcept

◆ BitVector() [4/11]

template<typename Allocator = std::allocator<std::byte>>
template<typename OtherAllocator >
encrypto::motion::BitVector< Allocator >::BitVector ( const BitVector< OtherAllocator > &  bit_vector)
inlinenoexcept

Copy from a BitVector with different allocator.

Template Parameters
OtherAllocator
Parameters
other

◆ BitVector() [5/11]

template<typename Allocator = std::allocator<std::byte>>
encrypto::motion::BitVector< Allocator >::BitVector ( const std::vector< bool > &  data)
inline

Initialize from a std::vector<bool>.

Parameters
data
Note
Initializing a BitVector this way is inefficient!

◆ BitVector() [6/11]

template<typename Allocator >
encrypto::motion::BitVector< Allocator >::BitVector ( const std::vector< bool > &  data,
std::size_t  number_of_bits 
)
explicit

Initialize from a std::vector<bool>.

Parameters
data
number_of_bitsExpected number of bits.
Precondition
data must be of size equal to number_of_bits.
Note
Initializing a BitVector this way is inefficient!

◆ BitVector() [7/11]

template<typename Allocator >
encrypto::motion::BitVector< Allocator >::BitVector ( std::size_t  number_of_bits,
bool  value = false 
)
explicitnoexcept

Construct a BitVector with exactly number_of_bits bits set to value.

Parameters
number_of_bits
value

◆ BitVector() [8/11]

template<typename Allocator = std::allocator<std::byte>>
encrypto::motion::BitVector< Allocator >::BitVector ( const unsigned char *  buffer,
std::size_t  bits 
)
inline

Initialize BitVector from buffer.

Parameters
buffer
bitsSize of the buffer.

◆ BitVector() [9/11]

template<typename Allocator >
encrypto::motion::BitVector< Allocator >::BitVector ( const std::byte *  buffer,
std::size_t  bits 
)

Initialize BitVector from buffer.

Parameters
buffer
bitsSize of the buffer.

◆ BitVector() [10/11]

template<typename Allocator >
template<typename OtherAllocator >
encrypto::motion::BitVector< Allocator >::BitVector ( const std::vector< std::byte, OtherAllocator > &  data,
std::size_t  number_of_bits 
)
explicit

Initialize by copying content of std::vector.

Parameters
data
number_of_bitsExpected number of bits.
Precondition
data must be of size equal to number_of_bits.

◆ BitVector() [11/11]

template<typename Allocator >
encrypto::motion::BitVector< Allocator >::BitVector ( std::vector< std::byte, Allocator > &&  data,
std::size_t  number_of_bits 
)
explicit

Initialize by moving content of std::vector (requires same allocator).

Parameters
data
number_of_bitsExpected number of bits.
Precondition
data must be of size equal to number_of_bits.

Member Function Documentation

◆ AndBitVectors() [1/3]

template<typename Allocator >
std::vector< BitVector< Allocator > > encrypto::motion::BitVector< Allocator >::AndBitVectors ( const std::vector< BitVector< Allocator > > &  a,
const std::vector< BitVector< Allocator > > &  b 
)
static

Performs AND operation between every BitVector in a and b.

Parameters
a
b
Precondition
a and b must be of equal size.

◆ AndBitVectors() [2/3]

template<typename Allocator >
BitVector< Allocator > encrypto::motion::BitVector< Allocator >::AndBitVectors ( const std::vector< BitVector< Allocator > > &  bit_vectors)
static

Performs AND operation between all BitVectors in bit_vectors.

Parameters
bit_vectors

◆ AndBitVectors() [3/3]

template<typename Allocator >
std::vector< BitVector< Allocator > > encrypto::motion::BitVector< Allocator >::AndBitVectors ( const std::vector< std::vector< BitVector< Allocator > >> &  bit_vectors)
static

Performs AndBitVectors operation between all vectors of BitVector in bit_vectors.

Parameters
bit_vectors

◆ AndReduceBitVector()

template<typename Allocator >
bool encrypto::motion::BitVector< Allocator >::AndReduceBitVector ( const BitVector< Allocator > &  bit_vector)
static

Performs AND operation between all bits in BitVector.

Parameters
bit_vector

◆ Append() [1/6]

template<typename Allocator >
void encrypto::motion::BitVector< Allocator >::Append ( BitSpan &&  other)

Appends a BitSpan to BitVector.

Parameters
other
Note
A BitSpan is essentially a BitVector, with the only difference that it does not have ownership of its data.

◆ Append() [2/6]

template<typename Allocator >
void encrypto::motion::BitVector< Allocator >::Append ( BitVector< Allocator > &&  other)
noexcept

Appends another BitVector to BitVector.

Parameters
other

◆ Append() [3/6]

template<typename Allocator >
void encrypto::motion::BitVector< Allocator >::Append ( bool  bit)
noexcept

Appends a bit to BitVector.

Parameters
bit
Here is the caller graph for this function:

◆ Append() [4/6]

template<typename Allocator >
void encrypto::motion::BitVector< Allocator >::Append ( const BitSpan other)

Appends a BitSpan to BitVector.

Parameters
other
Note
A BitSpan is essentially a BitVector, with the only difference that it does not have ownership of its data.

◆ Append() [5/6]

template<typename Allocator >
void encrypto::motion::BitVector< Allocator >::Append ( const BitVector< Allocator > &  other)
noexcept

Appends another BitVector to BitVector.

Parameters
other

◆ Append() [6/6]

template<typename Allocator >
void encrypto::motion::BitVector< Allocator >::Append ( const std::byte *  pointer,
const std::size_t  append_bit_size 
)
noexcept

Appends append_bit_size bytes starting from pointer to BitVector.

Parameters
pointer
append_bit_size

◆ Assign() [1/2]

template<typename Allocator = std::allocator<std::byte>>
void encrypto::motion::BitVector< Allocator >::Assign ( BitVector< Allocator > &&  other)
inlinenoexcept

Move-assign other BitVector.

Parameters
other

◆ Assign() [2/2]

template<typename Allocator = std::allocator<std::byte>>
void encrypto::motion::BitVector< Allocator >::Assign ( const BitVector< Allocator > &  other)
inlinenoexcept

Copy-assign other BitVector.

Parameters
other

◆ AsString()

template<typename Allocator >
std::string encrypto::motion::BitVector< Allocator >::AsString
noexcept

Returns a string representation of this BitVector.

◆ Clear()

template<typename Allocator >
void encrypto::motion::BitVector< Allocator >::Clear
noexcept

Clear this Bitvector.

Here is the caller graph for this function:

◆ Copy() [1/2]

template<typename Allocator >
void encrypto::motion::BitVector< Allocator >::Copy ( const std::size_t  dest_from,
const BitVector< Allocator > &  other 
)

copies other to this[dest_from...dest_from+GetSize()].

Exceptions
anstd::out_of_range exception if this is smaller than other.

◆ Copy() [2/2]

template<typename Allocator >
void encrypto::motion::BitVector< Allocator >::Copy ( const std::size_t  dest_from,
const std::size_t  dest_to,
const BitVector< Allocator > &  other 
)

copies the first (dest_to - dest_from) bits from other to the bits [dest_from, dest_to) in this.

Exceptions
anstd::out_of_range exception if accessing invalid positions in this or other.
Here is the caller graph for this function:

◆ Empty()

template<typename Allocator = std::allocator<std::byte>>
bool encrypto::motion::BitVector< Allocator >::Empty ( ) const
inline

Check if BitVector is empty.

Here is the caller graph for this function:

◆ Get()

template<typename Allocator >
bool encrypto::motion::BitVector< Allocator >::Get ( std::size_t  position) const

Get bit at given position.

Parameters
position
Here is the caller graph for this function:

◆ GetData()

template<typename Allocator = std::allocator<std::byte>>
const auto& encrypto::motion::BitVector< Allocator >::GetData ( ) const
inlinenoexcept

Get const reference to content of BitVector.

Here is the caller graph for this function:

◆ GetMutableData()

template<typename Allocator = std::allocator<std::byte>>
auto& encrypto::motion::BitVector< Allocator >::GetMutableData ( )
inlinenoexcept

Get reference to content of BitVector.

◆ GetSize()

template<typename Allocator = std::allocator<std::byte>>
auto encrypto::motion::BitVector< Allocator >::GetSize ( ) const
inlinenoexcept

Get size of BitVector.

Here is the caller graph for this function:

◆ Invert()

template<typename Allocator >
void encrypto::motion::BitVector< Allocator >::Invert

In-place bit-wise invert.

Here is the caller graph for this function:

◆ IsAligned()

template<typename Allocator = std::allocator<std::byte>>
static constexpr bool encrypto::motion::BitVector< Allocator >::IsAligned ( )
inlinestaticconstexprnoexcept

Returns true if Allocator is aligned allocator.

◆ IsEqualSizeDimensions()

template<typename Allocator >
bool encrypto::motion::BitVector< Allocator >::IsEqualSizeDimensions ( const std::vector< BitVector< Allocator > > &  bit_vectors)
static

Check if all Bitvectors in bit_vectors are of equal dimension.

Parameters
bit_vectors

◆ operator!=() [1/2]

template<typename Allocator = std::allocator<std::byte>>
bool encrypto::motion::BitVector< Allocator >::operator!= ( const BitSpan other) const
noexcept

Compares a BitVector and a BitSpan for inequality.

Parameters
other
Note
A BitSpan is essentially a BitVector, with the only difference that it does not have ownership of its data.

◆ operator!=() [2/2]

template<typename Allocator >
template<typename OtherAllocator >
bool encrypto::motion::BitVector< Allocator >::operator!= ( const BitVector< OtherAllocator > &  other) const
noexcept

Compares two BitVectors for inequality.

Parameters
other

◆ operator&() [1/3]

template<typename Allocator >
BitVector< Allocator > encrypto::motion::BitVector< Allocator >::operator& ( const BitSpan other) const
noexcept

Perform AND operation between every bit of a BitVector and a BitSpan.

Parameters
other
Note
A BitSpan is essentially a BitVector, with the only difference that it does not have ownership of its data.

◆ operator&() [2/3]

template<typename Allocator = std::allocator<std::byte>>
template<typename OtherAllocator >
BitVector encrypto::motion::BitVector< Allocator >::operator& ( const BitVector< OtherAllocator > &  other) const
noexcept

Perform AND operation between every bit of two BitVectors.

Parameters
other

◆ operator&() [3/3]

template<typename Allocator = std::allocator<std::byte>>
template<typename OtherAllocator >
BitVector<Allocator> encrypto::motion::BitVector< Allocator >::operator& ( const BitVector< OtherAllocator > &  other) const
noexcept

◆ operator&=() [1/3]

template<typename Allocator >
BitVector< Allocator > & encrypto::motion::BitVector< Allocator >::operator&= ( const BitSpan other)
noexcept

Perform AND-assign operation between every bit of this and a BitSpan.

Parameters
other
Note
A BitSpan is essentially a BitVector, with the only difference that it does not have ownership of its data.

◆ operator&=() [2/3]

template<typename Allocator = std::allocator<std::byte>>
template<typename OtherAllocator >
BitVector& encrypto::motion::BitVector< Allocator >::operator&= ( const BitVector< OtherAllocator > &  other)
noexcept

Perform AND-assign operation between every bit of this and the other BitVector.

Parameters
other

◆ operator&=() [3/3]

template<typename Allocator = std::allocator<std::byte>>
template<typename OtherAllocator >
BitVector<Allocator>& encrypto::motion::BitVector< Allocator >::operator&= ( const BitVector< OtherAllocator > &  other)
noexcept

◆ operator=() [1/3]

template<typename Allocator >
BitVector< Allocator > & encrypto::motion::BitVector< Allocator >::operator= ( BitVector< Allocator > &&  other)
noexcept

◆ operator=() [2/3]

template<typename Allocator >
BitVector< Allocator > & encrypto::motion::BitVector< Allocator >::operator= ( const BitVector< Allocator > &  other)
noexcept

◆ operator=() [3/3]

template<typename Allocator >
template<typename OtherAllocator >
BitVector< Allocator > & encrypto::motion::BitVector< Allocator >::operator= ( const BitVector< OtherAllocator > &  other)
noexcept

Copy-assign from BitVector with different allocator.

Template Parameters
OtherAllocator
Parameters
other

◆ operator==() [1/2]

template<typename Allocator >
bool encrypto::motion::BitVector< Allocator >::operator== ( const BitSpan other) const
noexcept

Compares a BitVector and a BitSpan for equality.

Parameters
other
Note
A BitSpan is essentially a BitVector, with the only difference that it does not have ownership of its data.

◆ operator==() [2/2]

template<typename Allocator >
template<typename OtherAllocator >
bool encrypto::motion::BitVector< Allocator >::operator== ( const BitVector< OtherAllocator > &  other) const
noexcept

Compares two BitVectors for equality.

Parameters
other

◆ operator[]()

template<typename Allocator = std::allocator<std::byte>>
bool encrypto::motion::BitVector< Allocator >::operator[] ( std::size_t  position) const
inline

Get bit at given position in the BitVector.

Parameters
position

◆ operator^() [1/3]

template<typename Allocator >
BitVector< Allocator > encrypto::motion::BitVector< Allocator >::operator^ ( const BitSpan other) const
noexcept

Perform XOR operation between every bit of a BitVector and a BitSpan.

Parameters
other
Note
A BitSpan is essentially a BitVector, with the only difference that it does not have ownership of its data.

◆ operator^() [2/3]

template<typename Allocator = std::allocator<std::byte>>
template<typename OtherAllocator >
BitVector encrypto::motion::BitVector< Allocator >::operator^ ( const BitVector< OtherAllocator > &  other) const
noexcept

Perform XOR operation between every bit of two BitVectors.

Parameters
other

◆ operator^() [3/3]

template<typename Allocator = std::allocator<std::byte>>
template<typename OtherAllocator >
BitVector<Allocator> encrypto::motion::BitVector< Allocator >::operator^ ( const BitVector< OtherAllocator > &  other) const
noexcept

◆ operator^=() [1/3]

template<typename Allocator >
BitVector< Allocator > & encrypto::motion::BitVector< Allocator >::operator^= ( const BitSpan other)
noexcept

Perform XOR-assign operation between every bit of this and a BitSpan.

Parameters
other
Note
A BitSpan is essentially a BitVector, with the only difference that it does not have ownership of its data.

◆ operator^=() [2/3]

template<typename Allocator = std::allocator<std::byte>>
template<typename OtherAllocator >
BitVector& encrypto::motion::BitVector< Allocator >::operator^= ( const BitVector< OtherAllocator > &  other)
noexcept

Perform XOR-assign operation between every bit of this and the other BitVector.

Parameters
other

◆ operator^=() [3/3]

template<typename Allocator = std::allocator<std::byte>>
template<typename OtherAllocator >
BitVector<Allocator>& encrypto::motion::BitVector< Allocator >::operator^= ( const BitVector< OtherAllocator > &  other)
noexcept

◆ operator|() [1/3]

template<typename Allocator >
BitVector< Allocator > encrypto::motion::BitVector< Allocator >::operator| ( const BitSpan other) const
noexcept

Perform OR operation between every bit of a BitVector and a BitSpan.

Parameters
other
Note
A BitSpan is essentially a BitVector, with the only difference that it does not have ownership of its data.

◆ operator|() [2/3]

template<typename Allocator = std::allocator<std::byte>>
template<typename OtherAllocator >
BitVector encrypto::motion::BitVector< Allocator >::operator| ( const BitVector< OtherAllocator > &  other) const
noexcept

Perform OR operation between every bit of two BitVectors.

Parameters
other

◆ operator|() [3/3]

template<typename Allocator = std::allocator<std::byte>>
template<typename OtherAllocator >
BitVector<Allocator> encrypto::motion::BitVector< Allocator >::operator| ( const BitVector< OtherAllocator > &  other) const
noexcept

◆ operator|=() [1/3]

template<typename Allocator >
BitVector< Allocator > & encrypto::motion::BitVector< Allocator >::operator|= ( const BitSpan other)
noexcept

Perform OR-assign operation between every bit of this and a BitSpan.

Parameters
other
Note
A BitSpan is essentially a BitVector, with the only difference that it does not have ownership of its data.

◆ operator|=() [2/3]

template<typename Allocator = std::allocator<std::byte>>
template<typename OtherAllocator >
BitVector& encrypto::motion::BitVector< Allocator >::operator|= ( const BitVector< OtherAllocator > &  other)
noexcept

Perform OR-assign operation between every bit of this and the other BitVector.

Parameters
other

◆ operator|=() [3/3]

template<typename Allocator = std::allocator<std::byte>>
template<typename OtherAllocator >
BitVector<Allocator>& encrypto::motion::BitVector< Allocator >::operator|= ( const BitVector< OtherAllocator > &  other)
noexcept

◆ operator~()

template<typename Allocator >
BitVector< Allocator > encrypto::motion::BitVector< Allocator >::operator~

Return an inverted copy of this BitVector.

◆ OrBitVectors()

template<typename Allocator >
BitVector< Allocator > encrypto::motion::BitVector< Allocator >::OrBitVectors ( const std::vector< BitVector< Allocator > > &  bit_vectors)
static

Performs OR operation between all BitVectors in bit_vectors.

Parameters
bit_vectors

◆ OrReduceBitVector()

template<typename Allocator >
bool encrypto::motion::BitVector< Allocator >::OrReduceBitVector ( const BitVector< Allocator > &  bit_vector)
static

Performs OR operation between all bits in BitVector.

Parameters
bit_vector

◆ RandomSeeded()

template<typename Allocator >
BitVector< Allocator > encrypto::motion::BitVector< Allocator >::RandomSeeded ( const std::size_t  size,
const std::size_t  seed = 0 
)
staticnoexcept

Returns a random BitVector using an input seed. Internally uses Mersenne twister, do not use as cryptographic randomness!

Parameters
sizeThe size of the returned BitVector.
seed

◆ Reserve()

template<typename Allocator = std::allocator<std::byte>>
void encrypto::motion::BitVector< Allocator >::Reserve ( std::size_t  number_of_bits)
inline

Reserves new space for BitVector, so that it can contain at least number_of_bits bits.

Parameters
number_of_bits
Here is the caller graph for this function:

◆ Resize()

template<typename Allocator >
void encrypto::motion::BitVector< Allocator >::Resize ( std::size_t  number_of_bits,
bool  zero_fill = false 
)
noexcept

Resize BitVector to size number_of_bits. New bits are uninitialized by default.

Parameters
number_of_bits
zero_fillSets new bits to 0 if option is set to true.
Here is the caller graph for this function:

◆ SecureRandom()

template<typename Allocator >
BitVector< Allocator > encrypto::motion::BitVector< Allocator >::SecureRandom ( const std::size_t  size)
staticnoexcept

Returns a random BitVector.

Parameters
sizeThe size of the returned BitVector.
Here is the caller graph for this function:

◆ Set() [1/2]

template<typename Allocator >
void encrypto::motion::BitVector< Allocator >::Set ( bool  value)
noexcept

Sets or unsets all bits in the BitVector.

Parameters
value
Here is the caller graph for this function:

◆ Set() [2/2]

template<typename Allocator >
void encrypto::motion::BitVector< Allocator >::Set ( bool  value,
std::size_t  position 
)

Sets or unsets the bit at position in the BitVector.

Parameters
value
position

◆ Subset()

template<typename Allocator >
BitVector< Allocator > encrypto::motion::BitVector< Allocator >::Subset ( std::size_t  from,
std::size_t  to 
) const

Returns a new BitVector containing the bits of this BitVector between positions from and to.

Parameters
from
Here is the caller graph for this function:

◆ XorBitVectors() [1/3]

template<typename Allocator >
std::vector< BitVector< Allocator > > encrypto::motion::BitVector< Allocator >::XorBitVectors ( const std::vector< BitVector< Allocator > > &  a,
const std::vector< BitVector< Allocator > > &  b 
)
static

Performs XOR operation between every BitVector in a and b.

Parameters
a
b
Precondition
a and b must be of equal size.

◆ XorBitVectors() [2/3]

template<typename Allocator >
BitVector< Allocator > encrypto::motion::BitVector< Allocator >::XorBitVectors ( const std::vector< BitVector< Allocator > > &  bit_vectors)
static

Performs XOR operation between all BitVectors in bit_vectors.

Parameters
bit_vectors
Here is the caller graph for this function:

◆ XorBitVectors() [3/3]

template<typename Allocator >
std::vector< BitVector< Allocator > > encrypto::motion::BitVector< Allocator >::XorBitVectors ( const std::vector< std::vector< BitVector< Allocator > >> &  bit_vectors)
static

Performs XorBitVectors operation between all vectors of BitVector in bit_vectors.

Parameters
bit_vectors

◆ XorReduceBitVector()

template<typename Allocator >
bool encrypto::motion::BitVector< Allocator >::XorReduceBitVector ( const BitVector< Allocator > &  bit_vector)
static

Performs XOR operation between all bits in BitVector.

Parameters
bit_vector

Friends And Related Function Documentation

◆ BitSpan

template<typename Allocator = std::allocator<std::byte>>
friend class BitSpan
friend

◆ BitVector

template<typename Allocator = std::allocator<std::byte>>
template<typename OtherAllocator >
friend class BitVector
friend

◆ ToInput()

template<typename T , typename = std::enable_if_t<std::is_floating_point_v<T> || std::is_unsigned_v<T>>, typename Allocator = std::allocator<std::byte>>
std::vector< BitVector< Allocator > > ToInput ( value)
related

Converts a value of an unsigned integer type or a floating point type to a vector of BitVector.

A vector of BitVectors allows to interleave multiple arithmetic values intended to be used in a SIMD way. Let x be an arithmetic value, with x0,...,xn being its little-endian bit representation. This value is then represented by a value v of type std::vector<BitVector> with v[j][0] == xj. Now, if we interleave x with y and z of the same bit representation, then: v[j][0] == xj, v[j][1] == yj, v[j][2] == zj.

Postcondition
- All BitVectors in the returned vector will have size equal 1.
  • The returned vector will have size equal to number of bits in UnsignedIntegralType.
Template Parameters
T
Parameters
value
Here is the caller graph for this function:

◆ ToVectorOutput()

template<typename UnsignedIntegralType , typename = std::enable_if_t<std::is_unsigned_v<UnsignedIntegralType>>, typename Allocator = std::allocator<std::byte>>
std::vector< UnsignedIntegralType > ToVectorOutput ( std::vector< BitVector< Allocator >>  bit_vectors)
related

Converts a vector of UnsignedIntegralType to a vector of BitVectors.

A vector of BitVectors allows to interleave multiple arithmetic values intended to be used in a SIMD way. Let x be an arithmetic value, with x0,...,xn being its little-endian bit representation. This value is then represented by a value v of type std::vector<BitVector> with v[j][0] == xj. Now, if we interleave x with y and z of the same bit representation, then: v[j][0] == xj, v[j][1] == yj, v[j][2] == zj.

Precondition
- Size of bit_vectors is equal to number of bits in UnsignedIntegralType
  • Each BitVector in bit_vectors has size equal to bit_vectors.size()
Template Parameters
UnsignedIntegralType
Parameters
bit_vectors

The documentation for this class was generated from the following files: