Skip to content

Commit cd98dff

Browse files
committed
Update src/NumField/Subfields.jl
1 parent 5efeca4 commit cd98dff

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

src/NumField/Subfields.jl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ end
152152
# In this case, we can use a block system to find if an element is
153153
# primitive (and find a primitive element) Input does not need to be
154154
# a basis, generators are sufficient
155-
function _subfield_primitive_element_from_basis(K::AbsSimpleNumField, as::Vector{AbsSimpleNumFieldElem})
155+
function _subfield_primitive_element_from_basis(K::AbsSimpleNumField, as::Vector{AbsSimpleNumFieldElem}, lincomb = false)
156156
if isempty(as) || degree(K) == 1
157157
return gen(K)
158158
end
@@ -183,8 +183,18 @@ function _subfield_primitive_element_from_basis(K::AbsSimpleNumField, as::Vector
183183
b = Vector{Int}[intersect(x, y) for x in b for y in _b]
184184
b = Vector{Int}[x for x in b if length(x) > 0]
185185
end
186-
@vprintln :Subfields 1 "Have block systems, degree of subfield is $(length(b))\n"
186+
@vprintln :Subfields 1 "Have block systems, degree of subfield is $(length(b))"
187187

188+
# b is the block of the subfield (with respect to the embeddings in C)
189+
190+
if lincomb
191+
return _subfield_primitive_element_from_basis_lincomb(K, b, all_b, C, as)
192+
else
193+
return _subfield_primitive_element_from_block(K, C, b)
194+
end
195+
end
196+
197+
function _subfield_primitive_element_from_basis_lincomb(K::AbsSimpleNumField, b, all_b, C, as::Vector{AbsSimpleNumFieldElem})
188198
indices = findall(x->length(x) == length(b), all_b)
189199

190200
@vprintln :Subfields 1 "Found $(length(indices)) primitive elements in the basis"
@@ -214,7 +224,7 @@ function _subfield_primitive_element_from_basis(K::AbsSimpleNumField, as::Vector
214224
cur_b = Vector{Int}[intersect(x, y) for x in cur_b for y in all_b[i]]
215225
cur_b = Vector{Int}[x for x in cur_b if length(x) > 0]
216226
j = 1
217-
while block_system(pe + j*as[i], C) != c
227+
while block_system(pe + j*as[i], C) != cur_b
218228
j += 1
219229
if j > 10
220230
error("dnw")
@@ -229,7 +239,7 @@ function _subfield_primitive_element_from_basis(K::AbsSimpleNumField, as::Vector
229239
error("should be hard...")
230240
end
231241

232-
function _subfield_from_block(K::AbsSimpleNumField, C#=::qAdicConj=#, b::Vector{Vector{Int}})
242+
function _subfield_primitive_element_from_block(K::AbsSimpleNumField, C#=::qAdicConj=#, b::Vector{Vector{Int}})
233243
@assert C isa qAdicConj
234244
# Klueners:
235245
# - try sum of conj. in block

test/NfAbs/Subfields.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,3 +453,12 @@ let
453453
LL, b = number_field(x^2 + 1, :b)
454454
@test_throws ArgumentError Hecke.subfield(L, [b])
455455
end
456+
457+
let
458+
Qx, x = QQ[:x]
459+
K, _ = number_field(x^8 - x^4 + 1, :a)
460+
b = Hecke._subfield_primitive_element_from_basis(K, [sqrt(K(2)), sqrt(K(3))], true)
461+
@test degree(minpoly(b)) == 2
462+
b = Hecke._subfield_primitive_element_from_basis(K, [sqrt(K(2)), sqrt(K(3))], false)
463+
@test degree(minpoly(b)) == 2
464+
end

0 commit comments

Comments
 (0)