-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from haskell-works/move-makeCsPoppyLayerM-to-r…
…eference-module Move makeCsPoppyLayerM to Reference module
- Loading branch information
Showing
4 changed files
with
37 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/HaskellWorks/Data/RankSelect/CsPoppy/Internal/Reference.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{-# OPTIONS_GHC-funbox-strict-fields #-} | ||
{-# LANGUAGE MultiWayIf #-} | ||
{-# LANGUAGE Rank2Types #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
|
||
module HaskellWorks.Data.RankSelect.CsPoppy.Internal.Reference | ||
( makeCsPoppyLayerM | ||
) where | ||
|
||
import Data.Word | ||
import HaskellWorks.Data.Bits.BitWise | ||
import HaskellWorks.Data.Length | ||
import HaskellWorks.Data.RankSelect.CsPoppy.Internal.Vector | ||
|
||
import qualified Data.Vector.Storable as DVS | ||
|
||
makeCsPoppyLayerM :: DVS.Vector Word64 -> DVS.Vector Word64 | ||
makeCsPoppyLayerM blocks = DVS.constructN (((DVS.length blocks + 4 - 1) `div` 4) + 1) genLayer1 | ||
where genLayer1 :: DVS.Vector Word64 -> Word64 | ||
genLayer1 u = | ||
let i = end u in | ||
let lx = lastOrZero u in | ||
let la = indexOrZero blocks (i * 4 - 4) in | ||
let lb = indexOrZero blocks (i * 4 - 3) in | ||
let lc = indexOrZero blocks (i * 4 - 2) in | ||
let ld = indexOrZero blocks (i * 4 - 1) in | ||
let nx = lx + (la + lb + lc + ld) in | ||
let na = indexOrZero blocks (i * 4 + 0) in | ||
let nb = indexOrZero blocks (i * 4 + 1) in | ||
let nc = indexOrZero blocks (i * 4 + 2) in | ||
( ( nx .&. 0x00000000ffffffff) | ||
.|. ((na .<. 32) .&. 0x000003ff00000000) | ||
.|. ((nb .<. 42) .&. 0x000ffc0000000000) | ||
.|. ((nc .<. 52) .&. 0x3ff0000000000000)) | ||
|