aboutsummaryrefslogtreecommitdiffstats
path: root/chilbert
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-08-19 16:52:51 +0200
committerDavid Robillard <d@drobilla.net>2018-09-29 14:49:09 +0200
commitff4d8986a35b6a67a2162208145371fcf427d040 (patch)
tree45d36ead5bf81a8e8898415943df1341f97263a7 /chilbert
parent03f39c8be08d632d1f982f5ba5f2e95256be1122 (diff)
downloadchilbert-ff4d8986a35b6a67a2162208145371fcf427d040.tar.gz
chilbert-ff4d8986a35b6a67a2162208145371fcf427d040.tar.bz2
chilbert-ff4d8986a35b6a67a2162208145371fcf427d040.zip
Clean up documentation and implementation header
Diffstat (limited to 'chilbert')
-rw-r--r--chilbert/Hilbert.hpp12
-rw-r--r--chilbert/Hilbert.ipp87
2 files changed, 30 insertions, 69 deletions
diff --git a/chilbert/Hilbert.hpp b/chilbert/Hilbert.hpp
index 80b0247..8db5b1c 100644
--- a/chilbert/Hilbert.hpp
+++ b/chilbert/Hilbert.hpp
@@ -25,6 +25,9 @@ namespace chilbert {
/** Map the point `p` to a Hilbert Index.
*
+ * @tparam P Type used to represent a value in a point dimension.
+ * @tparam H Hilbert Index.
+ *
* @param p Point with `n` dimensions.
* @param m Precision of each dimension in bits.
* @param n Number of dimensions.
@@ -38,6 +41,9 @@ inline void coords_to_index(const P* const p,
/** Map the Hilbert Index `p` to a point.
*
+ * @tparam P Type used to represent a value in a point dimension.
+ * @tparam H Hilbert Index.
+ *
* @param[out] p Point with `n` dimensions.
* @param m Precision of each dimension in bits.
* @param n Number of dimensions.
@@ -51,6 +57,9 @@ inline void index_to_coords(P* const p,
/** Map the point `p` to a Compact Hilbert Index.
*
+ * @tparam P Type used to represent a value in a point dimension.
+ * @tparam H Compact Hilbert Index.
+ *
* @param p Point with `n` dimensions.
* @param ms Array of `n` precision values for each dimension in bits.
* @param n Number of dimensions.
@@ -68,6 +77,9 @@ inline void coords_to_compact_index(const P* const p,
/** Map the Compact Hilbert Index `hc` to a point.
*
+ * @tparam P Type used to represent a value in a point dimension.
+ * @tparam H Compact Hilbert Index.
+ *
* @param[out] p Point with `n` dimensions.
* @param ms Array of `n` precision values for each dimension in bits.
* @param n Number of dimensions.
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 <cassert>
-
-// 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 <climits>
+#include <type_traits>
// The dimension across which the Hilbert curve travels
// principally.
@@ -51,10 +40,6 @@
// MUST HAVE 0 <= D0 < n
#define D0 1
-#include <cassert>
-#include <climits>
-#include <type_traits>
-
namespace chilbert {
template <class T>
@@ -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 <class P, class H>
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 <class P, class H>
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 <class P, class HC>
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, HC, CFixBitVec>(
p, ms, n, hc, CFixBitVec(n), M, m);
} else {
- // Otherwise, they must be BigBitVecs.
+ // Otherwise, they must be BigBitVecs
_coords_to_compact_index<P, HC, CBigBitVec>(
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 <class P, class HC>
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