Ticket #14876: trac_14876_ntl_typedef.patch
File trac_14876_ntl_typedef.patch, 6.5 KB (added by , 10 years ago) |
---|
-
c_lib/include/ntl_wrap.h
# HG changeset patch # User Volker Braun <vbraun.name@gmail.com> # Date 1373468950 14400 # Wed Jul 10 11:09:10 2013 -0400 # Node ID f595d0e4210ef833f35330ede8a41012ed58390a # Parent 5d8c13e7b81a1e152855073f97a4d48ee97255d1 NTL::mat<> is now a C++ template class instead of a #define hack diff --git a/c_lib/include/ntl_wrap.h b/c_lib/include/ntl_wrap.h
a b 249 249 //////// mat_ZZ ////////// 250 250 251 251 #ifndef __cplusplus 252 structmat_ZZ;252 typedef struct {} mat_ZZ; 253 253 #endif 254 254 255 EXTERN void mat_ZZ_SetDims( structmat_ZZ* mZZ, long nrows, long ncols);256 EXTERN struct mat_ZZ* mat_ZZ_pow(const struct mat_ZZ* x, long e);257 EXTERN long mat_ZZ_nrows(const structmat_ZZ* x);258 EXTERN long mat_ZZ_ncols(const structmat_ZZ* x);259 EXTERN void mat_ZZ_setitem( structmat_ZZ* x, int i, int j, const struct ZZ* z);260 EXTERN struct ZZ* mat_ZZ_getitem(const structmat_ZZ* x, int i, int j);261 EXTERN struct ZZ* mat_ZZ_determinant(const structmat_ZZ* x, long deterministic);262 EXTERN struct mat_ZZ* mat_ZZ_HNF(const struct mat_ZZ* A, const struct ZZ* D);263 EXTERN struct ZZX* mat_ZZ_charpoly(const structmat_ZZ* A);264 EXTERN long mat_ZZ_LLL(struct ZZ **det, structmat_ZZ *x, long a, long b, long verbose);265 EXTERN long mat_ZZ_LLL_U(struct ZZ **det, struct mat_ZZ *x, structmat_ZZ *U, long a, long b, long verbose);255 EXTERN void mat_ZZ_SetDims(mat_ZZ* mZZ, long nrows, long ncols); 256 EXTERN mat_ZZ* mat_ZZ_pow(const mat_ZZ* x, long e); 257 EXTERN long mat_ZZ_nrows(const mat_ZZ* x); 258 EXTERN long mat_ZZ_ncols(const mat_ZZ* x); 259 EXTERN void mat_ZZ_setitem(mat_ZZ* x, int i, int j, const struct ZZ* z); 260 EXTERN struct ZZ* mat_ZZ_getitem(const mat_ZZ* x, int i, int j); 261 EXTERN struct ZZ* mat_ZZ_determinant(const mat_ZZ* x, long deterministic); 262 EXTERN mat_ZZ* mat_ZZ_HNF(const mat_ZZ* A, const struct ZZ* D); 263 EXTERN struct ZZX* mat_ZZ_charpoly(const mat_ZZ* A); 264 EXTERN long mat_ZZ_LLL(struct ZZ **det, mat_ZZ *x, long a, long b, long verbose); 265 EXTERN long mat_ZZ_LLL_U(struct ZZ **det, mat_ZZ *x, mat_ZZ *U, long a, long b, long verbose); 266 266 267 267 /* //////// ZZ_p ////////// */ 268 268 /* #ifndef __cplusplus */ … … 314 314 //////// mat_GF2E ////////// 315 315 316 316 #ifndef __cplusplus 317 structmat_GF2E;317 typedef struct {} mat_GF2E; 318 318 #endif 319 319 320 EXTERN void mat_GF2E_setitem( structmat_GF2E* x, int i, int j, const struct GF2E* z);320 EXTERN void mat_GF2E_setitem(mat_GF2E* x, int i, int j, const struct GF2E* z); 321 321 322 322 //////// mat_GF2 ////////// 323 323 324 324 #ifndef __cplusplus 325 structmat_GF2;325 typedef struct {} mat_GF2; 326 326 #endif 327 327 328 EXTERN void mat_GF2_setitem( structmat_GF2* x, int i, int j, const struct GF2* z);328 EXTERN void mat_GF2_setitem(mat_GF2* x, int i, int j, const struct GF2* z); -
c_lib/src/ntl_wrap.cpp
diff --git a/c_lib/src/ntl_wrap.cpp b/c_lib/src/ntl_wrap.cpp
a b 845 845 846 846 //////// mat_ZZ ////////// 847 847 848 void mat_ZZ_SetDims( structmat_ZZ* mZZ, long nrows, long ncols){848 void mat_ZZ_SetDims(mat_ZZ* mZZ, long nrows, long ncols){ 849 849 mZZ->SetDims(nrows, ncols); 850 850 } 851 851 852 struct mat_ZZ* mat_ZZ_pow(const struct mat_ZZ* x, long e)852 mat_ZZ* mat_ZZ_pow(const mat_ZZ* x, long e) 853 853 { 854 854 mat_ZZ *z = new mat_ZZ(); 855 855 power(*z, *x, e); 856 856 return z; 857 857 } 858 858 859 long mat_ZZ_nrows(const structmat_ZZ* x)859 long mat_ZZ_nrows(const mat_ZZ* x) 860 860 { 861 861 return x->NumRows(); 862 862 } 863 863 864 864 865 long mat_ZZ_ncols(const structmat_ZZ* x)865 long mat_ZZ_ncols(const mat_ZZ* x) 866 866 { 867 867 return x->NumCols(); 868 868 } 869 869 870 void mat_ZZ_setitem( structmat_ZZ* x, int i, int j, const struct ZZ* z)870 void mat_ZZ_setitem(mat_ZZ* x, int i, int j, const struct ZZ* z) 871 871 { 872 872 (*x)[i][j] = *z; 873 873 874 874 } 875 875 876 struct ZZ* mat_ZZ_getitem(const structmat_ZZ* x, int i, int j)876 struct ZZ* mat_ZZ_getitem(const mat_ZZ* x, int i, int j) 877 877 { 878 878 return new ZZ((*x)(i,j)); 879 879 } 880 880 881 struct ZZ* mat_ZZ_determinant(const structmat_ZZ* x, long deterministic)881 struct ZZ* mat_ZZ_determinant(const mat_ZZ* x, long deterministic) 882 882 { 883 883 ZZ* d = new ZZ(); 884 884 determinant(*d, *x, deterministic); 885 885 return d; 886 886 } 887 887 888 struct mat_ZZ* mat_ZZ_HNF(const struct mat_ZZ* A, const struct ZZ* D)888 mat_ZZ* mat_ZZ_HNF(const mat_ZZ* A, const struct ZZ* D) 889 889 { 890 structmat_ZZ* W = new mat_ZZ();890 mat_ZZ* W = new mat_ZZ(); 891 891 HNF(*W, *A, *D); 892 892 return W; 893 893 } 894 894 895 long mat_ZZ_LLL(struct ZZ **det, structmat_ZZ *x, long a, long b, long verbose)895 long mat_ZZ_LLL(struct ZZ **det, mat_ZZ *x, long a, long b, long verbose) 896 896 { 897 897 *det = new ZZ(); 898 898 return LLL(**det,*x,a,b,verbose); 899 899 } 900 900 901 long mat_ZZ_LLL_U(struct ZZ **det, struct mat_ZZ *x, structmat_ZZ *U, long a, long b, long verbose)901 long mat_ZZ_LLL_U(struct ZZ **det, mat_ZZ *x, mat_ZZ *U, long a, long b, long verbose) 902 902 { 903 903 *det = new ZZ(); 904 904 return LLL(**det,*x,*U,a,b,verbose); 905 905 } 906 906 907 907 908 struct ZZX* mat_ZZ_charpoly(const structmat_ZZ* A)908 struct ZZX* mat_ZZ_charpoly(const mat_ZZ* A) 909 909 { 910 910 ZZX* f = new ZZX(); 911 911 CharPoly(*f, *A); … … 928 928 } 929 929 930 930 931 void mat_GF2E_setitem( structmat_GF2E* x, int i, int j, const struct GF2E* z)931 void mat_GF2E_setitem(mat_GF2E* x, int i, int j, const struct GF2E* z) 932 932 { 933 933 (*x)[i][j] = *z; 934 934 } 935 935 936 void mat_GF2_setitem( structmat_GF2* x, int i, int j, const struct GF2* z)936 void mat_GF2_setitem(mat_GF2* x, int i, int j, const struct GF2* z) 937 937 { 938 938 (*x)[i][j] = *z; 939 939 } -
sage/libs/ntl/decl.pxi
diff --git a/sage/libs/ntl/decl.pxi b/sage/libs/ntl/decl.pxi
a b 22 22 23 23 cdef extern from "ntl_wrap.h": 24 24 #### mat_ZZ_c 25 c typedef struct mat_ZZ_c "structmat_ZZ":25 cdef cppclass mat_ZZ_c "mat_ZZ": 26 26 pass 27 27 28 28 # Some boiler-plate … … 260 260 object vec_GF2E_to_PyString "_to_PyString<vec_GF2E>"(vec_GF2E_c *x) 261 261 262 262 #### mat_GF2E_c 263 c typedef struct mat_GF2E_c "structmat_GF2E":263 cdef cppclass mat_GF2E_c "mat_GF2E": 264 264 void (*SetDims)(long nrows, long ncols) 265 265 long (*NumRows)() 266 266 long (*NumCols)() … … 311 311 312 312 313 313 #### mat_GF2_c 314 c typedef struct mat_GF2_c "structmat_GF2":314 cdef cppclass mat_GF2_c "mat_GF2": 315 315 void (*SetDims)(long nrows, long ncols) 316 316 long (*NumRows)() 317 317 long (*NumCols)() -
sage/schemes/hyperelliptic_curves/hypellfrob.pyx
diff --git a/sage/schemes/hyperelliptic_curves/hypellfrob.pyx b/sage/schemes/hyperelliptic_curves/hypellfrob.pyx
a b 119 119 120 120 cdef int result 121 121 sig_on() 122 result = hypellfrob_matrix(mm.x, pp.x, N, QQ.x) 122 cdef mat_ZZ_c *mm_x = &mm.x # workaround for Cython misfeature 123 result = hypellfrob_matrix(mm_x[0], pp.x, N, QQ.x) 123 124 sig_off() 124 125 125 126 if not result: