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

Diff for /OpenXM_contrib2/asir2000/engine/dalg.c between version 1.9 and 1.13

version 1.9, 2005/07/11 00:24:02 version 1.13, 2006/01/05 00:21:20
Line 1 
Line 1 
 /*  /*
  * $OpenXM: OpenXM_contrib2/asir2000/engine/dalg.c,v 1.8 2005/01/23 14:03:47 noro Exp $   * $OpenXM: OpenXM_contrib2/asir2000/engine/dalg.c,v 1.12 2005/10/12 14:43:36 noro Exp $
 */  */
   
 #include "ca.h"  #include "ca.h"
Line 65  void setfield_dalg(NODE alist)
Line 65  void setfield_dalg(NODE alist)
                 mb[dim-i-1] = (DP)BDY(t);                  mb[dim-i-1] = (DP)BDY(t);
 }  }
   
   void setfield_gb(NODE gb,VL vl,struct order_spec *spec)
   {
           NumberField nf;
           VL vl1,vl2;
           int n,i,dim;
           Alg *gen;
           P *defpoly;
           P p;
           Q c,iq,two;
           DP *ps,*mb;
           DP one;
           NODE t,b,b1,b2,hlist,mblist;
           struct order_spec *current_spec;
   
           nf = (NumberField)MALLOC(sizeof(struct oNumberField));
           current_numberfield = nf;
           for ( vl1 = vl, n = 0; vl1; vl1 = NEXT(vl1), n++ );
           nf->n = n;
           nf->psn = length(gb);
           nf->vl = vl;
           nf->defpoly = defpoly = (P *)MALLOC(nf->psn*sizeof(P));
           nf->ps = ps = (DP *)MALLOC(nf->psn*sizeof(DP));
           current_spec = dp_current_spec;
           nf->spec = spec;
           initd(nf->spec);
           for ( b = hlist = 0, i = 0, t = gb; i < nf->psn; t = NEXT(t), i++ ) {
                   ptozp((P)BDY(t),1,&c,&defpoly[i]);
                   ptod(CO,vl,defpoly[i],&ps[i]);
                   STOQ(i,iq); MKNODE(b1,(pointer)iq,b); b = b1;
                   MKNODE(b2,(pointer)ps[i],hlist); hlist = b2;
           }
           ptod(ALG,vl,(P)ONE,&one);
           MKDAlg(one,ONE,nf->one);
           nf->ind = b;
           dp_mbase(hlist,&mblist);
           initd(current_spec);
           nf->dim = dim = length(mblist);
           nf->mb = mb = (DP *)MALLOC(dim*sizeof(DP));
           for ( i = 0, t = mblist; t; t = NEXT(t), i++ )
                   mb[dim-i-1] = (DP)BDY(t);
   }
   
 void qtodalg(Q q,DAlg *r)  void qtodalg(Q q,DAlg *r)
 {  {
         NumberField nf;          NumberField nf;
Line 358  void simpdalg(DAlg da,DAlg *r)
Line 400  void simpdalg(DAlg da,DAlg *r)
         }          }
         current_spec = dp_current_spec; initd(nf->spec);          current_spec = dp_current_spec; initd(nf->spec);
         dp_true_nf(nf->ind,da->nm,nf->ps,1,&nm,&dn);          dp_true_nf(nf->ind,da->nm,nf->ps,1,&nm,&dn);
         initd(current_spec);          if ( !nm ) *r = 0;
         mulq(da->dn,dn,&dn1);          else {
         MKDAlg(nm,dn1,d);                  initd(current_spec);
         rmcontdalg(d,r);                  mulq(da->dn,dn,&dn1);
                   MKDAlg(nm,dn1,d);
                   rmcontdalg(d,r);
           }
 }  }
   
 void adddalg(DAlg a,DAlg b,DAlg *c)  void adddalg(DAlg a,DAlg b,DAlg *c)
Line 606  NODE inv_or_split_dalg(DAlg a,DAlg *c)
Line 651  NODE inv_or_split_dalg(DAlg a,DAlg *c)
         struct order_spec *current_spec;          struct order_spec *current_spec;
         struct oEGT eg0,eg1;          struct oEGT eg0,eg1;
         extern struct oEGT eg_le;          extern struct oEGT eg_le;
           extern int DP_Print;
   
         if ( !(nf=current_numberfield) )          if ( !(nf=current_numberfield) )
                 error("invdalg : current_numberfield is not set");                  error("invdalg : current_numberfield is not set");
