Changeset 405ebc in git


Ignore:
Timestamp:
Jun 27, 2001, 3:58:06 PM (23 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
409020f4846b2e67e3e541d8288ef4e479652c98
Parents:
c7bbf368257aae665cbcd55c9a3d18af43aa3dc0
Message:
*hannes/GP: debug newfactoras, char_series, ...


git-svn-id: file:///usr/local/Singular/svn/trunk@5515 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
libfac
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • libfac/charset/alg_factor.cc

    rc7bbf3 r405ebc  
    33// emacs edit mode for this file is -*- C++ -*-
    44////////////////////////////////////////////////////////////
    5 static char * rcsid = "$Id: alg_factor.cc,v 1.6 2001-06-21 14:57:04 Singular Exp $";
     5static char * rcsid = "$Id: alg_factor.cc,v 1.7 2001-06-27 13:58:05 Singular Exp $";
    66////////////////////////////////////////////////////////////
    77// FACTORY - Includes
     
    3030TIMING_DEFINE_PRINT(newfactoras_time);
    3131
     32static Varlist
     33Var_is_in_AS(const Varlist & uord, const CFList & Astar);
     34
    3235int getAlgVar(const CanonicalForm &f, Variable &X)
    3336{
     
    177180    DEBOUTLN(cout, "sqrf_norm_sub: R= ", R);
    178181    // sqfree check ; R is a polynomial in K[x]
    179     if ( getCharacteristic() == 0 ){
     182    if ( getCharacteristic() == 0 )
     183    {
    180184      temp= gcd(R, R.deriv(vf));
    181185      DEBOUTLN(cout, "sqrf_norm_sub: temp= ", temp);
     
    355359
    356360  DEBINCLEVEL(cout,"alg_factor");
     361  DEBOUTLN(cout, "alg_factor: f= ", f);
    357362  substlist= simpleextension(Astar, vminpoly, Rstar);
    358363  DEBOUTLN(cout, "alg_factor: substlist= ", substlist);
     
    666671/*
    667672$Log: not supported by cvs2svn $
     673Revision 1.6  2001/06/21 14:57:04  Singular
     674*hannes/GP: Factorize, newfactoras, ...
     675
    668676Revision 1.5  2001/06/18 08:44:39  pfister
    669677* hannes/GP/michael: factory debug, Factorize
     
    685693
    686694*/
    687 
  • libfac/charset/algfactor.cc

    rc7bbf3 r405ebc  
    33// emacs edit mode for this file is -*- C++ -*-
    44////////////////////////////////////////////////////////////
    5 static char * rcsid = "$Id: algfactor.cc,v 1.4 2001-06-21 14:57:04 Singular Exp $";
     5static char * rcsid = "$Id: algfactor.cc,v 1.5 2001-06-27 13:58:05 Singular Exp $";
    66////////////////////////////////////////////////////////////
    77// FACTORY - Includes
     
    2828#include "timing.h"
    2929TIMING_DEFINE_PRINT(newfactoras_time);
     30
     31int hasVar(const CanonicalForm &f, const Variable &v);
    3032
    3133static CFFList
     
    146148  // check trivial case:
    147149  if ( degree(f, order.getLast())==0 || degree(g, order.getLast())==0)
     150  {
     151    DEBOUTLN(cout, "algcd Result= ", 1);
    148152    return CanonicalForm(1);
    149 
     153  }
    150154
    151155  CFList bs; bs.append(f); bs.append(g);
     
    163167  {
    164168    result= cs.getLast();
    165     result/=result.Lc();
     169    CanonicalForm c=vcontent(result,Variable(1));
     170    //CanonicalForm c=result.Lc();
     171    result/=c;
     172    for(CFListIterator i=as;i.hasItem(); i++ )
     173    {
     174      if(hasVar(result,i.getItem().mvar()))
     175      {
     176        c=vcontent(result,Variable(i.getItem().level()+1));
     177        result/=c;
     178      }
     179    }
    166180  }
    167181  else result= CanonicalForm(1);
    168   DEBOUTLN(cout, "Result= ", result);
     182  DEBOUTLN(cout, "algcd Result= ", result);
    169183  return result;
    170184}
     
    340354    DEBOUT(cout, ",", fp(substback,vf));
    341355    DEBOUT(cout, ") over K_r wrt ", vf);
    342     //cout << "algcd(" << g << "," << fp(substback,vf) << " as:" << as <<endl;
    343356    fp= algcd(g,fp(substback,vf), as, oldord);
    344     //cout << "algcd res:" << fp << endl;
    345357    DEBOUTLN(cout, " = ", fp);
    346358    if ( degree(fp,vf) > 0 ){ //otherwise it's a constant
     
    360372    DEBOUT(cout, ",", fp(substback,vf));
    361373    DEBOUT(cout, ") over K_r wrt ", vf);
    362     //cout << "algcd(" << g << "," << fp(substback,vf) << " as:" << as <<endl;
    363374    fp= algcd(g,fp(substback,vf), as, oldord);
    364     //cout << "algcd res:" << fp << endl;
    365375    DEBOUTLN(cout, " = ", fp);
    366376    if ( degree(fp,vf) > 0 ){ //otherwise it's a constant
     
    438448/*
    439449$Log: not supported by cvs2svn $
     450Revision 1.4  2001/06/21 14:57:04  Singular
     451*hannes/GP: Factorize, newfactoras, ...
     452
    440453Revision 1.3  2001/06/18 08:44:40  pfister
    441454* hannes/GP/michael: factory debug, Factorize
  • libfac/charset/charset.cc

    rc7bbf3 r405ebc  
    22////////////////////////////////////////////////////////////
    33// emacs edit mode for this file is -*- C++ -*-
    4 static char * rcsid = "$Id: charset.cc,v 1.6 2000-03-08 12:54:35 obachman Exp $";
     4static char * rcsid = "$Id: charset.cc,v 1.7 2001-06-27 13:58:06 Singular Exp $";
    55/////////////////////////////////////////////////////////////
    66// FACTORY - Includes
     
    5555    if ( PS.length() < 2 ) return PS;
    5656    while ( ! QS.isEmpty() ) {
    57         b = lowestRank( QS );
    58         cb = rank( b );
    59         DEBOUTLN(cout, "BasicSet: choose b  = ", b);
    60         DEBOUTLN(cout, "BasicSet: it's rank = ", cb);
    61         BS=Union(CFList(b),BS);//BS.append( b );
    62         if ( rank( b ) == 0 )
    63             return Union(PS, CFList(b)) ; // b should be the first elem!
    64         else {
    65             RS = CFList();
    66             // QS:= {q \in QS -{B} | q is reduced wrt b}
    67             // We can process whole QS, because b is not reduced wrt. b
    68             for ( CFListIterator i = QS; i.hasItem(); ++i )
    69                 if ( degree( i.getItem(), cb ) < degree( b ) )
    70                     //RS.append( i.getItem() );
     57        b = lowestRank( QS );
     58        cb = rank( b );
     59        DEBOUTLN(cout, "BasicSet: choose b  = ", b);
     60        DEBOUTLN(cout, "BasicSet: it's rank = ", cb);
     61        BS=Union(CFList(b),BS);//BS.append( b );
     62        if ( rank( b ) == 0 )
     63            return Union(PS, CFList(b)) ; // b should be the first elem!
     64        else {
     65            RS = CFList();
     66            // QS:= {q \in QS -{B} | q is reduced wrt b}
     67            // We can process whole QS, because b is not reduced wrt. b
     68            for ( CFListIterator i = QS; i.hasItem(); ++i )
     69                if ( degree( i.getItem(), cb ) < degree( b ) )
     70                    //RS.append( i.getItem() );
    7171                    RS = Union(CFList(i.getItem()),RS);
    72             QS = RS;
    73         }
     72            QS = RS;
     73        }
    7474    }
    7575    DEBOUTLN(cout, "BasicSet: returning bs= ", BS);
     
    8585    for (CFListIterator j=FS2; j.hasItem(); j++){
    8686      if (elem == j.getItem()){
    87         //      FS2= Difference(FS2,CFList(elem));
    88         return 0;
     87         //        FS2= Difference(FS2,CFList(elem));
     88         return 0;
    8989      }
    9090    }
     
    130130      //PremForm Newremember=Remembern;
    131131      for ( CFListIterator i = D; i.hasItem(); ++i ) {
    132         CanonicalForm r = Prem( i.getItem(), CS );
    133         DEBOUT(cout,"MCharSetN: Prem(", i.getItem()  );
    134         DEBOUT(cout, ",", CS);
    135         DEBOUTLN(cout,") = ", r);
     132        CanonicalForm r = Prem( i.getItem(), CS );
     133        DEBOUT(cout,"MCharSetN: Prem(", i.getItem()  );
     134        DEBOUT(cout, ",", CS);
     135        DEBOUTLN(cout,") = ", r);
    136136//cout << "MCharSetN: Prem("<< i.getItem() << "," << CS << ") = " << r << endl;
    137         if ( r != 0 ){
    138           //removefactor( r, Newremember );
    139           removefactor( r, Remembern );
    140           //Remembern.FS2 = Union(Remembern.FS2, Newremember.FS2);
    141           //Newremember = Oldremember;
    142           //if ( cls(r) > 0 )
    143             //RS=Union(CFList(r),RS);//RS.append( r );
     137        if ( r != 0 ){
     138          //removefactor( r, Newremember );
     139          removefactor( r, Remembern );
     140          //Remembern.FS2 = Union(Remembern.FS2, Newremember.FS2);
     141          //Newremember = Oldremember;
     142          //if ( cls(r) > 0 )
     143            //RS=Union(CFList(r),RS);//RS.append( r );
    144144            RS=Union(RS,CFList(r));
    145         }
     145        }
    146146      }
    147147      if ( ! checkok(RS,Remembern.FS2)) return CFList(CanonicalForm(1));
     
    179179  while ( ! RS.isEmpty() ) {
    180180    CS = BasicSet( QS );
     181    DEBOUTLN(cout, "CharSet: CS= ", CS);
    181182    RS = CFList();
    182183    if ( rank( CS.getFirst() ) != 0 ) {
    183184      CFList D = Difference( QS, CS );
    184185      for ( CFListIterator i = D; i.hasItem(); ++i ) {
    185         CanonicalForm r = Prem( i.getItem(), CS );
    186         if ( r != 0 )  RS=Union(CFList(r),RS);//RS.append( r );
     186        CanonicalForm r = Prem( i.getItem(), CS );
     187        if ( r != 0 )  RS=Union(CFList(r),RS);//RS.append( r );
    187188      }
    188189      QS = Union( QS, RS );
     
    202203      CFList D = Difference( QS, CS );
    203204      for ( CFListIterator i = D; i.hasItem(); ++i ) {
    204         CanonicalForm r = Prem( i.getItem(), CS );
    205         if ( r != 0 )  RS=Union(CFList(r),RS);//RS.append( r );
     205        CanonicalForm r = Prem( i.getItem(), CS );
     206        if ( r != 0 )  RS=Union(CFList(r),RS);//RS.append( r );
    206207      }
    207208      QS = Union(CS,Union( QS, RS ));
     
    235236    if ( ! member(iitem, mem))
    236237      for ( ListCFListIterator j=i; j.hasItem(); j++){
    237         jitem=j.getItem();
    238         if ( ! same( iitem, jitem ) )
    239           if ( ! member(jitem, mem))
    240             if ( contractsub(iitem, jitem) ){
    241               ts.append(jitem); mem.append(jitem);
    242             }
    243             else
    244               if ( contractsub(jitem, iitem) ){
    245                 ts.append(iitem);
    246               }
     238        jitem=j.getItem();
     239        if ( ! same( iitem, jitem ) )
     240          if ( ! member(jitem, mem))
     241            if ( contractsub(iitem, jitem) ){
     242              ts.append(jitem); mem.append(jitem);
     243            }
     244            else
     245              if ( contractsub(jitem, iitem) ){
     246                ts.append(iitem);
     247              }
    247248      }
    248249  }
     
    250251}
    251252
    252 static ListCFList 
     253static ListCFList
    253254adjoin(const CFList & is, const CFList & qs, const ListCFList & qh ){
    254255  ListCFList iss,qhi;
     
    261262  for ( i=is ; i.hasItem(); i++ ){
    262263    elem=i.getItem();
    263     if ( cls(elem) > 0 ) iscopy=Union(CFList(elem),iscopy); 
     264    if ( cls(elem) > 0 ) iscopy=Union(CFList(elem),iscopy);
    264265  }
    265266  if ( iscopy.isEmpty() ) return iss;
     
    271272    if ( length > 0 )
    272273      for ( j=qhi; j.hasItem(); j++ )
    273         if ( subset(j.getItem(),itt )) ind=1;
     274        if ( subset(j.getItem(),itt )) ind=1;
    274275    if ( ind == 0 ) iss.append(itt);
    275276  }
     
    277278}
    278279
    279 static ListCFList 
     280static ListCFList
    280281adjoinb(const CFList & is, const CFList & qs, const ListCFList & qh ,const CFList & cs){
    281282  ListCFList iss,qhi;
     
    288289  for ( i=is ; i.hasItem(); i++ ){
    289290    elem=i.getItem();
    290     if ( cls(elem) > 0 ) iscopy=Union(CFList(elem),iscopy); 
     291    if ( cls(elem) > 0 ) iscopy=Union(CFList(elem),iscopy);
    291292  }
    292293  if ( iscopy.isEmpty() ) return iss;
     
    298299    if ( length > 0 )
    299300      for ( j=qhi; j.hasItem(); j++ )
    300         if ( subset(j.getItem(),itt )) ind=1;
     301        if ( subset(j.getItem(),itt )) ind=1;
    301302    if ( ind == 0 ) {iss.append(itt);}
    302303  }
     
    313314  for ( ListCFListIterator i=copy ; i.hasItem(); i++ ){
    314315    elem = i.getItem();
    315     if ( elem.length() > l.length() ) { 
     316    if ( elem.length() > l.length() ) {
    316317      output = MyUnion( ListCFList(l), output);
    317318      l= elem;
     
    325326
    326327#ifdef EXPERIMENTAL
    327 static CFList 
     328static CFList
    328329getItemNr( int nr, const ListCFList & copy){
    329330  int i =1;
     
    349350  ListCFList output;
    350351
    351   cout << "Sort: list to sort is: " <<  list_to_sort << endl; 
     352  cout << "Sort: list to sort is: " <<  list_to_sort << endl;
    352353  for (int i=1; i<= number; i++){
    353354    cout << " Next elem = "; cin >> nr;
     
    370371  CFList qs,cs,factorset,is,ts;
    371372  ListCFList pi,ppi,qqi,qsi,iss,qhi= ListCFList(PS);
    372   int nr_of_iteration=0,ts2,highestlevel=0; 
     373  int nr_of_iteration=0,ts2,highestlevel=0;
    373374#ifdef EXPERIMENTAL
    374375  int choice=1;;
     
    426427      // next is preliminary: should be ==0
    427428      if ( ts2 <= 0 ){ //irreducible
    428         if ( ! subset(cs,qs) ){
    429           DEBOUTMSG(cout, "cs is not a subset of qs");
    430           cs = charseta(Union(qs,cs));
    431           DEBOUTLN(cout, "new cs is: ", cs);
    432         }
    433         if ( ! member(cs,pi) ){
    434           pi = MyUnion(pi, ListCFList(cs));
    435           DEBOUTMSG(cout, "cs is not a member of pi");
    436           DEBOUTLN(cout, "pi is: ", pi);
    437           if ( cls(cs.getFirst()) > 0 ){
    438             ts = irras(cs,ts2,reducible);
    439 
    440             // INTERRUPTHANDLER
    441             if ( interrupt_handle() ) return ListCFList() ;
    442             // INTERRUPTHANDLER
    443 
    444             DEBOUTLN(cout, "ts is: ", ts);
    445             DEBOUTLN(cout, "ts2 is: ", ts2);
    446             // next is preliminary: should be ==0
    447             if ( ts2 <= 0 ){ //irreducible
    448               qsi = MyUnion(qsi,ListCFList(cs));
    449               DEBOUTLN(cout, "qsi is: ", qsi);
    450               if ( cs.length() == highestlevel ){
    451                 DEBOUTLN(cout, "cs.length() == nops(ord) :", cs.length());
    452                 is = factorps(factorset);
    453               }
    454               else{
    455                 DEBOUT(cout,"cs.length() != nops(ord) :", cs.length());
    456                 DEBOUTLN(cout, "  nops(ord)= ", highestlevel);
    457                 is = Union(initalset1(cs),factorps(factorset));
    458               }
    459               DEBOUTLN(cout, "is is: ", is);
    460               iss = adjoin(is,qs,qqi);
    461               DEBOUTLN(cout, "iss is: ", iss);
    462             }
    463           }
    464           else{ iss = adjoin(factorps(factorset),qs,qqi); }
    465         }
    466         else{
    467           DEBOUTMSG(cout, "cs is a member of pi");
    468           iss = adjoin(factorps(factorset),qs,qqi); }
    469         DEBOUTLN(cout, "iss is: ", iss);
    470         DEBOUTLN(cout, "   factorps(factorset)= ", factorps(factorset));
    471         DEBOUTLN(cout, "   qs= ", qs);
    472         DEBOUTLN(cout, "   qqi= ", qqi);
     429        if ( ! subset(cs,qs) ){
     430          DEBOUTMSG(cout, "cs is not a subset of qs");
     431          cs = charseta(Union(qs,cs));
     432          DEBOUTLN(cout, "new cs is: ", cs);
     433        }
     434        if ( ! member(cs,pi) ){
     435          pi = MyUnion(pi, ListCFList(cs));
     436          DEBOUTMSG(cout, "cs is not a member of pi");
     437          DEBOUTLN(cout, "pi is: ", pi);
     438          if ( cls(cs.getFirst()) > 0 ){
     439            ts = irras(cs,ts2,reducible);
     440
     441            // INTERRUPTHANDLER
     442            if ( interrupt_handle() ) return ListCFList() ;
     443            // INTERRUPTHANDLER
     444
     445            DEBOUTLN(cout, "ts is: ", ts);
     446            DEBOUTLN(cout, "ts2 is: ", ts2);
     447            // next is preliminary: should be ==0
     448            if ( ts2 <= 0 ){ //irreducible
     449              qsi = MyUnion(qsi,ListCFList(cs));
     450              DEBOUTLN(cout, "qsi is: ", qsi);
     451              if ( cs.length() == highestlevel ){
     452                DEBOUTLN(cout, "cs.length() == nops(ord) :", cs.length());
     453                is = factorps(factorset);
     454              }
     455              else{
     456                DEBOUT(cout,"cs.length() != nops(ord) :", cs.length());
     457                DEBOUTLN(cout, "  nops(ord)= ", highestlevel);
     458                is = Union(initalset1(cs),factorps(factorset));
     459              }
     460              DEBOUTLN(cout, "is is: ", is);
     461              iss = adjoin(is,qs,qqi);
     462              DEBOUTLN(cout, "iss is: ", iss);
     463            }
     464          }
     465          else{ iss = adjoin(factorps(factorset),qs,qqi); }
     466        }
     467        else{
     468          DEBOUTMSG(cout, "cs is a member of pi");
     469          iss = adjoin(factorps(factorset),qs,qqi); }
     470        DEBOUTLN(cout, "iss is: ", iss);
     471        DEBOUTLN(cout, "   factorps(factorset)= ", factorps(factorset));
     472        DEBOUTLN(cout, "   qs= ", qs);
     473        DEBOUTLN(cout, "   qqi= ", qqi);
    473474      }
    474475      // next is preliminary: should be !=0
    475476      if ( ts2 > 0 ){
    476         is = factorps(factorset);
    477         DEBOUTLN(cout, "is is: ", is);
    478         if ( ts2 > 1 ){
    479           // setup cst: need it later for adjoinb
    480           CFList cst;
    481           for ( CFListIterator i=cs ; i.hasItem(); i++){
    482             if ( i.getItem() == reducible ) { break; }
    483             else { cst.append(i.getItem()); }
    484           }
    485           is = Union(initalset1(cst), is);
    486           iss = MyUnion(adjoin(is,qs,qqi), adjoinb(ts,qs,qqi,cst));
    487         }
    488         else{ iss = adjoin(Union(is,ts),qs,qqi); }
    489         DEBOUTLN(cout, "iss is: ", iss);
    490       }
    491     }
    492     else{ 
    493       iss = adjoin(factorps(factorset),qs,qqi); 
     477        is = factorps(factorset);
     478        DEBOUTLN(cout, "is is: ", is);
     479        if ( ts2 > 1 ){
     480          // setup cst: need it later for adjoinb
     481          CFList cst;
     482          for ( CFListIterator i=cs ; i.hasItem(); i++){
     483            if ( i.getItem() == reducible ) { break; }
     484            else { cst.append(i.getItem()); }
     485          }
     486          is = Union(initalset1(cst), is);
     487          iss = MyUnion(adjoin(is,qs,qqi), adjoinb(ts,qs,qqi,cst));
     488        }
     489        else{ iss = adjoin(Union(is,ts),qs,qqi); }
     490        DEBOUTLN(cout, "iss is: ", iss);
     491      }
     492    }
     493    else{
     494      iss = adjoin(factorps(factorset),qs,qqi);
    494495      DEBOUTMSG(cout, "case: cs is a constant.");
    495496      DEBOUTLN(cout, "  qs = ", qs);
     
    501502    DEBOUTLN(cout, "iss is: ", iss);
    502503  }
    503   if ( ! qsi.isEmpty() ){ 
     504  if ( ! qsi.isEmpty() ){
    504505    DEBOUTLN(cout, "qsi before contract= ", qsi);
    505506    if ( opt == 0 ){
    506        return contract( qsi ); 
     507       return contract( qsi );
    507508    }
    508509    else { return qsi; }
    509510  }
    510511  else{ return ListCFList() ; }
    511 } 
     512}
    512513
    513514// tests for characteristic sets
     
    548549    if ( (qs.length() >= 2 ) || (qs.getFirst().exp() > 1)){
    549550      DEBOUTLN(cout, "irras: Setting ind=0, ja= ", nr);
    550       ja=nr; ind=0; reducible= elem; 
     551      ja=nr; ind=0; reducible= elem;
    551552      break;
    552553    }
     
    556557  if ( (ind == 1) ){ //&& ( as.length() > 1) ){
    557558    if ( irreducible(AS) ){ // as quasilinear? => irreducible!
    558       ja = 0; 
     559      ja = 0;
    559560      DEBOUTLN(cout, "as is irreducible. as= ", AS);
    560561    }
     
    562563      i=AS;
    563564      for ( nr=1; nr< AS.length(); nr++){
    564         as.append(i.getItem());
    565         i++;
    566         if ( degree(i.getItem()) > 1 ){// search for a non linear elem
    567           elem=i.getItem();
    568 //        cout << "f=  " << elem << endl;
     565        as.append(i.getItem());
     566        i++;
     567        if ( degree(i.getItem()) > 1 ){// search for a non linear elem
     568          elem=i.getItem();
     569//          cout << "f=  " << elem << endl;
    569570//        cout << "as= " << as << endl;
    570           qs= newfactoras(elem,as,success);
    571 //        cout << "irras:newfactoras    qs= " << qs << endl;
    572 //        qs= factoras(elem,as,success);
    573 //        cout << "irras:factoras qs= " << qs << endl;
    574           if ( qs.length() > 1 || qs.getFirst().exp() > 1 ){ //found elem is reducible
    575             reducible=elem;
    576             ja=nr+1;
    577             break;
    578           }
    579           else
    580           {
     571          qs= newfactoras(elem,as,success);
     572//          cout << "irras:newfactoras    qs= " << qs << endl;
     573//          qs= factoras(elem,as,success);
     574//          cout << "irras:factoras qs= " << qs << endl;
     575          if ( qs.length() > 1 || qs.getFirst().exp() > 1 ){ //found elem is reducible
     576            reducible=elem;
     577            ja=nr+1;
     578            break;
     579          }
     580          else
     581          {
    581582#ifdef SINGULAR
    582 //            WarnS("libfac: Factoring over algebraic function field required!");
    583 #else 
     583            WarnS("libfac: Factoring over algebraic function field required!");
     584#else
    584585#ifndef NOSTREAMIO
    585586            cerr << "libfac: Factoring over algebraic function field!" << endl;
    586587#endif
    587588#endif
    588           }
    589         }
     589          }
     590        }
    590591      }
    591592    }
     
    598599/*
    599600$Log: not supported by cvs2svn $
     601Revision 1.6  2000/03/08 12:54:35  obachman
     602 * comment out warning "libfac: Factoring over algebraic function
     603   field required!"
     604
    600605Revision 1.5  2000/03/08 12:45:41  obachman
    601606* fixed Singular includes
  • libfac/factor/Truefactor.cc

    rc7bbf3 r405ebc  
    22///////////////////////////////////////////////////////////////////////////////
    33// emacs edit mode for this file is -*- C++ -*-
    4 //static char * rcsid = "@(#) $Id: Truefactor.cc,v 1.5 2001-06-21 14:57:06 Singular Exp $";
     4//static char * rcsid = "@(#) $Id: Truefactor.cc,v 1.6 2001-06-27 13:58:06 Singular Exp $";
    55///////////////////////////////////////////////////////////////////////////////
    66// Factory - Includes
     
    4141      if (hasAlgVar(i.coeff(),v)) return 1;
    4242    }
    43   } 
     43  }
     44  return 0;
     45}
     46
     47int hasVar(const CanonicalForm &f, const Variable &v)
     48{
     49  if (f.inBaseDomain()) return 0;
     50  if (f.inCoeffDomain())
     51  {
     52    if (f.mvar()==v) return 1;
     53    return hasAlgVar(f.LC(),v);
     54  }
     55  if (f.inPolyDomain())
     56  {
     57    if (f.mvar()==v) return 1;
     58    if (hasVar(f.LC(),v)) return 1;
     59    for( CFIterator i=f; i.hasTerms(); i++)
     60    {
     61      if (hasVar(i.coeff(),v)) return 1;
     62    }
     63  }
    4464  return 0;
    4565}
     
    5070  if (f.inCoeffDomain())
    5171  {
    52     if (f.level()!=0) 
     72    if (f.level()!=0)
    5373    {
    5474      //cout << "hasAlgVar:" << f.mvar() <<endl;
    5575      return 1;
    56     } 
     76    }
    5777    return hasAlgVar(f.LC());
    5878  }
     
    6484      if (hasAlgVar(i.coeff())) return 1;
    6585    }
    66   } 
     86  }
    6787  return 0;
    6888}
     
    7292// elements and return them in returnlist.                   //
    7393///////////////////////////////////////////////////////////////
    74 static void 
     94static void
    7595combinat( int k, int n, List<IntList> & returnlist ){
    7696  ListIntList ListofLists;
     
    88108      value = intermediate.getLast();
    89109      if ( value != n )
    90         for ( j=value+1; j<=n; j++ ){
    91           intermediate2 = intermediate; intermediate2.append(j);
    92           ListofLists.append( intermediate2 );
    93         }
     110        for ( j=value+1; j<=n; j++ ){
     111          intermediate2 = intermediate; intermediate2.append(j);
     112          ListofLists.append( intermediate2 );
     113        }
    94114    }
    95115    returnlist = ListofLists;
     
    100120// Return the CanonicalForm number nr in  Factorlist.        //
    101121///////////////////////////////////////////////////////////////
    102 static CanonicalForm 
     122static CanonicalForm
    103123getItemNr(int nr, const CFFList & Factorlist ){
    104124  ListIterator<CFFactor> i=Factorlist;
     
    112132// Generate all sets of m factors out of LiftedFactors list. //
    113133///////////////////////////////////////////////////////////////
    114 static CFFList 
     134static CFFList
    115135combine( int m, const CFFList & LiftedFactors ){
    116136  CFFList result;
     
    123143    for ( IntListIterator k=j.getItem(); k.hasItem(); k++ )
    124144      intermediate *= getItemNr(k.getItem(), LiftedFactors);
    125     if (!hasAlgVar(intermediate))   
     145    if (!hasAlgVar(intermediate))
    126146    result.append(CFFactor(intermediate,1));
    127147  }
     
    132152// Remove element elem from the list L.                      //
    133153///////////////////////////////////////////////////////////////
    134 static CFFList 
     154static CFFList
    135155Remove_from_List( const CFFList & L, const CanonicalForm & elem ){
    136156  CFFList Returnlist;
     
    139159  DEBOUTLN(cout, "                     and  elem= ",elem);
    140160  for ( ListIterator<CFFactor> i = L ; i.hasItem(); i++)
    141     if ( i.getItem().factor() != elem ) 
     161    if ( i.getItem().factor() != elem )
    142162      Returnlist.append( i.getItem() );
    143163
     
    148168// Here we solve:          G= F mod ( P, S^h )               //
    149169///////////////////////////////////////////////////////////////
    150 static CanonicalForm 
     170static CanonicalForm
    151171Multmod_power( const CanonicalForm & F, const SFormList & Substituionlist, int h, int levelF){
    152172  CanonicalForm G;
     
    164184// degree in the main variable levelU exceeeds degU.         //
    165185///////////////////////////////////////////////////////////////
    166 static CFFList 
     186static CFFList
    167187Rightdegree( const CFFList & CombL, int degU, int levelU ){
    168188  CFFList Returnlist;
     
    186206// Math. Comp. V29 Nr131 (July 1975) p. 935-950              //
    187207///////////////////////////////////////////////////////////////
    188 CFFList 
     208CFFList
    189209Truefactors( const CanonicalForm Ua, int levelU, const SFormList & SubstitutionList, const CFFList & PiList){
    190210  CanonicalForm U=Ua,a,b,Y;
     
    233253  DEBOUTLN(cout,"                     r   = ", r);
    234254  DEBOUTLN(cout,"                     degU= ", degU);
    235  
     255
    236256// Now do the real work!
    237 // Test all the combinations of possible factors. 
     257// Test all the combinations of possible factors.
    238258
    239259  onemore=1;
     
    265285      //      if (  c  && b == U.genZero()) { // Y divides U
    266286      if ( c && b.isZero() ){
    267         DEBOUT(cout,"Truefactors: (step6): ",Y );
    268         DEBOUTLN(cout, "  divides  ",U);
    269         U = a;
    270         FAC.append(Y); // Y is a real factor
    271         onemore = 0;
    272         degU = degree(U, levelU)/2; // new degU
    273         // L = L \ {factor}
    274         // Hier ist noch etwas faul; wir muessen (f=prod(f_i)) die f_i
    275         // entfernen und nicht f!
    276         L = Remove_from_List( L, factor.factor() );
    277         r -= 1;
    278         // delete from L any element with degree greater than degU
    279         L = Rightdegree( L, degU, levelU );
     287        DEBOUT(cout,"Truefactors: (step6): ",Y );
     288        DEBOUTLN(cout, "  divides  ",U);
     289        U = a;
     290        FAC.append(Y); // Y is a real factor
     291        onemore = 0;
     292        degU = degree(U, levelU)/2; // new degU
     293        // L = L \ {factor}
     294        // Hier ist noch etwas faul; wir muessen (f=prod(f_i)) die f_i
     295        // entfernen und nicht f!
     296        L = Remove_from_List( L, factor.factor() );
     297        r -= 1;
     298        // delete from L any element with degree greater than degU
     299        L = Rightdegree( L, degU, levelU );
    280300      }
    281301    }
     
    288308// Check if poly f is in Fp (returns true) or in Fp(a)       //
    289309///////////////////////////////////////////////////////////////
    290 static bool 
     310static bool
    291311is_in_Fp( const CanonicalForm & f ){
    292312  if ( f.inCoeffDomain() )
     
    335355      WerrorS("libfac: ERROR: TakeNorms less then two items remaining!");
    336356#else
    337       cerr << "libfac: ERROR: TakeNorms less then two items remaining! " 
    338            << endl;
     357      cerr << "libfac: ERROR: TakeNorms less then two items remaining! "
     358           << endl;
    339359#endif
    340360    }
     
    343363      combinat(n, PossibleFactors.length(), CombinatList);
    344364      for ( j=CombinatList ; j.hasItem(); j++ ){
    345         intermediate=1;
    346         for ( k=j.getItem(); k.hasItem(); k++ )
    347           intermediate *= getItemNr( k.getItem(), PossibleFactors );
    348         if ( is_in_Fp( intermediate ) ){
    349           TrueFactors.append(intermediate); // found a true factor
    350           CopyPossibleFactors=PossibleFactors; // save list
    351           for ( k=j.getItem(); k.hasItem(); k++ )
    352             //remove combined factors from PossibleFactors
    353             PossibleFactors=Remove_from_List(PossibleFactors,
    354                                 getItemNr( k.getItem(), CopyPossibleFactors ));
    355           n-=1; // look for the same number of combined factors:
    356           break;
    357         }
    358         else {
    359           //cout << "Schade!" << endl;
    360         }
    361         DEBOUT(cout, "Truefactor: Combined ", n);
    362         DEBOUTLN(cout, " factors to: ", intermediate);
     365        intermediate=1;
     366        for ( k=j.getItem(); k.hasItem(); k++ )
     367          intermediate *= getItemNr( k.getItem(), PossibleFactors );
     368        if ( is_in_Fp( intermediate ) ){
     369          TrueFactors.append(intermediate); // found a true factor
     370          CopyPossibleFactors=PossibleFactors; // save list
     371          for ( k=j.getItem(); k.hasItem(); k++ )
     372            //remove combined factors from PossibleFactors
     373            PossibleFactors=Remove_from_List(PossibleFactors,
     374                                getItemNr( k.getItem(), CopyPossibleFactors ));
     375          n-=1; // look for the same number of combined factors:
     376          break;
     377        }
     378        else {
     379          //cout << "Schade!" << endl;
     380        }
     381        DEBOUT(cout, "Truefactor: Combined ", n);
     382        DEBOUTLN(cout, " factors to: ", intermediate);
    363383      }
    364384      n += 1;
    365385    }
    366   // All remaining factors in PossibleFactors multiplied 
     386  // All remaining factors in PossibleFactors multiplied
    367387  // should lie in Fp domain
    368388    if ( PossibleFactors.length() >=1 ){
    369389      for ( i=PossibleFactors; i.hasItem(); i++ )
    370         intermediate *= i.getItem().factor();
     390        intermediate *= i.getItem().factor();
    371391      // a last check:
    372392      if ( is_in_Fp(intermediate) ){
    373         TrueFactors.append(CFFactor(intermediate,1));
     393        TrueFactors.append(CFFactor(intermediate,1));
    374394      }
    375       else{ 
     395      else{
    376396#ifdef HAVE_SINGULAR
    377         WerrorS("libfac: TakeNorms: somethings wrong with remaining factors!");
     397        WerrorS("libfac: TakeNorms: somethings wrong with remaining factors!");
    378398#else
    379         cerr << "libfac: TakeNorms: somethings wrong with remaining factors!"
    380              << endl;
     399        cerr << "libfac: TakeNorms: somethings wrong with remaining factors!"
     400             << endl;
    381401#endif
    382402      }
     
    389409/*
    390410$Log: not supported by cvs2svn $
     411Revision 1.5  2001/06/21 14:57:06  Singular
     412*hannes/GP: Factorize, newfactoras, ...
     413
    391414Revision 1.4  1997/11/18 16:39:07  Singular
    392415* hannes: moved WerrorS from C++ to C
Note: See TracChangeset for help on using the changeset viewer.