Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
Expand Down
3 changes: 2 additions & 1 deletion src/CommutativeRings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export characteristic, dimension, order
export ofindex
export generator, generators
export homomorphism
export num_primitives, isprimitive
export num_primitives, isprimitive, ismonomprimitive
export elementary_symmetric, newton_symmetric

export VectorSpace, complement, sum, intersect, isequal, issubset
Expand Down Expand Up @@ -97,6 +97,7 @@ include("fourier.jl")
include("fastmultiply.jl")
include("algebraic.jl")
include("numberfield.jl")
include("luebeck.jl")

using .SpecialPowerSeries
using .Conway
Expand Down
4 changes: 2 additions & 2 deletions src/algebraic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ end

Return the algebraic number at `exp(pi * r * im)`.
"""
Base.cispi(q::Q) where Q<:QQ = cispi(Q, value(q))
function Base.cispi(Q::Type{<:QQ}, r::Rational{<:Integer})
Base.cispi(q::Q) where Q<:QQ = _cispi(Q, value(q))
function _cispi(Q::Type{<:QQ}, r::Rational{<:Integer})
r = mod(r + 1, 2) - 1
r //= 2
num = numerator(r)
Expand Down
3 changes: 2 additions & 1 deletion src/conway.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@ function conway(p::Integer, n::Integer, X::Symbol = :x)
end

"""
isconway(::Type{GaloisField})
is_conway(::Type{GaloisField})

Return true, iff the modulus of the field is the standard conway polynomial.
"""
function is_conway(::Type{G}) where {G<:Union{GaloisField,Quotient{<:UnivariatePolynomial}}}
p = modulus(G)
p == conway(characteristic(G), dimension(G), varname(p))
end
is_conway(a::Type{Union{}}) = merror(is_conway, (a,))

"""
quasi_conway(p, m, X::Symbol, nr::Integer=1, factors=nothing)
Expand Down
3 changes: 0 additions & 3 deletions src/determinant.jl
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,6 @@ function reduce_off_diagonal!(a, u, k, piv, round)
end
end

Base.div(a::T, b::T, round::RoundingMode) where T<:ZZ = T(div(value(a), value(b), round))
Base.div(a::T, b::T, ::RoundingMode) where T<:Ring = div(a, b)

#
# u, v unimodular, d diagonal with mod(d[i+1,i+1], d[i,i]) == 0
# u * a * v = d
Expand Down
20 changes: 13 additions & 7 deletions src/enumerations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function iterate(::Type{Z}, s) where Z<:ZZmod
v = Z(s.val + 1)
iszero(v) ? nothing : (v, v)
end
function iterate(::Type{Q}, s) where {Z<:ZZmod,P<:UnivariatePolynomial{Z},Q<:Quotient{P}}
function iterate(::Type{Q}, s) where {Z,P<:UnivariatePolynomial{Z},Q<:Quotient{P}}
c = coeffs(s.val)
m = length(c)
n = deg(modulus(Q))
Expand Down Expand Up @@ -46,22 +46,21 @@ function next(c)
cs === nothing ? nothing : cs[1]
end

function iterate(::Type{G}) where G<:GaloisField
G(0), 0
end
iterate(::Type{G}, s...) where G<:GaloisField = _iterate(CType(G), s...)
_iterate(::CType{G}) where G<:GaloisField = (G(0), 0)

function iterate(::Type{G}, s::Integer) where G<:GaloisField
function _iterate(::CType{G}, s::Integer) where G<:GaloisField
s += 1
s >= order(G) && return nothing
ofindex(s, G), s
end

function next(g::G) where G<:GaloisField
s = gettypevar(G).exptable[g.val+1] + 1
s = tonumber(g) + 1
s >= order(G) ? nothing : ofindex(s, G)
end

Base.eltype(::Monic{Z,X}) where {X,Z<:Ring} = Z[X]
Base.eltype(::Type{<:Monic{Z,X}}) where {X,Z<:Ring} = Z[X]
IteratorSize(::Type{<:Monic{Z}}) where Z = IteratorSize(Z)
length(m::Monic{Z}) where Z = intpower(length(Z), m.n)

Expand Down Expand Up @@ -93,6 +92,11 @@ function _iterate(mo::Monic{Z,X}, s, ::IsInfinite) where {X,Z}
ofindex(s, P, mo.n) + monom(P, mo.n), s + 1
end

