 # [ANN] Released GaloisFields v1.0

I just released v1.0 of `GaloisFields.jl`. For those people not familiar – a Galois field (or ‘finite field’) is a finite set that supports addition and multiplication, both with their inverses subtraction and division. The most well-known examples are the integers modulo a prime number p. This package allows using these sets wherever a `Number` is expected.

Commonly, a bottleneck when using Galois fields is the modulo (`mod`) operation. An interesting feature of this package is the use of broadcasting to reduce the number of these: whenever there’s a sufficient number of bits in `Int`, we postpone computing this reduction until the end. Here’s the performance effect:

``````julia> using GaloisFields
julia> const F = GaloisField(29);
julia> x = rand(F, 1000); y = rand(F, 1000); z = rand(F);
julia> @btime x .+ z .* y; # fused modulo optimization
2.547 μs (7 allocations: 1.22 KiB)
julia> @btime broadcast((x,z,y) -> x + z * y, x, z, y); # same operation, no special optimization
4.998 μs (1 allocation: 1.06 KiB)
``````

`@b-reinke` contributed bug fixes and @Keno contributed support for `BitIntegers.jl` and code to compute primitive roots of unity. For fields of prime power order, we use Frank Lübeck’s database of Conway polynomials.

4 Likes

How do cast `15` in the `GaloisField(7)`? It’s should be the identity.

Is there a function to check if an element is a generator in the field?

``````julia> using GaloisFields
julia> const F = GaloisField(7);
julia> F(15)
1
julia> convert(F, 15)
1
``````

There is, thanks to @Keno:

``````julia> GaloisFields.is_primitive_root.(F, F.(1:6), char(F) - 1)
6-element BitArray{1}:
0
0
1
0
1
0
``````
1 Like