diff --git a/include/code3c/hamming743.hh b/include/code3c/hamming743.hh index fc52a062be0ff3de46f3c6ca83a0aae36aa596c8..72f942a463312d48424d0fe05601b077873232d1 100644 --- a/include/code3c/hamming743.hh +++ b/include/code3c/hamming743.hh @@ -40,10 +40,10 @@ namespace code3c matbase2 const & m_g; matbase2 const & m_h; public: // static functions - static matbase2 wtom(hword_t w, uint blen); + static matbase2 wtom(hword_t w, uint32_t blen); static hword_t mtow(const matbase2&); - static hword_t xptow(char x, char p, uint n); - static lhword_t wtoxp(char w, uint n, + static hword_t xptow(char x, char p, uint32_t n); + static lhword_t wtoxp(char w, uint32_t n, char*x = nullptr, char*p = nullptr); public: // class functions explicit hword(const Hamming& hamm); @@ -118,16 +118,16 @@ namespace code3c * @param pos (pos+1) * @return */ - hword invert_bit(uint pos) const; + hword invert_bit(uint32_t pos) const; - inline uint dim_n() const { return m_g.n(); } - inline uint dim_k() const { return m_g.m(); } + inline uint32_t dim_n() const { return m_g.n(); } + inline uint32_t dim_k() const { return m_g.m(); } /** - * Operator calling invert_bit(uint) + * Operator calling invert_bit(uint32_t) * @return */ - inline hword operator <=>(uint pos) const + inline hword operator <=>(uint32_t pos) const { return invert_bit(pos);} explicit inline operator const matbase2&() const @@ -147,8 +147,8 @@ namespace code3c Hamming(const Hamming& hamm); virtual ~Hamming(); - virtual inline uint dim_n() const final { return G().n(); } - virtual inline uint dim_k() const final { return G().m(); } + virtual inline uint32_t dim_n() const final { return G().n(); } + virtual inline uint32_t dim_k() const final { return G().m(); } inline size_t bitl() const { return m_hwordsl * dim_n(); } diff --git a/src/code3c/hamming743.cc b/src/code3c/hamming743.cc index 1b2bb2fa6d158a9264c8aca84280bcba62c85901..4827bc0f26b846ac72f00f6ab22e45bda28bd50f 100644 --- a/src/code3c/hamming743.cc +++ b/src/code3c/hamming743.cc @@ -72,10 +72,10 @@ namespace code3c return H_(); } - matbase2 Hamming::hword::wtom(hword_t w, uint blen) + matbase2 Hamming::hword::wtom(hword_t w, uint32_t blen) { matbase2 _wtom(blen, 1); - for (uint i(0); i < blen; i++) + for (uint32_t i(0); i < blen; i++) _wtom[i, 0] = static_cast<bool>((w>>(blen-1-i)) & 0b1); return _wtom; } @@ -88,14 +88,14 @@ namespace code3c return _mtow; } - Hamming::hword::hword_t Hamming::hword::xptow(char x, char p, uint n) + Hamming::hword::hword_t Hamming::hword::xptow(char x, char p, uint32_t n) { hword_t _hword(0); - uint pow2(0); + uint32_t pow2(0); while (1 << pow2 < n) pow2++; - for (uint i(0), pos(n); i < n; i++, pos--) + for (uint32_t i(0), pos(n); i < n; i++, pos--) { if (!(pos xor (1 << pow2))) { @@ -113,15 +113,15 @@ namespace code3c return _hword; } - Hamming::hword::lhword_t Hamming::hword::wtoxp(char w, uint n, char *x, char *p) + Hamming::hword::lhword_t Hamming::hword::wtoxp(char w, uint32_t n, char *x, char *p) { char _x(0), _p(0); - uint pow2(0), _pi; + uint32_t pow2(0), _pi; while (1 << pow2 < n) pow2++; _pi = pow2; - for (uint i(0), pos(n), _xi(0); i < n; i++, pos--, w>>=1) + for (uint32_t i(0), pos(n), _xi(0); i < n; i++, pos--, w>>=1) { if (pos == (1 << (pow2-1))) { @@ -171,9 +171,9 @@ namespace code3c bool Hamming::hword::parity() const { - uint _sum(0); + uint32_t _sum(0); char _p(p()); - for (uint i(0); i < dim_n()-dim_k(); i++, _p>>=1) + for (uint32_t i(0); i < dim_n()-dim_k(); i++, _p>>=1) _sum += _p&1; return _sum%2 == 0; } @@ -203,7 +203,7 @@ namespace code3c return m_matb; } - Hamming::hword Hamming::hword::invert_bit(uint pos) const + Hamming::hword Hamming::hword::invert_bit(uint32_t pos) const { matbase2 _matb(m_matb); _matb[pos-1, 0] = !_matb[pos-1, 0]; diff --git a/test/hamming.cxx b/test/hamming.cxx index 703b273d09f0f2472ff992d4bd0a8afcb07b1a5f..e6060c7b5bf31234ccfb6cf2dfabfc244de3a5b6 100644 --- a/test/hamming.cxx +++ b/test/hamming.cxx @@ -159,7 +159,7 @@ int hamm_detect_err_313() { Hamming313 h313; h313.set_buffer("This is a test sample", 21); - for (uint i(1); i <= 3; i++) + for (uint32_t i(1); i <= 3; i++) { for (Hamming743::hword *hword: h313) { @@ -175,7 +175,7 @@ int hamm_detect_err_743() { Hamming743 h743; h743.set_buffer("This is a test sample", 21); - for (uint i(1); i <= 7; i++) + for (uint32_t i(1); i <= 7; i++) { for (Hamming743::hword *hword: h743) {