arithmoi-0.13.0.0: Efficient basic number-theoretic functions.

Copyright | (c) 2018 Alexandre Rodrigues Baldé
License | MIT
Maintainer | Alexandre Rodrigues Baldé <alexandrer_b@outlook.com>
Safe Haskell | Safe-Inferred
Language | Haskell2010

Math.NumberTheory.Quadratic.EisensteinIntegers

Contents

- Primality functions

Description

This module exports functions for manipulating Eisenstein integers, including computing their prime factorisations.

Synopsis

- data EisensteinInteger = !Integer :+ !Integer
- ω :: EisensteinInteger
- conjugate :: EisensteinInteger -> EisensteinInteger
- norm :: EisensteinInteger -> Integer
- associates :: EisensteinInteger -> [EisensteinInteger]
- ids :: [EisensteinInteger]
- findPrime :: Prime Integer -> Prime EisensteinInteger
- primes :: Infinite (Prime EisensteinInteger)

# Documentation

data EisensteinInteger Source #

An Eisenstein integer is `a + bω`, where `a` and `b` are both integers.

Constructors

!Integer :+ !Integer infix 6 |

#### Instances

Instances details

UniqueFactorisation EisensteinInteger Source # | See the source code and Haddock comments for the `factorise` and `isPrime` functions in this module (they are not exported) for implementation details.
Instance details Defined in Math.NumberTheory.Quadratic.EisensteinIntegers Methods factorise :: EisensteinInteger -> [(Prime EisensteinInteger, Word)] Source # isPrime :: EisensteinInteger -> Maybe (Prime EisensteinInteger) Source #
Generic EisensteinInteger Source # |
Instance details Defined in Math.NumberTheory.Quadratic.EisensteinIntegers Associated Types type Rep EisensteinInteger :: Type -> Type Source # Methods from :: EisensteinInteger -> Rep EisensteinInteger x Source # to :: Rep EisensteinInteger x -> EisensteinInteger Source #
Num EisensteinInteger Source # |

Instance details

Defined in Math.NumberTheory.Quadratic.EisensteinIntegers

Methods

(+) :: EisensteinInteger -> EisensteinInteger -> EisensteinInteger Source #

(-) :: EisensteinInteger -> EisensteinInteger -> EisensteinInteger Source #

(*) :: EisensteinInteger -> EisensteinInteger -> EisensteinInteger Source #

negate :: EisensteinInteger -> EisensteinInteger Source #

abs :: EisensteinInteger -> EisensteinInteger Source #

signum :: EisensteinInteger -> EisensteinInteger Source #

fromInteger :: Integer -> EisensteinInteger Source #

Show EisensteinInteger Source # |
Instance details Defined in Math.NumberTheory.Quadratic.EisensteinIntegers Methods showsPrec :: Int -> EisensteinInteger -> ShowS Source # show :: EisensteinInteger -> String Source # showList :: [EisensteinInteger] -> ShowS Source #
NFData EisensteinInteger Source # |
Instance details Defined in Math.NumberTheory.Quadratic.EisensteinIntegers Methods rnf :: EisensteinInteger -> () Source #
Eq EisensteinInteger Source # |
Instance details Defined in Math.NumberTheory.Quadratic.EisensteinIntegers Methods (==) :: EisensteinInteger -> EisensteinInteger -> Bool Source # (/=) :: EisensteinInteger -> EisensteinInteger -> Bool Source #
Ord EisensteinInteger Source # |

Instance details

Defined in Math.NumberTheory.Quadratic.EisensteinIntegers

Methods

compare :: EisensteinInteger -> EisensteinInteger -> Ordering Source #

(<) :: EisensteinInteger -> EisensteinInteger -> Bool Source #

(<=) :: EisensteinInteger -> EisensteinInteger -> Bool Source #

(>) :: EisensteinInteger -> EisensteinInteger -> Bool Source #

