Skip to content

Commit

Permalink
Fix comments
Browse files Browse the repository at this point in the history
Fixes a typo for `Math.NumberTheory.EisensteinInteger.associates`
and rewords the comment for
`Math.NumberTheory.EisensteinInteger.primes`, as well as a few
other comments.
  • Loading branch information
rockbmb committed Aug 25, 2018
1 parent 7996d9a commit ac7dad4
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions Math/NumberTheory/EisensteinIntegers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import Math.NumberTheory.Utils.FromIntegral (integerToNatural)

infix 6 :+

-- |An Eisenstein integer is a + bω, where a and b are both integers.
-- | An Eisenstein integer is a + bω, where a and b are both integers.
data EisensteinInteger = (:+) { real :: !Integer, imag :: !Integer }
deriving (Eq, Ord, Generic)

Expand Down Expand Up @@ -98,7 +98,7 @@ instance Num EisensteinInteger where
ids :: [EisensteinInteger]
ids = take 6 (iterate ((1 + ω) *) 1)

-- | Produce a list of an @EisensteinInteger@s' associates.
-- | Produce a list of an @EisensteinInteger@'s associates.
associates :: EisensteinInteger -> [EisensteinInteger]
associates e = map (e *) ids

Expand All @@ -109,18 +109,18 @@ associates e = map (e *) ids
primary :: EisensteinInteger -> EisensteinInteger
primary = head . filter (\p -> p `modE` 3 == 2) . associates

-- |Simultaneous 'quot' and 'rem'.
-- | Simultaneous 'quot' and 'rem'.
quotRemE
:: EisensteinInteger
-> EisensteinInteger
-> (EisensteinInteger, EisensteinInteger)
quotRemE = divHelper quot

-- |Eisenstein integer division, truncating toward zero.
-- | Eisenstein integer division, truncating toward zero.
quotE :: EisensteinInteger -> EisensteinInteger -> EisensteinInteger
n `quotE` d = q where (q,_) = quotRemE n d

-- |Eisenstein integer remainder, satisfying
-- | Eisenstein integer remainder, satisfying
--
-- > (x `quotE` y)*y + (x `remE` y) == x
remE :: EisensteinInteger -> EisensteinInteger -> EisensteinInteger
Expand Down Expand Up @@ -218,9 +218,11 @@ findPrime p = case Moduli.sqrtModMaybe (9*k*k - 1) (FieldCharacteristic (PrimeNa
k :: Integer
k = p `div` 6

-- | An infinite list of the Eisenstein primes. Uses primes in Z to exhaustively
-- generate all Eisenstein primes (all in the first sextant), in order of
-- ascending magnitude.
-- | An infinite list of Eisenstein primes. Uses primes in Z to exhaustively
-- generate all Eisenstein primes in order of ascending magnitude.
-- * Every prime is in the first sextant, so the list contains no associates.
-- * Eisenstein primes from the whole complex plane can be generated by
-- applying @associates@ to each prime in this list.
primes :: [EisensteinInteger]
primes = (2 :+ 1) : mergeBy (comparing norm) l r
where (leftPrimes, rightPrimes) = partition (\p -> p `mod` 3 == 2) Sieve.primes
Expand All @@ -246,7 +248,8 @@ primes = (2 :+ 1) : mergeBy (comparing norm) l r
-- in Theorem 8.4 in Chapter 8, a way is given to express any Eisenstein
-- integer @μ@ as @(-1)^a * ω^b * (1 - ω)^c * product [π_i^a_i | i <- [1..N]]@
-- where @a, b, c, a_i@ are nonnegative integers, @N > 1@ is an integer and
-- @π_i@ are primary primes.
-- @π_i@ are primary primes (for a primary Eisenstein prime @p@,
-- @p ≡ 2 (modE 3)@, see @primary@ above).
--
-- * Aplying @norm@ to both sides of Theorem 8.4:
-- @norm μ = norm ((-1)^a * ω^b * (1 - ω)^c * product [ π_i^a_i | i <- [1..N]])@
Expand Down Expand Up @@ -277,8 +280,8 @@ factorise g = concat $
\ == " ++ show z ++ "but (1 - ω) is not\
\ a prime factor of z."
where
-- | Remove all @1 :+ (-1)@ (which is associated to @2 :+ 1@) factors from the
-- argument.
-- Remove all @1 :+ (-1)@ (which is associated to @2 :+ 1@) factors
-- from the argument.
(q, r) = divModE z (2 :+ 1)
go z (p, e) | p `mod` 3 == 2 =
let e' = e `quot` 2 in (z `quotI` (p ^ e'), [(p :+ 0, e')])
Expand Down

0 comments on commit ac7dad4

Please sign in to comment.