ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 06 Oct 2020 04:08:09 +0200Echelon form in cythonhttps://ask.sagemath.org/question/53685/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.Thu, 01 Oct 2020 12:36:01 +0200https://ask.sagemath.org/question/53685/echelon-form-in-cython/Answer by nbruin for <p>Is there an already function implemented in Cython which computes the echelon form of an integer matrix?
Thanks for the help.</p>
https://ask.sagemath.org/question/53685/echelon-form-in-cython/?answer=53693#post-id-53693I assume you mean Hermite normal form. Yes, there are highly optimized library functions for that. See hermite_form in matrix/matrix_integer_dense.pyx Thu, 01 Oct 2020 19:14:17 +0200https://ask.sagemath.org/question/53685/echelon-form-in-cython/?answer=53693#post-id-53693Comment by 1571 for <p>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 </p>
https://ask.sagemath.org/question/53685/echelon-form-in-cython/?comment=53695#post-id-53695Yes 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).Fri, 02 Oct 2020 01:14:51 +0200https://ask.sagemath.org/question/53685/echelon-form-in-cython/?comment=53695#post-id-53695Comment by nbruin for <p>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 </p>
https://ask.sagemath.org/question/53685/echelon-form-in-cython/?comment=53697#post-id-53697???? 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.Fri, 02 Oct 2020 09:33:07 +0200https://ask.sagemath.org/question/53685/echelon-form-in-cython/?comment=53697#post-id-53697Comment by 1571 for <p>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 </p>
https://ask.sagemath.org/question/53685/echelon-form-in-cython/?comment=53702#post-id-53702Sorry, 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/matrix/matrix_integer_dense.pyx
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?Fri, 02 Oct 2020 15:48:17 +0200https://ask.sagemath.org/question/53685/echelon-form-in-cython/?comment=53702#post-id-53702Comment by nbruin for <p>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 </p>
https://ask.sagemath.org/question/53685/echelon-form-in-cython/?comment=53739#post-id-53739Not 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.Tue, 06 Oct 2020 04:08:09 +0200https://ask.sagemath.org/question/53685/echelon-form-in-cython/?comment=53739#post-id-53739