Ask Your Question
2

Echelon form in cython

asked 2020-10-01 12:36:01 +0200

1571 gravatar image

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2020-10-01 19:14:17 +0200

nbruin gravatar image

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

edit flag offensive delete link more

Comments

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).

1571 gravatar image1571 ( 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.

nbruin gravatar imagenbruin ( 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?

1571 gravatar image1571 ( 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.

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-10-01 12:36:01 +0200

Seen: 312 times

Last updated: Oct 01 '20