Skip to content

Understanding the (partial) duplication of AbstractAlgebra.hnf_kb! in Hecke #2111

@fingolfin

Description

@fingolfin

In AA we have in src/Matrix.jl:5059:

function hnf_kb!(H, U, with_trafo::Bool = false, start_element::Int = 1)

Actually with https://github.com/Nemocas/AbstractAlgebra.jl/pull/2256 it will become

function hnf_kb!(H::MatrixElem{T}, U::MatrixElem{T}, with_trafo::Bool = false, start_element::Int = 1) where {T <: RingElement}

In Hecke, we have in src/LocalField/Matrix.jl:95:

function AbstractAlgebra.hnf_kb!(H::MatrixElem{T}, U::MatrixElem{T}, with_trafo::Bool = false, start_element::Int = 1) where T <: Hecke.LocalFieldValuationRingElem

Looking at the code, this is almost identical to the code in AA. The differences are:

  1. a bunch irrelevant ones (commented out debug code, addition of AbstractAlgebra. prefixes, the restriction of T to LocalFieldValuationRingElem)
  2. a switch from gcdx to the undocumented gcdxx
  3. insertion of pivot_max = col1 of an if with_trafo block

I am mostly concerned about point 3. As I see it, most likely this is either a bug in the Hecke version of the code (e.g. accidental leftover from some debugging); or it is a fix for an issue, but then shouldn't it also be in AA?

The fact that 3 happens only inside an if with_trafo makes me consider the "it's a bug" version as more likely (it is also indented incorrectly, further supporting this).

Regarding point 2, using gcdxx seems indeed superior to the code in AA (which uses gcdx plus some divisions)? So it'd be nice to use it in AA as well. Then we could delete the copy of hnf_kb! in Hecke. But that would require adding a bunch of "missing" gcdxx methods (resp. adding one general "fallback" method which calls gcdx ? and then as many as we can that are optimized)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions