[BACK]Return to nd.h CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / engine

Diff for /OpenXM_contrib2/asir2000/engine/nd.h between version 1.9 and 1.40

version 1.9, 2004/09/21 02:34:12 version 1.40, 2020/11/02 08:30:55
Line 1 
Line 1 
   /* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.h,v 1.39 2020/10/04 03:14:08 noro Exp $ */
 #include "ca.h"  #include "ca.h"
 #include "parse.h"  #include "parse.h"
 #include "ox.h"  #include "ox.h"
Line 6 
Line 7 
 #include <time.h>  #include <time.h>
   
 #if defined(__GNUC__)  #if defined(__GNUC__)
 #define INLINE inline  #define INLINE static inline
 #elif defined(VISUAL)  #elif defined(VISUAL) || defined(__MINGW32__)
 #define INLINE __inline  #define INLINE __inline
 #else  #else
 #define INLINE  #define INLINE
Line 23  typedef unsigned int UINT;
Line 24  typedef unsigned int UINT;
 /* GeoBucket for polynomial addition */  /* GeoBucket for polynomial addition */
   
 typedef struct oPGeoBucket {  typedef struct oPGeoBucket {
         int m;    int m;
         struct oND *body[32];    struct oND *body[32];
 } *PGeoBucket;  } *PGeoBucket;
   
 /* distributed polynomial; linked list rep. */  /* distributed polynomial; linked list rep. */
 typedef struct oND {  typedef struct oND {
         struct oNM *body;    struct oNM *body;
         int nv;    int nv;
         int len;    int len;
         int sugar;    int sugar;
 } *ND;  } *ND;
   
 /* distributed polynomial; array rep. */  /* distributed polynomial; array rep. */
 typedef struct oNDV {  typedef struct oNDV {
         struct oNMV *body;    struct oNMV *body;
         int nv;    int nv;
         int len;    int len;
         int sugar;    int sugar;
 } *NDV;  } *NDV;
   
 typedef union oNDC {  typedef union oNDC {
         int m;    int m;
         Q z;    Q z;
         P p;    LM lm;
     GZ gz;
     P p;
     R r;
     DAlg a;
 } *NDC;  } *NDC;
   
 /* monomial; linked list rep. */  /* monomial; linked list rep. */
 typedef struct oNM {  typedef struct oNM {
         struct oNM *next;    struct oNM *next;
         union oNDC c;    union oNDC c;
         UINT dl[1];    UINT dl[1];
 } *NM;  } *NM;
   
 /* monomial; array rep. */  /* monomial; array rep. */
 typedef struct oNMV {  typedef struct oNMV {
         union oNDC c;    union oNDC c;
         UINT dl[1];    UINT dl[1];
 } *NMV;  } *NMV;
   
 /* history of reducer */  /* history of reducer */
 typedef struct oRHist {  typedef struct oRHist {
         struct oRHist *next;    struct oRHist *next;
         int index;    int index;
         int sugar;    int sugar;
         UINT dl[1];    UINT dl[1];
 } *RHist;  } *RHist;
   
 /* S-pair list */  /* S-pair list */
 typedef struct oND_pairs {  typedef struct oND_pairs {
         struct oND_pairs *next;    struct oND_pairs *next;
         int i1,i2;    int i1,i2;
         int sugar;    int sugar;
         UINT lcm[1];    int sugar2;
     UINT lcm[1];
 } *ND_pairs;  } *ND_pairs;
   
 /* index and shift count for each exponent */  /* index and shift count for each exponent */
 typedef struct oEPOS {  typedef struct oEPOS {
         int i; /* index */    int i; /* index */
         int s; /* shift */    int s; /* shift */
 } *EPOS;  } *EPOS;
   
 typedef struct oBlockMask {  typedef struct oBlockMask {
         int n;    int n;
         struct order_pair *order_pair;    struct order_pair *order_pair;
         UINT **mask;    UINT **mask;
 } *BlockMask;  } *BlockMask;
   
 typedef struct oBaseSet {  typedef struct oBaseSet {
         int len;    int len;
         NDV *ps;    NDV *ps;
         UINT **bound;    UINT **bound;
 } *BaseSet;  } *BaseSet;
   
 typedef struct oNM_ind_pair  typedef struct oNM_ind_pair
 {  {
         NM mul;    NM mul;
         int index,sugar;    int index,sugar;
 } *NM_ind_pair;  } *NM_ind_pair;
   
 typedef struct oIndArray  typedef struct oIndArray
 {  {
         char width;    char width;
         int head;    int head;
         union {    union {
                 unsigned char *c;      unsigned char *c;
                 unsigned short *s;      unsigned short *s;
                 unsigned int *i;      unsigned int *i;
         } index;    } index;
 } *IndArray;  } *IndArray;
   
   typedef struct oNDVI {
     NDV p;
     int i;
   } *NDVI;
   
 extern int (*ndl_compare_function)(UINT *a1,UINT *a2);  extern int (*ndl_compare_function)(UINT *a1,UINT *a2);
 extern int nd_dcomp;  extern int nd_dcomp;
   
Line 125  extern char *Demand;
Line 136  extern char *Demand;
 extern VL CO;  extern VL CO;
 extern int Top,Reverse,DP_Print,dp_nelim,do_weyl,NoSugar;  extern int Top,Reverse,DP_Print,dp_nelim,do_weyl,NoSugar;
 extern int *current_weyl_weight_vector;  extern int *current_weyl_weight_vector;
   extern int *current_module_weight_vector;
   
 /* fundamental macros */  /* fundamental macros */
 #define TD(d) (d[0])  #define TD(d) (d[0])
 #define HDL(d) ((d)->body->dl)  #define HDL(d) ((d)->body->dl)
 #define HTD(d) (TD(HDL(d)))  #define HTD(d) (TD(HDL(d)))
   #define HCU(d) ((d)->body->c)
 #define HCM(d) ((d)->body->c.m)  #define HCM(d) ((d)->body->c.m)
   #define HCLM(d) ((d)->body->c.lm)
 #define HCQ(d) ((d)->body->c.z)  #define HCQ(d) ((d)->body->c.z)
   #define HCZ(d) ((d)->body->c.gz)
 #define HCP(d) ((d)->body->c.p)  #define HCP(d) ((d)->body->c.p)
 #define CM(a) ((a)->c.m)  #define HCA(d) ((d)->body->c.a)
 #define CQ(a) ((a)->c.z)  #define CM(x) ((x)->c.m)
 #define CP(a) ((a)->c.p)  #define CLM(x) ((x)->c.lm)
 #define DL(a) ((a)->dl)  #define CQ(x) ((x)->c.z)
 #define SG(a) ((a)->sugar)  #define CZ(x) ((x)->c.gz)
 #define LEN(a) ((a)->len)  #define CP(x) ((x)->c.p)
 #define LCM(a) ((a)->lcm)  #define CA(x) ((x)->c.a)
   #define DL(x) ((x)->dl)
   #define SG(x) ((x)->sugar)
   #define LEN(x) ((x)->len)
   #define LCM(x) ((x)->lcm)
 #define GET_EXP(d,a) (((d)[nd_epos[a].i]>>nd_epos[a].s)&nd_mask0)  #define GET_EXP(d,a) (((d)[nd_epos[a].i]>>nd_epos[a].s)&nd_mask0)
 #define GET_EXP_MASK(d,a,m) ((((d)[nd_epos[a].i]&(m)[nd_epos[a].i])>>nd_epos[a].s)&nd_mask0)  #define GET_EXP_MASK(d,a,m) ((((d)[nd_epos[a].i]&(m)[nd_epos[a].i])>>nd_epos[a].s)&nd_mask0)
 #define PUT_EXP(r,a,e) ((r)[nd_epos[a].i] |= ((e)<<nd_epos[a].s))  #define PUT_EXP(r,a,e) ((r)[nd_epos[a].i] |= ((e)<<nd_epos[a].s))
Line 147  extern int *current_weyl_weight_vector;
Line 166  extern int *current_weyl_weight_vector;
   
 #define GET_EXP_OLD(d,a) (((d)[oepos[a].i]>>oepos[a].s)&omask0)  #define GET_EXP_OLD(d,a) (((d)[oepos[a].i]>>oepos[a].s)&omask0)
 #define PUT_EXP_OLD(r,a,e) ((r)[oepos[a].i] |= ((e)<<oepos[a].s))  #define PUT_EXP_OLD(r,a,e) ((r)[oepos[a].i] |= ((e)<<oepos[a].s))
   #define MPOS(d) (d[nd_mpos])
   
 #define ROUND_FOR_ALIGN(s) ((((s)+sizeof(void *)-1)/sizeof(void *))*sizeof(void *))  #define ROUND_FOR_ALIGN(s) ((((s)+sizeof(void *)-1)/sizeof(void *))*sizeof(void *))
   
