Skip to content

Commit

Permalink
fix: make dot work again (#1593)
Browse files Browse the repository at this point in the history
  • Loading branch information
thofma authored Feb 2, 2024
1 parent 6fda78f commit 74910f3
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/AbstractAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ 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
import LinearAlgebra: ishermitian
import LinearAlgebra: issymmetric
Expand Down
12 changes: 12 additions & 0 deletions src/NCRings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,15 @@ Base.oftype(x::NCRingElem, y::Rational) = parent(x)(y)
###############################################################################

Base.broadcastable(x::NCRingElem) = Ref(x)

################################################################################
#
# Dot
#
################################################################################

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

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

dot(x::Union{Integer, Rational, AbstractFloat}, y::NCRingElem) = x * y
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
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

2 comments on commit 74910f3

@thofma
Copy link
Member Author

@thofma thofma commented on 74910f3 Feb 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/100149

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.37.4 -m "<description of version>" 74910f34b5b5d5553a554eae387dd997ddad1156
git push origin v0.37.4

Please sign in to comment.