"""
isqrt2(i::Integer)

Return the smallest integer `x`, for which `x^2 >= 2i`.
"""
isqrt2(i::T) where T<:Integer = T(floor(sqrt(8 * i + 1) - 1)) ÷ 2
function ipair(i::Integer)
m = isqrt2(i)
Expand Down Expand Up @@ -139,6 +143,7 @@ function indexv(i::T, nn::Vector{T}) where T<:Integer
end

len(::Type, d...) = 0
len(::Type{Union{}}, d...) = 0
len(T::Type{<:ZZmod}, d...) = modulus(T)
function len(T::Type{<:FractionRing{S}}, d...) where S
n = len(S, d...)
Expand All @@ -148,6 +153,7 @@ len(T::Type{<:UnivariatePolynomial{S}}, d::Integer) where S = intpower(len(S), d
len(T::Type{<:QuotientRing{S}}) where S<:UnivariatePolynomial = len(S, deg(modulus(T) - 1))
len(T::Type{<:GaloisField}) = order(T)

ofindex(a::Integer, u::Type{Union{}}) = throw(MethodError(ofindex, (a, u)))
ofindex(a::Integer, T::Type{<:Unsigned}) = T(a)
ofindex(a::Integer, T::Type{<:Signed}) = iseven(a) ? -(T(a) >> 1) : T(a + 1) >> 1
ofindex(a::Integer, T::Type{ZZ{S}}) where S = T(ofindex(a, S))
Expand Down
12 changes: 8 additions & 4 deletions src/factorization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ end
function num_irreducibles(::Type{G}, r) where G<:Ring
num_irreducibles(G[:x], r)
end
num_irreducibles(a::Type{Union{}}) = throw(MethodError(num_irreducibles, (a,)))

"""
isirreducible(p::F[X])
Expand All @@ -42,6 +43,7 @@ import Base.Iterators: Filter, take, drop

Returns an irreducible polynomial with in `P` with degree `n`. Skip first `nr` hits.
"""
irreducible(a::Type{Union{}}, s...) = merror(irreducible, (a, s...))
irreducible(::Type{P}, n) where P<:UnivariatePolynomial = first(irreducibles(P, n))
function irreducible(::Type{P}, n, nr::Integer) where P<:UnivariatePolynomial
first(drop(irreducibles(P, n), nr))
Expand All @@ -51,6 +53,7 @@ end

Returns a reducible polynomial with in `P` with degree `n`. Skip first `nr` hits.
"""
reducible(a::Type{Union{}}, s...) = merror(reducible, (a, s...))
reducible(::Type{P}, n) where P<:UnivariatePolynomial = first(reducibles(P, n))
function reducible(::Type{P}, n, nr::Integer) where P<:UnivariatePolynomial
first(drop(reducibles(P, n), nr))
Expand All @@ -68,6 +71,7 @@ reducibles(P, n)

Returns iterator of all reducible monic polynomials in `P` with degree `n`.
"""
irreducibles(a::Type{Union{}}, s...) = merror(reducibles, (a, s...))
function reducibles(::Type{P}, n) where P<:UnivariatePolynomial{<:Ring}
Base.Iterators.Filter(!isirreducible, Monic(P, n))
end
Expand Down Expand Up @@ -228,11 +232,11 @@ function isddf(f::P) where {Z<:QuotientRing,P<:UnivariatePolynomial{Z}}
q = order(Z)
x = monom(typeof(f), 1)
i = 1
fs = f
xqi = x
while deg(fs) >= 2i
xqi = powermod(xqi, q, fs)
g = gcd(fs, xqi - x)
d = deg(f)
while d >= 2i
xqi = powermod(xqi, q, f)
g = gcd(f, xqi - x)
deg(g) > 0 && return false
i += 1
end
Expand Down
3 changes: 2 additions & 1 deletion src/fraction.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

# class constructors
Frac(a::Type{Union{}}, s...) = merror(irreducible, (a, s...))
Frac(::Type{R}) where R<:Ring = Frac{R}
Frac(::Type{<:ZZ{R}}) where R<:Integer = QQ{R}
Frac(::Type{R}) where R<:Integer = QQ{R}
Expand Down Expand Up @@ -93,7 +94,7 @@ function Frac(a::T, b::T) where T<:Polynomial
a /= s
Frac{typeof(a)}(a, b, NOCHECK)
end
Frac(a::T, b::T) where T<:ZZ = QQ(a, b)
Frac(a::T, b::T) where T<:ZI = QQ(a, b)

//(a::T, b::T) where T<:QQ = a / b
//(a::T, b::T) where T<:Ring = Frac(a, b)
Expand Down
Loading