# Echelon form in cython

Is there an already function implemented in Cython which computes the echelon form of an integer matrix? Thanks for the help.

edit retag close merge delete

Sort by ยป oldest newest most voted

I assume you mean Hermite normal form. Yes, there are highly optimized library functions for that. See hermite_form in matrix/matrix_integer_dense.pyx

more

Yes I mean the Hermite normal form (in fact I do not care to have rational entries, so the usual echelon form is enough). But it seems to me that this library is coded in Sage, not in Cython? The point is that I have enormous matrices (e.g. of size 10^5*10^4, although there are many 0's), so I want to make use of the speed of cython (Sage is too slow).

( 2020-10-02 01:14:51 +0200 )edit

???? Look at the file extension. It's "pyx". That's cython. It may very well be possible to improve this code, but it's already received quite a bit of attention, so I'd be surprised if you can make spectacular gains.You might try playing around with the different algorithms available. One may be better suited to the type of problem you're considering than the other.

If rational echelon form is sufficient, you should do that. It's generally cheaper to compute than HNF.

( 2020-10-02 09:33:07 +0200 )edit

Sorry, I thought it had to be spyx for cython. I tried to use this library as follows: I created a file "Cython_Matrices.spyx" with the code in the webpage: https://sage.math.leidenuniv.nl/src/m...

Then I tried to load the file "Cython_Matrices.spyx" in my Sage terminal, but I have the following error: "Internal compiler error: 'sage/ext/cdefs.pxi' not found" What should I do?

( 2020-10-02 15:48:17 +0200 )edit

Not use "spyx". It's meant to be a form of "sage-preparsed cython", but I don't think it gets used very much and therefore is prone to failure. Better to just write straight-up cython as is used in the sage library, and interface with the sage libraries in the usual cythonic/pythonic way.

( 2020-10-06 04:08:09 +0200 )edit