Skip to content

Commit

Permalink
Update test/Rings-test.jl
Browse files Browse the repository at this point in the history
Co-authored-by: Lars Göttgens <lars.goettgens@rwth-aachen.de>
  • Loading branch information
thofma and lgoettgens committed Feb 2, 2024
1 parent 6f4d4e8 commit e6af0f4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
2 changes: 2 additions & 0 deletions src/AbstractAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const import_exclude = [:import_exclude, :QQ, :ZZ,
# imported here and in Generic.jl, and exported below.
# They should not be imported/exported anywhere else.

import LinearAlgebra

import LinearAlgebra: det
import LinearAlgebra: dot
import LinearAlgebra: hessenberg
Expand Down
3 changes: 0 additions & 3 deletions src/NemoStuff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,6 @@ end

Random.gentype(::Type{T}) where {T<:FinField} = elem_type(T)

import LinearAlgebra
LinearAlgebra.dot(a::NCRingElem, b::NCRingElem) = a * b

transpose!(A::MatrixElem) = transpose(A)

function Base.div(f::PolyRingElem, g::PolyRingElem)
Expand Down
6 changes: 3 additions & 3 deletions src/Rings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ characteristic(F::NumField) = 0
#
################################################################################

dot(x::RingElem, y::RingElem) = x * y
dot(x::NCRingElem, y::NCRingElem) = x * y

dot(x::RingElem, y::Union{Integer, Rational, AbstractFloat}) = x * y
dot(x::NCRingElem, y::Union{Integer, Rational, AbstractFloat}) = x * y

dot(x::Union{Integer, Rational, AbstractFloat}, y::RingElem) = x * y
dot(x::Union{Integer, Rational, AbstractFloat}, y::NCRingElem) = x * y
19 changes: 19 additions & 0 deletions test/NCRings-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,22 @@ end
M = matrix_space(ZZ, 2, rand(3:9))
@test_throws DomainError powers(rand(M, 1:9), rand(1:9))
end

@testset "dot" begin
dot = AbstractAlgebra.LinearAlgebra.dot

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

R = matrix_ring(QQ, 2)
x = R([1 2; 3 4])
@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
11 changes: 0 additions & 11 deletions test/Rings-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,3 @@ end
@test is_finite(GF(2))
@test !is_finite(QQ)
end

import LinearAlgebra: dot

@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

0 comments on commit e6af0f4

Please sign in to comment.