diff --git a/src/Modules/ModuleTypes.jl b/src/Modules/ModuleTypes.jl index cdbfe1ed9571..818929471599 100644 --- a/src/Modules/ModuleTypes.jl +++ b/src/Modules/ModuleTypes.jl @@ -82,6 +82,7 @@ option is set in suitable functions. n::Int S::Vector{Symbol} d::Union{Vector{FinGenAbGroupElem}, Nothing} + default_ordering::ModuleOrdering # We register the incoming and outgoing natural morphisms. # This must be done in a way that objects can be collected by the diff --git a/src/Modules/UngradedModules/Methods.jl b/src/Modules/UngradedModules/Methods.jl index d86acd1ade09..92d66bb355f8 100644 --- a/src/Modules/UngradedModules/Methods.jl +++ b/src/Modules/UngradedModules/Methods.jl @@ -229,10 +229,14 @@ ring_map(f::SubQuoHom{<:AbstractFreeMod, <:ModuleFP, Nothing}) = nothing ring_map(f::SubQuoHom) = f.ring_map function default_ordering(F::FreeMod) - if iszero(F) - return default_ordering(base_ring(F))*ModuleOrdering(F, Orderings.ModOrdering(Vector{Int}(), :lex)) + if !isdefined(F, :default_ordering) + if iszero(F) + F.default_ordering = default_ordering(base_ring(F))*ModuleOrdering(F, Orderings.ModOrdering(Vector{Int}(), :lex)) + else + F.default_ordering = default_ordering(base_ring(F))*lex(gens(F)) + end end - return default_ordering(base_ring(F))*lex(gens(F)) + return F.default_ordering::ModuleOrdering{typeof(F)} end ############################## diff --git a/src/Modules/UngradedModules/SubModuleOfFreeModule.jl b/src/Modules/UngradedModules/SubModuleOfFreeModule.jl index ca8ae8494564..c53cb41fbe81 100644 --- a/src/Modules/UngradedModules/SubModuleOfFreeModule.jl +++ b/src/Modules/UngradedModules/SubModuleOfFreeModule.jl @@ -143,6 +143,7 @@ end Get the default ordering of `M`. """ function default_ordering(M::SubModuleOfFreeModule) + return default_ordering(ambient_free_module(M)) if !isdefined(M, :default_ordering) ord = default_ordering(ambient_free_module(M)) set_default_ordering!(M, ord) @@ -166,7 +167,14 @@ end Compute a standard basis of `submod` with respect to the given `odering``. The return type is `ModuleGens`. """ -function standard_basis(submod::SubModuleOfFreeModule; ordering::ModuleOrdering = default_ordering(submod)) +function standard_basis(submod::SubModuleOfFreeModule; ordering::Union{ModuleOrdering, Nothing} = default_ordering(submod)) + # This is to circumvent hashing of the ordering in the obviously avoidable cases + if ordering===default_ordering(submod) + for (ord, gb) in submod.groebner_basis + ord === ordering && return gb + end + end + @req is_exact_type(elem_type(base_ring(submod))) "This functionality is only supported over exact fields." gb = get!(submod.groebner_basis, ordering) do return compute_standard_basis(submod, ordering)