Line 158  extern int *current_weyl_weight_vector;
Line 178  extern int *current_weyl_weight_vector;
 (nd_dcomp>0?TD_DL_COMPARE(d1,d2)\  (nd_dcomp>0?TD_DL_COMPARE(d1,d2)\
          :(nd_dcomp==0?ndl_lex_compare(d1,d2)\           :(nd_dcomp==0?ndl_lex_compare(d1,d2)\
                      :(nd_blockmask?ndl_block_compare(d1,d2)\                       :(nd_blockmask?ndl_block_compare(d1,d2)\
                                                                    :(*ndl_compare_function)(d1,d2))))                     :(*ndl_compare_function)(d1,d2))))
 #else  #else
 #define DL_COMPARE(d1,d2)\  #define DL_COMPARE(d1,d2)\
 (nd_dcomp>0?TD_DL_COMPARE(d1,d2):(*ndl_compare_function)(d1,d2))  (nd_dcomp>0?TD_DL_COMPARE(d1,d2):(*ndl_compare_function)(d1,d2))
Line 214  NODE append_one(NODE,int);
Line 234  NODE append_one(NODE,int);
 /* manipulation of coefficients */  /* manipulation of coefficients */
 void nd_removecont(int mod,ND p);  void nd_removecont(int mod,ND p);
 void nd_removecont2(ND p1,ND p2);  void nd_removecont2(ND p1,ND p2);
 void removecont_array(Q *c,int n);  void removecont_array(P *c,int n,int full);
   void removecont_array_q(Q *c,int n);
   
 /* GeoBucket functions */  /* GeoBucket functions */
 ND normalize_pbucket(int mod,PGeoBucket g);  ND normalize_pbucket(int mod,PGeoBucket g);
 int head_pbucket(int mod,PGeoBucket g);  int head_pbucket(int mod,PGeoBucket g);
 int head_pbucket_q(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_symbolic(PGeoBucket g,ND d);
 void add_pbucket(int mod,PGeoBucket g,ND d);  void add_pbucket(int mod,PGeoBucket g,ND d);
 void free_pbucket(PGeoBucket b);  void free_pbucket(PGeoBucket b);
Line 233  ND_pairs nd_newpairs( NODE g, int t );
Line 255  ND_pairs nd_newpairs( NODE g, int t );
 ND_pairs nd_minp( ND_pairs d, ND_pairs *prest );  ND_pairs nd_minp( ND_pairs d, ND_pairs *prest );
 ND_pairs nd_minsugarp( ND_pairs d, ND_pairs *prest );  ND_pairs nd_minsugarp( ND_pairs d, ND_pairs *prest );
 NODE update_base(NODE nd,int ndp);  NODE update_base(NODE nd,int ndp);
 ND_pairs update_pairs( ND_pairs d, NODE /* of index */ g, int t);  ND_pairs update_pairs( ND_pairs d, NODE /* of index */ g, int t, int gensyz);
 ND_pairs equivalent_pairs( ND_pairs d1, ND_pairs *prest );  ND_pairs equivalent_pairs( ND_pairs d1, ND_pairs *prest );
 ND_pairs crit_B( ND_pairs d, int s );  ND_pairs crit_B( ND_pairs d, int s );
 ND_pairs crit_M( ND_pairs d1 );  ND_pairs crit_M( ND_pairs d1 );
 ND_pairs crit_F( ND_pairs d1 );  ND_pairs crit_F( ND_pairs d1 );
 int crit_2( int dp1, int dp2 );  int crit_2( int dp1, int dp2 );
 int ndv_newps(int m,NDV a,NDV aq);  int ndv_newps(int m,NDV a,NDV aq,int f4);
   
 /* top level functions */  /* top level functions */
 void nd_gr(LIST f,LIST v,int m,int f4,struct order_spec *ord,LIST *rp);  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,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);  NODE nd_f4(int m,int checkonly,int **indp);
 NODE nd_gb(int m,int ishomo,int checkonly);  NODE nd_gb(int m,int ishomo,int checkonly,int gensyz,int **indp);
 NODE nd_gb_trace(int m,int ishomo);  NODE nd_gb_trace(int m,int ishomo,int **indp);
   NODE nd_f4_trace(int m,int **indp);
   
 /* ndl functions */  /* ndl functions */
 int ndl_weight(UINT *d);  int ndl_weight(UINT *d);
 void ndl_weight_mask(UINT *d);  void ndl_weight_mask(UINT *d);
 void ndl_homogenize(UINT *d,UINT *r,int obpe,EPOS oepos,int weight);  void ndl_homogenize(UINT *d,UINT *r,int obpe,EPOS oepos,int ompos,int weight);
 void ndl_dehomogenize(UINT *p);  void ndl_dehomogenize(UINT *p);
 void ndl_reconstruct(UINT *d,UINT *r,int obpe,EPOS oepos);  void ndl_reconstruct(UINT *d,UINT *r,int obpe,EPOS oepos);
 INLINE int ndl_reducible(UINT *d1,UINT *d2);  INLINE int ndl_reducible(UINT *d1,UINT *d2);
