Copyright | (c) OleksandrZhabenko 2020-2022 |
---|---|
License | MIT |
Maintainer | olexandr543@yahoo.com |
Stability | Experimental |
Safe Haskell | None |
Language | Haskell2010 |
A module allows to change the structure of the function output for the functions of
elements from RealFrac
class. At the moment only the equal intervals are supported.
Uses less dependencies than its former analogue package uniqueness-periods-vector-filters
.
Synopsis
- intervalNRealFrac :: (RealFrac b, Integral c) => b -> b -> c -> b -> c
- unsafeTransfer1I5 :: RealFrac b => b -> b -> b -> b -> b -> b
- transfer1IEq3 :: RealFrac b => b -> b -> b -> b
- unsafeRearrangeIG :: (RealFrac b, Integral c) => b -> b -> c -> [(c, c)] -> b -> b
- unsafeRearrangeIGArr :: (RealFrac b, Integral c) => b -> b -> c -> Array Int (c, c) -> b -> b
- unsafeRearrangeIGV :: (RealFrac b, Integral c, Ord c) => b -> b -> c -> [c] -> b -> b
- unsafeSwapIWithMaxI :: (RealFrac b, Integral c) => b -> b -> c -> c -> b -> b
- unsafeSwapVecIWithMaxI :: (RealFrac b, Integral c, Ord c) => b -> b -> c -> [c] -> b -> b
One interval used
intervalNRealFrac :: (RealFrac b, Integral c) => b -> b -> c -> b -> c #
Given the minimum and maximum elements, a quantity of equal intervals, and an element in between the first two arguments (or equal to one of them), finds out the index of the interval, to which the element belongs (starting from 1). The minimum element belongs to the interval with the index 1.
unsafeTransfer1I5 :: RealFrac b => b -> b -> b -> b -> b -> b #
Moves (if needed) the given value so that its result divides the new [min..max] interval in the same proportion as the starting one. Is intended to be used for the arguments satisfying some additional constraints, but they are not checked (hence, its name prefix "unsafe"). For example, the second argument must be greater than the first one, the fourth -- than the third one, and the fifth must be located in between the first two. Then the result is also located in between the third and fourth arguments similarly.
transfer1IEq3 :: RealFrac b => b -> b -> b -> b #
A variant of the unsafeTransfer1I5
where the lengths of the both intervals (the old and the new ones) are equal.
Several intervals
:: (RealFrac b, Integral c) | |
=> b | |
-> b | |
-> c | |
-> [(c, c)] | Must be finite and expected to be not empty, elements must have all different by the first element tuples. |
-> b | |
-> b |
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).
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.
:: (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 |
The more optimized variant of the unsafeRearrangeIG
, but the Array
must be sorted
in the ascending order by the first element in the tuples.
:: (RealFrac b, Integral c, Ord c) | |
=> b | |
-> b | |
-> c | |
-> [c] | Must be not empty and finite, the elements here greater or equal than the third argument are neglected. |
-> b | |
-> b |
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.
Some basic usage examples
:: (RealFrac b, Integral c) | |
=> b | |
-> b | |
-> c | It is expected to be greater than 0, though this is not checked. |
-> c | It is expected to be less than the previous argument, but greater than 0, though this is not checked. |
-> b | It is expected to lie between the first two arguments, though this is not checked. |
-> b |
Swaps the k-th inner interval values with the maximum one's (that is the n-th one) values.
unsafeSwapVecIWithMaxI Source #
:: (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 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 |
Deprecated: Is provided here for the compatibility with the previous ones versions. Please, use just unsafeRearrangeIGV
instead
Swaps the inner intervals values (given by the list of elements of the data type that has an instance of the
Integral
class that represent numbers-indices starting from 1 to n) with the maximum one's
(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.