Copyright | (c) 2016 Chris Fredrickson Google Inc. |
---|---|
License | MIT |
Maintainer | Chris Fredrickson <chris.p.fredrickson@gmail.com> |
Safe Haskell | None |
Language | Haskell2010 |
This module exports functions for manipulating Gaussian integers, including computing their prime factorisations.
Synopsis
- data GaussianInteger = (:+) {}
- ι :: GaussianInteger
- conjugate :: GaussianInteger -> GaussianInteger
- norm :: GaussianInteger -> Integer
- primes :: [Prime GaussianInteger]
- findPrime :: Prime Integer -> Prime GaussianInteger
Documentation
data GaussianInteger Source #
A Gaussian integer is a+bi, where a and b are both integers.
Instances
ι :: 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.
primes :: [Prime GaussianInteger] Source #
An infinite list of the Gaussian primes. Uses primes in Z to exhaustively generate all Gaussian primes (up to associates), in order of ascending magnitude.
findPrime :: Prime Integer -> Prime GaussianInteger Source #
Find a Gaussian integer whose norm is the given prime number of form 4k + 1 using Hermite-Serret algorithm.