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..." )
230240end
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
0 commit comments