quantizer 0.2.1.0 → 0.2.1.1
raw patch · 5 files changed
+34/−21 lines, 5 files
Files
- CHANGELOG.md +4/−0
- FoldableQuantizer.hs +7/−5
- ListQuantizer.hs +8/−5
- TwoQuantizer.hs +13/−9
- quantizer.cabal +2/−2
CHANGELOG.md view
@@ -14,3 +14,7 @@ ListQuantizer to be used in case of lists instead of FoldableQuantizer. Some documentation improvements. +## 0.2.1.1 -- 2023-01-27++* Second version revised B. Some documentation improvements.+
FoldableQuantizer.hs view
@@ -9,7 +9,9 @@ -- some values to another one with the values from the pre-defined structure. Similar to -- the measurement of the quantum state observables with the discrete spectrum. -- For performance reasons it is better to use module ListQuantizer whenever possible (especially if the--- given 'F.Foldable' and 'S.InsertLeft' instances are just lists).+-- given 'F.Foldable' and 'S.InsertLeft' instances are just lists). Contrary to+-- TwoQuantizer module, the results in every function here depend not just on the two values, +-- which the point is located in between, but on the whole structure. Defined for just positive real numbers of 'Double' type. {-# LANGUAGE NoImplicitPrelude #-} @@ -27,7 +29,7 @@ import qualified Data.SubG as S round2G - :: (Ord a, S.InsertLeft t a, Monoid (t a)) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. + :: (Ord a, S.InsertLeft t a, Monoid (t a)) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. The ambigous situation is defined by the second argument. -> (t a -> a -> Ordering) -> t a -> a @@ -45,7 +47,7 @@ u = fromJust . S.safeHeadG $ us foldableQuantizerG - :: (Ord a, Floating a, Integral a, S.InsertLeft t1 a, Monoid (t1 a), F.Foldable t2) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value.+ :: (Ord a, Floating a, Integral a, S.InsertLeft t1 a, Monoid (t1 a), F.Foldable t2) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. The ambigous situation is defined by the second argument. -> (t1 a -> a -> Ordering) -> t1 a -> t2 a@@ -55,7 +57,7 @@ ys = F.foldr (\t ts -> t * k : ts) [] xs round2GM - :: (Ord a, Monad m, S.InsertLeft t1 a, Monoid (t1 a)) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. + :: (Ord a, Monad m, S.InsertLeft t1 a, Monoid (t1 a)) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. The ambigous situation is defined by the second argument. -> (t1 a -> a -> m Ordering) -> t1 a -> a @@ -75,7 +77,7 @@ u = S.safeHeadG us foldableQuantizerGM - :: (Ord a, Floating a, Integral a, Monad m, S.InsertLeft t1 a, Monoid (t1 a), F.Foldable t2) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. + :: (Ord a, Floating a, Integral a, Monad m, S.InsertLeft t1 a, Monoid (t1 a), F.Foldable t2) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. The ambigous situation is defined by the second argument. -> (t1 a -> a -> m Ordering) -> t1 a -> t2 a
ListQuantizer.hs view
@@ -7,8 +7,11 @@ -- -- A module to provide the extended variants to convert a list with -- some values to another one with the values from the pre-defined another list. Similar to --- the measurement of the quantum state observables with the discrete spectrum.+-- the measurement of the quantum state observables with the discrete spectrum. Contrary to+-- TwoQuantizer module, the results in every function here depend not just on the two values, +-- which the point is located in between, but on the whole list. Defined for just positive real numbers of 'Double' type. + {-# LANGUAGE NoImplicitPrelude #-} module ListQuantizer where@@ -24,7 +27,7 @@ -- | A better suited variant for 'FoldableQuantizer.round2G' for lists. round2GL- :: (Ord a) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. + :: (Ord a) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. The ambigous situation is defined by the second argument. -> ([a] -> a -> Ordering) -> [a] -> a @@ -42,7 +45,7 @@ u = head us foldableQuantizerGL - :: (Ord a, Floating a, Integral a) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value.+ :: (Ord a, Floating a, Integral a) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. The ambigous situation is defined by the second argument. -> ([a] -> a -> Ordering) -> [a] -> [a]@@ -52,7 +55,7 @@ ys = foldr (\t ts -> t * k : ts) [] xs round2GML - :: (Ord a, Monad m) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. + :: (Ord a, Monad m) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. The ambigous situation is defined by the second argument. -> ([a] -> a -> m Ordering) -> [a] -> a @@ -72,7 +75,7 @@ u = if null us then Nothing else Just . head $ us foldableQuantizerGML - :: (Ord a, Floating a, Integral a, Monad m) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. + :: (Ord a, Floating a, Integral a, Monad m) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. The ambigous situation is defined by the second argument. -> ([a] -> a -> m Ordering) -> [a] -> [a]
TwoQuantizer.hs view
@@ -6,7 +6,9 @@ -- Maintainer : oleksandr.zhabenko@yahoo.com -- -- A module to provide the simple version of the obtaining from the list of values the list of other--- values, the pre-defined ones. Provides both pure functions and monadic versions.+-- values, the pre-defined ones. Provides both pure functions and monadic versions. Contrary to+-- ListQuantizer module, the results in every function here depend on the two values, +-- which the point is located in between. Defined for just positive real numbers of 'Double' type. {-# LANGUAGE NoImplicitPrelude #-} @@ -22,9 +24,9 @@ round2 - :: Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. - -> Double + :: Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. The ambigous situation is when the square of the third paremeter is equal to the product of the second one and the fourth one. -> Double + -> Double -- ^ This one should lie between the other two similar parameters — the one before and the one after it. -> Double -> Maybe Double -- ^ The numeric value (in 'Just' case) can be equal just to the one of the two first arguments. round2 bool x y z @@ -57,7 +59,7 @@ ys = map (*k) xs round2G - :: (Ord a) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. + :: (Ord a) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. The ambigous situation is defined by the second argument. -> (a -> a -> a -> Ordering) -> a -> a @@ -70,7 +72,7 @@ | otherwise = Nothing round2GL - :: (Ord a) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. + :: (Ord a) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. The ambigous situation is defined by the second argument. -> (a -> a -> a -> Ordering) -> [a] -> a @@ -86,7 +88,7 @@ y0 = last ks twoQuantizerG - :: (Ord a, Floating a, Integral a) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. + :: (Ord a, Floating a, Integral a) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. The ambigous situation is defined by the second argument. -> (a -> a -> a -> Ordering) -> [a] -> [a] @@ -96,7 +98,7 @@ ys = map (*k) xs round2GM - :: (Ord a, Monad m) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. + :: (Ord a, Monad m) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. The ambigous situation is defined by the second argument. -> (a -> a -> a -> m Ordering) -> a -> a @@ -111,7 +113,7 @@ | otherwise = return Nothing round2GLM - :: (Ord a, Monad m) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. + :: (Ord a, Monad m) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. The ambigous situation is defined by the second argument. -> (a -> a -> a -> m Ordering) -> [a] -> a @@ -126,6 +128,8 @@ y = head us y0 = last ks +-- | Simple arithmetic mean. Is vulnerable to floating point rounding error so if possible use just+-- for double-precision values. meanF2 :: (Floating a, Integral a) => [a] -> a @@ -135,7 +139,7 @@ meanF2 _ s l = s / fromIntegral l twoQuantizerGM - :: (Ord a, Floating a, Integral a, Monad m) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. + :: (Ord a, Floating a, Integral a, Monad m) => Bool -- ^ If 'True' then the function rounds the result in the ambiguous situation to the greater value. The ambigous situation is defined by the second argument. -> (a -> a -> a -> m Ordering) -> [a] -> [a]
quantizer.cabal view
@@ -1,7 +1,7 @@ name: quantizer-version: 0.2.1.0+version: 0.2.1.1 synopsis: Library to provide the behaviour similar to quantum states superposition. -description: Has two modules with similar functionality. The functions provide the somewhat generalized way to round the numbers based on some data.+description: Has three modules with similar functionality. The functions provide the somewhat generalized way to round the numbers based on some data. homepage: https://hackage.haskell.org/package/quantizer license: MIT license-file: LICENSE