Flint2-0.1.0.5: Haskell bindings for the flint library for number theory
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Number.Flint.NF.Fmpzi

Synopsis

Gaussian integers

data Fmpzi Source #

Constructors

Fmpzi !(ForeignPtr CFmpzi) 

Instances

Instances details
Num Fmpzi Source # 
Instance details

Defined in Data.Number.Flint.NF.Fmpzi.Instances

Show Fmpzi Source # 
Instance details

Defined in Data.Number.Flint.NF.Fmpzi.Instances

Methods

showsPrec :: Int -> Fmpzi -> ShowS #

show :: Fmpzi -> String #

showList :: [Fmpzi] -> ShowS #

Eq Fmpzi Source # 
Instance details

Defined in Data.Number.Flint.NF.Fmpzi.Instances

Methods

(==) :: Fmpzi -> Fmpzi -> Bool #

(/=) :: Fmpzi -> Fmpzi -> Bool #

data CFmpzi Source #

Constructors

CFmpzi CFmpz CFmpz 

Instances

Instances details
Storable CFmpzi Source # 
Instance details

Defined in Data.Number.Flint.NF.Fmpzi.FFI

withFmpzi :: Fmpzi -> (Ptr CFmpzi -> IO a) -> IO (Fmpzi, a) Source #

Use Fmpzi

withNewFmpzi :: (Ptr CFmpzi -> IO a) -> IO (Fmpzi, a) Source #

Use new Fmpzi

withFmpziReal :: Fmpzi -> (Ptr b -> IO a) -> IO (Fmpzi, a) Source #

Use real part of Fmpzi

withFmpziImag :: Storable a => Fmpzi -> (Ptr a -> IO a) -> IO (Fmpzi, a) Source #

Use imaginary part of Fmpzi

Types

Basic manipulation

Input and output

Random number generation

Properties

Units

Norms

Arithmetic

Division

fmpzi_divexact :: Ptr CFmpzi -> Ptr CFmpzi -> Ptr CFmpzi -> IO () Source #

fmpzi_divexact q x y

Sets q to the quotient of x and y, assuming that the division is exact.

fmpzi_divrem :: Ptr CFmpzi -> Ptr CFmpzi -> Ptr CFmpzi -> Ptr CFmpzi -> IO () Source #

fmpzi_divrem q r x y

Computes a quotient and remainder satisfying \(x = q y + r\) with \(N(r) \le N(y)/2\), with a canonical choice of remainder when breaking ties.

fmpzi_divrem_approx :: Ptr CFmpzi -> Ptr CFmpzi -> Ptr CFmpzi -> Ptr CFmpzi -> IO () Source #

fmpzi_divrem_approx q r x y

Computes a quotient and remainder satisfying \(x = q y + r\) with \(N(r) < N(y)\), with an implementation-defined, non-canonical choice of remainder.

fmpzi_remove_one_plus_i :: Ptr CFmpzi -> Ptr CFmpzi -> IO CLong Source #

fmpzi_remove_one_plus_i res x

Divide x exactly by the largest possible power \((1+i)^k\) and return the exponent k.

GCD

fmpzi_gcd_euclidean :: Ptr CFmpzi -> Ptr CFmpzi -> Ptr CFmpzi -> IO () Source #

fmpzi_gcd_euclidean res x y

Computes the GCD of x and y. The result is in canonical unit form.

The euclidean version is a straightforward implementation of Euclid's algorithm. The euclidean_improved version is optimized by performing approximate divisions. The binary version uses a (1+i)-ary analog of the binary GCD algorithm for integers [Wei2000]. The shortest version finds the GCD as the shortest vector in a lattice. The default version chooses an algorithm automatically.