Line 270  INLINE int ndl_hash_value(UINT *d);
Line 293  INLINE int ndl_hash_value(UINT *d);
 /* normal forms */  /* normal forms */
 INLINE int ndl_find_reducer(UINT *g);  INLINE int ndl_find_reducer(UINT *g);
 int nd_sp(int mod,int trace,ND_pairs p,ND *nf);  int nd_sp(int mod,int trace,ND_pairs p,ND *nf);
 int nd_nf(int mod,ND g,NDV *ps,int full,NDC dn,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);  int nd_nf_pbucket(int mod,ND g,NDV *ps,int full,ND *nf);
   
 /* finalizers */  /* finalizers */
 NODE ndv_reducebase(NODE x);  NODE ndv_reducebase(NODE x,int *perm);
 NODE ndv_reduceall(int m,NODE f);  NODE ndv_reduceall(int m,NODE f);
   
 /* allocators */  /* allocators */
Line 294  void ndp_print(ND_pairs d);
Line 318  void ndp_print(ND_pairs d);
 /* setup, reconstruct */  /* setup, reconstruct */
 void nd_init_ord(struct order_spec *spec);  void nd_init_ord(struct order_spec *spec);
 ND_pairs nd_reconstruct(int trace,ND_pairs ndp);  ND_pairs nd_reconstruct(int trace,ND_pairs ndp);
 void ndv_setup(int mod,int trace,NODE f);  int ndv_setup(int mod,int trace,NODE f,int dont_sort,int dont_removecont);
 void nd_setup_parameters(int nvar,int max);  void nd_setup_parameters(int nvar,int max);
 BlockMask nd_create_blockmask(struct order_spec *ord);  BlockMask nd_create_blockmask(struct order_spec *ord);
 EPOS nd_create_epos(struct order_spec *ord);  EPOS nd_create_epos(struct order_spec *ord);
 int nd_get_exporigin(struct order_spec *ord);  int nd_get_exporigin(struct order_spec *ord);
 void ndv_mod(int mod,NDV p);  void ndv_mod(int mod,NDV p);
 NDV ndv_dup(int mod,NDV p);  NDV ndv_dup(int mod,NDV p);
   NDV ndv_symbolic(int mod,NDV p);
 ND nd_dup(ND p);  ND nd_dup(ND p);
   int ndv_ishomo(NDV p);
   
 /* ND functions */  /* ND functions */
 int ndv_check_candidate(NODE input,int obpe,int oadv,EPOS oepos,NODE cand);  int ndv_check_membership(int m,NODE input,int obpe,int oadv,EPOS oepos,NODE cand);
 void nd_mul_c(int mod,ND p,int mul);  void nd_mul_c(int mod,ND p,int mul);
 void nd_mul_c_q(ND p,Q mul);  void nd_mul_c_q(ND p,P mul);
 void nd_mul_c_p(VL vl,ND p,P mul);  void nd_mul_c_p(VL vl,ND p,P mul);
 ND nd_remove_head(ND p);  ND nd_remove_head(ND p);
 ND nd_separate_head(ND p,ND *head);  ND nd_separate_head(ND p,ND *head);
 int nd_length(ND p);  INLINE int nd_length(ND p);
 void nd_append_red(UINT *d,int i);  void nd_append_red(UINT *d,int i);
 UINT *ndv_compute_bound(NDV p);  UINT *ndv_compute_bound(NDV p);
 UINT *nd_compute_bound(ND p);  UINT *nd_compute_bound(ND p);
