From ff4d8986a35b6a67a2162208145371fcf427d040 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 19 Aug 2018 16:52:51 +0200 Subject: Clean up documentation and implementation header --- chilbert/Hilbert.ipp | 87 +++++++++++----------------------------------------- 1 file changed, 18 insertions(+), 69 deletions(-) (limited to 'chilbert/Hilbert.ipp') diff --git a/chilbert/Hilbert.ipp b/chilbert/Hilbert.ipp index 66849ea..44b5b5f 100644 --- a/chilbert/Hilbert.ipp +++ b/chilbert/Hilbert.ipp @@ -30,19 +30,8 @@ #include "chilbert/StaticBitVec.hpp" #include - -// Templated Hilbert functions. -// P - is the class used to represent each dimension -// of a multidimensional point. -// H - is the class used to represent the point as a Hilbert -// index. -// I - is the class used to represent interim variables. -// Needs to have as many bits as there are dimensions. -// -// In general, each of P,H,I should be a FixBitVec if they -// fit in that fixed precision. Otherwise, use a BigBitVec. -// Whatever you use, they must all be of consistent underlying -// storage types. +#include +#include // The dimension across which the Hilbert curve travels // principally. @@ -51,10 +40,6 @@ // MUST HAVE 0 <= D0 < n #define D0 1 -#include -#include -#include - namespace chilbert { template @@ -197,19 +182,9 @@ _coords_to_index(const P* const p, gray_code_inv(h); } -// This is wrapper to the basic Hilbert curve index -// calculation function. It will support fixed or -// arbitrary precision, templated. Depending on the -// number of dimensions, it will use the most efficient -// representation for interim variables. -// Assumes h is big enough for the output (n*m bits!) template inline void -coords_to_index(const P* const p, // [in ] point - const size_t m, // [in ] precision of each dimension in bits - const size_t n, // [in ] number of dimensions - H& h // [out] Hilbert index -) +coords_to_index(const P* const p, const size_t m, const size_t n, H& h) { assert(num_bits(h) >= n * m); assert(num_bits(p[0]) >= m); @@ -265,20 +240,9 @@ _index_to_coords(P* p, const size_t m, const size_t n, const H& h, I&& scratch) } } -// This is wrapper to the basic Hilbert curve inverse -// index function. It will support fixed or -// arbitrary precision, templated. Depending on the -// number of dimensions, it will use the most efficient -// representation for interim variables. -// Assumes each entry of p is big enough to hold the -// appropriate variable. template inline void -index_to_coords(P* const p, // [out] point - const size_t m, // [in ] precision of each dimension in bits - const size_t n, // [in ] number of dimensions - const H& h // [out] Hilbert index -) +index_to_coords(P* const p, const size_t m, const size_t n, const H& h) { assert(m > 0); assert(n > 0); @@ -338,28 +302,21 @@ _coords_to_compact_index(const P* const p, delete[] ds; } -// This is wrapper to the basic Hilbert curve index -// calculation function. It will support fixed or -// arbitrary precision, templated. Depending on the -// number of dimensions, it will use the most efficient -// representation for interim variables. -// Assumes h is big enough for the output (n*m bits!) template inline void -coords_to_compact_index( - const P* const p, // [in ] point - const size_t* const ms, // [in ] precision of each dimension in bits - size_t n, // [in ] number of dimensions - HC& hc, // [out] Hilbert index - const size_t M, - const size_t m) +coords_to_compact_index(const P* const p, + const size_t* const ms, + size_t n, + HC& hc, + const size_t M, + const size_t m) { if (n <= FBV_BITS) { - // Intermediate variables will fit in fixed width? + // Intermediate variables will fit in fixed width _coords_to_compact_index( p, ms, n, hc, CFixBitVec(n), M, m); } else { - // Otherwise, they must be BigBitVecs. + // Otherwise, they must be BigBitVecs _coords_to_compact_index( p, ms, n, hc, CBigBitVec(n), M, m); } @@ -439,22 +396,14 @@ _compact_index_to_coords(P* const p, } } -// This is wrapper to the basic Hilbert curve inverse -// index function. It will support fixed or -// arbitrary precision, templated. Depending on the -// number of dimensions, it will use the most efficient -// representation for interim variables. -// Assumes each entry of p is big enough to hold the -// appropriate variable. template inline void -compact_index_to_coords( - P* const p, // [out] point - const size_t* ms, // [in ] precision of each dimension in bits - const size_t n, // [in ] number of dimensions - const HC& hc, // [out] Hilbert index - const size_t M, - const size_t m) +compact_index_to_coords(P* const p, + const size_t* ms, + const size_t n, + const HC& hc, + const size_t M, + const size_t m) { if (n <= FBV_BITS) { // Intermediate variables will fit in fixed width -- cgit v1.2.1