Open fieker opened 4 years ago
So QQ(:x)
does not work (should it?), but I tried this:
julia> R, y = FractionField(QQ[:x][1])[:y]
(Univariate Polynomial Ring in y over Fraction field of Univariate Polynomial Ring in x over Rational Field, y)
julia> factor(y)
ERROR: MethodError: no method matching factor(::AbstractAlgebra.Generic.Poly{AbstractAlgebra.Generic.Frac{fmpq_poly}})
Closest candidates are:
factor(::PolyElem, ::AbstractAlgebra.Field) at /Users/mhorn/.julia/packages/AbstractAlgebra/KPT2D/src/generic/Misc/Poly.jl:25
factor(::T) where T<:Union{Int64, UInt64} at /Users/mhorn/.julia/packages/Nemo/p0uGs/src/flint/fmpz.jl:1301
factor(::FracElem, ::AbstractAlgebra.Ring) at /Users/mhorn/.julia/packages/AbstractAlgebra/KPT2D/src/generic/Misc/Poly.jl:31
...
Stacktrace:
[1] factor(a::AbstractAlgebra.Generic.Poly{AbstractAlgebra.Generic.Frac{fmpq_poly}}; b::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Hecke ~/.julia/packages/Hecke/M7nVW/src/Misc/Integer.jl:721
[2] factor(a::AbstractAlgebra.Generic.Poly{AbstractAlgebra.Generic.Frac{fmpq_poly}})
@ Hecke ~/.julia/packages/Hecke/M7nVW/src/Misc/Integer.jl:721
[3] top-level scope
@ REPL[82]:1
julia> quo(R, y)
ERROR: MethodError: no method matching quo(::AbstractAlgebra.Generic.PolyRing{AbstractAlgebra.Generic.Frac{fmpq_poly}}, ::AbstractAlgebra.Generic.Poly{AbstractAlgebra.Generic.Frac{fmpq_poly}})
Closest candidates are:
quo(::S, ::Hecke.AbsAlgAssIdl{S, T, U}) where {S, T, U} at /Users/mhorn/.julia/packages/Hecke/M7nVW/src/AlgAss/Ideal.jl:428
Stacktrace:
[1] top-level scope
@ REPL[83]:1
So is the first part something for @tthsqe12's generic factorization implementation in Julia?
I don't think there is a generic factorization implementation yet.
the factoring over rational function fields is only implemented for the multivariate type and for only one level deep, i.e.
julia> R, (y,) = PolynomialRing(FractionField(PolynomialRing(QQ, [:x])[1]), [:y])
(Multivariate Polynomial Ring in y over Fraction field of Multivariate Polynomial Ring in x over Rational Field, AbstractAlgebra.Generic.MPoly{AbstractAlgebra.Generic.Frac{fmpq_mpoly}}[y])
julia> factor(y^2)
1 * y^2
One simply needs to add the 2^2 - 1=3 other methods for the other combinations involving the univariate versions of these rings.
And, yes, there is no "generic factoring". What there is is a methods for factoring multivariates over characteristic zero fields assuming that univariate factorization over that same field already exists.
So in general we have a reduction F[x1, ..., xn] -> F[x]. But for fraction fields F as here we could do the reduction F[x] -> F[x1,] (univariate to fake univariate)?
In order to solve the factoring issue and not turn Rings/mpoly-nested.jl into a disgrace, I support supporting univariate polys (PolyElems) in
MPolyBuildCtx
coefficients
exponent_vectors
push_term!
ok?
I think it is fine. Do you see possible problems down the road?
well, coefficients returns zero stuff for univariates, but as long as the exponent_vectors matches, I don't see a huge problem, except for the people expecting non-zero coeffs. They will have their expectation and dreams shattered. Or, can we change the behaviour of coefficients for univars?
I don't know. If I remember correctly, at some point this was moved from Hecke to AA. So maybe @fieker has an opinion on what the behaviour should be and if it should be changed.
Can this be closed? The factoring woes have been addressed:
julia> R, y = fraction_field(QQ[:x][1])[:y]
(Univariate polynomial ring in y over fraction field, y)
julia> factor(y)
1 * y
julia> quo(R,y)
(Residue ring of R modulo y, Map: R -> residue ring)
Not sure what @fieker means by " for elems in the quotient, charpoly, minpoly does not work (via rep-mat?)"
Consider f in R = QQ(x)[y], then
Just to note this down somewhere, possibly to be done in AA, or partially in Nemo