Skip to content

Commit

Permalink
test dimension and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Bieler authored and Jonathan Bieler committed Apr 4, 2018
1 parent 257e93a commit 91adcef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ Convert the ndims-dimensional coordinates `p` into the linear index `d` :

`d = hilbert(p::Vector{T}, ndims, nbits = 32) where T <: Integer`

The number of bits `nbits` determines the precision of the curve, and the algorithm work
under the constrain:
All coordinates are positive integers (zero included). The number of bits `nbits` determines the precision of the curve, and the algorithm work under the constrain:

- `ndims * nbits <= 64`

Expand Down
4 changes: 3 additions & 1 deletion src/HilbertSpaceFillingCurve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ module HilbertSpaceFillingCurve
global const bits_per_byte = 8

function hilbert(d::T, ndims, nbits = 32) where T <: Integer

@assert ndims*nbits <= sizeof(bitmask_t) * bits_per_byte

p = bitmask_t.(zeros(ndims))
ccall((:hilbert_i2c, libhilbert), Void, (Int,Int,bitmask_t,Ptr{bitmask_t}),ndims,nbits,d,p)
Int.(p)
end

function hilbert(p::Vector{T}, ndims, nbits = 32) where T <: Integer
@assert ndims*nbits <= sizeof(bitmask_t) * bits_per_byte
@assert length(p) == ndims

Int(ccall((:hilbert_c2i, libhilbert), bitmask_t, (Int,Int,Ptr{bitmask_t}),ndims,nbits, bitmask_t.(p)))
end

Expand Down

0 comments on commit 91adcef

Please sign in to comment.