aboutsummaryrefslogtreecommitdiffstats
path: root/Hilbert/GetLocation.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/GetLocation.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/GetLocation.hpp')
-rw-r--r--Hilbert/GetLocation.hpp96
1 files changed, 10 insertions, 86 deletions
diff --git a/Hilbert/GetLocation.hpp b/Hilbert/GetLocation.hpp
index e66dc04..7fc2bca 100644
--- a/Hilbert/GetLocation.hpp
+++ b/Hilbert/GetLocation.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,95 +19,19 @@
#ifndef _GETLOCATION_HPP_
#define _GETLOCATION_HPP_
+#include <Hilbert/Operations.hpp>
-#include <Hilbert/BigBitVec.hpp>
+namespace Hilbert {
-
-namespace Hilbert
+template <class P, class I>
+inline void
+getLocation(const P* const p, const int n, const int i, I& l)
{
-
- template<class P,class I>
- inline
- void
- _getLocation(
- const P *p,
- int jo,
- int jn,
- int ir,
- FBV_UINT im,
- FBV_UINT &l
- )
- {
- l = 0;
- switch ( jn )
- {
-#define GETLOC_CASE(i) case ((i)+1): if (p[jo+(i)].racks()[ir]&im) l|=(FBV1<<(i))
-#define GETLOC_CASE2(i) \
- GETLOC_CASE(i+1); \
- GETLOC_CASE(i)
-#define GETLOC_CASE4(i) \
- GETLOC_CASE2(i+2); \
- GETLOC_CASE2(i)
-#define GETLOC_CASE8(i) \
- GETLOC_CASE4(i+4); \
- GETLOC_CASE4(i)
-#define GETLOC_CASE16(i) \
- GETLOC_CASE8(i+8); \
- GETLOC_CASE8(i)
-#define GETLOC_CASE32(i) \
- GETLOC_CASE16(i+16); \
- GETLOC_CASE16(i)
-#if FBV_BITS == 64
- GETLOC_CASE32(32);
-#endif
- GETLOC_CASE32(0);
- }
- return;
- }
-
-
- template<class P,class I>
- inline
- void
- getLocation(
- const P *p,
- int n,
- int i,
- I &l
- )
- {
- /*int j;
- for ( j = n-1; j >= 0; --j )
- l.set(j,p[j].test(i));
- return;*/
-
- int j, jo, ir;
- FBV_UINT im;
-
- if ( P::type() == eBig )
- {
- ir = i / FBV_BITS;
- im = FBV1 << (i-ir*FBV_BITS);
- }
- else
- {
- ir = 0;
- im = FBV1 << i;
- }
-
- j = 0;
- jo = 0;
- if ( I::type() == eBig )
- {
- for ( ; j < l.rackCount()-1; ++j, jo += FBV_BITS )
- _getLocation<P,I>(p,jo,FBV_BITS,ir,im,l.racks()[j]);
- }
- _getLocation<P,I>(p,jo,n-jo,ir,im,l.racks()[j]);
-
- return;
+ for (int j = 0; j < n; ++j) {
+ setBit(l, j, testBit(p[j], i));
}
-
-};
+}
+} // namespace Hilbert
#endif