Line 624  NODE inv_or_split_dalg(DAlg a,DAlg *c)
Line 670  NODE inv_or_split_dalg(DAlg a,DAlg *c)
         simp = (DAlg *)ALLOCA(dim*sizeof(DAlg));          simp = (DAlg *)ALLOCA(dim*sizeof(DAlg));
         current_spec = dp_current_spec; initd(nf->spec);          current_spec = dp_current_spec; initd(nf->spec);
         for ( i = 0; i < dim; i++ ) {          for ( i = 0; i < dim; i++ ) {
                   if ( DP_Print ) { fprintf(asir_out,"."); fflush(asir_out); }
                 m = mb[i];                  m = mb[i];
                 for ( j = i-1; j >= 0; j-- )                  for ( j = i-1; j >= 0; j-- )
                         if ( dp_redble(m,mb[j]) )                          if ( dp_redble(m,mb[j]) )
                                 break;                                  break;
                 if ( j >= 0 ) {                  if ( j >= 0 ) {
                         dp_subd(m,mb[j],&d);                          dp_subd(m,mb[j],&d);
                         muld(CO,d,simp[j]->nm,&u);                          if ( simp[j] ) {
                         MKDAlg(u,simp[j]->dn,t);                                  muld(CO,d,simp[j]->nm,&u);
                         simpdalg(t,&simp[i]);                                  MKDAlg(u,simp[j]->dn,t);
                                   simpdalg(t,&simp[i]);
                           } else
                                   simp[i] = 0;
                 } else {                  } else {
                         MKDAlg(m,ONE,t);                          MKDAlg(m,ONE,t);
                         muldalg(t,a0,&simp[i]);                          muldalg(t,a0,&simp[i]);
                 }                  }
                 gcdn(NM(simp[i]->dn),ln,&gn); divsn(ln,gn,&qn);                  if ( simp[i] ) {
                 muln(NM(simp[i]->dn),qn,&ln);                          gcdn(NM(simp[i]->dn),ln,&gn); divsn(ln,gn,&qn);
                           muln(NM(simp[i]->dn),qn,&ln);
                   }
         }          }
         initd(current_spec);          initd(current_spec);
         NTOQ(ln,1,dn);          NTOQ(ln,1,dn);
Line 646  NODE inv_or_split_dalg(DAlg a,DAlg *c)
Line 698  NODE inv_or_split_dalg(DAlg a,DAlg *c)
         mat = (Q **)BDY(mobj);          mat = (Q **)BDY(mobj);
         mulq(dn,a->dn,&mat[0][dim]);          mulq(dn,a->dn,&mat[0][dim]);
         for ( j = 0; j < dim; j++ ) {          for ( j = 0; j < dim; j++ ) {
                 divq(dn,simp[j]->dn,&mul);                  if ( simp[j] ) {
                 for ( i = dim-1, mp = BDY(simp[j]->nm); mp && i >= 0; i-- )                          divq(dn,simp[j]->dn,&mul);
                         if ( dl_equal(n,BDY(mb[i])->dl,mp->dl) ) {                          for ( i = dim-1, mp = BDY(simp[j]->nm); mp && i >= 0; i-- )
                                 mulq(mul,(Q)mp->c,&mat[i][j]);                                  if ( dl_equal(n,BDY(mb[i])->dl,mp->dl) ) {
                                 mp = NEXT(mp);                                          mulq(mul,(Q)mp->c,&mat[i][j]);
                         }                                          mp = NEXT(mp);
                                   }
                   }
         }          }
         get_eg(&eg0);          get_eg(&eg0);
         rank = generic_gauss_elim_hensel(mobj,&sol,&dnsol,&rinfo,&cinfo);          rank = generic_gauss_elim_hensel_dalg(mobj,&sol,&dnsol,&rinfo,&cinfo);
         get_eg(&eg1); add_eg(&eg_le,&eg0,&eg1);          get_eg(&eg1); add_eg(&eg_le,&eg0,&eg1);
         if ( cinfo[0] == dim ) {          if ( cinfo[0] == dim ) {
                 /* the input is invertible */                  /* the input is invertible */
Line 672  NODE inv_or_split_dalg(DAlg a,DAlg *c)
Line 726  NODE inv_or_split_dalg(DAlg a,DAlg *c)
                 return 0;                  return 0;
         } else {          } else {
                 /* the input is not invertible */                  /* the input is not invertible */
                 nparam = (dim+1)-rank;                  nparam = sol->col;
                 /* the index 'dim' should not be in cinfo[] */  
                 solmat = (Q **)BDY(sol);                  solmat = (Q **)BDY(sol);
                 for ( k = 0; k < nparam; k++ )  
                         if ( cinfo[k] == dim )  
                                 error("invdalg : cannot happen");  
                 nd0 = 0;                  nd0 = 0;
                 for ( k = 0; k < nparam; k++ ) {                  for ( k = 0; k < nparam; k++ ) {
                         m = mb[cinfo[k]];  
                         for ( ndt = nd0; ndt; ndt = NEXT(ndt) ) {  
                                 if ( dp_redble(m,(DP)BDY(ndt)) ) break;  
                         }  
                         /* skip a redundunt basis element */  
                         if ( ndt ) continue;  
                         /* construct a new basis element */                          /* construct a new basis element */
                           m = mb[cinfo[k]];
                         mp0 = 0;                          mp0 = 0;
                         NEXTMP(mp0,mp);                          NEXTMP(mp0,mp);
                         chsgnq(dnsol,&dn1); mp->c = (P)dn1;                          chsgnq(dnsol,&dn1); mp->c = (P)dn1;

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

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