Skip to content

Commit

Permalink
Optimize some dispatches of *_type (#1517)
Browse files Browse the repository at this point in the history
* Optimize two dispatches of `elem_type`

* Optimize two dispatches of `parent_type`

* Remove unnecessary dispatches for `dense_matrix_type`
  • Loading branch information
lgoettgens authored Dec 5, 2023
1 parent c7804d9 commit 8fe5835
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 0 additions & 2 deletions src/NemoStuff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ function identity_matrix(::Type{MatElem}, R::Ring, n::Int)
return identity_matrix(R, n)
end

dense_matrix_type(::Type{T}) where {T} = Generic.MatSpaceElem{T}

################################################################################
#
# Unsafe functions for generic matrices
Expand Down
8 changes: 4 additions & 4 deletions src/generic/LaurentSeries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ function O(a::LaurentSeriesElem{T}) where T <: RingElement
return parent(a)(Vector{T}(undef, 0), 0, val, val, 1)
end

parent_type(::Type{T}) where {S <: RingElement, T <: LaurentSeriesRingElem{S}} = LaurentSeriesRing{S}
parent_type(::Type{LaurentSeriesRingElem{T}}) where T <: RingElement = LaurentSeriesRing{T}

parent_type(::Type{T}) where {S <: FieldElement, T <: LaurentSeriesFieldElem{S}} = LaurentSeriesField{S}
parent_type(::Type{LaurentSeriesFieldElem{T}}) where T <: FieldElement = LaurentSeriesField{T}

parent(a::LaurentSeriesElem) = a.parent

elem_type(::Type{T}) where {S <: RingElement, T <: LaurentSeriesRing{S}} = LaurentSeriesRingElem{S}
elem_type(::Type{LaurentSeriesRing{T}}) where T <: RingElement = LaurentSeriesRingElem{T}

elem_type(::Type{T}) where {S <: FieldElement, T <: LaurentSeriesField{S}} = LaurentSeriesFieldElem{S}
elem_type(::Type{LaurentSeriesField{T}}) where T <: FieldElement = LaurentSeriesFieldElem{T}

base_ring_type(::Type{LaurentSeriesRing{T}}) where T <: RingElement = parent_type(T)

Expand Down
8 changes: 4 additions & 4 deletions src/generic/PuiseuxSeries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ function O(a::PuiseuxSeriesElem{T}) where T <: RingElement
return parent(a)(laur, denominator(val))
end

parent_type(::Type{T}) where {S <: RingElement, T <: PuiseuxSeriesRingElem{S}} = PuiseuxSeriesRing{S}
parent_type(::Type{PuiseuxSeriesRingElem{T}}) where T <: RingElement = PuiseuxSeriesRing{T}

parent_type(::Type{T}) where {S <: FieldElement, T <: PuiseuxSeriesFieldElem{S}} = PuiseuxSeriesField{S}
parent_type(::Type{PuiseuxSeriesFieldElem{T}}) where T <: FieldElement = PuiseuxSeriesField{T}

parent(a::PuiseuxSeriesElem) = a.parent

elem_type(::Type{T}) where {S <: RingElement, T <: PuiseuxSeriesRing{S}} = PuiseuxSeriesRingElem{S}
elem_type(::Type{PuiseuxSeriesRing{T}}) where T <: RingElement = PuiseuxSeriesRingElem{T}

elem_type(::Type{T}) where {S <: FieldElement, T <: PuiseuxSeriesField{S}} = PuiseuxSeriesFieldElem{S}
elem_type(::Type{PuiseuxSeriesField{T}}) where T <: FieldElement = PuiseuxSeriesFieldElem{T}

base_ring(R::PuiseuxSeriesRing{T}) where T <: RingElement = base_ring(laurent_ring(R))

Expand Down

0 comments on commit 8fe5835

Please sign in to comment.