From 4c7deac5cfc383546dd0e2c8d4aa7967a57eae82 Mon Sep 17 00:00:00 2001 From: Tommy Hofmann Date: Fri, 2 Feb 2024 15:26:13 +0100 Subject: [PATCH] fix: make dot work again --- src/AbstractAlgebra.jl | 1 + src/Rings.jl | 12 ++++++++++++ test/Rings-test.jl | 9 +++++++++ 3 files changed, 22 insertions(+) diff --git a/src/AbstractAlgebra.jl b/src/AbstractAlgebra.jl index 70f18bd604..d91016ed4e 100644 --- a/src/AbstractAlgebra.jl +++ b/src/AbstractAlgebra.jl @@ -29,6 +29,7 @@ const import_exclude = [:import_exclude, :QQ, :ZZ, # They should not be imported/exported anywhere else. import LinearAlgebra: det +import LinearAlgebra: dot import LinearAlgebra: hessenberg import LinearAlgebra: ishermitian import LinearAlgebra: issymmetric diff --git a/src/Rings.jl b/src/Rings.jl index cc02013e26..282dc06245 100644 --- a/src/Rings.jl +++ b/src/Rings.jl @@ -174,3 +174,15 @@ is_finite(F::FinField) = true is_finite(F::Field) = characteristic(F) != 0 && throw(NotImplementedError(:is_finite, F)) characteristic(F::NumField) = 0 + +################################################################################ +# +# Dot +# +################################################################################ + +dot(x::RingElem, y::RingElem) = x * y + +dot(x::RingElem, y::Union{Integer, Rational, AbstractFloat}) = x * y + +dot(x::Union{Integer, Rational, AbstractFloat}, y::RingElem) = x * y diff --git a/test/Rings-test.jl b/test/Rings-test.jl index a790decd07..c3369b541c 100644 --- a/test/Rings-test.jl +++ b/test/Rings-test.jl @@ -67,3 +67,12 @@ end @test is_finite(GF(2)) @test !is_finite(QQ) end + +@testset "dot" begin + Qx, x = QQ["x"] + @test dot([x, x^2], [1, 1]) == x + x^2 + @test dot([x, x^2], Rational{BigInt}[1, 1]) == x + x^2 + @test dot([1, 1], [x, x^2]) == x + x^2 + @test dot(Rational{BigInt}[1, 1], [x, x^2]) == x + x^2 + @test dot([x], [x^2]) == x^3 +end