finite-fields-0.2: Arithmetic in finite fields

Math.FiniteField.PrimeField.Generic

Description

Arbitrary prime fields, naive implementation

Synopsis

# Witness for the existence of the field

newtype WitnessFp (p :: Nat) Source #

A witness for the existence of the prime field F_p

Constructors

 WitnessFp FieldsfromWitnessFp :: IsPrime p

#### Instances

Instances details
 Source # Instance detailsDefined in Math.FiniteField.PrimeField.Generic MethodsshowsPrec :: Int -> WitnessFp p -> ShowS #show :: WitnessFp p -> String #showList :: [WitnessFp p] -> ShowS #

Constructors

 forall p. SomeWitnessFp (WitnessFp p)

#### Instances

Instances details
 Source # Instance detailsDefined in Math.FiniteField.PrimeField.Generic MethodsshowList :: [SomeWitnessFp] -> ShowS #

Note: currently this checks the primality of the input using trial division, so it's not really practical...

But you can use unsafePrimeField to cheat.

You are responsible for guaranteeing that the input is a prime.

# Field elements

data Fp (p :: Nat) Source #

An element of the prime field F_p

#### Instances

Instances details
 Eq (Fp p) Source # Instance detailsDefined in Math.FiniteField.PrimeField.Generic Methods(==) :: Fp p -> Fp p -> Bool #(/=) :: Fp p -> Fp p -> Bool # Fractional (Fp p) Source # Instance detailsDefined in Math.FiniteField.PrimeField.Generic Methods(/) :: Fp p -> Fp p -> Fp p #recip :: Fp p -> Fp p # Num (Fp p) Source # Instance detailsDefined in Math.FiniteField.PrimeField.Generic Methods(+) :: Fp p -> Fp p -> Fp p #(-) :: Fp p -> Fp p -> Fp p #(*) :: Fp p -> Fp p -> Fp p #negate :: Fp p -> Fp p #abs :: Fp p -> Fp p #signum :: Fp p -> Fp p # Ord (Fp p) Source # Note: the Ord instance is present only so that you can use GF as key in Maps - the ordering is kind of arbitrary! Instance detailsDefined in Math.FiniteField.PrimeField.Generic Methodscompare :: Fp p -> Fp p -> Ordering #(<) :: Fp p -> Fp p -> Bool #(<=) :: Fp p -> Fp p -> Bool #(>) :: Fp p -> Fp p -> Bool #(>=) :: Fp p -> Fp p -> Bool #max :: Fp p -> Fp p -> Fp p #min :: Fp p -> Fp p -> Fp p # Show (Fp p) Source # Instance detailsDefined in Math.FiniteField.PrimeField.Generic MethodsshowsPrec :: Int -> Fp p -> ShowS #show :: Fp p -> String #showList :: [Fp p] -> ShowS # Field (Fp p) Source # Instance detailsDefined in Math.FiniteField.PrimeField.Generic Associated Typestype Witness (Fp p) = (w :: Type) Source #type Prime (Fp p) :: Nat Source #type Dim (Fp p) :: Nat Source # Methodsdimension :: Witness (Fp p) -> Integer Source #fieldSize :: Witness (Fp p) -> Integer Source #zero :: Witness (Fp p) -> Fp p Source #one :: Witness (Fp p) -> Fp p Source #isZero :: Fp p -> Bool Source #isOne :: Fp p -> Bool Source #embed :: Witness (Fp p) -> Integer -> Fp p Source #embedSmall :: Witness (Fp p) -> Int -> Fp p Source #randomFieldElem :: RandomGen gen => Witness (Fp p) -> gen -> (Fp p, gen) Source #randomInvertible :: RandomGen gen => Witness (Fp p) -> gen -> (Fp p, gen) Source #primGen :: Witness (Fp p) -> Fp p Source #witnessOf :: Fp p -> Witness (Fp p) Source #power :: Fp p -> Integer -> Fp p Source #powerSmall :: Fp p -> Int -> Fp p Source #frobenius :: Fp p -> Fp p Source #enumerate :: Witness (Fp p) -> [Fp p] Source # type Witness (Fp p) Source # Instance detailsDefined in Math.FiniteField.PrimeField.Generic type Witness (Fp p) = WitnessFp p type Prime (Fp p) Source # Instance detailsDefined in Math.FiniteField.PrimeField.Generic type Prime (Fp p) = p type Dim (Fp p) Source # Instance detailsDefined in Math.FiniteField.PrimeField.Generic type Dim (Fp p) = 1