(>=) :: EisensteinInteger -> EisensteinInteger -> Bool Source #

max :: EisensteinInteger -> EisensteinInteger -> EisensteinInteger Source #

min :: EisensteinInteger -> EisensteinInteger -> EisensteinInteger Source #

Euclidean EisensteinInteger Source # |
Instance details Defined in Math.NumberTheory.Quadratic.EisensteinIntegers Methods quotRem :: EisensteinInteger -> EisensteinInteger -> (EisensteinInteger, EisensteinInteger) Source # quot :: EisensteinInteger -> EisensteinInteger -> EisensteinInteger Source # rem :: EisensteinInteger -> EisensteinInteger -> EisensteinInteger Source # degree :: EisensteinInteger -> Natural Source #
GcdDomain EisensteinInteger Source # |
Instance details Defined in Math.NumberTheory.Quadratic.EisensteinIntegers Methods divide :: EisensteinInteger -> EisensteinInteger -> Maybe EisensteinInteger Source # gcd :: EisensteinInteger -> EisensteinInteger -> EisensteinInteger Source # lcm :: EisensteinInteger -> EisensteinInteger -> EisensteinInteger Source # coprime :: EisensteinInteger -> EisensteinInteger -> Bool Source #
Ring EisensteinInteger Source # |
Instance details Defined in Math.NumberTheory.Quadratic.EisensteinIntegers Methods negate :: EisensteinInteger -> EisensteinInteger Source #
Semiring EisensteinInteger Source # |
Instance details Defined in Math.NumberTheory.Quadratic.EisensteinIntegers Methods plus :: EisensteinInteger -> EisensteinInteger -> EisensteinInteger Source # zero :: EisensteinInteger Source # times :: EisensteinInteger -> EisensteinInteger -> EisensteinInteger Source # one :: EisensteinInteger Source # fromNatural :: Natural -> EisensteinInteger Source #
type Rep EisensteinInteger Source # |

Instance details

Defined in Math.NumberTheory.Quadratic.EisensteinIntegers

type Rep EisensteinInteger = D1 ('MetaData "EisensteinInteger" "Math.NumberTheory.Quadratic.EisensteinIntegers" "arithmoi-0.13.0.0-Gu7wAZ5ppC1YpMjsEnZVk" 'False) (C1 ('MetaCons ":+" ('InfixI 'NotAssociative 6) 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Integer) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Integer)))

ω :: EisensteinInteger Source #

The imaginary unit for Eisenstein integers, where

    ω == (-1/2) + ((sqrt 3)/2)ι == exp(2*pi*ι/3)

and `ι` is the usual imaginary unit with `ι² == -1`.

conjugate :: EisensteinInteger -> EisensteinInteger Source #

Conjugate a Eisenstein integer.

norm :: EisensteinInteger -> Integer Source #

The square of the magnitude of a Eisenstein integer.

associates :: EisensteinInteger -> [EisensteinInteger] Source #

Produce a list of an `EisensteinInteger`'s associates.

ids :: [EisensteinInteger] Source #

List of all Eisenstein units, counterclockwise across all sextants, starting with `1`.

# Primality functions

findPrime :: Prime Integer -> Prime EisensteinInteger Source #

Find an Eisenstein integer whose norm is the given prime number in the form `3k + 1`.

    >>> import Math.NumberTheory.Primes (nextPrime)
    >>> findPrime (nextPrime 7)
    Prime 3+2*ω

primes :: Infinite (Prime EisensteinInteger) Source #

An infinite list of Eisenstein primes. Uses primes in `Z` to exhaustively generate all Eisenstein primes in order of ascending norm.

- 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.

    >>> take 10 primes
    [Prime 2+ω,Prime 2,Prime 3+2*ω,Prime 3+ω,Prime 4+3*ω,Prime 4+ω,Prime 5+3*ω,Prime 5+2*ω,Prime 5,Prime 6+5*ω]