Copyright | (c) 2017-2018 Andrew Lelechenko |
---|---|

License | MIT |

Maintainer | Andrew Lelechenko <andrew.lelechenko@gmail.com> |

Safe Haskell | None |

Language | Haskell2010 |

Container for pairwise coprime numbers.

# Documentation

splitIntoCoprimes :: (Euclidean a, Eq b, Num b) => [(a, b)] -> Coprimes a b Source #

The input list is assumed to be a factorisation of some number into a list of powers of (possibly, composite) non-zero factors. The output list is a factorisation of the same number such that all factors are coprime. Such transformation is crucial to continue factorisation (lazily, in parallel or concurrent fashion) without having to merge multiplicities of primes, which occurs more than in one composite factor.

`>>>`

Coprimes {unCoprimes = [(28,1),(33,1),(5,2)]}`splitIntoCoprimes [(140, 1), (165, 1)]`

`>>>`

Coprimes {unCoprimes = [(7,1),(5,2),(3,3),(2,4)]}`splitIntoCoprimes [(360, 1), (210, 1)]`

A list of pairwise coprime numbers with their multiplicities.

unCoprimes :: Coprimes a b -> [(a, b)] Source #

Unwrap.

singleton :: (Eq a, Num a, Eq b, Num b) => a -> b -> Coprimes a b Source #

Wrap a non-zero number with its multiplicity into `Coprimes`

.

`>>>`

Coprimes {unCoprimes = [(210,1)]}`singleton 210 1`

insert :: (Euclidean a, Eq b, Num b) => a -> b -> Coprimes a b -> Coprimes a b Source #

Add a non-zero number with its multiplicity to `Coprimes`

.

`>>>`

Coprimes {unCoprimes = [(7,1),(5,2),(3,3),(2,4)]}`insert 360 1 (singleton 210 1)`

`>>>`

Coprimes {unCoprimes = [(7,1),(5,2),(2,10)]}`insert 2 4 (insert 7 1 (insert 5 2 (singleton 4 3)))`