arithmoi-0.6.0.1: Efficient basic number-theoretic functions.

Copyright(c) 2016 Chris Fredrickson
LicenseMIT
MaintainerChris Fredrickson <chris.p.fredrickson@gmail.com>
StabilityProvisional
PortabilityNon-portable (GHC extensions)
Safe HaskellNone
LanguageHaskell2010

Math.NumberTheory.GaussianIntegers

Description

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

Synopsis

Documentation

ι :: GaussianInteger Source #

The imaginary unit, where

ι .^ 2 == -1

conjugate :: GaussianInteger -> GaussianInteger Source #

Conjugate a Gaussian integer.

norm :: GaussianInteger -> Integer Source #

The square of the magnitude of a Gaussian integer.

divG :: GaussianInteger -> GaussianInteger -> GaussianInteger Source #

Gaussian integer division, truncating toward negative infinity.

modG :: GaussianInteger -> GaussianInteger -> GaussianInteger Source #

Gaussian integer remainder, satisfying

(x `divG` y)*y + (x `modG` y) == x

quotG :: GaussianInteger -> GaussianInteger -> GaussianInteger Source #

Gaussian integer division, truncating toward zero.

remG :: GaussianInteger -> GaussianInteger -> GaussianInteger Source #

Gaussian integer remainder, satisfying

(x `quotG` y)*y + (x `remG` y) == x

(.^) :: Integral a => GaussianInteger -> a -> GaussianInteger infixr 8 Source #

Raise a Gaussian integer to a given power.

isPrime :: GaussianInteger -> Bool Source #

Compute whether a given Gaussian integer is prime.

primes :: [GaussianInteger] Source #

An infinite list of the Gaussian primes. Uses primes in Z to exhaustively generate all Gaussian primes, but not quite in order of ascending magnitude.

gcdG :: GaussianInteger -> GaussianInteger -> GaussianInteger Source #

Compute the GCD of two Gaussian integers. Enforces the precondition that each integer must be in the first quadrant (or zero).

gcdG' :: GaussianInteger -> GaussianInteger -> GaussianInteger Source #

Compute the GCD of two Gauss integers. Does not check the precondition.

findPrime :: Integer -> GaussianInteger Source #

Find a Gaussian integer whose norm is the given prime number. Checks the precondition that p is prime and that p mod 4 /= 3.

findPrime' :: Integer -> GaussianInteger Source #

Find a Gaussian integer whose norm is the given prime number. Does not check the precondition.

factorise :: GaussianInteger -> [(GaussianInteger, Int)] Source #

Compute the prime factorisation of a Gaussian integer. This is unique up to units (+- 1, +- i).