aboutsummaryrefslogtreecommitdiffstats
path: root/Hilbert/SetLocation.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-08-04 23:13:50 +0200
committerDavid Robillard <d@drobilla.net>2018-08-07 20:01:14 +0200
commitc5ad5673a76ba969edadfb3d5cfd5a2516b6fdcd (patch)
treef2b8b625910601479ac48d3315d36e5299ad6d8a /Hilbert/SetLocation.hpp
parentacb6aae319ba56bc52bf6209c343a3f46c624ad8 (diff)
downloadchilbert-c5ad5673a76ba969edadfb3d5cfd5a2516b6fdcd.tar.gz
chilbert-c5ad5673a76ba969edadfb3d5cfd5a2516b6fdcd.tar.bz2
chilbert-c5ad5673a76ba969edadfb3d5cfd5a2516b6fdcd.zip
Simplify bit operations and support integral points
Diffstat (limited to 'Hilbert/SetLocation.hpp')
-rw-r--r--Hilbert/SetLocation.hpp78
1 files changed, 10 insertions, 68 deletions
diff --git a/Hilbert/SetLocation.hpp b/Hilbert/SetLocation.hpp
index 66e6459..4a2ba3d 100644
--- a/Hilbert/SetLocation.hpp
+++ b/Hilbert/SetLocation.hpp
@@ -1,4 +1,4 @@
-/*
+/* Copyright (C) 2018 David Robillard <d@drobilla.net>
* Copyright (C) 2006-2007 Chris Hamilton <chamilton@cs.dal.ca>
*
* This program is free software; you can redistribute it and/or modify
@@ -19,77 +19,19 @@
#ifndef _SETLOCATION_HPP_
#define _SETLOCATION_HPP_
+#include <Hilbert/Operations.hpp>
-#include <Hilbert/BigBitVec.hpp>
+namespace Hilbert {
-
-namespace Hilbert
+template <class P, class I>
+inline void
+setLocation(P* const p, const int n, const int i, const I& l)
{
- template <class P,class I>
- inline
- void
- setLocation(
- P *p,
- int n,
- int i,
- const I &l
- )
- {
- // Easy to understand implementation
- /*int j;
- for ( j = 0; j < n; j++ )
- p[j].set(i,l.test(j));
- return;*/
-
- // Much faster loop-unrolled implementation.
- int ir, ib;
- FBV_UINT im;
- BBV_MODSPLIT(ir,ib,i);
- im = (FBV1<<ib);
-
-#define SETBIT p->racks()[ir]|=im; if ((*lr&jm)==0) p->racks()[ir]^=im; jm<<=1; ++p;
-#define SETBIT1(a) \
- case (a+1): SETBIT;
-#define SETBIT2(a) \
- SETBIT1(a+1); \
- SETBIT1(a);
-#define SETBIT4(a) \
- SETBIT2(a+2); \
- SETBIT2(a);
-#define SETBIT8(a) \
- SETBIT4(a+4); \
- SETBIT4(a);
-#define SETBIT16(a) \
- SETBIT8(a+8); \
- SETBIT8(a);
-#define SETBIT32(a) \
- SETBIT16(a+16); \
- SETBIT16(a);
-
- int j = 0;
- FBV_UINT jm = 1;
- const FBV_UINT *lr = l.racks();
- while ( j < n )
- {
- if ( jm == 0 )
- {
- jm = 1;
- ++lr;
- }
-
- int dj = n - j;
- switch ( n - j )
- {
- default: dj = 32;
- SETBIT32(0);
- }
- j += dj;
- }
-
- return;
+ for (int j = 0; j < n; j++) {
+ setBit(p[j], i, testBit(l, j));
}
+}
-};
-
+} // namespace Hilbert
#endif