Skip to content

Commit

Permalink
Adjust to introduction of Nemo 0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
thofma committed Sep 26, 2018
1 parent 6b52b1c commit 4f011c8
Show file tree
Hide file tree
Showing 34 changed files with 275 additions and 217 deletions.
4 changes: 2 additions & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
julia 1.0
Nemo 0.9.1 0.10.0
AbstractAlgebra 0.1.1
Nemo 0.10.1
AbstractAlgebra 0.1.3
15 changes: 5 additions & 10 deletions src/AlgAss/AlgAss.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function AlgAss(O::NfOrd, I::NfOrdIdl, p::Union{Integer, fmpz})
n = degree(O)
BO = basis(O)

Fp = ResidueRing(FlintZZ, p, cached=false)
Fp = GF(p, cached=false)
BOmod = [ mod(O(v), I) for v in BO ]
B = zero_matrix(Fp, n, n)
for i = 1:n
Expand All @@ -141,7 +141,7 @@ function AlgAss(O::NfOrd, I::NfOrdIdl, p::Union{Integer, fmpz})
bbasis = Vector{NfOrdElem}(undef, r)
for i = 1:r
for j = 1:n
b[j] = fmpz(B[i, j])
b[j] = lift(B[i, j])
end
bbasis[i] = O(b)
end
Expand Down Expand Up @@ -191,7 +191,7 @@ function AlgAss(O::NfOrd, I::NfOrdIdl, p::Union{Integer, fmpz})
end

function _preimage(a::AlgAssElem)
return sum(fmpz(a.coeffs[i])*bbasis[i] for i = 1:r)
return sum(lift(a.coeffs[i])*bbasis[i] for i = 1:r)
end

OtoA = NfOrdToAlgAssMor{elem_type(Fp)}(O, A, _image, _preimage)
Expand Down Expand Up @@ -644,7 +644,7 @@ function _primitive_element(A::AlgAss)
return nothing
end

function _primitive_element(A::AlgAss{T}) where T <: Union{nmod, fq, fq_nmod, Generic.Res{fmpz}, fmpq}
function _primitive_element(A::AlgAss{T}) where T <: Union{nmod, fq, fq_nmod, Generic.Res{fmpz}, fmpq, Generic.ResF{fmpz}, gfp_elem}
d = dim(A)
a = rand(A)
f = minpoly(a)
Expand All @@ -665,12 +665,7 @@ function _as_field(A::AlgAss{T}) where T
b = mul!(b, b, a)
elem_to_mat_row!(M, i + 1, b)
end
if T == Generic.Res{fmpz}
A, c = inv(M)
B = divexact(A, c)
elseif T == nmod
B = inv(M)
end
B = inv(M)
N = zero_matrix(base_ring(A), 1, d)
local f
let N = N, B = B
Expand Down
48 changes: 24 additions & 24 deletions src/AlgAss/AlgAssOrd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -448,24 +448,24 @@ end
###############################################################################

function quo(O::AlgAssAbsOrd, p::Int)

R=ResidueRing(FlintZZ, p, cached=false)
M=Array{nmod, 3}(undef, O.dim, O.dim, O.dim)
x=fmpz[0 for i=1:O.dim]
for i=1:O.dim
x[i]=1
N=representation_matrix(O(x))
for j=1:O.dim
for k=1:O.dim
M[i,j,k]=R(N[j,k])
# p must be prime

R = GF(p, cached = false)
M = Array{gfp_elem, 3}(undef, O.dim, O.dim, O.dim)
x = fmpz[0 for i=1:O.dim]
for i = 1:O.dim
x[i] = 1
N = representation_matrix(O(x))
for j = 1:O.dim
for k = 1:O.dim
M[i, j, k] = R(N[j, k])
end
end
x[i]=0
x[i] = 0
end
oneO=elem_in_basis(O(one(O.algebra)))
oneQ=nmod[R(s) for s in oneO]
oneO = elem_in_basis(O(one(O.algebra)))
oneQ = gfp_elem[R(s) for s in oneO]
return AlgAss(R, M, oneQ)

end

function _mod(x::fmpz_mat, y::fmpz_mat, pivots::Array{Int,1})
Expand Down Expand Up @@ -493,8 +493,8 @@ function quo(O::AlgAssAbsOrd, I::AlgAssAbsOrdIdl, p::Int)
end
end
@hassert :AlgAssOrd 1 check_ideal(I)
F= ResidueRing(FlintZZ, p, cached = false)
M=Array{nmod, 3}(undef, length(pivots), length(pivots), length(pivots))
F= GF(p, cached = false)
M=Array{gfp_elem, 3}(undef, length(pivots), length(pivots), length(pivots))
x=fmpz[0 for s=1:O.dim]
for i=1:length(pivots)
x[pivots[i]]=1
Expand All @@ -520,7 +520,7 @@ function quo(O::AlgAssAbsOrd, I::AlgAssAbsOrdIdl, p::Int)
end
end
end
oneA = Array{nmod, 1}(undef, length(pivots))
oneA = Array{gfp_elem, 1}(undef, length(pivots))
for i=1:length(pivots)
oneA[i] = F(oneO[pivots[i]])
end
Expand Down Expand Up @@ -789,7 +789,7 @@ function pradical(O::AlgAssAbsOrd, p::Int)
return pradical_meataxe(O,p)
end
n = root(O.dim,2)
F = ResidueRing(FlintZZ, p, cached=false)
F = GF(p, cached=false)

