Skip to content

Commit a35f2a5

Browse files
authored
Make Antic accept symbols and chars (Nemocas#1202)
1 parent 382e00a commit a35f2a5

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/antic/nf_elem.jl

+12-12
Original file line numberDiff line numberDiff line change
@@ -1224,22 +1224,22 @@ rand(K::AnticNumberField, r) = rand(Random.GLOBAL_RNG, K, r)
12241224
###############################################################################
12251225

12261226
@doc Markdown.doc"""
1227-
NumberField(f::fmpq_poly, s::AbstractString; cached::Bool = true, check::Bool = true)
1227+
NumberField(f::fmpq_poly, s::Union{AbstractString, Char, Symbol};
1228+
cached::Bool = true, check::Bool = true)
12281229
12291230
Return a tuple $R, x$ consisting of the parent object $R$ and generator $x$
12301231
of the number field $\mathbb{Q}[x]/(f)$ where $f$ is the supplied polynomial.
12311232
The supplied string `s` specifies how the generator of the number field
12321233
should be printed.
12331234
"""
1234-
function NumberField(f::fmpq_poly, s::AbstractString; cached::Bool = true, check::Bool = true)
1235-
S = Symbol(s)
1236-
parent_obj = AnticNumberField(f, S, cached, check)
1235+
function NumberField(f::fmpq_poly, s::Union{AbstractString, Char, Symbol}; cached::Bool = true, check::Bool = true)
1236+
parent_obj = AnticNumberField(f, Symbol(s), cached, check)
12371237

12381238
return parent_obj, gen(parent_obj)
12391239
end
12401240

12411241
@doc Markdown.doc"""
1242-
CyclotomicField(n::Int, s::AbstractString, t = "\$"; cached = true)
1242+
CyclotomicField(n::Int, s::Union{AbstractString, Char, Symbol} = "z_$n", t = "_\$"; cached = true)
12431243
12441244
Return a tuple $R, x$ consisting of the parent object $R$ and generator $x$
12451245
of the $n$-th cyclotomic field, $\mathbb{Q}(\zeta_n)$. The supplied string
@@ -1248,11 +1248,11 @@ provided, the string `t` specifies how the generator of the polynomial ring
12481248
from which the number field is constructed, should be printed. If it is not
12491249
supplied, a default dollar sign will be used to represent the variable.
12501250
"""
1251-
function CyclotomicField(n::Int, s::AbstractString = "z_$n", t = "_\$"; cached = true)
1252-
Zx, x = PolynomialRing(FlintZZ, string(gensym()); cached = cached)
1251+
function CyclotomicField(n::Int, s::Union{AbstractString, Char, Symbol} = "z_$n", t = "_\$"; cached = true)
1252+
Zx, x = PolynomialRing(FlintZZ, gensym(); cached = cached)
12531253
Qx, = PolynomialRing(FlintQQ, t; cached = cached)
12541254
f = cyclotomic(n, x)
1255-
C, g = NumberField(Qx(f), s; cached = cached, check = false)
1255+
C, g = NumberField(Qx(f), Symbol(s); cached = cached, check = false)
12561256
set_special(C, :show => show_cyclo, :cyclo => n)
12571257
return C, g
12581258
end
@@ -1264,7 +1264,7 @@ end
12641264

12651265

12661266
@doc Markdown.doc"""
1267-
CyclotomicRealSubfield(n::Int, s::AbstractString, t = "\$"; cached = true)
1267+
CyclotomicRealSubfield(n::Int, s::Union{AbstractString, Char, Symbol} = "(z_$n + 1/z_$n)", t = "\$"; cached = true)
12681268
12691269
Return a tuple $R, x$ consisting of the parent object $R$ and generator $x$
12701270
of the totally real subfield of the $n$-th cyclotomic field,
@@ -1274,11 +1274,11 @@ the generator of the polynomial ring from which the number field is
12741274
constructed, should be printed. If it is not supplied, a default dollar sign
12751275
will be used to represent the variable.
12761276
"""
1277-
function CyclotomicRealSubfield(n::Int, s::AbstractString = "(z_$n + 1/z_$n)", t = "\$"; cached = true)
1278-
Zx, x = PolynomialRing(FlintZZ, string(gensym()); cached = cached)
1277+
function CyclotomicRealSubfield(n::Int, s::Union{AbstractString, Char, Symbol} = "(z_$n + 1/z_$n)", t = "\$"; cached = true)
1278+
Zx, x = PolynomialRing(FlintZZ, gensym(); cached = cached)
12791279
Qx, = PolynomialRing(FlintQQ, t; cached = cached)
12801280
f = cos_minpoly(n, x)
1281-
R, a = NumberField(Qx(f), s; cached = cached, check = false)
1281+
R, a = NumberField(Qx(f), Symbol(s); cached = cached, check = false)
12821282
set_special(R, :show => show_maxreal, :maxreal => n)
12831283
return R, a
12841284
end

0 commit comments

Comments
 (0)