aboutsummaryrefslogtreecommitdiffstats
path: root/chilbert/Hilbert.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'chilbert/Hilbert.hpp')
-rw-r--r--chilbert/Hilbert.hpp224
1 files changed, 62 insertions, 162 deletions
diff --git a/chilbert/Hilbert.hpp b/chilbert/Hilbert.hpp
index a6b48fb..5b4646d 100644
--- a/chilbert/Hilbert.hpp
+++ b/chilbert/Hilbert.hpp
@@ -19,172 +19,72 @@
#ifndef CHILBERT_HILBERT_HPP
#define CHILBERT_HILBERT_HPP
-#include "chilbert/Algorithm.hpp"
-#include "chilbert/BigBitVec.hpp"
-#include "chilbert/FixBitVec.hpp"
-
-// Description of parameters:
-//
-// FOR REGULAR HILBERT INDICES
-//
-// CFixBitVec/CBigBitVec *p
-// Pointer to array of non-negative coordinate values.
-//
-// int m
-// Precision of all coordinate values (number of bits required to
-// represent the largest possible coordinate value).
-//
-// int n
-// Number of dimensions (size of the array *p).
-//
-// CFixBitVec/CBigBitVec &h
-// Hilbert index of maximum precision m*n.
-//
-// int *ms
-// Array of precision values, one per dimension.
-//
-// FOR COMPACT HILBERT INDICES
-//
-// CFixBitVec/CBigBitVec &hc
-// Compact Hilbert index of maximum precision M.
-//
-// int M
-// Net precision value, corresponding to the size of the compact
-// Hilbert code. If not provided, defaults to zero and will be calculated
-// by the function (sum_i { ms[i] }).
-//
-// int m
-// Largest precision value (max_i { ms[i] }). If not provided, defaults
-// to zero and will be calculated by the function,
+#include <cstddef>
namespace chilbert {
-// fix -> fix
-
-inline void
-coordsToIndex(const CFixBitVec* const p,
- const size_t m,
- const size_t n,
- CFixBitVec& h)
-{
- coordsToIndex<CFixBitVec, CFixBitVec>(p, m, n, h);
-}
-
-inline void
-indexToCoords(CFixBitVec* const p,
- const size_t m,
- const size_t n,
- const CFixBitVec& h)
-{
- indexToCoords<CFixBitVec, CFixBitVec>(p, m, n, h);
-}
-
-inline void
-coordsToCompactIndex(const CFixBitVec* const p,
- const size_t* const ms,
- const size_t n,
- CFixBitVec& hc,
- const size_t M,
- const size_t m)
-{
- coordsToCompactIndex<CFixBitVec, CFixBitVec>(p, ms, n, hc, M, m);
-}
-
-inline void
-compactIndexToCoords(CFixBitVec* const p,
- const size_t* const ms,
- const size_t n,
- const CFixBitVec& hc,
- const size_t M,
- const size_t m)
-{
- compactIndexToCoords<CFixBitVec, CFixBitVec>(p, ms, n, hc, M, m);
-}
-
-// fix -> big
-
-inline void
-coordsToIndex(const CFixBitVec* const p,
- const size_t m,
- const size_t n,
- CBigBitVec& h)
-{
- coordsToIndex<CFixBitVec, CBigBitVec>(p, m, n, h);
-}
-
-inline void
-indexToCoords(CFixBitVec* const p,
- const size_t m,
- const size_t n,
- const CBigBitVec& h)
-{
- indexToCoords<CFixBitVec, CBigBitVec>(p, m, n, h);
-}
-
-inline void
-coordsToCompactIndex(const CFixBitVec* const p,
- const size_t* const ms,
- const size_t n,
- CBigBitVec& hc,
- const size_t M,
- const size_t m)
-{
- coordsToCompactIndex<CFixBitVec, CBigBitVec>(p, ms, n, hc, M, m);
-}
-
-inline void
-compactIndexToCoords(CFixBitVec* const p,
- const size_t* const ms,
- const size_t n,
- const CBigBitVec& hc,
- const size_t M,
- const size_t m)
-{
- compactIndexToCoords<CFixBitVec, CBigBitVec>(p, ms, n, hc, M, m);
-}
-
-// big -> big
-
-inline void
-coordsToIndex(const CBigBitVec* p,
- const size_t m,
- const size_t n,
- CBigBitVec& h)
-{
- coordsToIndex<CBigBitVec, CBigBitVec>(p, m, n, h);
-}
-
-inline void
-indexToCoords(CBigBitVec* const p,
- const size_t m,
- const size_t n,
- const CBigBitVec& h)
-{
- indexToCoords<CBigBitVec, CBigBitVec>(p, m, n, h);
-}
-
-inline void
-coordsToCompactIndex(const CBigBitVec* const p,
- const size_t* const ms,
- const size_t n,
- CBigBitVec& hc,
- const size_t M,
- const size_t m)
-{
- coordsToCompactIndex<CBigBitVec, CBigBitVec>(p, ms, n, hc, M, m);
-}
-
-inline void
-compactIndexToCoords(CBigBitVec* const p,
- const size_t* const ms,
- const size_t n,
- const CBigBitVec& hc,
- const size_t M,
- const size_t m)
-{
- compactIndexToCoords<CBigBitVec, CBigBitVec>(p, ms, n, hc, M, m);
-}
+/** Map the point `p` to a Hilbert Index.
+ *
+ * @param p Point with `n` dimensions.
+ * @param m Precision of each dimension in bits.
+ * @param n Number of dimensions.
+ * @param[out] h Hilbert Index.
+ */
+template <class P, class H>
+inline void coordsToIndex(const P* const p,
+ const size_t m,
+ const size_t n,
+ H& h);
+
+/** Map the Hilbert Index `p` to a point.
+ *
+ * @param[out] p Point with `n` dimensions.
+ * @param m Precision of each dimension in bits.
+ * @param n Number of dimensions.
+ * @param h Hilbert Index.
+ */
+template <class P, class H>
+inline void indexToCoords(P* const p,
+ const size_t m,
+ const size_t n,
+ const H& h);
+
+/** Map the point `p` to a 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.
+ * @param[out] hc Compact Hilbert Index.
+ * @param M Optional net precision (sum of `ms`), the size of `hc` in bits.
+ * @param m Optional largest precision in `m`.
+ */
+template <class P, class H>
+inline void coordsToCompactIndex(const P* const p,
+ const size_t* const ms,
+ const size_t n,
+ H& hc,
+ const size_t M = 0,
+ const size_t m = 0);
+
+/** Map the Compact Hilbert Index `hc` to a point.
+ *
+ * @param[out] p Point with `n` dimensions.
+ * @param ms Array of `n` precision values for each dimension in bits.
+ * @param n Number of dimensions.
+ * @param hc Compact Hilbert Index.
+ * @param M Optional net precision (sum of `ms`), the size of `hc` in bits.
+ * @param m Optional largest precision in `m`.
+ */
+template <class P, class H>
+inline void compactIndexToCoords(P* const p,
+ const size_t* const ms,
+ const size_t n,
+ const H& hc,
+ const size_t M = 0,
+ const size_t m = 0);
} // namespace chilbert
+#include "chilbert/Hilbert.ipp"
+
#endif