#First step: kernel of the trace matrix mod p
W = MatrixSpace(F,O.dim, O.dim, false)
Expand Down Expand Up @@ -1027,8 +1027,8 @@ function _maximal_ideals(O::AlgAssAbsOrd, p::Int)
#@show dim(A1)
@vtime :AlgAssOrd 1 lg = gens(A1)
#@show length(lg)
lM = nmod_mat[representation_matrix(lg[i]) for i=1:length(lg)]
append!(lM, nmod_mat[representation_matrix(lg[i], :right) for i=1:length(lg)])
lM = gfp_mat[representation_matrix(lg[i]) for i=1:length(lg)]
append!(lM, gfp_mat[representation_matrix(lg[i], :right) for i=1:length(lg)])
#lM = nmod_mat[representation_matrix(A1[i]) for i=1:dim(A1)]
#append!(lM, nmod_mat[representation_matrix(A1[i], :right) for i=1:dim(A1)])
M = ModAlgAss(lM)
Expand All @@ -1045,8 +1045,8 @@ function _maximal_ideals(O::AlgAssAbsOrd, I::AlgAssAbsOrdIdl, p::Int)
#@show dim(A1)
@vtime :AlgAssOrd 1 lg = gens(A1)
#@show length(lg)
lM = nmod_mat[representation_matrix(lg[i]) for i=1:length(lg)]
append!(lM, nmod_mat[representation_matrix(lg[i], :right) for i=1:length(lg)])
lM = gfp_mat[representation_matrix(lg[i]) for i=1:length(lg)]
append!(lM, gfp_mat[representation_matrix(lg[i], :right) for i=1:length(lg)])
#lM = nmod_mat[representation_matrix(A1[i]) for i=1:dim(A1)]
#append!(lM, nmod_mat[representation_matrix(A1[i], :right) for i=1:dim(A1)])
M = ModAlgAss(lM)
Expand All @@ -1057,7 +1057,7 @@ function _maximal_ideals(O::AlgAssAbsOrd, I::AlgAssAbsOrdIdl, p::Int)

end

