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

Diff for /OpenXM_contrib2/asir2018/engine/dist.c between version 1.5 and 1.8

version 1.5, 2019/09/04 05:32:10 version 1.8, 2019/09/13 02:04:42
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/engine/dist.c,v 1.4 2019/09/04 01:12:02 noro Exp $   * $OpenXM: OpenXM_contrib2/asir2018/engine/dist.c,v 1.7 2019/09/06 00:11:59 noro Exp $
 */  */
 #include "ca.h"  #include "ca.h"
   
Line 2635  NBP harmonic_mul_nbm(NBM a,NBM b)
Line 2635  NBP harmonic_mul_nbm(NBM a,NBM b)
 /* DPM functions */  /* DPM functions */
   
 DMMstack dmm_stack;  DMMstack dmm_stack;
   extern LIST schreyer_obj;
   
 void push_schreyer_order(LIST data)  void push_schreyer_order(LIST data)
 {  {
   DMMstack t;    DMMstack t;
   int len,i;    int len,i;
   NODE in;    NODE in,t1;
   
   /* data = [DPM,...,DPM] */    /* data = [DPM,...,DPM] */
   in = BDY(data);    in = BDY(data);
Line 2655  void push_schreyer_order(LIST data)
Line 2656  void push_schreyer_order(LIST data)
   t->next = dmm_stack;    t->next = dmm_stack;
   dmm_stack = t;    dmm_stack = t;
   dpm_ordtype = 2;    dpm_ordtype = 2;
     MKNODE(t1,data,schreyer_obj?BDY(schreyer_obj):0);
     MKLIST(schreyer_obj,t1);
 }  }
   
   
 // data=[Ink,...,In0]  // data=[Ink,...,In0]
 // Ini = a list of module monomials  // Ini = a list of module monomials
   
