From 24ac955df7143d456766dca66d4d7955b94440a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 13 Dec 2024 10:36:15 +0100 Subject: [PATCH] Bump AbstractAlgebra to 0.44.0 (#1972) * Bump AbstractAlgebra to 0.44.0 * sanitize the solve_triu and sync with AA (#1958) * Remove duplicate polynomial call code (#1933) --------- Co-authored-by: Claus Fieker Co-authored-by: Max Horn Co-authored-by: Tommy Hofmann --- Project.toml | 2 +- src/Rings.jl | 2 -- src/flint/fmpz_mat.jl | 18 +++++++++++++++--- src/flint/fmpz_mod_poly.jl | 13 ------------- src/flint/fq_default_poly.jl | 13 ------------- src/flint/fq_nmod_poly.jl | 13 ------------- src/flint/fq_poly.jl | 13 ------------- src/flint/gfp_fmpz_poly.jl | 13 ------------- src/flint/gfp_poly.jl | 13 ------------- src/flint/nmod_poly.jl | 13 ------------- src/polysubst.jl | 35 ----------------------------------- test/flint/fmpz_mat-test.jl | 4 ++-- test/generic/Matrix-test.jl | 2 +- 13 files changed, 19 insertions(+), 135 deletions(-) delete mode 100644 src/polysubst.jl diff --git a/Project.toml b/Project.toml index 7e350b9e6..3199c52d7 100644 --- a/Project.toml +++ b/Project.toml @@ -13,7 +13,7 @@ SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce" TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76" [compat] -AbstractAlgebra = "0.43.10" +AbstractAlgebra = "0.44.0" FLINT_jll = "^300.100.100" Libdl = "1.6" LinearAlgebra = "1.6" diff --git a/src/Rings.jl b/src/Rings.jl index 671232d37..0388670a4 100644 --- a/src/Rings.jl +++ b/src/Rings.jl @@ -126,5 +126,3 @@ include("arb/ComplexMat.jl") include("gaussiannumbers/ZZi.jl") include("Factor.jl") - -include("polysubst.jl") diff --git a/src/flint/fmpz_mat.jl b/src/flint/fmpz_mat.jl index dda2c543e..f94aa3c95 100644 --- a/src/flint/fmpz_mat.jl +++ b/src/flint/fmpz_mat.jl @@ -1554,7 +1554,7 @@ function _solve_dixon(a::ZZMatrix, b::ZZMatrix) end #XU = B. only the upper triangular part of U is used -function _solve_triu_left(U::ZZMatrix, b::ZZMatrix) +function AbstractAlgebra._solve_triu_left(U::ZZMatrix, b::ZZMatrix) n = ncols(U) m = nrows(b) R = base_ring(U) @@ -1595,8 +1595,14 @@ function _solve_triu_left(U::ZZMatrix, b::ZZMatrix) return X end -#UX = B -function _solve_triu(U::ZZMatrix, b::ZZMatrix) +#UX = B, U has to be upper triangular +#I think due to the Strassen calling path, where Strasse.solve(side = :left) +#call directly AA.solve_left, this has to be in AA and cannot be independent. +function AbstractAlgebra._solve_triu(U::ZZMatrix, b::ZZMatrix; side::Symbol=:left) + if side == :left + return AbstractAlgebra._solve_triu_left(U, b) + end + @assert side == :right n = nrows(U) m = ncols(b) X = zero(b) @@ -1638,6 +1644,12 @@ function _solve_triu(U::ZZMatrix, b::ZZMatrix) return X end +#solves Ax = B for A lower triagular. if f != 0 (f is true), the diagonal +#is assumed to be 1 and not actually used. +#the upper part of A is not used/ touched. +#one cannot assert is_lower_triangular as this is used for the inplace +#lu decomposition where the matrix is full, encoding an upper triangular +#using the diagonal and a lower triangular with trivial diagonal function AbstractAlgebra._solve_tril!(A::ZZMatrix, B::ZZMatrix, C::ZZMatrix, f::Int = 0) # a x u ax = u diff --git a/src/flint/fmpz_mod_poly.jl b/src/flint/fmpz_mod_poly.jl index 34396da2e..0658b758a 100644 --- a/src/flint/fmpz_mod_poly.jl +++ b/src/flint/fmpz_mod_poly.jl @@ -823,19 +823,6 @@ promote_rule(::Type{T}, ::Type{ZZRingElem}) where {T <: Zmodn_fmpz_poly} = T promote_rule(::Type{ZZModPolyRingElem}, ::Type{ZZModRingElem}) = ZZModPolyRingElem -############################################################################### -# -# Polynomial substitution -# -############################################################################### - -function (f::ZZModPolyRingElem)(a::ZZModRingElem) - if parent(a) != base_ring(f) - return subst(f, a) - end - return evaluate(f, a) -end - ################################################################################ # # Parent object call overloads diff --git a/src/flint/fq_default_poly.jl b/src/flint/fq_default_poly.jl index b5a4a4bdd..5e6670f24 100644 --- a/src/flint/fq_default_poly.jl +++ b/src/flint/fq_default_poly.jl @@ -676,19 +676,6 @@ promote_rule(::Type{FqPolyRingElem}, ::Type{ZZRingElem}) = FqPolyRingElem promote_rule(::Type{FqPolyRingElem}, ::Type{FqFieldElem}) = FqPolyRingElem -############################################################################### -# -# Polynomial substitution -# -############################################################################### - -function (f::FqPolyRingElem)(a::FqFieldElem) - if parent(a) != base_ring(f) - return subst(f, a) - end - return evaluate(f, a) -end - ################################################################################ # # Parent object call overloads diff --git a/src/flint/fq_nmod_poly.jl b/src/flint/fq_nmod_poly.jl index 4c765f870..69c1da09b 100644 --- a/src/flint/fq_nmod_poly.jl +++ b/src/flint/fq_nmod_poly.jl @@ -679,19 +679,6 @@ promote_rule(::Type{fqPolyRepPolyRingElem}, ::Type{ZZRingElem}) = fqPolyRepPolyR promote_rule(::Type{fqPolyRepPolyRingElem}, ::Type{fqPolyRepFieldElem}) = fqPolyRepPolyRingElem -############################################################################### -# -# Polynomial substitution -# -############################################################################### - -function (f::fqPolyRepPolyRingElem)(a::fqPolyRepFieldElem) - if parent(a) != base_ring(f) - return subst(f, a) - end - return evaluate(f, a) -end - ################################################################################ # # Parent object call overloads diff --git a/src/flint/fq_poly.jl b/src/flint/fq_poly.jl index 99cec63af..ab033b5dc 100644 --- a/src/flint/fq_poly.jl +++ b/src/flint/fq_poly.jl @@ -674,19 +674,6 @@ promote_rule(::Type{FqPolyRepPolyRingElem}, ::Type{ZZRingElem}) = FqPolyRepPolyR promote_rule(::Type{FqPolyRepPolyRingElem}, ::Type{FqPolyRepFieldElem}) = FqPolyRepPolyRingElem -############################################################################### -# -# Polynomial substitution -# -############################################################################### - -function (f::FqPolyRepPolyRingElem)(a::FqPolyRepFieldElem) - if parent(a) != base_ring(f) - return subst(f, a) - end - return evaluate(f, a) -end - ################################################################################ # # Parent object call overloads diff --git a/src/flint/gfp_fmpz_poly.jl b/src/flint/gfp_fmpz_poly.jl index 5d42998ce..991a7ca2d 100644 --- a/src/flint/gfp_fmpz_poly.jl +++ b/src/flint/gfp_fmpz_poly.jl @@ -396,19 +396,6 @@ promote_rule(::Type{FpPolyRingElem}, ::Type{FpFieldElem}) = FpPolyRingElem promote_rule(::Type{FpPolyRingElem}, ::Type{ZZRingElem}) = FpPolyRingElem -############################################################################### -# -# Polynomial substitution -# -############################################################################### - -function (f::FpPolyRingElem)(a::FpFieldElem) - if parent(a) != base_ring(f) - return subst(f, a) - end - return evaluate(f, a) -end - ################################################################################ # # Parent object call overloads diff --git a/src/flint/gfp_poly.jl b/src/flint/gfp_poly.jl index 778ac4316..cb1aaddc9 100644 --- a/src/flint/gfp_poly.jl +++ b/src/flint/gfp_poly.jl @@ -479,19 +479,6 @@ promote_rule(::Type{fpPolyRingElem}, ::Type{ZZRingElem}) = fpPolyRingElem promote_rule(::Type{fpPolyRingElem}, ::Type{fpFieldElem}) = fpPolyRingElem -############################################################################### -# -# Polynomial substitution -# -############################################################################### - -function (f::fpPolyRingElem)(a::fpFieldElem) - if parent(a) != base_ring(f) - return subst(f, a) - end - return evaluate(f, a) -end - ################################################################################ # # Parent object call overloads diff --git a/src/flint/nmod_poly.jl b/src/flint/nmod_poly.jl index 296717558..bd4bab902 100644 --- a/src/flint/nmod_poly.jl +++ b/src/flint/nmod_poly.jl @@ -896,19 +896,6 @@ promote_rule(::Type{zzModPolyRingElem}, ::Type{ZZRingElem}) = zzModPolyRingElem promote_rule(::Type{zzModPolyRingElem}, ::Type{zzModRingElem}) = zzModPolyRingElem -############################################################################### -# -# Polynomial substitution -# -############################################################################### - -function (f::zzModPolyRingElem)(a::zzModRingElem) - if parent(a) != base_ring(f) - return subst(f, a) - end - return evaluate(f, a) -end - ################################################################################ # # Parent object call overloads diff --git a/src/polysubst.jl b/src/polysubst.jl deleted file mode 100644 index d4ed10d2e..000000000 --- a/src/polysubst.jl +++ /dev/null @@ -1,35 +0,0 @@ -for T in [ - zzModPolyRingElem, - fpPolyRingElem, - ZZModPolyRingElem, - FpPolyRingElem, - QQPolyRingElem, - ZZPolyRingElem, - FqPolyRepPolyRingElem, - fqPolyRepPolyRingElem, - FqPolyRingElem, - AcbPolyRingElem, - ArbPolyRingElem, - ComplexPolyRingElem, - RealPolyRingElem, - ] - (f::T)(a) = subst(f, a) - - function (f::T)(a::T) - if parent(f) != parent(a) - return subst(f, a) - end - return compose(f, a, inner = :second) - end - - (f::T)(a::Integer) = evaluate(f, a) - - function (f::T)(a::RingElem) - if parent(a) != base_ring(f) - return subst(f, a) - end - return evaluate(f, a) - end - -end - diff --git a/test/flint/fmpz_mat-test.jl b/test/flint/fmpz_mat-test.jl index fcdd232dd..f361bda45 100644 --- a/test/flint/fmpz_mat-test.jl +++ b/test/flint/fmpz_mat-test.jl @@ -710,9 +710,9 @@ end @test AbstractAlgebra.Solve.matrix_normal_form_type(A) === AbstractAlgebra.Solve.HermiteFormTrait() b = matrix(ZZ, 1, 2, [1, 6]) - @test Nemo._solve_triu_left(A, b) == matrix(ZZ, 1, 2, [1, 1]) + @test AbstractAlgebra._solve_triu_left(A, b) == matrix(ZZ, 1, 2, [1, 1]) b = matrix(ZZ, 2, 1, [3, 4]) - @test Nemo._solve_triu(A, b) == matrix(ZZ, 2, 1, [1, 1]) + @test AbstractAlgebra._solve_triu(A, b; side = :right) == matrix(ZZ, 2, 1, [1, 1]) b = matrix(ZZ, 2, 1, [1, 7]) c = similar(b) AbstractAlgebra._solve_tril!(c, A, b) diff --git a/test/generic/Matrix-test.jl b/test/generic/Matrix-test.jl index 3acf4234b..28a53bf83 100644 --- a/test/generic/Matrix-test.jl +++ b/test/generic/Matrix-test.jl @@ -135,7 +135,7 @@ end M = randmat_triu(S, -100:100) b = rand(U, -100:100) - x = AbstractAlgebra._solve_triu(M, b, false) + x = AbstractAlgebra._solve_triu_right(M, b; unipotent = false) @test M*x == b end