arithmoi-0.6.0.1: Efficient basic number-theoretic functions.

Copyright (c) 2016 Chris Fredrickson MIT Chris Fredrickson Provisional Non-portable (GHC extensions) None Haskell2010

Math.NumberTheory.GaussianIntegers

Description

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

Synopsis

# Documentation

A Gaussian integer is a+bi, where a and b are both integers.

Constructors

 (:+) infix 6 Fieldsreal :: !Integer imag :: !Integer

Instances

 Source # Methods Source # Methods Source # MethodsshowList :: [GaussianInteger] -> ShowS # Source # Methods Source #

The imaginary unit, where

ι .^ 2 == -1

Conjugate a Gaussian integer.

The square of the magnitude of a Gaussian integer.

Simultaneous div and mod.

Gaussian integer division, truncating toward negative infinity.

Gaussian integer remainder, satisfying

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

Simultaneous quot and rem.

Gaussian integer division, truncating toward zero.

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.

Compute whether a given Gaussian integer is prime.

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.

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

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

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

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

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