diff --git a/benchmark/experiments/normalform_f4.jl b/benchmark/experiments/normalform_f4.jl new file mode 100644 index 00000000..a998ef01 --- /dev/null +++ b/benchmark/experiments/normalform_f4.jl @@ -0,0 +1,26 @@ + +include("../../src/Groebner.jl") + +if !isdefined(Main, :Groebner) + import Groebner +end + +import AbstractAlgebra +using Nemo +using BenchmarkTools +using Logging +global_logger(ConsoleLogger(stderr, Logging.Error)) + +BenchmarkTools.DEFAULT_PARAMETERS.samples = 4 + +system = Groebner.cyclicn(7, ground=Nemo.QQ, ordering=:degrevlex) +gb = Groebner.groebner(system); +xs = gens(parent(system[1])) + +@time Groebner.normalform(gb, system, check=false); +collect([AbstractAlgebra.normal_form(s, gb) for s in system]) + +@benchmark Groebner.normalform($gb, $system, check=false) +@benchmark for s in system + AbstractAlgebra.normal_form(s, gb) +end diff --git a/src/arithmetic/QQ.jl b/src/arithmetic/QQ.jl index ea7b63e2..1385f533 100644 --- a/src/arithmetic/QQ.jl +++ b/src/arithmetic/QQ.jl @@ -3,4 +3,15 @@ # All implementations of arithmetic in QQ are a subtype of it. abstract type AbstractArithmeticQQ end -struct BuiltinArithmeticQQ <: AbstractArithmeticQQ end +struct BuiltinArithmeticQQ <: AbstractArithmeticQQ + buf1::BigInt + buf2::Rational{BigInt} + function BuiltinArithmeticQQ() + new(BigInt(0), Rational{BigInt}(0)) + end +end + +# arithmetic over rational numbers +function select_arithmetic(coeffs::Vector{Vector{T}}, ch) where {T <: CoeffQQ} + BuiltinArithmeticQQ() +end diff --git a/src/arithmetic/Zp.jl b/src/arithmetic/Zp.jl index 968ccf01..1c6739fa 100644 --- a/src/arithmetic/Zp.jl +++ b/src/arithmetic/Zp.jl @@ -66,8 +66,3 @@ end function select_arithmetic(coeffs::Vector{Vector{T}}, ch) where {T <: CoeffFF} SpecializedBuiltinArithmeticZp(convert(T, ch)) end - -# arithmetic over rational numbers -function select_arithmetic(coeffs::Vector{Vector{T}}, ch) where {T <: CoeffQQ} - ch -end diff --git a/src/f4/matrix.jl b/src/f4/matrix.jl index 67f78f0a..e8132afc 100644 --- a/src/f4/matrix.jl +++ b/src/f4/matrix.jl @@ -215,15 +215,16 @@ function reduce_by_pivot!( row::Vector{T}, indices::Vector{ColumnIdx}, cfs::Vector{T}, - ch + arithmetic::BuiltinArithmeticQQ ) where {T <: CoeffQQ} @inbounds mul = -row[indices[1]] - + buf2 = arithmetic.buf2 @inbounds for j in 1:length(indices) idx = indices[j] row[idx] = row[idx] + mul * cfs[j] + # Base.GMP.MPQ.mul!(buf2, cfs[j], mul) + # row[idx] = row[idx] + buf2 end - nothing end