Open GiacomoPope opened 3 months ago
Here we have:
cdef extern from "flint/fmpz_mod_mat.h":
ctypedef struct fmpz_mod_mat_struct:
fmpz_mat_t mat
fmpz_t mod
ctypedef fmpz_mod_mat_struct fmpz_mod_mat_t[1]
and in the C source: https://github.com/flintlib/flint/blob/05340d2a7349761aff2cd3370810c93e2174ce46/src/fmpz_mod_types.h#L36
typedef fmpz_mat_struct fmpz_mod_mat_struct;
typedef fmpz_mod_mat_struct fmpz_mod_mat_t[1];
So maybe we want instead
cdef extern from "flint/fmpz_mod_mat.h":
ctypedef fmpz_mat_struct fmpz_mod_mat_struct:
ctypedef fmpz_mod_mat_struct fmpz_mod_mat_t[1]
oh i see there's this change in 3.1.0 versus earlier versions of flint -- so maybe that's the issue?
It is probably better to correct the struct definition but I don't know if that would break under older Flint. It might be that we can just make it an opaque struct. I assume we don't need to access the mat
or mod
members directly anywhere.
I have been seeing warnings like that for a long time coming from different parts of the codebase but I don't see them now when building with latest flint. The CI job you point to is using Flint 3.0.1 though.
We're not able to do two different struct definitions for different flint, right?
We can have different struct definitions but it needs to be done in the C preprocessor just like the other #define
:
https://github.com/flintlib/python-flint/blob/5445684db1481b806e8027499fa591c7508f6f03/src/flint/flintlib/fmpz_mod_mat.pxd#L21-L30
From Cython's perspective the struct would be opaque but we could also use the preprocessor to define macros to access the elements if needed.
so could we do:
cdef extern from "flint/fmpz_mod_mat.h":
ctypedef struct fmpz_mod_mat_struct_new:
fmpz_mat_t mat
fmpz_t mod
ctypedef fmpz_mod_mat_struct_newfmpz_mod_mat_new_t[1]
ctypedef fmpz_mat_struct fmpz_mod_mat_struct_old:
ctypedef fmpz_mod_mat_struct fmpz_mod_mat_old_t[1]
Then use #define fmpz_mod_mat_struct_old fmpz_mod_mat_struct
etc?
That might work.
I was imagining something more like
cdef extern from *
"""
#if FLINTVER < 3.1
# define compat_fmpz_mod_mat_struct ...
"""
ctypedef compat_fmpz_mod_mat_struct
If we need something to be different at the C level for different Flint versions it needs to be handled by the C preprocessor and it all needs to be opaque from Cython's perspective.
Noticed in the CI that there's something wrong about the mat_mul operations (https://github.com/flintlib/python-flint/actions/runs/10402835971/job/28808112409?pr=182)
For example