Document the new DPF surfaces in one command set, and test the field, half-tree, and multipoint edges.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Ryan Henry 2026-09-24 23:18:10 -06:00
parent 0d8a5a8131
commit 0dff6df8ed
250 changed files with 12199 additions and 1981 deletions

View file

@ -68,6 +68,7 @@ namespace dpf
/// `dpf::bit_array_base` and is parametrized on `Nbits`, which is
/// the length of the bitstring.
/// @tparam Nbits the bitlength of the string
/// @tparam WordT word used to pack bits
template <std::size_t Nbits,
typename WordT = utils::integral_type_from_bitlength_t<Nbits, 8, 64>>
class bitstring : public bit_array_base<bitstring<Nbits, WordT>, WordT>
@ -81,6 +82,7 @@ class bitstring : public bit_array_base<bitstring<Nbits, WordT>, WordT>
using const_pointer = typename base::const_pointer;
using size_type = typename base::size_type;
static constexpr auto bits_per_word = base::bits_per_word;
static constexpr bool dpf_bitstring = true;
private:
/// @brief the number of `word_type`s are being used to represent the
/// `num_bits_` bits
@ -135,11 +137,15 @@ class bitstring : public bit_array_base<bitstring<Nbits, WordT>, WordT>
/// and length `len` can be provided, as well as characters
/// denoting alternate values for set (`one`) and unset (`zero`)
/// bits.
/// @tparam CharT character type
/// @tparam Traits character traits
/// @tparam Alloc allocator type
/// @param str `string` used to initialize the `dpf::bitstring`
/// @param pos a starting offset into `str`
/// @param len number of characters to use from `str`
/// @param zero character used to represent `0` (default: `CharT('0')`)
/// @param one character used to represent `1` (default: `CharT('1')`)
/// @throws std::out_of_range
template <typename CharT,
typename Traits,
typename Alloc>
@ -166,10 +172,12 @@ class bitstring : public bit_array_base<bitstring<Nbits, WordT>, WordT>
/// `CharT *` `str`. An optional starting position `pos` and length
/// `len` can be provided, as well as characters denoting alternate
/// values for set (`one`) and unset (`zero`) bits.
/// @tparam CharT character type
/// @param str string used to initialize the `dpf::bitstring`
/// @param len number of characters to use from `str`
/// @param zero character used to represent `false`/`0` (default: ``CharT('0')``)
/// @param one character used to represent `true`/`1` (default: ``CharT('1')``)
/// @throws std::invalid_argument if `null string`
template <typename CharT>
explicit bitstring(const CharT * str,
typename std::basic_string<CharT>::size_type len
@ -293,6 +301,7 @@ class bitstring : public bit_array_base<bitstring<Nbits, WordT>, WordT>
/// @brief shifts the bit mask to the right by the given number of
/// bits
/// @param shift_by number of bits to shift the mask to the right
/// @param mask the bit mask
/// @return a reference to the modified `dpf::bitstring::bit_mask`
HEDLEY_ALWAYS_INLINE
HEDLEY_NO_THROW
@ -306,6 +315,7 @@ class bitstring : public bit_array_base<bitstring<Nbits, WordT>, WordT>
/// @brief shifts the bit mask to the left by the given number of
/// bits
/// @param shift_by number of bits to shift the mask to the right
/// @param mask the bit mask
/// @return a reference to the modified `dpf::bitstring::bit_mask`
HEDLEY_ALWAYS_INLINE
HEDLEY_NO_THROW
@ -342,6 +352,8 @@ class bitstring : public bit_array_base<bitstring<Nbits, WordT>, WordT>
}
/// @brief Inequality of the defined bits.
/// @param rhs the right-hand operand
/// @return Inequality of the defined bits
HEDLEY_ALWAYS_INLINE
constexpr bool operator!=(const bitstring & rhs) const
{
@ -349,6 +361,8 @@ class bitstring : public bit_array_base<bitstring<Nbits, WordT>, WordT>
}
/// @brief Less than, most-significant bit first.
/// @param rhs the right-hand operand
/// @return Less than, most-significant bit first
HEDLEY_ALWAYS_INLINE
constexpr bool operator<(const bitstring & rhs) const
{
@ -356,6 +370,8 @@ class bitstring : public bit_array_base<bitstring<Nbits, WordT>, WordT>
}
/// @brief Less than or equal, most-significant bit first.
/// @param rhs the right-hand operand
/// @return Less than or equal, most-significant bit first
HEDLEY_ALWAYS_INLINE
constexpr bool operator<=(const bitstring & rhs) const
{
@ -363,6 +379,8 @@ class bitstring : public bit_array_base<bitstring<Nbits, WordT>, WordT>
}
/// @brief Greater than, most-significant bit first.
/// @param rhs the right-hand operand
/// @return Greater than, most-significant bit first
HEDLEY_ALWAYS_INLINE
constexpr bool operator>(const bitstring & rhs) const
{
@ -501,7 +519,7 @@ class bitstring : public bit_array_base<bitstring<Nbits, WordT>, WordT>
}
/// @brief returns the number of bits
/// @returns number of bits that the `bitstring` holds
/// @return number of bits that the `bitstring` holds
/// @complexity `O(1)`
HEDLEY_NO_THROW
HEDLEY_PURE
@ -517,6 +535,7 @@ class bitstring : public bit_array_base<bitstring<Nbits, WordT>, WordT>
std::array<word_type, data_length_> data_{};
/// @brief Mask of the bits that belong to this string in the high word.
/// @return the returned `word_type`
HEDLEY_NO_THROW
static constexpr word_type defined_high_mask() noexcept
{
@ -537,6 +556,8 @@ class bitstring : public bit_array_base<bitstring<Nbits, WordT>, WordT>
/// @brief Most-significant word first. Unused high bits are ignored.
/// Every limb is visited, so the time does not depend on where
/// the strings differ.
/// @param rhs the right-hand operand
/// @return Most-significant word first
constexpr int compare(const bitstring & rhs) const
{
if constexpr (data_length_ == 0) return 0;
@ -558,6 +579,12 @@ class bitstring : public bit_array_base<bitstring<Nbits, WordT>, WordT>
}
/// @brief Last character is bit 0. `len` must be at most `Nbits`.
/// @tparam CharT character type
/// @param str the source string
/// @param len the number of bytes
/// @param zero the character used for 0
/// @param one the character used for 1
/// @throws std::out_of_range if `string longer than Nbits`
template <typename CharT>
void assign_msb_string(const CharT * str, std::size_t len, CharT zero, CharT one)
{
@ -615,6 +642,8 @@ namespace utils
{
/// @brief specializes `dpf::utils::bitlength_of` for `dpf::bitstring`
/// @tparam Nbits width in bits
/// @tparam WordT word used to pack bits
template <std::size_t Nbits,
typename WordT>
struct bitlength_of<dpf::bitstring<Nbits, WordT>>
@ -622,6 +651,8 @@ struct bitlength_of<dpf::bitstring<Nbits, WordT>>
{ };
/// @brief specializes `dpf::utils::msb_of` for `dpf::bitstring`
/// @tparam Nbits width in bits
/// @tparam WordT word used to pack bits
template <std::size_t Nbits,
typename WordT>
struct msb_of<dpf::bitstring<Nbits, WordT>>
@ -633,6 +664,8 @@ struct msb_of<dpf::bitstring<Nbits, WordT>>
/// @brief specializes `dpf::utils::countl_zero_symmetric_difference` for
/// `dpf::bitstring`
/// @tparam Nbits width in bits
/// @tparam WordT word used to pack bits
template <std::size_t Nbits,
typename WordT>
struct countl_zero_symmetric_difference<dpf::bitstring<Nbits, WordT>>
@ -909,6 +942,9 @@ namespace bitstrings
/// @brief Build a bitstring from characters. The first character is the
/// most significant bit of the digit string (same order as `0b...`).
/// Digits shorter than `Bitstring::size()` occupy the low bits.
/// @tparam Bitstring bitstring
/// @tparam bits bits
/// @return the returned `Bitstring`
template <typename Bitstring, char... bits>
constexpr Bitstring bitstring_literal()
{
@ -925,6 +961,8 @@ constexpr Bitstring bitstring_literal()
/// @details The leftmost character is the most significant bit, matching
/// `0b` integer literals. `10101001_bitstring` equals
/// `dpf::bitstring<8>(0b10101001)`.
/// @tparam bits bits
/// @return user-defined numeric literal for creating `dpf::bitstring` objects
template <char ...bits>
constexpr static auto operator "" _bitstring()
{
@ -937,7 +975,9 @@ constexpr static auto operator "" _bitstring_u8()
return bitstring_literal<dpf::bitstring<sizeof...(bits), psnip_uint8_t>, bits...>();
}
/// Alias used by the test suite: word type `uint8_t`, not length 8.
/// @brief Alias used by the test suite: word type `uint8_t`, not length 8.
/// @tparam bits bits
/// @return Alias used by the test suite: word type `uint8_t`, not length 8
template <char ...bits>
constexpr static auto operator "" _bitstring_8()
{
@ -1123,6 +1163,8 @@ namespace std
/// @{
/// @details specializes `std::numeric_limits` for `dpf::bitstring<Nbits, WordT>`
/// @tparam Nbits width in bits
/// @tparam WordT word used to pack bits
template<std::size_t Nbits,
typename WordT>
class numeric_limits<dpf::bitstring<Nbits, WordT>>
@ -1174,20 +1216,26 @@ class numeric_limits<dpf::bitstring<Nbits, WordT>>
};
/// @details specializes `std::numeric_limits` for `dpf::bitstring<Nbits, WordT> const`
/// @tparam Nbits width in bits
/// @tparam WordT word used to pack bits
template<std::size_t Nbits,
typename WordT>
class numeric_limits<dpf::bitstring<Nbits, WordT> const>
: public numeric_limits<dpf::bitstring<Nbits, WordT>> {};
/// @details specializes `std::numeric_limits` for
/// `dpf::bitstring<Nbits, WordT> volatile`
/// @brief `dpf::bitstring<Nbits, WordT> volatile`
/// @tparam Nbits width in bits
/// @tparam WordT word used to pack bits
template<std::size_t Nbits,
typename WordT>
class numeric_limits<dpf::bitstring<Nbits, WordT> volatile>
: public numeric_limits<dpf::bitstring<Nbits, WordT>> {};
/// @details specializes `std::numeric_limits` for
/// `dpf::bitstring<Nbits, WordT> const volatile`
/// @brief `dpf::bitstring<Nbits, WordT> const volatile`
/// @tparam Nbits width in bits
/// @tparam WordT word used to pack bits
template<std::size_t Nbits,
typename WordT>
class numeric_limits<dpf::bitstring<Nbits, WordT> const volatile>