Line 2714  NODE dpm_reduceall(NODE in)
Line 2716  NODE dpm_reduceall(NODE in)
   for ( i = 0, t = in; i < n; i++, t = NEXT(t) ) ps[i] = BDY(t);    for ( i = 0, t = in; i < n; i++, t = NEXT(t) ) ps[i] = BDY(t);
   for ( i = 0; i < n; i++ ) {    for ( i = 0; i < n; i++ ) {
     g = ps[i]; ps[i] = 0;      g = ps[i]; ps[i] = 0;
     dpm_nf_z(0,g,psv,1,DP_Multiple,&r);  //    dpm_nf_z(0,g,psv,1,DP_Multiple,&ps[i]);
     ps[i] = r;      dpm_nf_z(0,g,psv,1,0,&ps[i]);
   }    }
   t = 0;    t = 0;
   for ( i = n-1; i >= 0; i-- ) {    for ( i = n-1; i >= 0; i-- ) {
Line 2725  NODE dpm_reduceall(NODE in)
Line 2727  NODE dpm_reduceall(NODE in)
   return t;    return t;
 }  }
   
   struct oEGT egra;
   
 void dpm_schreyer_base(LIST g,LIST *s)  void dpm_schreyer_base(LIST g,LIST *s)
 {  {
   NODE nd,t,b0,b;    NODE nd,t,b0,b;
Line 2738  void dpm_schreyer_base(LIST g,LIST *s)
Line 2742  void dpm_schreyer_base(LIST g,LIST *s)
   DPM *ps;    DPM *ps;
   VECT psv;    VECT psv;
   DP **m,*quo;    DP **m,*quo;
   struct oEGT eg_nf,eg0,eg1;    struct oEGT eg0,eg1;
   extern struct oEGT egc,egcomp;    extern struct oEGT egred;
   
 //  init_eg(&eg_nf);    init_eg(&egra);
 //  init_eg(&egcomp);  
   nd = BDY(g);    nd = BDY(g);
   n = length(nd);    n = length(nd);
   MKVECT(psv,n);    MKVECT(psv,n);
Line 2751  void dpm_schreyer_base(LIST g,LIST *s)
Line 2754  void dpm_schreyer_base(LIST g,LIST *s)
   nv = ps[0]->nv;    nv = ps[0]->nv;
   m = (DP **)almat_pointer(n,n);    m = (DP **)almat_pointer(n,n);
   b0 = 0;    b0 = 0;
 //  init_eg(&egc);  
   for ( i = 0; i < n; i++ ) {    for ( i = 0; i < n; i++ ) {
     // sp(ps[i],ps[j]) = ti*ps[i]-tj*ps[j] => m[i][j] = ti      // sp(ps[i],ps[j]) = ti*ps[i]-tj*ps[j] => m[i][j] = ti
     for ( j = i+1; j < n; j++ ) m[i][j] = dpm_sp_hm(ps[i],ps[j]);      for ( j = i+1; j < n; j++ ) m[i][j] = dpm_sp_hm(ps[i],ps[j]);
     for ( j = i+1; j < n; j++ ) {      for ( j = i+1; j < n; j++ ) {
 //    for ( j = n-1; j > i; j-- ) {  
       if ( !m[i][j] ) continue;        if ( !m[i][j] ) continue;
       for ( h = m[i][j], k = i+1; k < n; k++ )        for ( h = m[i][j], k = i+1; k < n; k++ )
         if ( k != j && m[i][k] && dp_redble(m[i][k],h) ) m[i][k] = 0;          if ( k != j && m[i][k] && dp_redble(m[i][k],h) ) m[i][k] = 0;
Line 2764  void dpm_schreyer_base(LIST g,LIST *s)
Line 2765  void dpm_schreyer_base(LIST g,LIST *s)
     for ( j = i+1; j < n; j++ ) {      for ( j = i+1; j < n; j++ ) {
       if ( m[i][j] ) {        if ( m[i][j] ) {
         dpm_sp(ps[i],ps[j],&sp,&t1,&t2);          dpm_sp(ps[i],ps[j],&sp,&t1,&t2);
 //        get_eg(&eg0);  
         quo = dpm_nf_and_quotient(0,sp,psv,&nf,&dn);          quo = dpm_nf_and_quotient(0,sp,psv,&nf,&dn);
 //        get_eg(&eg1); add_eg(&eg_nf,&eg0,&eg1);  
         if ( nf )          if ( nf )
           error("dpm_schreyer_base : cannot happen");            error("dpm_schreyer_base : cannot happen");
         NEWDMM(r0); r = r0;          NEWDMM(r0); r = r0;
Line 2795  void dpm_schreyer_base(LIST g,LIST *s)
Line 2794  void dpm_schreyer_base(LIST g,LIST *s)
     BDY(t) = (pointer)dpm;      BDY(t) = (pointer)dpm;
   }    }
   b0 = dpm_sort_list(b0);    b0 = dpm_sort_list(b0);
 //  b0 = dpm_reduceall(b0);  // get_eg(&eg0);
     b0 = dpm_reduceall(b0);
   // get_eg(&eg1); add_eg(&egra,&eg0,&eg1); print_eg("RA",&egra);
   MKLIST(*s,b0);    MKLIST(*s,b0);
 //  print_eg("nf",&eg_nf); printf("\n");  //  print_eg("red",&egred); printf("\n");
 //  print_eg("coef",&egc); printf("\n");  
 }  }
   
 int compdmm_schreyer(int n,DMM m1,DMM m2)  int compdmm_schreyer(int n,DMM m1,DMM m2)
Line 2965  void chsgndpm(DPM p,DPM *pr)
Line 2965  void chsgndpm(DPM p,DPM *pr)
   }    }
 }  }
   
   void mulcmp(Obj c,MP m)
   {
     MP t;
     Obj c1;
   
     for ( t = m; t; t = NEXT(t) ) {
       arf_mul(CO,c,C(t),&c1); C(t) = c1;
     }
   }
   
   void mulcdmm(Obj c,DMM m)
   {
     DMM t;
     Obj c1;
   
     for ( t = m; t; t = NEXT(t) ) {
       arf_mul(CO,c,C(t),&c1); C(t) = c1;
     }
   }
   
 void mulcdpm(VL vl,Obj c,DPM p,DPM *pr)  void mulcdpm(VL vl,Obj c,DPM p,DPM *pr)
 {  {
   DMM m,mr=0,mr0;    DMM m,mr=0,mr0;
Line 3134  DPM dpm_eliminate_term(DPM a,DPM p,Obj c,int pos)
Line 3154  DPM dpm_eliminate_term(DPM a,DPM p,Obj c,int pos)
       NEXTMP(d0,d); d->dl = m->dl; arf_chsgn(m->c,&d->c);        NEXTMP(d0,d); d->dl = m->dl; arf_chsgn(m->c,&d->c);
     }      }
   if ( d0 ) {    if ( d0 ) {
     NEXT(d) = 0; MKDP(NV(a),d,f);      NEXT(d) = 0; MKDP(NV(a),d0,f);
       mulcdpm(CO,c,a,&a1);
       mulobjdpm(CO,(Obj)f,p,&p1);
       adddpm(CO,a1,p1,&r);
       return r;
   } else    } else
     f = 0;      return a;
   mulcdpm(CO,c,a,&a1);  
   mulobjdpm(CO,(Obj)f,p,&p1);  
   adddpm(CO,a1,p1,&r);  
   return r;  
 }  }
   
 // <<...:i>> -> <<...:tab[i]>>  // <<...:i>> -> <<...:tab[i]>>
Line 3153  DPM dpm_compress(DPM p,int *tab)
Line 3173  DPM dpm_compress(DPM p,int *tab)
   else {    else {
     for ( m = BDY(p), mr0 = 0; m; m = NEXT(m) ) {      for ( m = BDY(p), mr0 = 0; m; m = NEXT(m) ) {
       NEXTDMM(mr0,mr);        NEXTDMM(mr0,mr);
       mr->dl = m->dl; mr->c = m->c; mr->pos = tab[mr->pos];        mr->dl = m->dl; mr->c = m->c; mr->pos = tab[m->pos];
       if ( mr->pos <= 0 )        if ( mr->pos <= 0 )
         error("dpm_compress : invalid position");          error("dpm_compress : invalid position");
     }      }
Line 3164  DPM dpm_compress(DPM p,int *tab)
Line 3184  DPM dpm_compress(DPM p,int *tab)
 }  }
   
 // input : s, s = syz(m) output simplified s, m  // input : s, s = syz(m) output simplified s, m
 void dpm_simplify_syz(LIST m,LIST s,LIST *m1,LIST *s1)  void dpm_simplify_syz(LIST s,LIST m,LIST *s1,LIST *m1)
 {  {
   int lm,ls,i,j,pos;    int lm,ls,i,j,pos;
   DPM *am,*as;    DPM *am,*as;
Line 3179  void dpm_simplify_syz(LIST m,LIST s,LIST *m1,LIST *s1)
Line 3199  void dpm_simplify_syz(LIST m,LIST s,LIST *m1,LIST *s1)
   ls = length(BDY(s));    ls = length(BDY(s));
   as = (DPM *)MALLOC(ls*sizeof(DPM));    as = (DPM *)MALLOC(ls*sizeof(DPM));
   for ( i = 1, t = BDY(m); i <= lm; i++, t = NEXT(t) ) am[i] = (DPM)BDY(t);    for ( i = 1, t = BDY(m); i <= lm; i++, t = NEXT(t) ) am[i] = (DPM)BDY(t);
   for ( i = 0, t = BDY(m); i < ls; i++, t = NEXT(t) ) as[i] = (DPM)BDY(t);    for ( i = 0, t = BDY(s); i < ls; i++, t = NEXT(t) ) as[i] = (DPM)BDY(t);
   
   for ( i = 0; i < ls; i++ ) {    for ( i = 0; i < ls; i++ ) {
     p = as[i];      p = as[i];
       if ( p == 0 ) continue;
     for ( d = BDY(p); d; d = NEXT(d) ) if ( d->dl->td == 0 ) break;      for ( d = BDY(p); d; d = NEXT(d) ) if ( d->dl->td == 0 ) break;
     if ( d ) {      if ( d ) {
       c = d->c; pos = d->pos;        c = d->c; pos = d->pos;
       for ( j = 0; j < ls; j++ )        for ( j = 0; j < ls; j++ )
         if ( j != i )          if ( j != i ) {
           as[j] = dpm_eliminate_term(as[j],p,c,pos);            as[j] = dpm_eliminate_term(as[j],p,c,pos);
           }
       // remove m[i]        // remove m[i]
       am[pos] = 0;        am[pos] = 0;
       as[i] = 0;        as[i] = 0;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.8

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