rhythmic-sequences 0.2.3.1 → 0.3.0.0
raw patch · 4 files changed
+44/−4 lines, 4 files
Files
- CHANGELOG.md +7/−0
- rhythmic-sequences.cabal +1/−1
- src/Rhythmicity/BasicF.hs +6/−1
- src/Rhythmicity/MarkerSeqs.hs +30/−2
CHANGELOG.md view
@@ -51,3 +51,10 @@ * Second version revised E. Some minor code improvement. Documentation improvements. +## 0.3.0.0 -- 2023-03-28++* Third version. Added two generalized functions to Rhythmicity.MarkersSeqs module and one +- to Rhythmicity.BasicF module. They allow to specify step of second hashing. Changed also+the values in the hashList function for the positive values of the second parameter in +the argument HashCorrections in it.+
rhythmic-sequences.cabal view
@@ -2,7 +2,7 @@ name: rhythmic-sequences -- The package version.-version: 0.2.3.1+version: 0.3.0.0 -- A short (one-line) description of the package. synopsis:
src/Rhythmicity/BasicF.hs view
@@ -27,11 +27,16 @@ {-# INLINE hashPosLF2 #-} hashBalancingLF2 :: Int8 -> [Integer] -> Integer-hashBalancingLF2 _ = sum . zipWith (\pos n -> shiftR n (20*pos)) [6,5..0]+hashBalancingLF2 = hashBalancingLF2G 20 {-# INLINE hashBalancingLF2 #-} hashBasicLF2 :: Int8 -> [Integer] -> Integer hashBasicLF2 _ = sum {-# INLINE hashBasicLF2 #-} +-- | Here semantically the first argument must be greater than at least 2. But this is not checked for+-- performance reasons.+hashBalancingLF2G :: Int -> Int8 -> [Integer] -> Integer+hashBalancingLF2G k _ = sum . zipWith (\pos n -> shiftR n (k*pos)) [6,5..0]+{-# INLINE hashBalancingLF2G #-}
src/Rhythmicity/MarkerSeqs.hs view
@@ -143,7 +143,7 @@ one can be considered the basic option for the computation). -} hashList :: HashCorrections -> [Int8]-hashList (H _ 1) = [10,9..]+hashList (H _ 1) = [24,23..] hashList (H _ 2) = [1..21] `mappend` cycle [0] hashList (H xs _) = xs `mappend` cycle [0] {-# INLINE hashList #-}@@ -164,7 +164,8 @@ -- in general case. The default value is @H [0,0..] 0@. This one corresponds to usage of the -- 'hashBalancingLF2' without any corrections (equi-sensitive to all the parts of the line except -- probably the last syllables if the number of syllables is not wholely divisible without remainder--- to the groupLength parameter in the 'countHashesG' function).+-- to the groupLength parameter in the 'countHashesG' function). And this is equivalent to just+-- use the 'hashBasicLF2'. -- readHashCorrections :: String -> HashCorrections readHashCorrections xs = if length ys > 1 then let (ts,us) = splitAt 1 ys in H (map (\x -> read [x]::Int8) us) (if sgn then (-(read ts::Int8)) else (read ts::Int8)) else H [0,0..] 0@@ -206,6 +207,22 @@ !ws = sortOn (*(-1)) . filter (>= 0) $ ks {-# INLINE countHashesG #-} +-- | General implementation of the hash-based algorithm to evaluate the level of rhythmicity +-- of the list data. The relatively greater result (for PhLADiPreLiO) corresponds to greater detected periodicity.+countHashes2G + :: Ord a => Int -- ^ The first parameter for 'createHash2G' function — the step of hashing shift. For 'countHashesG' it is equal to 20 (the default sensible value). Is expected to be greater than 2.+ -> HashCorrections -- ^ Data that specifies how the arguments influence the result. Somewhat the kernel of the 'countHashesG' computation.+ -> Int8 -- ^ The period of the length of the initial list.+ -> [Int8] -- ^ List of ordinary positions of the maximum-minimum levels for values of the list in the group. The length of the unique elements together in the list is expected to be+ -- in the list [1..7]. + -> [a]+ -> [Integer]+countHashes2G k hc groupLength ks = -- sum . + zipWith (createHash2G k hc) positions . countHashesPrioritized . getHashes2 groupLength ws+ where positions = hashList hc+ !ws = sortOn (*(-1)) . filter (>= 0) $ ks+{-# INLINE countHashes2G #-}+ -- | Provided for testing. createNewHash :: [Integer] -> Integer createNewHash (x1:x2:x3:x4:x5:x6:x7:_) = sum [shiftL x1 120, shiftL x2 100, shiftL x3 80, shiftL x4 60, shiftL x5 40, shiftL x6 20, x7]@@ -221,6 +238,17 @@ createHashG :: (Int8 -> [Integer] -> Integer) -> Int8 -> [Integer] -> Integer createHashG f pos = f pos . zipWith (\n x -> shift x (n*20)) [6,5..0] {-# INLINE createHashG #-}++-- | General implementation of the second hashing of the data for the algorithm with the additional+-- parameter that specifies the step of hashing (by default, e. g. in 'createHashG' it is equal to+-- 20, but here you can provide your own value). Therefore, is more flexible than 'createHashG', but+-- can lead to not well coordinated evaluations in general case that wipe by hashing some+-- information in the data. Is intended that the first argument is greater than 2 though it is not+-- checked.+createHash2G :: Int -> HashCorrections -> Int8 -> [Integer] -> Integer+createHash2G k hc@(H _ 0) pos = (hashBalancingLF2G k) pos . zipWith (\n x -> shift x (n*k)) [6,5..0]+createHash2G k (H _ m) pos = (if m > 0 then hashPosLF2 else hashBasicLF2) pos . zipWith (\n x -> shift x (n*k)) [6,5..0]+{-# INLINE createHash2G #-} -- | A variant of the 'createHashG' that actually must be equal to the 'createNewHash' for the -- second argument lists