=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/engine/nd.h,v retrieving revision 1.32 retrieving revision 1.39 diff -u -p -r1.32 -r1.39 --- OpenXM_contrib2/asir2000/engine/nd.h 2015/08/06 10:01:52 1.32 +++ OpenXM_contrib2/asir2000/engine/nd.h 2020/10/04 03:14:08 1.39 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.h,v 1.31 2013/12/20 02:02:24 noro Exp $ */ +/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.h,v 1.38 2018/03/29 01:32:52 noro Exp $ */ #include "ca.h" #include "parse.h" #include "ox.h" @@ -8,7 +8,7 @@ #if defined(__GNUC__) #define INLINE static inline -#elif defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) +#elif defined(VISUAL) || defined(__MINGW32__) #define INLINE __inline #else #define INLINE @@ -24,102 +24,104 @@ typedef unsigned int UINT; /* GeoBucket for polynomial addition */ typedef struct oPGeoBucket { - int m; - struct oND *body[32]; + int m; + struct oND *body[32]; } *PGeoBucket; /* distributed polynomial; linked list rep. */ typedef struct oND { - struct oNM *body; - int nv; - int len; - int sugar; + struct oNM *body; + int nv; + int len; + int sugar; } *ND; /* distributed polynomial; array rep. */ typedef struct oNDV { - struct oNMV *body; - int nv; - int len; - int sugar; + struct oNMV *body; + int nv; + int len; + int sugar; } *NDV; typedef union oNDC { - int m; - Q z; - GZ gz; - P p; - R r; - DAlg a; + int m; + Q z; + LM lm; + GZ gz; + P p; + R r; + DAlg a; } *NDC; /* monomial; linked list rep. */ typedef struct oNM { - struct oNM *next; - union oNDC c; - UINT dl[1]; + struct oNM *next; + union oNDC c; + UINT dl[1]; } *NM; /* monomial; array rep. */ typedef struct oNMV { - union oNDC c; - UINT dl[1]; + union oNDC c; + UINT dl[1]; } *NMV; /* history of reducer */ typedef struct oRHist { - struct oRHist *next; - int index; - int sugar; - UINT dl[1]; + struct oRHist *next; + int index; + int sugar; + UINT dl[1]; } *RHist; /* S-pair list */ typedef struct oND_pairs { - struct oND_pairs *next; - int i1,i2; - int sugar; - UINT lcm[1]; + struct oND_pairs *next; + int i1,i2; + int sugar; + int sugar2; + UINT lcm[1]; } *ND_pairs; /* index and shift count for each exponent */ typedef struct oEPOS { - int i; /* index */ - int s; /* shift */ + int i; /* index */ + int s; /* shift */ } *EPOS; typedef struct oBlockMask { - int n; - struct order_pair *order_pair; - UINT **mask; + int n; + struct order_pair *order_pair; + UINT **mask; } *BlockMask; typedef struct oBaseSet { - int len; - NDV *ps; - UINT **bound; + int len; + NDV *ps; + UINT **bound; } *BaseSet; typedef struct oNM_ind_pair { - NM mul; - int index,sugar; + NM mul; + int index,sugar; } *NM_ind_pair; typedef struct oIndArray { - char width; - int head; - union { - unsigned char *c; - unsigned short *s; - unsigned int *i; - } index; + char width; + int head; + union { + unsigned char *c; + unsigned short *s; + unsigned int *i; + } index; } *IndArray; typedef struct oNDVI { - NDV p; - int i; + NDV p; + int i; } *NDVI; extern int (*ndl_compare_function)(UINT *a1,UINT *a2); @@ -142,11 +144,13 @@ extern int *current_module_weight_vector; #define HTD(d) (TD(HDL(d))) #define HCU(d) ((d)->body->c) #define HCM(d) ((d)->body->c.m) +#define HCLM(d) ((d)->body->c.lm) #define HCQ(d) ((d)->body->c.z) #define HCZ(d) ((d)->body->c.gz) #define HCP(d) ((d)->body->c.p) #define HCA(d) ((d)->body->c.a) #define CM(x) ((x)->c.m) +#define CLM(x) ((x)->c.lm) #define CQ(x) ((x)->c.z) #define CZ(x) ((x)->c.gz) #define CP(x) ((x)->c.p) @@ -174,7 +178,7 @@ extern int *current_module_weight_vector; (nd_dcomp>0?TD_DL_COMPARE(d1,d2)\ :(nd_dcomp==0?ndl_lex_compare(d1,d2)\ :(nd_blockmask?ndl_block_compare(d1,d2)\ - :(*ndl_compare_function)(d1,d2)))) + :(*ndl_compare_function)(d1,d2)))) #else #define DL_COMPARE(d1,d2)\ (nd_dcomp>0?TD_DL_COMPARE(d1,d2):(*ndl_compare_function)(d1,d2)) @@ -237,6 +241,7 @@ void removecont_array_q(Q *c,int n); ND normalize_pbucket(int mod,PGeoBucket g); int head_pbucket(int mod,PGeoBucket g); int head_pbucket_q(PGeoBucket g); +int head_pbucket_lf(PGeoBucket g); void add_pbucket_symbolic(PGeoBucket g,ND d); void add_pbucket(int mod,PGeoBucket g,ND d); void free_pbucket(PGeoBucket b); @@ -261,7 +266,7 @@ int ndv_newps(int m,NDV a,NDV aq,int f4); /* top level functions */ void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int f4,struct order_spec *ord,LIST *rp); void nd_gr_trace(LIST f,LIST v,int trace,int homo,int f4,struct order_spec *ord,LIST *rp); -NODE nd_f4(int m,int **indp); +NODE nd_f4(int m,int checkonly,int **indp); NODE nd_gb(int m,int ishomo,int checkonly,int gensyz,int **indp); NODE nd_gb_trace(int m,int ishomo,int **indp); NODE nd_f4_trace(int m,int **indp); @@ -288,6 +293,7 @@ INLINE int ndl_hash_value(UINT *d); /* normal forms */ INLINE int ndl_find_reducer(UINT *g); int nd_sp(int mod,int trace,ND_pairs p,ND *nf); +int nd_sp_f4(int m,int trace,ND_pairs l,PGeoBucket bucket); int nd_nf(int mod,ND d,ND g,NDV *ps,int full,NDC dn,ND *nf); int nd_nf_pbucket(int mod,ND g,NDV *ps,int full,ND *nf); @@ -321,6 +327,7 @@ void ndv_mod(int mod,NDV p); NDV ndv_dup(int mod,NDV p); NDV ndv_symbolic(int mod,NDV p); ND nd_dup(ND p); +int ndv_ishomo(NDV p); /* ND functions */ int ndv_check_membership(int m,NODE input,int obpe,int oadv,EPOS oepos,NODE cand); @@ -343,11 +350,15 @@ INLINE int nd_length(ND p); NODE nd_f4_red(int m,ND_pairs sp0,int trace,UINT *s0vect,int col,NODE rp0,ND_pairs *nz); NODE nd_f4_red_dist(int m,ND_pairs sp0,UINT *s0vect,int col,NODE rp0, ND_pairs *nz); NODE nd_f4_red_main(int m,ND_pairs sp0,int nsp,UINT *s0vect,int col, - NM_ind_pair *rvect,int *rhead,IndArray *imat,int nred,ND_pairs *nz); + NM_ind_pair *rvect,int *rhead,IndArray *imat,int nred,ND_pairs *nz); +NODE nd_f4_red_mod_main(int m,ND_pairs sp0,int nsp,UINT *s0vect,int col, + NM_ind_pair *rvect,int *rhead,IndArray *imat,int nred,ND_pairs *nz); +NODE nd_f4_red_sf_main(int m,ND_pairs sp0,int nsp,UINT *s0vect,int col, + NM_ind_pair *rvect,int *rhead,IndArray *imat,int nred,ND_pairs *nz); NODE nd_f4_red_q_main(ND_pairs sp0,int nsp,int trace,UINT *s0vect,int col, - NM_ind_pair *rvect,int *rhead,IndArray *imat,int nred); + NM_ind_pair *rvect,int *rhead,IndArray *imat,int nred); NODE nd_f4_red_gz_main(ND_pairs sp0,int nsp,int trace,UINT *s0vect,int col, - NM_ind_pair *rvect,int *rhead,IndArray *imat,int nred); + NM_ind_pair *rvect,int *rhead,IndArray *imat,int nred); /* NDV functions */ ND weyl_ndv_mul_nm(int mod,NM m0,NDV p); @@ -386,5 +397,10 @@ int nd_gauss_elim_sf(int **mat0,int *sugar,int row,int int nd_gauss_elim_q(Q **mat0,int *sugar,int row,int col,int *colstat); int ndl_ww_lex_compare(UINT *a1,UINT *a2); + +void red_by_vect_lf(mpz_t *p,mpz_t *r,mpz_t hc,int len); +void red_by_vect64(int m, U64 *p,unsigned int *c,U64 *r,unsigned int hc,int len); +int nd_symbolic_preproc(PGeoBucket bucket,int trace,UINT **s0vect,NODE *r); +int nd_gauss_elim_mod64(U64 **mat,int *sugar,ND_pairs *spactive,int row,int col,int md,int *colstat);