aboutsummaryrefslogtreecommitdiffstats
path: root/chilbert/chilbert.ipp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-04-23 20:55:47 +0200
committerDavid Robillard <d@drobilla.net>2019-04-23 20:55:47 +0200
commit66f8ba7f06b9369276e6210f756b075591efa6fa (patch)
tree6c9601a60226a8e38dd1c227b10fb0e2f06e8d4b /chilbert/chilbert.ipp
parent045128813d1a69a6483ff2f8f870562b96be0a65 (diff)
downloadchilbert-66f8ba7f06b9369276e6210f756b075591efa6fa.tar.gz
chilbert-66f8ba7f06b9369276e6210f756b075591efa6fa.tar.bz2
chilbert-66f8ba7f06b9369276e6210f756b075591efa6fa.zip
Support using any array-like type for points
Diffstat (limited to 'chilbert/chilbert.ipp')
-rw-r--r--chilbert/chilbert.ipp41
1 files changed, 21 insertions, 20 deletions
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)));