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

Diff for /OpenXM_contrib2/asir2000/engine/nd.c between version 1.120 and 1.121

version 1.120, 2004/12/07 15:15:52 version 1.121, 2004/12/09 08:56:43
Line 1 
Line 1 
 /* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.119 2004/12/06 09:29:34 noro Exp $ */  /* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.120 2004/12/07 15:15:52 noro Exp $ */
   
 #include "nd.h"  #include "nd.h"
   
Line 8  NM _nm_free_list;
Line 8  NM _nm_free_list;
 ND _nd_free_list;  ND _nd_free_list;
 ND_pairs _ndp_free_list;  ND_pairs _ndp_free_list;
   
   static int nd_ntrans;
 static int nd_nalg;  static int nd_nalg;
 #if 0  #if 0
 static int ndv_alloc;  static int ndv_alloc;
Line 2214  void ndv_setup(int mod,int trace,NODE f)
Line 2215  void ndv_setup(int mod,int trace,NODE f)
 struct order_spec *append_block(struct order_spec *spec,  struct order_spec *append_block(struct order_spec *spec,
     int nv,int nalg,int ord);      int nv,int nalg,int ord);
   
   extern VECT current_dl_weight_vector_obj;
   static VECT prev_weight_vector_obj;
   
 void preprocess_algcoef(VL vv,VL av,struct order_spec *ord,LIST f,  void preprocess_algcoef(VL vv,VL av,struct order_spec *ord,LIST f,
         struct order_spec **ord1p,LIST *f1p,NODE *alistp)          struct order_spec **ord1p,LIST *f1p,NODE *alistp)
 {  {
         NODE alist,t,s,r0,r;          NODE alist,t,s,r0,r,arg;
         VL tv;          VL tv;
         P poly;          P poly;
         DP d;          DP d;
         Alg alpha,dp;          Alg alpha,dp;
         DAlg inv,da,hc;          DAlg inv,da,hc;
         MP m;          MP m;
         int i,nvar,nalg;          int i,nvar,nalg,n;
         NumberField nf;          NumberField nf;
         LIST f1,f2;          LIST f1,f2;
         struct order_spec *current_spec;          struct order_spec *current_spec;
           VECT obj,obj0;
           Obj tmp;
   
         for ( nvar = 0, tv = vv; tv; tv = NEXT(tv), nvar++);          for ( nvar = 0, tv = vv; tv; tv = NEXT(tv), nvar++);
         for ( nalg = 0, tv = av; tv; tv = NEXT(tv), nalg++);          for ( nalg = 0, tv = av; tv; tv = NEXT(tv), nalg++);
Line 2271  void preprocess_algcoef(VL vv,VL av,struct order_spec 
Line 2277  void preprocess_algcoef(VL vv,VL av,struct order_spec 
         MKLIST(f1,t);          MKLIST(f1,t);
         *alistp = alist;          *alistp = alist;
         algobjtorat(f1,f1p);          algobjtorat(f1,f1p);
   
           /* creating a new weight vector */
           prev_weight_vector_obj = obj0 = current_dl_weight_vector_obj;
           n = nvar+nalg+1;
           MKVECT(obj,n);
           if ( obj0 && obj0->len == nvar )
                   for ( i = 0; i < nvar; i++ ) BDY(obj)[i] = BDY(obj0)[i];
           else
                   for ( i = 0; i < nvar; i++ ) BDY(obj)[i] = (pointer)ONE;
           for ( i = 0; i < nalg; i++ ) BDY(obj)[i+nvar] = 0;
           BDY(obj)[n-1] = (pointer)ONE;
           arg = mknode(1,obj);
           Pdp_set_weight(arg,&tmp);
 }  }
   
   NODE postprocess_algcoef(VL av,NODE alist,NODE r)
   {
           NODE s,t,u0,u;
           P p;
           VL tv;
           Obj obj,tmp;
           NODE arg;
   
           u0 = 0;
           for ( t = r; t; t = NEXT(t) ) {
                   p = (P)BDY(t);
                   for ( tv = av, s = alist; tv; tv = NEXT(tv), s = NEXT(s) ) {
                           substr(CO,0,(Obj)p,tv->v,(Obj)BDY(s),&obj); p = (P)obj;
                   }
                   if ( OID(p) == O_P || (OID(p) == O_N && NID((Num)p) != N_A) ) {
                           NEXTNODE(u0,u);
                           BDY(u) = (pointer)p;
                   }
           }
           arg = mknode(1,prev_weight_vector_obj);
           Pdp_set_weight(arg,&tmp);
   
           return u0;
   }
   
 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 f4,struct order_spec *ord,LIST *rp)
 {  {
         VL tv,fv,vv,vc,av;          VL tv,fv,vv,vc,av;
Line 2307  void nd_gr(LIST f,LIST v,int m,int f4,struct order_spe
Line 2351  void nd_gr(LIST f,LIST v,int m,int f4,struct order_spe
         if ( !m ) {          if ( !m ) {
                 get_algtree((Obj)f,&av);                  get_algtree((Obj)f,&av);
                 for ( nalg = 0, tv = av; tv; tv = NEXT(tv), nalg++ );                  for ( nalg = 0, tv = av; tv; tv = NEXT(tv), nalg++ );
                   nd_ntrans = nvar;
                 nd_nalg = nalg;                  nd_nalg = nalg;
                 /* #i -> t#i */                  /* #i -> t#i */
                 if ( nalg ) {                  if ( nalg ) {
Line 2340  void nd_gr(LIST f,LIST v,int m,int f4,struct order_spe
Line 2385  void nd_gr(LIST f,LIST v,int m,int f4,struct order_spe
         for ( r0 = 0, t = x; t; t = NEXT(t) ) {          for ( r0 = 0, t = x; t; t = NEXT(t) ) {
                 NEXTNODE(r0,r);                  NEXTNODE(r0,r);
                 BDY(r) = ndvtop(m,CO,vv,BDY(t));                  BDY(r) = ndvtop(m,CO,vv,BDY(t));
                 if ( nalg ) {  
                         p = BDY(r);  
                         for ( tv = av, s = alist; tv; tv = NEXT(tv), s = NEXT(s) ) {  
                                 substr(CO,0,(Obj)p,tv->v,(Obj)BDY(s),&obj); p = (P)obj;  
                         }  
                         BDY(r) = p;  
                 }  
         }          }
         if ( r0 ) NEXT(r) = 0;          if ( r0 ) NEXT(r) = 0;
           if ( nalg )
                   r0 = postprocess_algcoef(av,alist,r0);
         MKLIST(*rp,r0);          MKLIST(*rp,r0);
 #if 0  #if 0
         fprintf(asir_out,"ndv_alloc=%d\n",ndv_alloc);          fprintf(asir_out,"ndv_alloc=%d\n",ndv_alloc);
Line 2385  void nd_gr_trace(LIST f,LIST v,int trace,int homo,stru
Line 2425  void nd_gr_trace(LIST f,LIST v,int trace,int homo,stru
   
         get_algtree((Obj)f,&av);          get_algtree((Obj)f,&av);
         for ( nalg = 0, tv = av; tv; tv = NEXT(tv), nalg++ );          for ( nalg = 0, tv = av; tv; tv = NEXT(tv), nalg++ );
           nd_ntrans = nvar;
         nd_nalg = nalg;          nd_nalg = nalg;
         /* #i -> t#i */          /* #i -> t#i */
         if ( nalg ) {          if ( nalg ) {
Line 2483  void nd_gr_trace(LIST f,LIST v,int trace,int homo,stru
Line 2524  void nd_gr_trace(LIST f,LIST v,int trace,int homo,stru
         /* dp->p */          /* dp->p */
         nd_bpe = cbpe;          nd_bpe = cbpe;
         nd_setup_parameters(nd_nvar,0);          nd_setup_parameters(nd_nvar,0);
         for ( r = cand; r; r = NEXT(r) ) {          for ( r = cand; r; r = NEXT(r) )
                 BDY(r) = (pointer)ndvtop(0,CO,vv,BDY(r));                  BDY(r) = (pointer)ndvtop(0,CO,vv,BDY(r));
                 if ( nalg ) {          if ( nalg )
                         poly = BDY(r);                  cand = postprocess_algcoef(av,alist,cand);
                         for ( tv = av, s = alist; tv; tv = NEXT(tv), s = NEXT(s) ) {  
                                 substr(CO,0,(Obj)poly,tv->v,(Obj)BDY(s),&obj); poly = (P)obj;  
                         }  
                         BDY(r) = poly;  
                 }  
         }  
         MKLIST(*rp,cand);          MKLIST(*rp,cand);
 }  }
   
Line 5241  UINT *nd_det_compute_bound(NDV **dm,int n,int j)
Line 5276  UINT *nd_det_compute_bound(NDV **dm,int n,int j)
   
 DL nd_separate_d(UINT *d,UINT *trans)  DL nd_separate_d(UINT *d,UINT *trans)
 {  {
         int n,ntrans,td,i,e;          int n,td,i,e,j;
         DL a;          DL a;
   
         n = nd_nvar; ntrans = n-nd_nalg;  
         ndl_zero(trans);          ndl_zero(trans);
         td = 0;          td = 0;
         for ( i = 0; i < ntrans; i++ ) {          for ( i = 0; i < nd_ntrans; i++ ) {
                 e = GET_EXP(d,i);                  e = GET_EXP(d,i);
                 PUT_EXP(trans,i,e);                  PUT_EXP(trans,i,e);
                 td += MUL_WEIGHT(e,i);                  td += MUL_WEIGHT(e,i);
         }          }
           if ( nd_ntrans+nd_nalg < nd_nvar ) {
                   /* homogenized */
                   i = nd_nvar-1;
                   e = GET_EXP(d,i);
                   PUT_EXP(trans,i,e);
                   td += MUL_WEIGHT(e,i);
           }
         TD(trans) = td;          TD(trans) = td;
         if ( nd_blockmask) ndl_weight_mask(trans);          if ( nd_blockmask) ndl_weight_mask(trans);
         NEWDL(a,nd_nalg);          NEWDL(a,nd_nalg);
         td = 0;          td = 0;
         for ( ; i < n; i++ ) {          for ( i = 0; i < nd_nalg; i++ ) {
                 e = GET_EXP(d,i);                  j = nd_ntrans+i;
                 a->d[i-ntrans] = e;                  e = GET_EXP(d,j);
                   a->d[i] = e;
                 td += e;                  td += e;
         }          }
         a->td = td;          a->td = td;
Line 5286  int nd_monic(int mod,ND *p)
Line 5328  int nd_monic(int mod,ND *p)
         if ( !(nf = get_numberfield()) )          if ( !(nf = get_numberfield()) )
                 error("nd_monic : current_numberfield is not set");                  error("nd_monic : current_numberfield is not set");
   
         n = nd_nvar; ntrans = n-nd_nalg;  
         /* Q coef -> DAlg coef */          /* Q coef -> DAlg coef */
         NEWNM(ma0); ma = ma0;          NEWNM(ma0); ma = ma0;
         m = BDY(*p);          m = BDY(*p);
Line 5340  int nd_monic(int mod,ND *p)
Line 5381  int nd_monic(int mod,ND *p)
                         dl = mp->dl;                          dl = mp->dl;
                         td = TD(DL(m));                          td = TD(DL(m));
                         ndl_copy(DL(m),DL(mr));                          ndl_copy(DL(m),DL(mr));
                         for ( i = ntrans; i < n; i++ ) {                          for ( i = 0; i < nd_nalg; i++ ) {
                                 e = dl->d[i-ntrans];                                  e = dl->d[i];
                                 PUT_EXP(DL(mr),i,e);                                  PUT_EXP(DL(mr),i+nd_ntrans,e);
                                 td += MUL_WEIGHT(e,i);                                  td += MUL_WEIGHT(e,i+nd_ntrans);
                         }                          }
                         TD(DL(mr)) = td;                          TD(DL(mr)) = td;
                         if ( nd_blockmask) ndl_weight_mask(DL(mr));                          if ( nd_blockmask) ndl_weight_mask(DL(mr));

Legend:
Removed from v.1.120  
changed lines
  Added in v.1.121

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