diff options
Diffstat (limited to 'chilbert')
-rw-r--r-- | chilbert/chilbert.hpp | 16 | ||||
-rw-r--r-- | chilbert/chilbert.ipp | 41 |
2 files changed, 29 insertions, 28 deletions
diff --git a/chilbert/chilbert.hpp b/chilbert/chilbert.hpp index 7a69ab2..e8d10f4 100644 --- a/chilbert/chilbert.hpp +++ b/chilbert/chilbert.hpp @@ -25,7 +25,7 @@ namespace chilbert { /** Map the point `p` to a Hilbert Index. * - * @tparam P Type used to represent a value in a point dimension. + * @tparam P Array-like type with [] operator that represents a point. * @tparam H Hilbert Index. * * @param p Point with `n` dimensions. @@ -34,11 +34,11 @@ namespace chilbert { * @param[out] h Hilbert Index. */ template <class P, class H> -inline void coords_to_index(const P* p, size_t m, size_t n, H& h); +inline void coords_to_index(const P& p, size_t m, size_t n, H& h); /** Map the Hilbert Index `p` to a point. * - * @tparam P Type used to represent a value in a point dimension. + * @tparam P Array-like type with [] operator that represents a point. * @tparam H Hilbert Index. * * @param[out] p Point with `n` dimensions. @@ -47,11 +47,11 @@ inline void coords_to_index(const P* p, size_t m, size_t n, H& h); * @param h Hilbert Index. */ template <class P, class H> -inline void index_to_coords(P* p, size_t m, size_t n, const H& h); +inline void index_to_coords(P& p, size_t m, size_t n, const H& h); /** Map the point `p` to a Compact Hilbert Index. * - * @tparam P Type used to represent a value in a point dimension. + * @tparam P Array-like type with [] operator that represents a point. * @tparam H Compact Hilbert Index. * * @param p Point with `n` dimensions. @@ -62,7 +62,7 @@ inline void index_to_coords(P* p, size_t m, size_t n, const H& h); * @param m Optional largest precision in `m`. */ template <class P, class H> -inline void coords_to_compact_index(const P* p, +inline void coords_to_compact_index(const P& p, const size_t* ms, size_t n, H& hc, @@ -71,7 +71,7 @@ inline void coords_to_compact_index(const P* p, /** Map the Compact Hilbert Index `hc` to a point. * - * @tparam P Type used to represent a value in a point dimension. + * @tparam P Array-like type with [] operator that represents a point. * @tparam H Compact Hilbert Index. * * @param[out] p Point with `n` dimensions. @@ -82,7 +82,7 @@ inline void coords_to_compact_index(const P* p, * @param m Optional largest precision in `m`. */ template <class P, class H> -inline void compact_index_to_coords(P* p, +inline void compact_index_to_coords(P& p, const size_t* ms, size_t n, const H& hc, diff --git a/chilbert/chilbert.ipp b/chilbert/chilbert.ipp index a62a258..fca7516 100644 --- a/chilbert/chilbert.ipp +++ b/chilbert/chilbert.ipp @@ -112,7 +112,7 @@ set_bits(H& h, const size_t n, const size_t i, const I& w) */ template <class P, class I> inline void -get_location(const P* const p, const size_t n, const size_t i, I& l) +get_location(const P& p, const size_t n, const size_t i, I& l) { for (size_t j = 0; j < n; ++j) { set_bit(l, j, test_bit(p[j], i)); @@ -128,7 +128,7 @@ get_location(const P* const p, const size_t n, const size_t i, I& l) */ template <class P, class I> inline void -set_location(P* const p, const size_t n, const size_t i, const I& l) +set_location(P& p, const size_t n, const size_t i, const I& l) { for (size_t j = 0; j < n; ++j) { set_bit(p[j], i, test_bit(l, j)); @@ -140,6 +140,7 @@ template <class I> inline void transform(const I& e, const size_t d, const size_t n, I& a) { + (void)n; assert(a.size() == n); a ^= e; a.rotr(d); @@ -201,12 +202,12 @@ update2(const I& l, const I& t, const size_t n, I& e, size_t& d) template <class P, class H, class I> inline void -coords_to_index(const P* const p, - const size_t m, - const size_t n, - H& h, - I&& scratch, - size_t* const ds = nullptr) +coords_to_index(const P& p, + const size_t m, + const size_t n, + H& h, + I&& scratch, + size_t* const ds = nullptr) { I e{std::move(scratch)}; I l{e}; @@ -252,7 +253,7 @@ coords_to_index(const P* const p, template <class P, class H, class I> inline void -index_to_coords(P* p, const size_t m, const size_t n, const H& h, I&& scratch) +index_to_coords(P& p, const size_t m, const size_t n, const H& h, I&& scratch) { I e{std::move(scratch)}; I l{e}; @@ -294,7 +295,7 @@ index_to_coords(P* p, const size_t m, const size_t n, const H& h, I&& scratch) template <class P, class HC, class I> inline void -coords_to_compact_index(const P* const p, +coords_to_compact_index(const P& p, const size_t* const ms, const size_t n, HC& hc, @@ -340,7 +341,7 @@ coords_to_compact_index(const P* const p, template <class P, class HC, class I> inline void -compact_index_to_coords(P* const p, +compact_index_to_coords(P& p, const size_t* ms, const size_t n, const HC& hc, @@ -416,7 +417,7 @@ compact_index_to_coords(P* const p, template <class P, class H> inline void -coords_to_index(const P* const p, const size_t m, const size_t n, H& h) +coords_to_index(const P& p, const size_t m, const size_t n, H& h) { assert(detail::num_bits(h) >= n * m); assert(detail::num_bits(p[0]) >= m); @@ -433,7 +434,7 @@ coords_to_index(const P* const p, const size_t m, const size_t n, H& h) template <class P, class H> inline void -index_to_coords(P* const p, const size_t m, const size_t n, const H& h) +index_to_coords(P& p, const size_t m, const size_t n, const H& h) { assert(m > 0); assert(n > 0); @@ -452,7 +453,7 @@ index_to_coords(P* const p, const size_t m, const size_t n, const H& h) template <class P, class HC> inline void -coords_to_compact_index(const P* const p, +coords_to_compact_index(const P& p, const size_t* const ms, size_t n, HC& hc, @@ -474,12 +475,12 @@ coords_to_compact_index(const P* const p, template <class P, class HC> inline void -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) +compact_index_to_coords(P& p, + const size_t* const ms, + const size_t n, + const HC& hc, + const size_t M, + const size_t m) { assert(hc.size() >= std::accumulate(ms, ms + n, size_t(0))); |