Ticket #8830: crc_polynomial.2.patch

File crc_polynomial.2.patch, 20.7 KB (added by Ed Beroset <beroset@…>, 9 years ago)

amended patch to fix misspelling of "polynomial" in crc library

  • boost/crc.hpp

     
    198198
    199199    // Internal Operations
    200200    //! Return the (truncated) polynomial divisor
    201     value_type  get_truncated_polynominal() const;
     201    value_type  get_truncated_polynomial() const;
    202202    //! Return what the polynomial remainder was set to during construction
    203203    value_type  get_initial_remainder() const;
    204204    //! Return the XOR-mask used during output processing
     
    284284    //! \copydoc  boost::crc_basic::bit_count
    285285    BOOST_STATIC_CONSTANT( std::size_t, bit_count = Bits );
    286286    //! A copy of \a TruncPoly provided for meta-programming purposes
    287     BOOST_STATIC_CONSTANT( value_type, truncated_polynominal = TruncPoly );
     287    BOOST_STATIC_CONSTANT( value_type, truncated_polynomial = TruncPoly );
    288288    //! A copy of \a InitRem provided for meta-programming purposes
    289289    BOOST_STATIC_CONSTANT( value_type, initial_remainder = InitRem );
    290290    //! A copy of \a FinalXor provided for meta-programming purposes
     
    299299    explicit  crc_optimal( value_type init_rem = initial_remainder );
    300300
    301301    // Internal Operations
    302     //! \copybrief  boost::crc_basic::get_truncated_polynominal
    303     value_type  get_truncated_polynominal() const;
     302    //! \copybrief  boost::crc_basic::get_truncated_polynomial
     303    value_type  get_truncated_polynomial() const;
    304304    //! \copybrief  boost::crc_basic::get_initial_remainder
    305305    value_type  get_initial_remainder() const;
    306306    //! \copybrief  boost::crc_basic::get_final_xor_value
     
    15681568      the RMCA)
    15691569
    15701570    \post  <code><var>truncated_polynomial</var> ==
    1571       this-&gt;get_truncated_polynominal()</code>
     1571      this-&gt;get_truncated_polynomial()</code>
    15721572    \post  <code><var>initial_remainder</var> ==
    15731573      this-&gt;get_initial_remainder()</code>
    15741574    \post  <code><var>final_xor_value</var> ==
     
    16111611template < std::size_t Bits >
    16121612inline
    16131613typename crc_basic<Bits>::value_type
    1614 crc_basic<Bits>::get_truncated_polynominal
     1614crc_basic<Bits>::get_truncated_polynomial
    16151615(
    16161616) const
    16171617{
     
    19411941    \param[in] init_rem  The (unaugmented) initial state of the polynomial
    19421942      remainder.  Defaults to #initial_remainder if omitted.
    19431943
    1944     \post  <code>#truncated_polynominal ==
    1945       this-&gt;get_truncated_polynominal()</code>
     1944    \post  <code>#truncated_polynomial ==
     1945      this-&gt;get_truncated_polynomial()</code>
    19461946    \post  <code>#initial_remainder == this-&gt;get_initial_remainder()</code>
    19471947    \post  <code>#final_xor_value == this-&gt;get_final_xor_value()</code>
    19481948    \post  <code>#reflect_input == this-&gt;get_reflect_input()</code>
     
    19631963{
    19641964}
    19651965
    1966 //! \copydetails  boost::crc_basic::get_truncated_polynominal
     1966//! \copydetails  boost::crc_basic::get_truncated_polynomial
    19671967template < std::size_t Bits, BOOST_CRC_PARM_TYPE TruncPoly,
    19681968           BOOST_CRC_PARM_TYPE InitRem, BOOST_CRC_PARM_TYPE FinalXor,
    19691969           bool ReflectIn, bool ReflectRem >
    19701970inline
    19711971typename BOOST_CRC_OPTIMAL_NAME::value_type
    1972 BOOST_CRC_OPTIMAL_NAME::get_truncated_polynominal
     1972BOOST_CRC_OPTIMAL_NAME::get_truncated_polynomial
    19731973(
    19741974) const
    19751975{
    1976     return truncated_polynominal;
     1976    return truncated_polynomial;
    19771977}
    19781978
    19791979//! \copydetails  boost::crc_basic::get_initial_remainder
  • libs/crc/crc.html

     
    102102
    103103<h2><a name="background">Background</a></h2>
    104104
    105 <p>CRCs work by computing the remainder of a modulo-2 polynominal
     105<p>CRCs work by computing the remainder of a modulo-2 polynomial
    106106division.  The message is treated as the (binary) coefficents of a long
    107 polynominal for the dividend, with the earlier bits of the message fed
    108 first as the polynominal's highest coefficents.  A particular CRC
    109 algorithm has another polynominal associated with it to be used as the
     107polynomial for the dividend, with the earlier bits of the message fed
     108first as the polynomial's highest coefficents.  A particular CRC
     109algorithm has another polynomial associated with it to be used as the
    110110divisor.  The quotient is ignored.  The remainder of the division
    111111considered the checksum.  However, the division uses modulo-2 rules (no
    112112carries) for the coefficents.</p>
     
    120120<h3><a name="parameters">CRC Parameters</a></h3>
    121121
    122122<dl>
    123         <dt>Truncated polynominal
    124         <dd>The divisor polynominal has a degree one bit larger than the
     123        <dt>Truncated polynomial
     124        <dd>The divisor polynomial has a degree one bit larger than the
    125125                checksum (remainder) size.  That highest bit is always one, so
    126126                it is ignored when describing a particular CRC type.  Excluding
    127127                this bit makes the divisor fit in the same data type as the
     
    145145        <dt>Reflected input
    146146        <dd>A message's bits are usually fed a byte at a time, with the
    147147                highest bits of the byte treated as the higher bits of the
    148                 dividend polynominal.  Some CRCs reflect the bits (about the
     148                dividend polynomial.  Some CRCs reflect the bits (about the
    149149                byte's center, so the first and last bits are switched,
    150150                <i>etc.</i>) before feeding.
    151151
     
    167167    static  std::size_t const  bit_count = Bits;
    168168
    169169    // Constructor
    170     explicit  crc_basic( value_type truncated_polynominal,
     170    explicit  crc_basic( value_type truncated_polynomial,
    171171               value_type initial_remainder = 0, value_type final_xor_value = 0,
    172172               bool reflect_input = false, bool reflect_remainder = false );
    173173
    174174    // Internal Operations
    175     value_type  get_truncated_polynominal() const;
     175    value_type  get_truncated_polynomial() const;
    176176    value_type  get_initial_remainder() const;
    177177    value_type  get_final_xor_value() const;
    178178    bool        get_reflect_input() const;
     
    218218
    219219    // Constants reflecting template parameters
    220220    static  std::size_t const  bit_count = Bits;
    221     static  value_type const   truncated_polynominal = TruncPoly;
     221    static  value_type const   truncated_polynomial = TruncPoly;
    222222    static  value_type const   initial_remainder = InitRem;
    223223    static  value_type const   final_xor_value = FinalXor;
    224224    static  bool const         reflect_input = ReflectIn;
     
    228228    explicit  crc_optimal( value_type init_rem = InitRem );
    229229
    230230    // Internal Operations
    231     value_type  get_truncated_polynominal() const;
     231    value_type  get_truncated_polynomial() const;
    232232    value_type  get_initial_remainder() const;
    233233    value_type  get_final_xor_value() const;
    234234    bool        get_reflect_input() const;
     
    264264template parameters.  No individual bits are considered; only whole
    265265bytes are passed.  A table of interim CRC values versus byte values is
    266266pre-computed when the first object using a particular bit size,
    267 truncated polynominal, and input reflection state is processed.</p>
     267truncated polynomial, and input reflection state is processed.</p>
    268268
    269269<h2><a name="usage">Computer Usage</a></h2>
    270270
     
    278278default-constructed.</p>
    279279
    280280<p>The CRC parameters can be inspected at run-time with the following
    281 member functions: <code>get_truncated_polynominal</code>,
     281member functions: <code>get_truncated_polynomial</code>,
    282282<code>get_initial_remainder</code>, <code>get_final_xor_value</code>,
    283283<code>get_reflect_input</code>, and <code>get_reflect_remainder</code>.
    284284The fast computer also provides compile-time constants for its CRC
     
    449449as the register size) after the message bits.</p>
    450450
    451451<p>The template parameters of the function template are
    452 the CRC's bit size (<code>Bits</code>) and the truncated polynominal
     452the CRC's bit size (<code>Bits</code>) and the truncated polynomial
    453453(<code>TruncPoly</code>).  The function parameters are the starting address of
    454454the data block to be worked on (<var>buffer</var>), the number of bytes in that
    455455data block (<var>byte_count</var>), and the incoming value of the remainder
     
    473473<var>initial_remainder</var> when calling <code>augmented_crc</code> on
    474474the next data block.  Remember that the actual CRC can only be
    475475determined after feeding the augmented bytes.  Since this method uses
    476 modulo-2 polynominal division at its most raw, neither final XOR values
     476modulo-2 polynomial division at its most raw, neither final XOR values
    477477nor reflection can be used.</p>
    478478
    479479<p>Note that for the same CRC system, the initial remainder for
  • libs/crc/doc/crc.qbk

     
    241241[table:crc_basic_rmca  RMCA Parameters in boost::crc_basic
    242242    [[Parameter]  [Member Name]                 [Kind]                               [Expression Type]]
    243243    [[['WIDTH]]   [`bit_count`]                 [class-static immutable data member] [`std::size_t`]]
    244     [[['POLY]]    [`get_truncated_polynominal`] [`const` member function]            [`value_type`]]
     244    [[['POLY]]    [`get_truncated_polynomial`] [`const` member function]            [`value_type`]]
    245245    [[['INIT]]    [`get_initial_remainder`]     [`const` member function]            [`value_type`]]
    246246    [[['REFIN]]   [`get_reflect_input`]         [`const` member function]            [`bool`]]
    247247    [[['REFOUT]]  [`get_reflect_remainder`]     [`const` member function]            [`bool`]]
     
    323323  template parameters.
    324324  [table:crc_optimal_rmca  Additional RMCA Expressions in boost::crc_optimal
    325325    [[New Member]              [Equivalent]]
    326     [[`truncated_polynominal`] [`get_truncated_polynominal`]]
     326    [[`truncated_polynomial`] [`get_truncated_polynomial`]]
    327327    [[`initial_remainder`]     [`get_initial_remainder`]]
    328328    [[`reflect_input`]         [`get_reflect_input`]]
    329329    [[`reflect_remainder`]     [`get_reflect_remainder`]]
  • libs/crc/test/crc_test.cpp

     
    88//  See <http://www.boost.org/libs/crc/> for the library's home page.
    99
    1010//  Revision History
    11 //  28 Aug 2004  Added CRC tests for polynominals shorter than 8 bits
     11//  28 Aug 2004  Added CRC tests for polynomials shorter than 8 bits
    1212//               (Daryle Walker, by patch from Bert Klaps)
    1313//  23 Aug 2003  Adjust to updated Test framework (Daryle Walker)
    1414//  14 May 2001  Initial version (Daryle Walker)
     
    138138
    139139    // Process the first half of the data (also test accessors)
    140140    optimal_crc_type  fast_crc1;
    141     basic_crc_type    slow_crc1( fast_crc1.get_truncated_polynominal(),
     141    basic_crc_type    slow_crc1( fast_crc1.get_truncated_polynomial(),
    142142     fast_crc1.get_initial_remainder(), fast_crc1.get_final_xor_value(),
    143143     fast_crc1.get_reflect_input(), fast_crc1.get_reflect_remainder() );
    144144
     
    154154
    155155    // Process the second half of the data (also test accessors)
    156156    boost::crc_optimal<optimal_crc_type::bit_count,
    157      optimal_crc_type::truncated_polynominal, optimal_crc_type::initial_remainder,
     157     optimal_crc_type::truncated_polynomial, optimal_crc_type::initial_remainder,
    158158     optimal_crc_type::final_xor_value, optimal_crc_type::reflect_input,
    159159     optimal_crc_type::reflect_remainder>
    160160      fast_crc2( fast_crc1.get_interim_remainder() );
    161161    boost::crc_basic<basic_crc_type::bit_count>  slow_crc2(
    162      slow_crc1.get_truncated_polynominal(), slow_crc1.get_interim_remainder(),
     162     slow_crc1.get_truncated_polynomial(), slow_crc1.get_interim_remainder(),
    163163     slow_crc1.get_final_xor_value(), slow_crc1.get_reflect_input(),
    164164     slow_crc1.get_reflect_remainder() );
    165165
     
    180180{
    181181    PRIVATE_DECLARE_BOOST( uint32_t );
    182182
    183     // A single-bit error is ensured to be detected if the polynominal
     183    // A single-bit error is ensured to be detected if the polynomial
    184184    // has at least two bits set.  The highest bit is what is removed
    185     // to give the truncated polynominal, and it is always set.  This
    186     // means that the truncated polynominal needs at least one of its
     185    // to give the truncated polynomial, and it is always set.  This
     186    // means that the truncated polynomial needs at least one of its
    187187    // bits set, which implies that it cannot be zero.
    188188    if ( !(TrPo & boost::detail::low_bits_mask_c<Bits>::value) )
    189189    {
     
    744744    small_crc_test1();
    745745    small_crc_test2();
    746746
    747     // Try a CRC based on the (x + 1) polynominal, which is a factor in
    748     // many real-life polynominals and doesn't fit evenly in a byte.
    749     cout << "Doing one-bit polynominal CRC test." << endl;
     747    // Try a CRC based on the (x + 1) polynomial, which is a factor in
     748    // many real-life polynomials and doesn't fit evenly in a byte.
     749    cout << "Doing one-bit polynomial CRC test." << endl;
    750750    boost::crc_basic<1>  crc_1( 1 );
    751751    crc_1.process_bytes( std_data, std_data_len );
    752752    BOOST_CHECK( crc_1.checksum() == 1 );
  • libs/crc/test/crc_test2.cpp

     
    101101    typedef typename boost::uint_t<Bits>::fast  register_type;
    102102    typedef boost::crc_basic<Bits>              computer_type;
    103103
    104     register_type  divisor_polynominal;
     104    register_type  divisor_polynomial;
    105105    register_type  initial_remainder;
    106106    bool           reflect_input_byte;
    107107    bool           reflect_output_remainder;
    108108    register_type  final_xor_mask;
    109109
    110110    computer_type  make_crc_basic() const
    111     { return computer_type(divisor_polynominal, initial_remainder,
     111    { return computer_type(divisor_polynomial, initial_remainder,
    112112     final_xor_mask, reflect_input_byte, reflect_output_remainder); }
    113113};
    114114
    115 template < std::size_t Bits, boost::uintmax_t DivisorPolynominal,
     115template < std::size_t Bits, boost::uintmax_t DivisorPolynomial,
    116116           boost::uintmax_t InitialRemainder, bool ReflectInputBytes,
    117117           bool ReflectOutputRemainder, boost::uintmax_t FinalXorMask >
    118118class my_crc_ct_traits
     
    120120public:
    121121    typedef my_crc_rt_traits<Bits>                           rt_adaptor_type;
    122122    typedef typename rt_adaptor_type::register_type            register_type;
    123     typedef boost::crc_optimal<Bits, DivisorPolynominal, InitialRemainder,
     123    typedef boost::crc_optimal<Bits, DivisorPolynomial, InitialRemainder,
    124124     FinalXorMask, ReflectInputBytes, ReflectOutputRemainder>  computer_type;
    125125
    126126    typedef boost::mpl::size_t<Bits>  register_length_c;
    127     typedef boost::mpl::integral_c<register_type, DivisorPolynominal>
    128       divisor_polynominal_c;
     127    typedef boost::mpl::integral_c<register_type, DivisorPolynomial>
     128      divisor_polynomial_c;
    129129    typedef boost::mpl::integral_c<register_type, InitialRemainder>
    130130      initial_remainder_c;
    131131    typedef boost::mpl::bool_<ReflectInputBytes>  reflect_input_byte_c;
     
    136136
    137137    operator rt_adaptor_type() const
    138138    {
    139         rt_adaptor_type const  result = { divisor_polynominal_c::value,
     139        rt_adaptor_type const  result = { divisor_polynomial_c::value,
    140140         initial_remainder_c::value, reflect_input_byte_c::value,
    141141         reflect_output_remainder_c::value, final_xor_mask_c::value };
    142142
     
    145145
    146146    static  computer_type  make_crc_optimal()
    147147    { return boost::crc_optimal<register_length_c::value,
    148      divisor_polynominal_c::value, initial_remainder_c::value,
     148     divisor_polynomial_c::value, initial_remainder_c::value,
    149149     final_xor_mask_c::value, reflect_input_byte_c::value,
    150150     reflect_output_remainder_c::value>(); }
    151151};
    152152
    153 template < std::size_t Bits, boost::uintmax_t DivisorPolynominal,
     153template < std::size_t Bits, boost::uintmax_t DivisorPolynomial,
    154154           boost::uintmax_t InitialRemainder, bool ReflectInputBytes,
    155155           bool ReflectOutputRemainder, boost::uintmax_t FinalXorMask,
    156156           boost::uintmax_t StandardTestDataResult >
    157157class my_crc_test_traits
    158158{
    159159public:
    160     typedef my_crc_ct_traits<Bits, DivisorPolynominal, InitialRemainder,
     160    typedef my_crc_ct_traits<Bits, DivisorPolynomial, InitialRemainder,
    161161     ReflectInputBytes, ReflectOutputRemainder, FinalXorMask>  ct_traits_type;
    162162    typedef my_crc_rt_traits<Bits>  rt_traits_type;
    163163
    164164    typedef typename rt_traits_type::register_type  register_type;
    165165
    166166    typedef boost::mpl::size_t<Bits>  register_length_c;
    167     typedef boost::mpl::integral_c<register_type, DivisorPolynominal>
    168       divisor_polynominal_c;
     167    typedef boost::mpl::integral_c<register_type, DivisorPolynomial>
     168      divisor_polynomial_c;
    169169    typedef boost::mpl::integral_c<register_type, InitialRemainder>
    170170      initial_remainder_c;
    171171    typedef boost::mpl::bool_<ReflectInputBytes>  reflect_input_byte_c;
     
    239239    BOOST_AUTO( crc_s, CRCPolicy::make_crc_basic() );
    240240    typename CRCPolicy::register_type const  func_result
    241241     = boost::crc<CRCPolicy::register_length_c::value,
    242         CRCPolicy::divisor_polynominal_c::value,
     242        CRCPolicy::divisor_polynomial_c::value,
    243243        CRCPolicy::initial_remainder_c::value,
    244244        CRCPolicy::final_xor_mask_c::value,
    245245        CRCPolicy::reflect_input_byte_c::value,
     
    264264
    265265    // Test accessors
    266266    optimal_crc_type  faster_crc1;
    267     basic_crc_type    slower_crc1( faster_crc1.get_truncated_polynominal(),
     267    basic_crc_type    slower_crc1( faster_crc1.get_truncated_polynomial(),
    268268     faster_crc1.get_initial_remainder(), faster_crc1.get_final_xor_value(),
    269269     faster_crc1.get_reflect_input(), faster_crc1.get_reflect_remainder() );
    270270
     
    282282    // Process the second half of the standard data, testing more accessors
    283283    unsigned char const * const  std_data_end = std_data + std_data_len;
    284284    boost::crc_optimal<optimal_crc_type::bit_count,
    285      optimal_crc_type::truncated_polynominal,
     285     optimal_crc_type::truncated_polynomial,
    286286     optimal_crc_type::initial_remainder, optimal_crc_type::final_xor_value,
    287287     optimal_crc_type::reflect_input, optimal_crc_type::reflect_remainder>
    288288      faster_crc2( faster_crc1.get_interim_remainder() );
    289289    boost::crc_basic<basic_crc_type::bit_count>  slower_crc2(
    290      slower_crc1.get_truncated_polynominal(),
     290     slower_crc1.get_truncated_polynomial(),
    291291     slower_crc1.get_interim_remainder(), slower_crc1.get_final_xor_value(),
    292292     slower_crc1.get_reflect_input(), slower_crc1.get_reflect_remainder() );
    293293
     
    308308    // modulo-2 polynomial divisor has at least two non-zero coefficients.  The
    309309    // implicit highest coefficient is always one, so that leaves an explicit
    310310    // coefficient, i.e. at least one of the polynomial's bits is set.
    311     BOOST_REQUIRE( CRCPolicy::divisor_polynominal_c::value &
     311    BOOST_REQUIRE( CRCPolicy::divisor_polynomial_c::value &
    312312     low_bits_mask_c<CRCPolicy::register_length_c::value>::value );
    313313
    314314    // Create a random block of data
     
    481481    return boost::crc<3u, 0x03u, 0u, 0u, false, false>( buffer, byte_count );
    482482}
    483483
    484 BOOST_AUTO_TEST_CASE( sub_nybble_polynominal_test )
     484BOOST_AUTO_TEST_CASE( sub_nybble_polynomial_test )
    485485{
    486486    // The CRC standard is a SDH/SONET Low Order LCAS control word with CRC-3
    487487    // taken from ITU-T G.707 (12/03) XIII.2.
     
    529529    return boost::crc<7u, 0x09u, 0u, 0u, false, false>( buffer, byte_count );
    530530}
    531531
    532 BOOST_AUTO_TEST_CASE( sub_octet_polynominal_test )
     532BOOST_AUTO_TEST_CASE( sub_octet_polynomial_test )
    533533{
    534534    // The CRC standard is a SDH/SONET J0/J1/J2/N1/N2/TR TTI (trace message)
    535535    // with CRC-7, o.a. ITU-T G.707 Annex B, G.832 Annex A.
     
    564564    // byte-wise, so the register size needs to be a multiple of CHAR_BIT.)
    565565}
    566566
    567 BOOST_AUTO_TEST_CASE( one_bit_polynominal_test )
     567BOOST_AUTO_TEST_CASE( one_bit_polynomial_test )
    568568{
    569     // Try a CRC based on the (x + 1) polynominal, which is a factor in
    570     // many real-life polynominals and doesn't fit evenly in a byte.
     569    // Try a CRC based on the (x + 1) polynomial, which is a factor in
     570    // many real-life polynomials and doesn't fit evenly in a byte.
    571571    boost::crc_basic<1u>  crc_1( 1u );
    572572
    573573    crc_1.process_bytes( std_data, std_data_len );
  • libs/math/test/common_factor_test.cpp

     
    3131
    3232namespace {
    3333
    34 // TODO: add polynominal/non-real type; especially after any switch to the
     34// TODO: add polynomial/non-real type; especially after any switch to the
    3535// binary-GCD algorithm for built-in types
    3636
    3737// Custom integer class (template)
     
    363363}
    364364
    365365// TODO: non-built-in signed and unsigned integer tests, with and without
    366 // numeric_limits specialization; polynominal tests; note any changes if
     366// numeric_limits specialization; polynomial tests; note any changes if
    367367// built-ins switch to binary-GCD algorithm
    368368
    369369BOOST_AUTO_TEST_SUITE_END()