phonetic-languages-filters-array 0.4.0.0 → 0.5.0.0
raw patch · 3 files changed
+46/−18 lines, 3 filesdep ~filters-basicdep ~mmsyn2-arrayPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: filters-basic, mmsyn2-array
API changes (from Hackage documentation)
+ Phonetic.Languages.Filters: unsafeRearrangeIGArr :: (RealFrac b, Integral c) => b -> b -> c -> Array Int (c, c) -> b -> b
- Phonetic.Languages.Filters: unsafeRearrangeIGV :: (RealFrac b, Integral c) => b -> b -> c -> [c] -> b -> b
+ Phonetic.Languages.Filters: unsafeRearrangeIGV :: (RealFrac b, Integral c, Ord c) => b -> b -> c -> [c] -> b -> b
- Phonetic.Languages.Filters: unsafeSwapVecIWithMaxI :: (RealFrac b, Integral c) => b -> b -> c -> [c] -> b -> b
+ Phonetic.Languages.Filters: unsafeSwapVecIWithMaxI :: (RealFrac b, Integral c, Ord c) => b -> b -> c -> [c] -> b -> b
Files
- CHANGELOG.md +6/−0
- Phonetic/Languages/Filters.hs +38/−16
- phonetic-languages-filters-array.cabal +2/−2
CHANGELOG.md view
@@ -18,3 +18,9 @@ * Fourth version. Fixed issue with incorrectly defined functions unsafeRearrangeIGV and unsafeSwapIWithMaxI that influence almost all the module functionality. This means that all the results obtained earlier with these functions or that ones that use them must be checked and fixed.++## 0.5.0.0 -- 2022-08-22++* Fifth version. Fixed issues with the unsafeSwapVecIWithMaxI. Changed the described semantics of the+functions. Please, check the updated documentation. Added new variant of the function unsafeRearrangeIG.+
Phonetic/Languages/Filters.hs view
@@ -17,6 +17,7 @@ , transfer1IEq3 -- * Several intervals , unsafeRearrangeIG+ , unsafeRearrangeIGArr , unsafeRearrangeIGV -- * Some basic usage examples , unsafeSwapIWithMaxI@@ -27,10 +28,11 @@ import GHC.Arr import CaseBi.Arr import Data.Monoid (mappend)+import Data.List (sort) -- | Makes a complex interval-based transformation moving the value from its own interval to the corresponding by the list of tuples second element of the--- respective pair with the first element being the starting number of the interval (numeration of them begins at 1). The list argument must be sorted--- by the first argument in the ascending order. Usually, its first elements in the tuples are from the range @[1..n]@. Number of the intervals are given as+-- respective pair with the first element being the starting number of the interval (numeration of them begins at 1). +-- Usually, its first elements in the tuples are from the range @[1..n]@. Number of the intervals are given as -- the third argument and for many cases should not be greater than 10. There do exist several semantical constraints for the possible accurate arguments, -- but they are not checked. For example, the first argument must be less than the second one; the fifth argument must be located between the first two ones; -- the third argument must be greater than zero.@@ -38,24 +40,47 @@ :: (RealFrac b, Integral c) => b -> b -> c- -> [(c,c)]+ -> [(c,c)] -- ^ Must be finite and expected to be not empty, elements must have all different by the first element tuples. -> b -> b unsafeRearrangeIG minE maxE n xs x | minE == maxE = x- | otherwise = x + fromIntegral (getBFstLSorted' n0 xs n0 - n0) * (maxE - minE) / fromIntegral n+ | otherwise = x + fromIntegral (getBFstL' n0 xs n0 - n0) * (maxE - minE) / fromIntegral n where n0 = intervalNRealFrac minE maxE n x +-- | The more optimized variant of the 'unsafeRearrangeIG', but the 'Array' must be sorted +-- in the ascending order by the first element in the tuples.+unsafeRearrangeIGArr+ :: (RealFrac b, Integral c) => b+ -> b+ -> c+ -> Array Int (c,c) -- ^ Must be sorted in the ascending order by the first elements in the tuples and finite+ -> b+ -> b+unsafeRearrangeIGArr minE maxE n arr x+ | minE == maxE = x+ | otherwise = x + fromIntegral (getBFst' (n0, arr) n0 - n0) * (maxE - minE) / fromIntegral n+ where n0 = intervalNRealFrac minE maxE n x++ -- | An unzipped variant of the 'unsafeRearrangeIG' function where the list argument is internally 'zip'ped as the second argument with the @[1..n]@.--- This allows to shorten the time of the arguments writing.+-- This allows to shorten the time of the arguments writing. unsafeRearrangeIGV- :: (RealFrac b, Integral c) => b+ :: (RealFrac b, Integral c, Ord c) => b -> b -> c- -> [c] -- ^ Must be not empty though this is not checked+ -> [c] -- ^ Must be not empty and finite, the elements here greater or equal than the third argument are neglected. -> b -> b-unsafeRearrangeIGV minE maxE n xs = unsafeRearrangeIG minE maxE n (zip xs (cycle [n]) `mappend` [(n,head xs)])+unsafeRearrangeIGV minE maxE n xs = unsafeRearrangeIGArr minE maxE n arr+ where ts = f . sort . filter (<n) $ xs+ f (t:u:ts) + | t == u = f (t:ts)+ | otherwise = t:f(u:ts)+ f ts = ts+ ks = zip ts (cycle [n]) `mappend` [(n,head xs)]+ l = length ts+ arr = listArray (0,l) ks {-# INLINE unsafeRearrangeIGV #-} -- | Swaps the k-th inner interval values with the maximum one's (that is the n-th one) values.@@ -74,15 +99,12 @@ -- (that is the n-th one) values. The list must be not empty and sorted in the ascending order, though it is not checked. Be aware that this can -- significantly change the density of the values and break some other properties for distributions. unsafeSwapVecIWithMaxI- :: (RealFrac b, Integral c) => b+ :: (RealFrac b, Integral c, Ord c) => b -> b -> c -- ^ It is expected to be greater than 0, though this is not checked.- -> [c] -- ^ It is expected the list to be sorted in the ascending order (indices are counted in it starting with 1 opposed to the usual behaviour for lists and are the numbers of the intervals in the range from 1 to n), and besides all the elements to be less than the previous argument, greater than 0 and to be not pairwise equal, though it is not checked.- -> b -- ^ It is expected to lie between the first two arguments, though this is not checked.+ -> [c] -- ^ It is expected the non-empty finite list (indices are counted in it starting with 1 opposed to the usual behaviour for lists) and numbers here should be the numbers of the intervals less than n.+ -> b -- ^ It is expected to be less than the second argument (if it expected to be probably changed). -> b-unsafeSwapVecIWithMaxI minE maxE n xs = unsafeRearrangeIGV minE maxE n (map h [0..n - 1])- where h i- | getBFstLSorted' False (zip (map (+ (-1)) xs) . replicate (fromIntegral n) $ True) i = n - 1- | i == n - 1 = head xs- | otherwise = i+unsafeSwapVecIWithMaxI = unsafeRearrangeIGV {-# INLINE unsafeSwapVecIWithMaxI #-}+{-# DEPRECATED unsafeSwapVecIWithMaxI "Is provided here for the compatibility with the previous ones versions. Please, use just 'unsafeRearrangeIGV' instead" #-}
phonetic-languages-filters-array.cabal view
@@ -2,7 +2,7 @@ -- For further documentation, see http://haskell.org/cabal/users-guide/ name: phonetic-languages-filters-array-version: 0.4.0.0+version: 0.5.0.0 synopsis: Allows to change the structure of the function output. description: Allows to change the structure of the function output for the data types that have instances of the RealFrac class. Is rewritten from the predecessor uniqueness-periods-vector-filters package. homepage: https://hackage.haskell.org/package/phonetic-languages-filters-array@@ -20,6 +20,6 @@ exposed-modules: Phonetic.Languages.Filters -- other-modules: -- other-extensions:- build-depends: base >=4.8 && <5, filters-basic >=0.1.1 && <1, mmsyn2-array >= 0.3 && <1+ build-depends: base >=4.8 && <5, filters-basic ==0.1.1.0, mmsyn2-array == 0.3.0.0 -- hs-source-dirs: default-language: Haskell2010