arithmoi-0.12.0.2: Efficient basic number-theoretic functions.
Copyright(c) 2017-2018 Andrew Lelechenko
LicenseMIT
MaintainerAndrew Lelechenko <andrew.lelechenko@gmail.com>
Safe HaskellNone
LanguageHaskell2010

Math.NumberTheory.Euclidean.Coprimes

Description

Container for pairwise coprime numbers.

Synopsis

Documentation

splitIntoCoprimes :: (Eq a, GcdDomain 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.

>>> splitIntoCoprimes [(140, 1), (165, 1)]
Coprimes {unCoprimes = [(28,1),(33,1),(5,2)]}
>>> splitIntoCoprimes [(360, 1), (210, 1)]
Coprimes {unCoprimes = [(7,1),(5,2),(3,3),(2,4)]}

data Coprimes a b Source #

A list of pairwise coprime numbers with their multiplicities.

Instances

Instances details
(Eq a, Eq b) => Eq (Coprimes a b) Source # 
Instance details

Defined in Math.NumberTheory.Euclidean.Coprimes

Methods

(==) :: Coprimes a b -> Coprimes a b -> Bool #

(/=) :: Coprimes a b -> Coprimes a b -> Bool #

(Show a, Show b) => Show (Coprimes a b) Source # 
Instance details

Defined in Math.NumberTheory.Euclidean.Coprimes

Methods

showsPrec :: Int -> Coprimes a b -> ShowS #

show :: Coprimes a b -> String #

showList :: [Coprimes a b] -> ShowS #

(Eq a, GcdDomain a, Eq b, Num b) => Semigroup (Coprimes a b) Source # 
Instance details

Defined in Math.NumberTheory.Euclidean.Coprimes

Methods

(<>) :: Coprimes a b -> Coprimes a b -> Coprimes a b #

sconcat :: NonEmpty (Coprimes a b) -> Coprimes a b #

stimes :: Integral b0 => b0 -> Coprimes a b -> Coprimes a b #

(Eq a, GcdDomain a, Eq b, Num b) => Monoid (Coprimes a b) Source # 
Instance details

Defined in Math.NumberTheory.Euclidean.Coprimes

Methods

mempty :: Coprimes a b #

mappend :: Coprimes a b -> Coprimes a b -> Coprimes a b #

mconcat :: [Coprimes a b] -> Coprimes a b #

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

Unwrap.

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

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

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

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

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

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