function _from_submodules_to_ideals(M::ModAlgAss, O::AlgAssAbsOrd, I::AlgAssAbsOrdIdl, x::nmod_mat, p::fmpz, poneO::AlgAssAbsOrdElem, A1::AlgAss, A1toO::Function)
function _from_submodules_to_ideals(M::ModAlgAss, O::AlgAssAbsOrd, I::AlgAssAbsOrdIdl, x::Zmodn_mat, p::fmpz, poneO::AlgAssAbsOrdElem, A1::AlgAss, A1toO::Function)
@hassert :AlgAssOrd 1 begin r = rref(x)[1]; closure(x, M.action) == sub(rref(x)[2], 1:r, 1:cols(x)) end
m = zero_matrix(FlintZZ, rows(x)+O.dim , O.dim)
gens = Vector{AlgAssAbsOrdElem}(undef, rows(x))
Expand Down Expand Up @@ -1085,7 +1085,7 @@ function _from_submodules_to_ideals(M::ModAlgAss, O::AlgAssAbsOrd, I::AlgAssAbsO

end

function _from_submodules_to_ideals(M::ModAlgAss, O::AlgAssAbsOrd, x::nmod_mat, p::fmpz, poneO::AlgAssAbsOrdElem)
function _from_submodules_to_ideals(M::ModAlgAss, O::AlgAssAbsOrd, x::Zmodn_mat, p::fmpz, poneO::AlgAssAbsOrdElem)

@hassert :AlgAssOrd 1 begin r = rref(x)[1]; closure(x, M.action) == sub(rref(x)[2], 1:r, 1:cols(x)) end
m = zero_matrix(FlintZZ, O.dim, O.dim)
Expand Down
2 changes: 1 addition & 1 deletion src/EllCrv/Cleanup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ function mod_red(E, B)

for i in 1:length(P)
p = P[i]
R = ResidueRing(FlintZZ, p)
R = GF(p, cached = false)
Ep = EllipticCurve([R(numerator(minmodel.coeff[1])), R(numerator(minmodel.coeff[2])), R(numerator(minmodel.coeff[3])), R(numerator(minmodel.coeff[4])), R(numerator(minmodel.coeff[5]))], false) # reduction of E mod p

if disc(Ep) != 0 # can only determine group order if curve is non-singular
Expand Down
4 changes: 2 additions & 2 deletions src/EllCrv/Finite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ function order_via_schoof(E::EllCrv)
t = 0
for i = 1:L
n_i = div(product, S[i])
B = ResidueRing(FlintZZ, S[i])
B = ResidueRing(FlintZZ, S[i], cached = false)
M_i = inv(B(n_i))
M_i = M_i.data
t = t + (M_i * n_i * t_mod_l[i])
Expand Down Expand Up @@ -454,7 +454,7 @@ function t_mod_prime(l, E)

S, x = PolynomialRing(R, "x")
T, y = PolynomialRing(S, "y")
Z = ResidueRing(FlintZZ, l)
Z = GF(l, cached = false)

f = x^3 + E.coeff[1]*x + E.coeff[2]
fl = fn_from_schoof(E, l, x)
Expand Down
11 changes: 6 additions & 5 deletions src/EllCrv/Misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ function issquare(x::ResElem{fmpz})
return false, zero(R)
end
end
function issquare(x::Nemo.nmod)

function issquare(x::Union{nmod, gfp_elem})
R = parent(x)
p = modulus(R)
xnew = x.data
Expand All @@ -184,7 +185,7 @@ end
"""
function issquare(x::FinFieldElem)
R = parent(x)
S, t = PolynomialRing(R, "t")
S, t = PolynomialRing(R, "t", cached = false)

# check if x is a square by considering the polynomial f = t^2 - x
# x is a square in F_q iff f has a root in F_q
Expand Down Expand Up @@ -212,8 +213,8 @@ end
> $ax^2 + bx + c = 0$ has a root modulo $p$.
"""
function quadroots(a, b, c, p)
F_p = ResidueRing(FlintZZ, p)
R, x = PolynomialRing(F_p, "x")
F_p = GF(p, cached = false)
R, x = PolynomialRing(F_p, "x", cached = false)
f = F_p(a)*x^2 + F_p(b)*x + F_p(c)

if degree(f) == -1
Expand Down Expand Up @@ -244,7 +245,7 @@ end
> modulo $p$.
"""
function nrootscubic(b, c, d, p)
F_p = ResidueRing(FlintZZ, p)
F_p = GF(p, cached = false)
R, x = PolynomialRing(F_p, "x")
f = x^3 + F_p(b)*x^2 + F_p(c)*x + F_p(d)

Expand Down
2 changes: 1 addition & 1 deletion src/Hecke.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ for i in names(Nemo)
end

import Nemo: acb_struct, Ring, Group, Field, NmodRing, nmod, arf_struct,
elem_to_mat_row!, elem_from_mat_row,
elem_to_mat_row!, elem_from_mat_row, gfp_elem, gfp_mat, Zmodn_poly, Zmodn_mat, GaloisField,
acb_vec, array, acb_vec_clear

export @vprint, @hassert, @vtime, add_verbose_scope, get_verbose_level,
Expand Down
2 changes: 1 addition & 1 deletion src/LargeField/FB.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function induce(FB::Hecke.NfFactorBase, A::Map)
push!(prm, (i, FP.lp[id][1]))
end
else
px = PolynomialRing(ResidueRing(FlintZZ, Int(p), cached=false), "x", cached=false)[1]
px = PolynomialRing(GF(Int(p), cached=false), "x", cached=false)[1]
fpx = px(f)
gpx = px(K.pol)
#idea/ reason
Expand Down
12 changes: 6 additions & 6 deletions src/LargeField/misc2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,9 @@ function basis_rels_5(b::Array{nf_elem, 1}, no_b::Int = 250, no_rel::Int = 10000


lpx = [modular_init(K, p) for p=lp]
bp = Array{nmod_mat}(length(lpx))
bp = Array{gfp_mat}(length(lpx))
for i=1:length(lpx)
bp[i] = zero_matrix(ResidueRing(FlintZZ, lpx[i].p, cached=false), n, n)
bp[i] = zero_matrix(GF(lpx[i].p, cached=false), n, n)
for k=1:n
ap = modular_proj(b[k], lpx[i])
for l=1:n
Expand All @@ -308,11 +308,11 @@ function basis_rels_5(b::Array{nf_elem, 1}, no_b::Int = 250, no_rel::Int = 10000
end
# bp = [[deepcopy(modular_proj(x, me)) for x = b] for me = lpx]

tmp = Array{nmod_mat}(length(lpx))
lcp = Array{nmod_mat}(length(lpx))
tmp = Array{gfp_mat}(length(lpx))
lcp = Array{gfp_mat}(length(lpx))
for i=1:length(lpx)
tmp[i] = zero_matrix(ResidueRing(FlintZZ, lpx[i].p, cached=false), n, 1)
lcp[i] = zero_matrix(ResidueRing(FlintZZ, lpx[i].p, cached=false), n, 1)
tmp[i] = zero_matrix(GF(lpx[i].p, cached=false), n, 1)
lcp[i] = zero_matrix(GF(lpx[i].p, cached=false), n, 1)
end

lc = Array{Int, 1}()
Expand Down
Loading

0 comments on commit 4f011c8

Please sign in to comment.