fmpzi.h – Gaussian integers¶
This module allows working with elements of the ring \(\mathbb{Z}[i]\). At present, only a minimal interface is provided.
Types, macros and constants¶
-
type fmpzi_struct¶
-
type fmpzi_t¶
Contains a pairs of integers representing the real and imaginary parts. An fmpzi_t is defined as an array of length one of type fmpzi_struct, permitting an fmpzi_t to be passed by reference.
-
fmpzi_realref(x)¶
Macro giving a pointer to the real part of x.
-
fmpzi_imagref(x)¶
Macro giving a pointer to the imaginary part of x.
Basic manipulation¶
Input and output¶
Random number generation¶
-
void fmpzi_randtest(fmpzi_t res, flint_rand_t state, flint_bitcnt_t bits)¶
Properties¶
Units¶
Norms¶
Arithmetic¶
Division¶
-
void fmpzi_divexact(fmpzi_t q, const fmpzi_t x, const fmpzi_t y)¶
Sets q to the quotient of x and y, assuming that the division is exact.
-
void fmpzi_divrem(fmpzi_t q, fmpzi_t r, const fmpzi_t x, const fmpzi_t 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.
GCD¶
-
void fmpzi_gcd_euclidean(fmpzi_t res, const fmpzi_t x, const fmpzi_t y)¶
-
void fmpzi_gcd_euclidean_improved(fmpzi_t res, const fmpzi_t x, const fmpzi_t y)¶
-
void fmpzi_gcd_binary(fmpzi_t res, const fmpzi_t x, const fmpzi_t y)¶
-
void fmpzi_gcd_shortest(fmpzi_t res, const fmpzi_t x, const fmpzi_t y)¶
-
void fmpzi_gcd(fmpzi_t res, const fmpzi_t x, const fmpzi_t 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.