Line 321  ND nd_add_q(ND p1,ND p2);
Line 347  ND nd_add_q(ND p1,ND p2);
 ND nd_add_sf(ND p1,ND p2);  ND nd_add_sf(ND p1,ND p2);
 ND nd_quo(int mod,PGeoBucket p,NDV d);  ND nd_quo(int mod,PGeoBucket p,NDV d);
 INLINE int nd_length(ND p);  INLINE int nd_length(ND p);
 NODE nd_f4_red(int m,ND_pairs sp0,UINT *s0vect,int col,NODE rp0);  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);  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,  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);    NM_ind_pair *rvect,int *rhead,IndArray *imat,int nred,ND_pairs *nz);
 NODE nd_f4_red_q_main(ND_pairs sp0,int nsp,UINT *s0vect,int col,  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);    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);
   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);
   
 /* NDV functions */  /* NDV functions */
 ND weyl_ndv_mul_nm(int mod,NM m0,NDV p);  ND weyl_ndv_mul_nm(int mod,NM m0,NDV p);
Line 338  ND ndv_mul_nm(int mod,NM m0,NDV p);
Line 370  ND ndv_mul_nm(int mod,NM m0,NDV p);
 ND ndv_mul_nmv_trunc(int mod,NMV m0,NDV p,UINT *d);  ND ndv_mul_nmv_trunc(int mod,NMV m0,NDV p,UINT *d);
 void ndv_realloc(NDV p,int obpe,int oadv,EPOS oepos);  void ndv_realloc(NDV p,int obpe,int oadv,EPOS oepos);
 NDV ndv_dup_realloc(NDV p,int obpe,int oadv,EPOS oepos);  NDV ndv_dup_realloc(NDV p,int obpe,int oadv,EPOS oepos);
 void ndv_homogenize(NDV p,int obpe,int oadv,EPOS eops);  void ndv_homogenize(NDV p,int obpe,int oadv,EPOS eops,int ompos);
 void ndv_dehomogenize(NDV p,struct order_spec *spec);  void ndv_dehomogenize(NDV p,struct order_spec *spec);
 void ndv_removecont(int mod,NDV p);  void ndv_removecont(int mod,NDV p);
 void ndv_print(NDV p);  void ndv_print(NDV p);
Line 353  NDV ptondv(VL vl,VL dvl,P p);
Line 385  NDV ptondv(VL vl,VL dvl,P p);
 P ndvtop(int mod,VL vl,VL dvl,NDV p);  P ndvtop(int mod,VL vl,VL dvl,NDV p);
 NDV ndtondv(int mod,ND p);  NDV ndtondv(int mod,ND p);
 ND ndvtond(int mod,NDV p);  ND ndvtond(int mod,NDV p);
 int nm_ind_pair_to_vect(int m,UINT *s0,int n,NM_ind_pair pair,UINT *r);  Q *nm_ind_pair_to_vect(int m,UINT *s0,int n,NM_ind_pair pair);
 IndArray nm_ind_pair_to_vect_compress(int m,UINT *s0,int n,NM_ind_pair pair);  IndArray nm_ind_pair_to_vect_compress(int m,UINT *s0,int n,int *s0hash,NM_ind_pair pair);
 int nd_to_vect(int mod,UINT *s0,int n,ND d,UINT *r);  int nd_to_vect(int mod,UINT *s0,int n,ND d,UINT *r);
 int nd_to_vect_q(UINT *s0,int n,ND d,Q *r);  int nd_to_vect_q(UINT *s0,int n,ND d,Q *r);
 NDV vect_to_ndv_q(Q *vect,int spcol,int col,int *rhead,UINT *s0vect);  NDV vect_to_ndv_q(Q *vect,int spcol,int col,int *rhead,UINT *s0vect);
   
 /* elimination */  /* elimination */
 int nd_gauss_elim_mod(int **mat0,int *sugar,int row,int col,int md,int *colstat);  int nd_gauss_elim_mod(int **mat0,int *sugar,ND_pairs *spactive,int row,int col,int md,int *colstat);
 int nd_gauss_elim_sf(int **mat0,int *sugar,int row,int col,int md,int *colstat);  int nd_gauss_elim_sf(int **mat0,int *sugar,int row,int col,int md,int *colstat);
 int nd_gauss_elim_q(Q **mat0,int *sugar,int row,int col,int *colstat);  int nd_gauss_elim_q(Q **mat0,int *sugar,int row,int col,int *colstat);
   
 int ndl_ww_lex_compare(UINT *a1,UINT *a2);  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);
   int nd_symbolic_preproc(PGeoBucket bucket,int trace,UINT **s0vect,NODE *r);
   
   #if SIZEOF_LONG==8
   void red_by_vect64(int m, U64 *p,unsigned int *c,U64 *r,unsigned int hc,int len);
   int nd_gauss_elim_mod64(U64 **mat,int *sugar,ND_pairs *spactive,int row,int col,int md,int *colstat);
   #endif
   

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.40

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>