diff options
author | David Robillard <d@drobilla.net> | 2018-08-04 19:12:43 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-08-04 20:04:30 +0200 |
commit | 3ea9ed0d2a14468d698dfe24bdb790b6f4103596 (patch) | |
tree | 4452a4920f46bba6fdc67bc2bb56332e456e6be4 /Hilbert/Hilbert.hpp | |
download | chilbert-3ea9ed0d2a14468d698dfe24bdb790b6f4103596.tar.gz chilbert-3ea9ed0d2a14468d698dfe24bdb790b6f4103596.tar.bz2 chilbert-3ea9ed0d2a14468d698dfe24bdb790b6f4103596.zip |
Initial import
Diffstat (limited to 'Hilbert/Hilbert.hpp')
-rw-r--r-- | Hilbert/Hilbert.hpp | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/Hilbert/Hilbert.hpp b/Hilbert/Hilbert.hpp new file mode 100644 index 0000000..bd39962 --- /dev/null +++ b/Hilbert/Hilbert.hpp @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2006-2007 Chris Hamilton <chamilton@cs.dal.ca> + * Copyright (C) 2015 David Robillard <d@drobilla.net> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _HILBERT_HPP_ +#define _HILBERT_HPP_ + + +#include <Hilbert/FixBitVec.hpp> +#include <Hilbert/BigBitVec.hpp> +#include <Hilbert/Algorithm.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, + + +namespace Hilbert +{ + +// fix -> fix + +inline void coordsToIndex( const CFixBitVec *p, int m, int n, CFixBitVec &h ) +{ + coordsToIndex<CFixBitVec,CFixBitVec>(p,m,n,h); +} + +inline void indexToCoords( CFixBitVec *p, int m, int n, const CFixBitVec &h ) +{ + indexToCoords<CFixBitVec,CFixBitVec>(p,m,n,h); +} + +inline void coordsToCompactIndex( const CFixBitVec *p, const int *ms, int n, + CFixBitVec &hc, int M, int m ) +{ + coordsToCompactIndex<CFixBitVec,CFixBitVec>(p,ms,n,hc,M,m); +} + +inline void compactIndexToCoords( CFixBitVec *p, const int *ms, int n, + const CFixBitVec &hc, int M, int m ) +{ + compactIndexToCoords<CFixBitVec,CFixBitVec>(p,ms,n,hc,M,m); +} + +// fix -> big + +inline void coordsToIndex( const CFixBitVec *p, int m, int n, CBigBitVec &h ) +{ + coordsToIndex<CFixBitVec,CBigBitVec>(p,m,n,h); +} + +inline void indexToCoords( CFixBitVec *p, int m, int n, const CBigBitVec &h ) +{ + indexToCoords<CFixBitVec,CBigBitVec>(p,m,n,h); +} + +inline void coordsToCompactIndex( const CFixBitVec *p, const int *ms, int n, + CBigBitVec &hc, int M, int m ) +{ + coordsToCompactIndex<CFixBitVec,CBigBitVec>(p,ms,n,hc,M,m); +} + +inline void compactIndexToCoords( CFixBitVec *p, const int *ms, int n, + const CBigBitVec &hc, int M, int m ) +{ + compactIndexToCoords<CFixBitVec,CBigBitVec>(p,ms,n,hc,M,m); +} + +// big -> big + +inline void coordsToIndex( const CBigBitVec *p, int m, int n, CBigBitVec &h ) +{ + coordsToIndex<CBigBitVec,CBigBitVec>(p,m,n,h); +} + +inline void indexToCoords( CBigBitVec *p, int m, int n, const CBigBitVec &h ) +{ + indexToCoords<CBigBitVec,CBigBitVec>(p,m,n,h); +} + +inline void coordsToCompactIndex( const CBigBitVec *p, const int *ms, int n, + CBigBitVec &hc, int M, int m ) +{ + coordsToCompactIndex<CBigBitVec,CBigBitVec>(p,ms,n,hc,M,m); +} + +inline void compactIndexToCoords( CBigBitVec *p, const int *ms, int n, + const CBigBitVec &hc, int M, int m ) +{ + compactIndexToCoords<CBigBitVec,CBigBitVec>(p,ms,n,hc,M,m); +} + +}; + + +#endif + |