Copyright | (c) 2015 Stephen Dekker <steve.dekk@gmail.com> |
---|---|
License | BSD3 |
Maintainer | steve.dekk@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
This modules contains the implementation of Butz's Hilbert curve encoding algorithm. Of these, the hilbert and hilbertInverse function are exposed through the Data.SpaceFillingCurve.Hilbert.Integer module.
- hilbert :: (Bits a, Bits b, Num b) => Int -> [a] -> b
- hilbertInverse :: (Num a, Bits a, Bits b) => Int -> Int -> a -> [b]
- bitAt :: (Bits a, Bits b) => a -> Int -> b
- trailingSetBits :: (Bits a, Num b) => a -> b
- mask :: Num a => Int -> a
- rotR :: (Num a, Bits a) => Int -> a -> Int -> a
- rotL :: (Num a, Bits a) => Int -> a -> Int -> a
- grayCode :: Bits a => a -> a
- grayCodeInverse :: Bits a => a -> a
- entryPoint :: (Num a, Bits a) => a -> a
- direction :: (Num a, Bits a) => Int -> a -> Int
- transform :: (Num a, Bits a) => Int -> a -> Int -> a -> a
- transformInverse :: (Num a, Bits a) => Int -> a -> Int -> a -> a
- pivot :: (Bits a, Bits b) => Int -> a -> [Int] -> [b]
Encoding and decoding the Hilbert curve
hilbert :: (Bits a, Bits b, Num b) => Int -> [a] -> b Source
Given the number of bits required to represent the largest value in the given input list (which represents a point in an N-dimensional Cartesian space), returns the Hilbert index of the point.
hilbertInverse :: (Num a, Bits a, Bits b) => Int -> Int -> a -> [b] Source
Given the number of bits required to represent the largest value in the output vector, the number of dimensions in the output space and the Hilbert index of the output point, returns a list of values representing the point in Cartesian space.
Internal helper functions for the Hilbert transformations
bitAt :: (Bits a, Bits b) => a -> Int -> b Source
Returns the value of the given bit in the source bit string. Note that if the bit was set, the returned value will be of the output type with only the first bit set.
trailingSetBits :: (Bits a, Num b) => a -> b Source
Counts the number of trailing set bits in the given bit string.
rotR :: (Num a, Bits a) => Int -> a -> Int -> a Source
Performs a windowed right rotate by i
within a window from bit 0 to
bit width
on a number x
.
rotL :: (Num a, Bits a) => Int -> a -> Int -> a Source
Performs a windowed left rotate by i
within a window from bit 0 to
bit width
on a number x
.
grayCodeInverse :: Bits a => a -> a Source
Returns the enumeration index of a given binary-reflected Gray code, inverting the Gray code transform.
entryPoint :: (Num a, Bits a) => a -> a Source
Returns the i
-th element in the sequence of entry points.
direction :: (Num a, Bits a) => Int -> a -> Int Source
Given the dimensionality of the Hilbert curve and an index i
,
returns the i
-th element in the sequence of directions.
transform :: (Num a, Bits a) => Int -> a -> Int -> a -> a Source
Given a dimensionality, an entry point, a direction and a Gray code representing a canonical, unrotated sub-hypercube path we wish to transform, returns the path rotated so that it is correctly oriented within its quadrant.