[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.136 and 1.144

version 1.136, 2006/06/11 06:01:55 version 1.144, 2006/08/26 03:09:55
Line 1 
Line 1 
 /* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.135 2006/06/06 09:00:38 noro Exp $ */  /* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.143 2006/08/09 02:48:49 noro Exp $ */
   
 #include "nd.h"  #include "nd.h"
   
Line 1592  NODE nd_gb(int m,int ishomo,int checkonly)
Line 1592  NODE nd_gb(int m,int ishomo,int checkonly)
         NDV nfv;          NDV nfv;
         Q q,num,den;          Q q,num,den;
         union oNDC dn;          union oNDC dn;
           int diag_count = 0;
   
         g = 0; d = 0;          g = 0; d = 0;
         for ( i = 0; i < nd_psn; i++ ) {          for ( i = 0; i < nd_psn; i++ ) {
Line 1604  again:
Line 1605  again:
                 l = nd_minp(d,&d);                  l = nd_minp(d,&d);
                 if ( SG(l) != sugar ) {                  if ( SG(l) != sugar ) {
                         if ( ishomo ) {                          if ( ishomo ) {
                                   diag_count = 0;
                                 stat = do_diagonalize(sugar,m);                                  stat = do_diagonalize(sugar,m);
                                 if ( !stat ) {                                  if ( !stat ) {
                                         NEXT(l) = d; d = l;                                          NEXT(l) = d; d = l;
Line 1639  again:
Line 1641  again:
                         }                          }
                         nfv = ndtondv(m,nf); nd_free(nf);                          nfv = ndtondv(m,nf); nd_free(nf);
                         nh = ndv_newps(m,nfv,0);                          nh = ndv_newps(m,nfv,0);
                           if ( !m && (ishomo && ++diag_count == diag_period) ) {
                                   diag_count = 0;
                                   stat = do_diagonalize(sugar,m);
                                   if ( !stat ) {
                                           NEXT(l) = d; d = l;
                                           d = nd_reconstruct(1,d);
                                           goto again;
                                   }
                           }
                         d = update_pairs(d,g,nh);                          d = update_pairs(d,g,nh);
                         g = update_base(g,nh);                          g = update_base(g,nh);
                         FREENDP(l);                          FREENDP(l);
Line 2083  ND_pairs equivalent_pairs( ND_pairs d1, ND_pairs *pres
Line 2094  ND_pairs equivalent_pairs( ND_pairs d1, ND_pairs *pres
 NODE update_base(NODE nd,int ndp)  NODE update_base(NODE nd,int ndp)
 {  {
         UINT *dl, *dln;          UINT *dl, *dln;
         NODE last, p, head, cur, prev;          NODE last, p, head;
   
         dl = DL(nd_psh[ndp]);          dl = DL(nd_psh[ndp]);
         for ( head = last = 0, p = nd; p; ) {          for ( head = last = 0, p = nd; p; ) {
Line 2096  NODE update_base(NODE nd,int ndp)
Line 2107  NODE update_base(NODE nd,int ndp)
                         p = NEXT(last = p);                          p = NEXT(last = p);
                 }                  }
         }          }
 #if 1  
         head = append_one(head,ndp);          head = append_one(head,ndp);
 #else  
         for ( prev = 0, cur = head;  cur; prev = cur, cur = NEXT(cur) )  
                 if ( ndv_compare(&(nd_ps[ndp]),&(nd_ps[(int)BDY(cur)]))<0 ) break;  
         MKNODE(p,(pointer)ndp,cur);  
         if ( !prev )  
                 head = p;  
         else  
                 NEXT(prev) = p;  
 #endif  
         return head;          return head;
 }  }
   
Line 2218  void ndv_setup(int mod,int trace,NODE f,int dont_sort)
Line 2219  void ndv_setup(int mod,int trace,NODE f,int dont_sort)
         for ( nd_psn = 0, s = f; s; s = NEXT(s) ) if ( BDY(s) ) nd_psn++;          for ( nd_psn = 0, s = f; s; s = NEXT(s) ) if ( BDY(s) ) nd_psn++;
         w = (NDV *)ALLOCA(nd_psn*sizeof(NDV));          w = (NDV *)ALLOCA(nd_psn*sizeof(NDV));
         for ( i = 0, s = f; s; s = NEXT(s) ) if ( BDY(s) ) w[i++] = BDY(s);          for ( i = 0, s = f; s; s = NEXT(s) ) if ( BDY(s) ) w[i++] = BDY(s);
         if ( !dont_sort )          if ( !dont_sort ) {
                 qsort(w,nd_psn,sizeof(NDV),                  /* XXX heuristic */
                         (int (*)(const void *,const void *))ndv_compare);                  if ( !nd_ord->id && (nd_ord->ord.simple<2) )
                           qsort(w,nd_psn,sizeof(NDV),
                                   (int (*)(const void *,const void *))ndv_compare_rev);
                   else
                           qsort(w,nd_psn,sizeof(NDV),
                                   (int (*)(const void *,const void *))ndv_compare);
           }
         nd_pslen = 2*nd_psn;          nd_pslen = 2*nd_psn;
         nd_ps = (NDV *)MALLOC(nd_pslen*sizeof(NDV));          nd_ps = (NDV *)MALLOC(nd_pslen*sizeof(NDV));
         nd_ps_trace = (NDV *)MALLOC(nd_pslen*sizeof(NDV));          nd_ps_trace = (NDV *)MALLOC(nd_pslen*sizeof(NDV));
Line 2369  void nd_gr(LIST f,LIST v,int m,int f4,struct order_spe
Line 2376  void nd_gr(LIST f,LIST v,int m,int f4,struct order_spe
         NDV b;          NDV b;
         int ishomo,nalg;          int ishomo,nalg;
         Alg alpha,dp;          Alg alpha,dp;
         P p;          P p,zp;
           Q dmy;
         LIST f1,f2;          LIST f1,f2;
         Obj obj;          Obj obj;
         NumberField nf;          NumberField nf;
Line 2415  void nd_gr(LIST f,LIST v,int m,int f4,struct order_spe
Line 2423  void nd_gr(LIST f,LIST v,int m,int f4,struct order_spe
         nd_setup_parameters(nvar,max);          nd_setup_parameters(nvar,max);
         ishomo = 1;          ishomo = 1;
         for ( fd0 = 0, t = BDY(f); t; t = NEXT(t) ) {          for ( fd0 = 0, t = BDY(f); t; t = NEXT(t) ) {
                 b = (pointer)ptondv(CO,vv,(P)BDY(t));                  ptozp((P)BDY(t),1,&dmy,&zp);
                   b = (pointer)ptondv(CO,vv,zp);
                 if ( ishomo )                  if ( ishomo )
                         ishomo = ishomo && ndv_ishomo(b);                          ishomo = ishomo && ndv_ishomo(b);
                 if ( m ) ndv_mod(m,b);                  if ( m ) ndv_mod(m,b);
Line 2448  void nd_gr_postproc(LIST f,LIST v,int m,struct order_s
Line 2457  void nd_gr_postproc(LIST f,LIST v,int m,struct order_s
         NDV b;          NDV b;
         int ishomo,nalg;          int ishomo,nalg;
         Alg alpha,dp;          Alg alpha,dp;
         P p;          P p,zp;
           Q dmy;
         LIST f1,f2;          LIST f1,f2;
         Obj obj;          Obj obj;
         NumberField nf;          NumberField nf;
Line 2488  void nd_gr_postproc(LIST f,LIST v,int m,struct order_s
Line 2498  void nd_gr_postproc(LIST f,LIST v,int m,struct order_s
         nd_setup_parameters(nvar,max);          nd_setup_parameters(nvar,max);
         ishomo = 1;          ishomo = 1;
         for ( fd0 = 0, t = BDY(f); t; t = NEXT(t) ) {          for ( fd0 = 0, t = BDY(f); t; t = NEXT(t) ) {
                 b = (pointer)ptondv(CO,vv,(P)BDY(t));                  ptozp((P)BDY(t),1,&dmy,&zp);
                   b = (pointer)ptondv(CO,vv,zp);
                 if ( ishomo )                  if ( ishomo )
                         ishomo = ishomo && ndv_ishomo(b);                          ishomo = ishomo && ndv_ishomo(b);
                 if ( m ) ndv_mod(m,b);                  if ( m ) ndv_mod(m,b);
Line 2527  void nd_gr_trace(LIST f,LIST v,int trace,int homo,int 
Line 2538  void nd_gr_trace(LIST f,LIST v,int trace,int homo,int 
         int m,nocheck,nvar,mindex,e,max;          int m,nocheck,nvar,mindex,e,max;
         NDV c;          NDV c;
         NMV a;          NMV a;
         P p;          P p,zp;
           Q dmy;
         EPOS oepos;          EPOS oepos;
         int obpe,oadv,wmax,i,len,cbpe,ishomo,nalg;          int obpe,oadv,wmax,i,len,cbpe,ishomo,nalg;
         Alg alpha,dp;          Alg alpha,dp;
Line 2582  void nd_gr_trace(LIST f,LIST v,int trace,int homo,int 
Line 2594  void nd_gr_trace(LIST f,LIST v,int trace,int homo,int 
         obpe = nd_bpe; oadv = nmv_adv; oepos = nd_epos;          obpe = nd_bpe; oadv = nmv_adv; oepos = nd_epos;
         ishomo = 1;          ishomo = 1;
         for ( in0 = 0, fd0 = 0, t = BDY(f); t; t = NEXT(t) ) {          for ( in0 = 0, fd0 = 0, t = BDY(f); t; t = NEXT(t) ) {
                 c = ptondv(CO,vv,(P)BDY(t));                  ptozp((P)BDY(t),1,&dmy,&zp);
                   c = (pointer)ptondv(CO,vv,zp);
                 if ( ishomo )                  if ( ishomo )
                         ishomo = ishomo && ndv_ishomo(c);                          ishomo = ishomo && ndv_ishomo(c);
                 if ( c ) {                  if ( c ) {
Line 4844  NODE nd_f4_red_q_main(ND_pairs sp0,int nsp,int trace,U
Line 4857  NODE nd_f4_red_q_main(ND_pairs sp0,int nsp,int trace,U
         struct oEGT eg0,eg1,eg2,eg_f4,eg_f4_1,eg_f4_2;          struct oEGT eg0,eg1,eg2,eg_f4,eg_f4_1,eg_f4_2;
         int maxrs;          int maxrs;
         int *spsugar;          int *spsugar;
           pointer *w;
   
         spcol = col-nred;          spcol = col-nred;
         get_eg(&eg0);          get_eg(&eg0);
Line 4877  NODE nd_f4_red_q_main(ND_pairs sp0,int nsp,int trace,U
Line 4891  NODE nd_f4_red_q_main(ND_pairs sp0,int nsp,int trace,U
         /* elimination (2nd step) */          /* elimination (2nd step) */
         colstat = (int *)ALLOCA(spcol*sizeof(int));          colstat = (int *)ALLOCA(spcol*sizeof(int));
         rank = nd_gauss_elim_q(spmat,spsugar,sprow,spcol,colstat);          rank = nd_gauss_elim_q(spmat,spsugar,sprow,spcol,colstat);
         r0 = 0;          w = (pointer *)ALLOCA(rank*sizeof(pointer));
         for ( i = 0; i < rank; i++ ) {          for ( i = 0; i < rank; i++ ) {
                 NEXTNODE(r0,r); BDY(r) =                  w[rank-i-1] = (pointer)vect_to_ndv_q(spmat[i],spcol,col,rhead,s0vect);
                         (pointer)vect_to_ndv_q(spmat[i],spcol,col,rhead,s0vect);                  SG((NDV)w[rank-i-1]) = spsugar[i];
                 SG((NDV)BDY(r)) = spsugar[i];  
 /*              GC_free(spmat[i]); */  /*              GC_free(spmat[i]); */
         }          }
   #if 0
           qsort(w,rank,sizeof(NDV),
                   (int (*)(const void *,const void *))ndv_compare);
   #endif
           r0 = 0;
           for ( i = 0; i < rank; i++ ) {
                   NEXTNODE(r0,r); BDY(r) = w[i];
           }
         if ( r0 ) NEXT(r) = 0;          if ( r0 ) NEXT(r) = 0;
   
 /*      for ( ; i < sprow; i++ ) GC_free(spmat[i]); */  /*      for ( ; i < sprow; i++ ) GC_free(spmat[i]); */
         get_eg(&eg2); init_eg(&eg_f4_2); add_eg(&eg_f4_2,&eg1,&eg2);          get_eg(&eg2); init_eg(&eg_f4_2); add_eg(&eg_f4_2,&eg1,&eg2);
         init_eg(&eg_f4); add_eg(&eg_f4,&eg0,&eg2);          init_eg(&eg_f4); add_eg(&eg_f4,&eg0,&eg2);

Legend:
Removed from v.1.136  
changed lines
  Added in v.1.144

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