![]() |
NumCpp
2.14.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
|
Functions | |
bool | calculateParity (const boost::dynamic_bitset<> &data) noexcept |
template<std::size_t DataBits> | |
constexpr bool | calculateParity (const std::bitset< DataBits > &data) noexcept |
template<std::size_t DataBits, typename IntType , std::enable_if_t< std::is_integral_v< IntType >, int > = 0> | |
bool | calculateParity (const std::bitset< DataBits > &data, IntType parityBit) |
template<std::size_t DataBits, std::size_t EncodedBits, std::enable_if_t< greaterThan_v< EncodedBits, DataBits >, int > = 0> | |
std::size_t | checkBitsConsistent () |
template<typename IntType1 , typename IntType2 , std::enable_if_t< std::is_integral_v< IntType1 >, int > = 0, std::enable_if_t< std::is_integral_v< IntType2 >, int > = 0> | |
std::vector< std::size_t > | dataBitsCovered (IntType1 numDataBits, IntType2 parityBit) |
template<std::size_t DataBits, std::size_t EncodedBits, std::enable_if_t< greaterThan_v< EncodedBits, DataBits >, int > = 0> | |
std::bitset< DataBits > | extractData (const std::bitset< EncodedBits > &encodedBits) noexcept |
template<typename IntType , std::enable_if_t< std::is_integral_v< IntType >, int > = 0> | |
constexpr bool | isPowerOfTwo (IntType n) noexcept |
Tests if value is a power of two. | |
template<typename IntType , std::enable_if_t< std::is_integral_v< IntType >, int > = 0> | |
std::size_t | nextPowerOfTwo (IntType n) |
template<typename IntType , std::enable_if_t< std::is_integral_v< IntType >, int > = 0> | |
std::size_t | numSecdedParityBitsNeeded (IntType numDataBits) |
template<typename IntType , std::enable_if_t< std::is_integral_v< IntType >, int > = 0> | |
std::vector< std::size_t > | powersOfTwo (IntType n) |
Calculates the overall parity of the data, assumes last bit is the parity bit itself
data | the data word |
|
constexprnoexcept |
Calculates the overall parity of the data, assumes last bit is the parity bit itself
data | the data word |
bool nc::edac::detail::calculateParity | ( | const std::bitset< DataBits > & | data, |
IntType | parityBit | ||
) |
Calculates the specified Hamming parity bit (1, 2, 4, 8, etc.) for the given data. Assumes even parity to allow for easier computation of parity using XOR.
data | the data word |
parityBit | the parity bit number |
std::invalid_argument | if parityBit is not a power of two |
std::bad_alloc | if unable to allocate return vector |
std::size_t nc::edac::detail::checkBitsConsistent | ( | ) |
Checks that the number of DataBits and EncodedBits are consistent
std::runtime_error | if DataBits and EncodedBits are not consistent |
std::runtime_error | if the number of data bits does not represent a valid Hamming SECDED code |
std::vector< std::size_t > nc::edac::detail::dataBitsCovered | ( | IntType1 | numDataBits, |
IntType2 | parityBit | ||
) |
Returns the indices of all data bits covered by a specified parity bit in a bitstring of length numDataBits. The indices are relative to DATA BITSTRING ITSELF, NOT including parity bits.
numDataBits | the number of data bits to encode |
parityBit | the parity bit number |
std::invalid_argument | if parityBit is not a power of two |
std::bad_alloc | if unable to allocate return vector |
|
noexcept |
Returns the Hamming SECDED decoded bits from the endoded bits. Assumes that the DataBits and EncodedBits have been checks for consistancy already
encodedBits | the Hamming SECDED encoded word |
Tests if value is a power of two.
n | integer value |
std::size_t nc::edac::detail::nextPowerOfTwo | ( | IntType | n | ) |
Calculates the next power of two after n
_next_power_of_two(768)
1024
_next_power_of_two(4)
8
n | integer value |
std::invalid_argument | if input value is less than zero |
std::size_t nc::edac::detail::numSecdedParityBitsNeeded | ( | IntType | numDataBits | ) |
Calculates the number of needed Hamming SECDED parity bits to encode the data
numDataBits | the number of data bits to encode |
std::invalid_argument | if input value is less than zero |
std::runtime_error | if the number of data bits does not represent a valid Hamming SECDED code |
std::vector< std::size_t > nc::edac::detail::powersOfTwo | ( | IntType | n | ) |
Calculates the first n powers of two
n | integer value |
std::bad_alloc | if unable to allocate for return vector |