Changeset 4a81ec in git for libfac/charset/charset.cc


Ignore:
Timestamp:
Sep 12, 1997, 9:20:02 AM (27 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
0fbdd16f374f7f4570da62a453e2328e4d8a4b4c
Parents:
0479e09dbc0fb17be7ebce384df4ba0318ba20eb
Message:
* hannes/michael: libfac-0.3.0


git-svn-id: file:///usr/local/Singular/svn/trunk@708 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfac/charset/charset.cc

    r0479e09 r4a81ec  
    22////////////////////////////////////////////////////////////
    33// emacs edit mode for this file is -*- C++ -*-
    4 static char * rcsid = "$Id: charset.cc,v 1.2 1997-06-09 15:55:53 Singular Exp $";
     4static char * rcsid = "$Id: charset.cc,v 1.3 1997-09-12 07:19:40 Singular Exp $";
    55/////////////////////////////////////////////////////////////
    66// FACTORY - Includes
     
    1212// Charset - Includes
    1313#include "csutil.h"
     14#include "algfactor.h"
     15#include "alg_factor.h"
     16// Some CC's need this:
     17#include "charset.h"
    1418
    1519#ifdef BASICSETDEBUG
     
    4751        b = lowestRank( QS );
    4852        cb = rank( b );
     53        DEBOUTLN(cout, "BasicSet: choose b  = ", b);
     54        DEBOUTLN(cout, "BasicSet: it's rank = ", cb);
    4955        BS=Union(CFList(b),BS);//BS.append( b );
    5056        if ( rank( b ) == 0 )
     
    6571}
    6672
    67  int
    68  checkok( const CFList & PS, CFList & FS2){
    69    CanonicalForm elem;
    70 
    71    for ( CFListIterator i=PS; i.hasItem(); i++){
    72      elem= i.getItem();
    73      for (CFListIterator j=FS2; j.hasItem(); j++){
    74        if (elem == j.getItem()){
     73int
     74checkok( const CFList & PS, CFList & FS2){
     75  CanonicalForm elem;
     76
     77  for ( CFListIterator i=PS; i.hasItem(); i++){
     78    elem= i.getItem();
     79    for (CFListIterator j=FS2; j.hasItem(); j++){
     80      if (elem == j.getItem()){
    7581        //      FS2= Difference(FS2,CFList(elem));
    7682        return 0;
    77        }
    78      }
    79    }
    80    return 1;
    81  }
     83      }
     84    }
     85  }
     86  return 1;
     87}
    8288
    8389#ifdef MCHARSETNDEBUG
     
    147153}
    148154
     155
     156CFList
     157mcharset( const CFList &PS, PremForm & Remembern ){
     158  CFList cs= MCharSetN(PS, Remembern );
     159  CFList rs= remsetb(Difference(PS,cs),cs);
     160
     161  DEBOUTLN(cout, "mcharset: cs= ", cs);
     162  DEBOUTLN(cout, "mcharset: rs= ", rs);
     163  if ( rs.length() > 0 )
     164    cs= mcharset(Union(PS,Union(cs,rs)), Remembern);
     165  return cs;
     166}
     167
    149168// the "original" extended characteristic set
    150169CFList
     
    311330}
    312331
     332static int
     333choosefrom(){
     334int choice;
     335    cout << "choose from qhi! ->";
     336    cin >> choice;
     337return choice;
     338}
     339
    313340static ListCFList
    314341msort( const ListCFList & list_to_sort ){
     
    333360
    334361ListCFList
    335 IrrCharSeries( const CFList &PS ){
     362IrrCharSeries( const CFList &PS, int opt ){
    336363  CanonicalForm reducible,reducible2;
    337364  CFList qs,cs,factorset,is,ts;
    338365  ListCFList pi,ppi,qqi,qsi,iss,qhi= ListCFList(PS);
    339   int nr_of_iteration=0,ts2,highestlevel=0;
     366  int nr_of_iteration=0,ts2,highestlevel=0;
     367#ifdef EXPERIMENTAL
     368  int choice=1;;
     369#endif
    340370
    341371  DEBOUTMSG(cout, rcsid);
     372//  cout << getCharacteristic() << endl;
    342373  for ( CFListIterator Ps=PS; Ps.hasItem(); Ps++ )
    343374    if ( level(Ps.getItem() ) > highestlevel ) highestlevel = level(Ps.getItem()) ;
    344 
     375//  for ( int xx=1; xx <= highestlevel; xx++)
     376//   cout << Variable(xx) ;
     377//  cout << endl;
     378//  for ( CFListIterator Ps=PS; Ps.hasItem(); Ps++ )
     379//    cout << Ps.getItem() << ", " ;//<< endl;
     380//  cout <<  endl;
    345381  while ( ! qhi.isEmpty() ) {
    346382    qhi=sort(qhi);
    347383    DEBOUTLN(cout, "qhi is: ", qhi);
     384#ifdef EXPERIMENTAL
     385    choice=choosefrom();
     386    cout <<"/n Choose " << choice << endl;
     387    qs= getItemNr(choice, qhi);
     388#else
    348389    qs=qhi.getFirst();
     390#endif
    349391    DEBOUTLN(cout, "qs  is: ", qs);
    350392    DEBOUTLN(cout, "ppi is: ", ppi);
     
    454496  }
    455497  if ( ! qsi.isEmpty() ){
    456     return contract( qsi );
     498    DEBOUTLN(cout, "qsi before contract= ", qsi);
     499    if ( opt == 0 ){
     500       return contract( qsi );
     501    }
     502    else { return qsi; }
    457503  }
    458504  else{ return ListCFList() ; }
     
    474520  CFList ts,as;
    475521  CanonicalForm elem;
    476   int ind=1,nr=0;
     522  int ind=1,nr=0, success=-1;
     523  CFListIterator i;
    477524
    478525  ja = 0;
    479526  DEBOUTLN(cout, "irras: called with: AS= ", AS);
    480   for ( CFListIterator i=AS; i.hasItem(); i++ ){
     527  for ( i=AS; i.hasItem(); i++ ){
    481528    elem = i.getItem();
    482529    nr += 1;
    483530    DEBOUT(cout, "irras: factoring: ", elem);
    484     qs = Factorize(elem);
    485 
     531    if ( degree(elem) > 1 ) // linear poly's are irreduzible
     532      qs = Factorize(elem);
     533    else{
     534      qs=(CFFactor(elem,1));
     535      qs.insert(CFFactor(CanonicalForm(1),1));
     536    }
     537    DEBOUTLN(cout, "  = ", qs);
    486538    // INTERRUPTHANDLER
    487539    if ( interrupt_handle() ) return CFList() ;
    488540    // INTERRUPTHANDLER
    489 
    490541    qs.removeFirst();
    491     DEBOUTLN(cout, "  = ", qs);
    492     //    if ( num(qs.getFirst().factor() / LC(qs.getFirst().factor())) !=
    493     //         num(elem / LC(elem))){
    494542    if ( (qs.length() >= 2 ) || (qs.getFirst().exp() > 1)){
    495543      DEBOUTLN(cout, "irras: Setting ind=0, ja= ", nr);
    496544      ja=nr; ind=0; reducible= elem;
    497       // return(qs); // ist das nicht genauso gut?
    498545      break;
    499546    }
    500     else{ as.append(elem) ; }
    501   }
    502   AS=as; // warum das?
    503   if ( (ind == 1) && ( AS.length() > 1) ){
    504     if ( irreducible(AS) ) ja = 0;
     547    //    else{ as.append(elem) ; }
     548  }
     549  //  cout << "ind= " << ind << endl;
     550  if ( (ind == 1) ){ //&& ( as.length() > 1) ){
     551    if ( irreducible(AS) ){ // as quasilinear? => irreducible!
     552      ja = 0;
     553      DEBOUTLN(cout, "as is irreducible. as= ", AS);
     554    }
    505555    else {
    506 #ifdef HAVE_SINGULAR
    507       extern void WerrorS(char *);
    508       WerrorS("libfac: Factorization over algebraic function field required!");
    509 #else
    510       cerr << "Factorization over algebraic function field required!" << endl;
    511 #endif
    512       ja = -1;
     556//#ifdef HAVE_SINGULAR
     557//      extern void WerrorS(char *);
     558//      WerrorS("libfac: Factoring over algebraic function field!");
     559//#else
     560//      cerr << "libfac: Factoring over algebraic function field!" << endl;
     561//#endif
     562      i=AS;
     563      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;
     569//        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        }
     580      }
    513581    }
    514582  }
Note: See TracChangeset for help on using the changeset viewer.