From 09f8d4a4b20f234dafcdf2ce667f220801b9210f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 19 Aug 2018 01:42:30 +0200 Subject: Make size of bit vectors precise --- chilbert/Hilbert.ipp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'chilbert/Hilbert.ipp') diff --git a/chilbert/Hilbert.ipp b/chilbert/Hilbert.ipp index 523bfec..92a2f0e 100644 --- a/chilbert/Hilbert.ipp +++ b/chilbert/Hilbert.ipp @@ -77,8 +77,9 @@ template inline void transform(const I& e, const size_t d, const size_t n, I& a) { + assert(a.size() == n); a ^= e; - a.rotr(d, n); //#D d+1, n ); + a.rotr(d); } // Inverse 'transforms' a point. @@ -86,7 +87,8 @@ template inline void transformInv(const I& e, const size_t d, const size_t n, I& a) { - a.rotl(d, n); //#D d+1, n ); + assert(a.size() == n); + a.rotl(d); a ^= e; } @@ -206,7 +208,7 @@ coordsToIndex(const P* const p, // [in ] point if (n <= FBV_BITS) { // Intermediate variables will fit in fixed width - _coordsToIndex(p, m, n, h, CFixBitVec{}); + _coordsToIndex(p, m, n, h, CFixBitVec(n)); } else { // Otherwise, they must be BigBitVecs _coordsToIndex(p, m, n, h, CBigBitVec(n)); @@ -277,7 +279,7 @@ indexToCoords(P* const p, // [out] point if (n <= FBV_BITS) { // Intermediate variables will fit in fixed width - _indexToCoords(p, m, n, h, CFixBitVec{}); + _indexToCoords(p, m, n, h, CFixBitVec(n)); } else { // Otherwise, they must be BigBitVecs _indexToCoords(p, m, n, h, CBigBitVec(n)); @@ -320,7 +322,7 @@ _coordsToCompactIndex(const P* const p, _coordsToIndex(p, m, n, h, std::move(scratch), ds); compactIndex(ms, ds, n, m, h, hc); } else { - CFixBitVec h; + CFixBitVec h(mn); _coordsToIndex(p, m, n, h, std::move(scratch), ds); compactIndex(ms, ds, n, m, h, hc); } @@ -347,7 +349,7 @@ coordsToCompactIndex( if (n <= FBV_BITS) { // Intermediate variables will fit in fixed width? _coordsToCompactIndex( - p, ms, n, hc, CFixBitVec{}, M, m); + p, ms, n, hc, CFixBitVec(n), M, m); } else { // Otherwise, they must be BigBitVecs. _coordsToCompactIndex( @@ -403,7 +405,8 @@ _compactIndexToCoords(P* const p, size_t b = 0; extractMask(ms, n, d, static_cast(i), mask, b); ptrn = e; - ptrn.rotr(d, n); //#D ptrn.Rotr(d+1,n); + assert(ptrn.size() == n); + ptrn.rotr(d); // Get the Hilbert index bits M -= b; @@ -447,9 +450,9 @@ compactIndexToCoords( { if (n <= FBV_BITS) { // Intermediate variables will fit in fixed width - CFixBitVec scratch; + CFixBitVec scratch(n); _compactIndexToCoords( - p, ms, n, hc, CFixBitVec{}, M, m); + p, ms, n, hc, std::move(scratch), M, m); } else { // Otherwise, they must be BigBitVecs CBigBitVec scratch(n); -- cgit v1.2.1