Tom wrote:
>
> I want to write a Cython version of a Python function f(m) where the
> input is a sage matrix of the form
>
> m= matrix(GF(p), n, k)
>
> How can I pass m to the .spyx function? I couldn't find any examples
> online.
>
> My only idea is to convert m to a matrix over Z, and then to a list,
> but I'm assuming there must be a better way.
Why not just:
f(m)
Does that not work for you?
To make things faster, you ought to declare the type of variable.
Something like this in the definition of the function should do it:
from sage.matrix.matrix_modn_dense cimport Matrix_modn_dense
def f(Matrix_modn_dense m):
....
or
from sage.matrix.matrix_modn_dense cimport Matrix_modn_dense
def f(m)
cdef Matrix_modn_dense mat = m
... (using mat instead of m)
I haven't tested the above, though.
This is assuming that p\neq 2 above. For p=2, there is:
from sage.matrix.matrix_mod2_dense cimport Matrix_mod2_dense
etc.
Jason
Jason
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---