[BACK]Return to dp-supp.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2018 / builtin

Diff for /OpenXM_contrib2/asir2018/builtin/dp-supp.c between version 1.3 and 1.4

version 1.3, 2019/08/21 00:37:47 version 1.4, 2019/09/04 01:12:02
Line 45 
Line 45 
  * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,   * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
  * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.   * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
  *   *
  * $OpenXM: OpenXM_contrib2/asir2018/builtin/dp-supp.c,v 1.2 2018/09/28 08:20:27 noro Exp $   * $OpenXM: OpenXM_contrib2/asir2018/builtin/dp-supp.c,v 1.3 2019/08/21 00:37:47 noro Exp $
 */  */
 #include "ca.h"  #include "ca.h"
 #include "base.h"  #include "base.h"
Line 657  void dpm_sp(DPM p1,DPM p2,DPM *rp,DP *mul1,DP *mul2)
Line 657  void dpm_sp(DPM p1,DPM p2,DPM *rp,DP *mul1,DP *mul2)
   }    }
 }  }
   
   DP dpm_sp_hm(DPM p1,DPM p2)
   {
     int i,n,td;
     int *w;
     DL d1,d2,d;
     MP m;
     DP s1;
   
     n = p1->nv; d1 = BDY(p1)->dl; d2 = BDY(p2)->dl;
     if ( BDY(p1)->pos != BDY(p2)->pos ) {
       return 0;
     }
     w = (int *)ALLOCA(n*sizeof(int));
     for ( i = 0, td = 0; i < n; i++ ) {
       w[i] = MAX(d1->d[i],d2->d[i]); td += MUL_WEIGHT(w[i],i);
     }
   
     NEWDL(d,n); d->td = td - d1->td;
     for ( i = 0; i < n; i++ )
       d->d[i] = w[i] - d1->d[i];
   
     NEWMP(m); m->dl = d; m->c = (Obj)ONE; NEXT(m) = 0;
     MKDP(n,m,s1); s1->sugar = d->td;
     return s1;
   }
   
 void _dp_sp_dup(DP p1,DP p2,DP *rp)  void _dp_sp_dup(DP p1,DP p2,DP *rp)
 {  {
   int i,n,td;    int i,n,td;
Line 841  void dpm_red(DPM p0,DPM p1,DPM p2,DPM *head,DPM *rest,
Line 867  void dpm_red(DPM p0,DPM p1,DPM p2,DPM *head,DPM *rest,
   int i,n,pos;    int i,n,pos;
   DL d1,d2,d;    DL d1,d2,d;
   MP m;    MP m;
   DP s;    DP s,ms;
   DPM t,r,h,u,w;    DPM t,r,h,u,w;
   Z c,c1,c2,gn;    Z c,c1,c2,gn;
   P g,a;    P g,a;
Line 873  void dpm_red(DPM p0,DPM p1,DPM p2,DPM *head,DPM *rest,
Line 899  void dpm_red(DPM p0,DPM p1,DPM p2,DPM *head,DPM *rest,
   }    }
   NEWMP(m); m->dl = d; m->c = (Obj)c1; NEXT(m) = 0; MKDP(n,m,s); s->sugar = d->td;    NEWMP(m); m->dl = d; m->c = (Obj)c1; NEXT(m) = 0; MKDP(n,m,s); s->sugar = d->td;
   *multp = s;    *multp = s;
   mulobjdpm(CO,(Obj)s,p2,&u); mulobjdpm(CO,(Obj)c2,p1,&w); subdpm(CO,w,u,&r);    chsgnd(s,&ms); mulobjdpm(CO,(Obj)ms,p2,&u); mulobjdpm(CO,(Obj)c2,p1,&w); adddpm(CO,w,u,&r);
   mulobjdpm(CO,(Obj)c2,p0,&h);    mulobjdpm(CO,(Obj)c2,p0,&h);
   *head = h; *rest = r; *dnp = (P)c2;    *head = h; *rest = r; *dnp = (P)c2;
 }  }
Line 1354  last:
Line 1380  last:
   return q;    return q;
 }  }
   
   // struct oEGT egc;
   
 DP *dpm_nf_and_quotient(NODE b,DPM g,VECT psv,DPM *rp,P *dnp)  DP *dpm_nf_and_quotient(NODE b,DPM g,VECT psv,DPM *rp,P *dnp)
 {  {
   DPM u,p,d,s,t;    DPM u,p,d,s,t;
Line 1367  DP *dpm_nf_and_quotient(NODE b,DPM g,VECT psv,DPM *rp,
Line 1395  DP *dpm_nf_and_quotient(NODE b,DPM g,VECT psv,DPM *rp,
   int sugar,psugar,multiple;    int sugar,psugar,multiple;
   P nm,tnm1,dn,tdn,tdn1;    P nm,tnm1,dn,tdn,tdn1;
   Q cont;    Q cont;
     struct oEGT eg0,eg1;
   
   dn = (P)ONE;    dn = (P)ONE;
   if ( !g ) {    if ( !g ) {
Line 1395  DP *dpm_nf_and_quotient(NODE b,DPM g,VECT psv,DPM *rp,
Line 1424  DP *dpm_nf_and_quotient(NODE b,DPM g,VECT psv,DPM *rp,
         dpm_red(d,g,p,&t,&u,&tdn,&mult);          dpm_red(d,g,p,&t,&u,&tdn,&mult);
         psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar;          psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar;
         sugar = MAX(sugar,psugar);          sugar = MAX(sugar,psugar);
   // get_eg(&eg0);
         for ( j = 0; j < len; j++ ) {          for ( j = 0; j < len; j++ ) {
           muldc(CO,q[j],(Obj)tdn,&dmy); q[j] = dmy;            muldc(CO,q[j],(Obj)tdn,&dmy); q[j] = dmy;
         }          }
         addd(CO,q[wb[i]],mult,&dmy); q[wb[i]] = dmy;          addd(CO,q[wb[i]],mult,&dmy); q[wb[i]] = dmy;
   // get_eg(&eg1); add_eg(&egc,&eg0,&eg1);
         mulp(CO,dn,tdn,&tdn1); dn = tdn1;          mulp(CO,dn,tdn,&tdn1); dn = tdn1;
         d = t;          d = t;
         if ( !u ) goto last;          if ( !u ) goto last;
Line 1546  void dp_nf_z(NODE b,DP g,DP *ps,int full,int multiple,
Line 1577  void dp_nf_z(NODE b,DP g,DP *ps,int full,int multiple,
   *rp = d;    *rp = d;
 }  }
   
 void dpm_nf_z(NODE b,DPM g,DPM *ps,int full,int multiple,DPM *rp)  void dpm_nf_z(NODE b,DPM g,VECT psv,int full,int multiple,DPM *rp)
 {  {
     DPM *ps;
   DPM u,p,d,s,t;    DPM u,p,d,s,t;
   DP dmy1;    DP dmy1;
   P dmy;    P dmy;
Line 1562  void dpm_nf_z(NODE b,DPM g,DPM *ps,int full,int multip
Line 1594  void dpm_nf_z(NODE b,DPM g,DPM *ps,int full,int multip
   if ( !g ) {    if ( !g ) {
     *rp = 0; return;      *rp = 0; return;
   }    }
   for ( n = 0, l = b; l; l = NEXT(l), n++ );    if ( b ) {
   wb = (int *)ALLOCA(n*sizeof(int));      for ( n = 0, l = b; l; l = NEXT(l), n++ );
   for ( i = 0, l = b; i < n; l = NEXT(l), i++ )      wb = (int *)ALLOCA(n*sizeof(int));
     wb[i] = ZTOS((Q)BDY(l));      for ( i = 0, l = b; i < n; l = NEXT(l), i++ )
         wb[i] = ZTOS((Q)BDY(l));
       ps = (DPM *)BDY(psv);
     } else {
       n = psv->len;
       wb = (int *)MALLOC(n*sizeof(int));
       for ( i = 0; i < n; i++ ) wb[i] = i;
       ps = (DPM *)BDY(psv);
     }
   
   hmag = multiple*HMAG(g);    hmag = multiple*HMAG(g);
   sugar = g->sugar;    sugar = g->sugar;
   
   for ( d = 0; g; ) {    for ( d = 0; g; ) {
     for ( u = 0, i = 0; i < n; i++ ) {      for ( u = 0, i = 0; i < n; i++ ) {
       if ( dpm_redble(g,p = ps[wb[i]]) ) {        if ( (p=ps[wb[i]])!=0 && dpm_redble(g,p) ) {
         dpm_red(d,g,p,&t,&u,&dmy,&dmy1);          dpm_red(d,g,p,&t,&u,&dmy,&dmy1);
         psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar;          psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar;
         sugar = MAX(sugar,psugar);          sugar = MAX(sugar,psugar);
Line 1720  void dp_nf_f(NODE b,DP g,DP *ps,int full,DP *rp)
Line 1760  void dp_nf_f(NODE b,DP g,DP *ps,int full,DP *rp)
   *rp = d;    *rp = d;
 }  }
   
 void dpm_nf_f(NODE b,DPM g,DPM *ps,int full,DPM *rp)  void dpm_nf_f(NODE b,DPM g,VECT psv,int full,DPM *rp)
 {  {
     DPM *ps;
   DPM u,p,d,s,t;    DPM u,p,d,s,t;
   NODE l;    NODE l;
   DMM m,mr;    DMM m,mr;
Line 1732  void dpm_nf_f(NODE b,DPM g,DPM *ps,int full,DPM *rp)
Line 1773  void dpm_nf_f(NODE b,DPM g,DPM *ps,int full,DPM *rp)
   if ( !g ) {    if ( !g ) {
     *rp = 0; return;      *rp = 0; return;
   }    }
   for ( n = 0, l = b; l; l = NEXT(l), n++ );    if ( b ) {
   wb = (int *)ALLOCA(n*sizeof(int));      for ( n = 0, l = b; l; l = NEXT(l), n++ );
   for ( i = 0, l = b; i < n; l = NEXT(l), i++ )      wb = (int *)ALLOCA(n*sizeof(int));
     wb[i] = ZTOS((Q)BDY(l));      for ( i = 0, l = b; i < n; l = NEXT(l), i++ )
         wb[i] = ZTOS((Q)BDY(l));
       ps = (DPM *)BDY(psv);
     } else {
       n = psv->len;
       wb = (int *)MALLOC(n*sizeof(int));
       for ( i = 0; i < n; i++ ) wb[i] = i;
       ps = (DPM *)BDY(psv);
     }
   
   sugar = g->sugar;    sugar = g->sugar;
   for ( d = 0; g; ) {    for ( d = 0; g; ) {
     for ( u = 0, i = 0; i < n; i++ ) {      for ( u = 0, i = 0; i < n; i++ ) {
       if ( dpm_redble(g,p = ps[wb[i]]) ) {        if ( ( (p=ps[wb[i]]) != 0 ) && dpm_redble(g,p) ) {
         dpm_red_f(g,p,&u);          dpm_red_f(g,p,&u);
         psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar;          psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar;
         sugar = MAX(sugar,psugar);          sugar = MAX(sugar,psugar);

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

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