From 8fe5835d22caf8c213cbae907170eaf95e9b473b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Tue, 5 Dec 2023 18:40:37 +0100 Subject: [PATCH] Optimize some dispatches of `*_type` (#1517) * Optimize two dispatches of `elem_type` * Optimize two dispatches of `parent_type` * Remove unnecessary dispatches for `dense_matrix_type` --- src/NemoStuff.jl | 2 -- src/generic/LaurentSeries.jl | 8 ++++---- src/generic/PuiseuxSeries.jl | 8 ++++---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/NemoStuff.jl b/src/NemoStuff.jl index 17cd2cd497..42c92a32eb 100644 --- a/src/NemoStuff.jl +++ b/src/NemoStuff.jl @@ -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 diff --git a/src/generic/LaurentSeries.jl b/src/generic/LaurentSeries.jl index a09eec8dd8..bd78fa8300 100644 --- a/src/generic/LaurentSeries.jl +++ b/src/generic/LaurentSeries.jl @@ -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) diff --git a/src/generic/PuiseuxSeries.jl b/src/generic/PuiseuxSeries.jl index f83a7b9f38..01967ac04e 100644 --- a/src/generic/PuiseuxSeries.jl +++ b/src/generic/PuiseuxSeries.jl @@ -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))