Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Fmpzi = Fmpzi !(ForeignPtr CFmpzi)
- data CFmpzi = CFmpzi CFmpz CFmpz
- newFmpzi :: IO Fmpzi
- newFmpzi_ :: CLong -> CLong -> IO Fmpzi
- withFmpzi :: Fmpzi -> (Ptr CFmpzi -> IO a) -> IO (Fmpzi, a)
- withNewFmpzi :: (Ptr CFmpzi -> IO a) -> IO (Fmpzi, a)
- withFmpziReal :: Fmpzi -> (Ptr b -> IO a) -> IO (Fmpzi, a)
- withFmpziImag :: Storable a => Fmpzi -> (Ptr a -> IO a) -> IO (Fmpzi, a)
- fmpzi_init :: Ptr CFmpzi -> IO ()
- fmpzi_clear :: Ptr CFmpzi -> IO ()
- fmpzi_swap :: Ptr CFmpzi -> Ptr CFmpzi -> IO ()
- fmpzi_zero :: Ptr CFmpzi -> IO ()
- fmpzi_one :: Ptr CFmpzi -> IO ()
- fmpzi_set :: Ptr CFmpzi -> Ptr CFmpzi -> IO ()
- fmpzi_set_si_si :: Ptr CFmpzi -> CLong -> CLong -> IO ()
- fmpzi_get_str :: Ptr CFmpzi -> IO CString
- fmpzi_fprint :: Ptr CFile -> Ptr CFmpzi -> IO ()
- fmpzi_print :: Ptr CFmpzi -> IO ()
- fmpzi_randtest :: Ptr CFmpzi -> Ptr CFRandState -> CMpBitCnt -> IO ()
- fmpzi_equal :: Ptr CFmpzi -> Ptr CFmpzi -> IO CInt
- fmpzi_is_zero :: Ptr CFmpzi -> IO CInt
- fmpzi_is_one :: Ptr CFmpzi -> IO CInt
- fmpzi_is_unit :: Ptr CFmpzi -> IO CInt
- fmpzi_canonical_unit_i_pow :: Ptr CFmpzi -> IO CLong
- fmpzi_canonicalise_unit :: Ptr CFmpzi -> Ptr CFmpzi -> IO ()
- fmpzi_bits :: Ptr CFmpzi -> IO CLong
- fmpzi_norm :: Ptr CFmpz -> Ptr CFmpzi -> IO ()
- fmpzi_conj :: Ptr CFmpzi -> Ptr CFmpzi -> IO ()
- fmpzi_neg :: Ptr CFmpzi -> Ptr CFmpzi -> IO ()
- fmpzi_add :: Ptr CFmpzi -> Ptr CFmpzi -> Ptr CFmpzi -> IO ()
- fmpzi_sub :: Ptr CFmpzi -> Ptr CFmpzi -> Ptr CFmpzi -> IO ()
- fmpzi_sqr :: Ptr CFmpzi -> Ptr CFmpzi -> IO ()
- fmpzi_mul :: Ptr CFmpzi -> Ptr CFmpzi -> Ptr CFmpzi -> IO ()
- fmpzi_pow_ui :: Ptr CFmpzi -> Ptr CFmpzi -> CULong -> IO ()
- fmpzi_divexact :: Ptr CFmpzi -> Ptr CFmpzi -> Ptr CFmpzi -> IO ()
- fmpzi_divrem :: Ptr CFmpzi -> Ptr CFmpzi -> Ptr CFmpzi -> Ptr CFmpzi -> IO ()
- fmpzi_divrem_approx :: Ptr CFmpzi -> Ptr CFmpzi -> Ptr CFmpzi -> Ptr CFmpzi -> IO ()
- fmpzi_remove_one_plus_i :: Ptr CFmpzi -> Ptr CFmpzi -> IO CLong
- fmpzi_gcd_euclidean :: Ptr CFmpzi -> Ptr CFmpzi -> Ptr CFmpzi -> IO ()
Gaussian integers
Instances
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
fmpzi_randtest :: Ptr CFmpzi -> Ptr CFRandState -> CMpBitCnt -> IO () Source #
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.