Changeset aa7480c in git


Ignore:
Timestamp:
Jan 7, 2008, 2:34:56 PM (15 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
Children:
46f6af6b0ad4f593376191e4bbe9dda46e6d8fae
Parents:
1e6de686866af59b3d97fffef1d92033d15f47c6
Message:
*hannes: omse optiomzations(isOne)


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

Legend:

Unmodified
Added
Removed
  • libfac/factor/Factor.cc

    r1e6de6 raa7480c  
    11/* Copyright 1996 Michael Messollen. All rights reserved. */
    22///////////////////////////////////////////////////////////////////////////////
    3 static char * rcsid = "$Id: Factor.cc,v 1.37 2007-10-25 14:45:41 Singular Exp $ ";
     3static char * rcsid = "$Id: Factor.cc,v 1.38 2008-01-07 13:34:56 Singular Exp $ ";
    44static char * errmsg = "\nYou found a bug!\nPlease inform (Michael Messollen) michael@math.uni-sb.de \nPlease include above information and your input (the ideal/polynomial and characteristic) in your bug-report.\nThank you.";
    55///////////////////////////////////////////////////////////////////////////////
     
    116116  if ( totaldegree(remlc)==0 ){ remlc=f.genOne() ; }
    117117  DEBOUTLN(CERR, "remlc= " , remlc);
    118   for ( int i=n-1; i>=1; i-- ){
     118  for ( int i=n-1; i>=1; i-- )
     119  {
    119120    newlc= LC(f,i);
    120121    if ( totaldegree(newlc)==0 ){ newlc=f.genOne() ; }
     
    222223  int test1;
    223224
    224   if ( lt == lt.genOne() ) return TheList; // the poly was already monic
     225  if ( lt.isOne() ) return TheList; // the poly was already monic
    225226  if ( TheList.length() <= 1 ) // only one factor to substitute back
    226227  {
     
    356357///////////////////////////////////////////////////////////////
    357358static int
    358 various_tests( const CanonicalForm & g, int deg, int vars_left){
     359various_tests( const CanonicalForm & g, int deg, int vars_left)
     360{
    359361  CFMap m;
    360362
     
    362364    if ( level(compress(g,m)) == (vars_left) ) // exactly one variable less
    363365      if ( SqrFreeTest(g,1) ) // poly is sqrfree
    364         if ( gcd(g,g.deriv()) == 1 ) // Discriminante != 0
     366        if ( gcd(g,g.deriv()).isOne() ) // Discriminante != 0
    365367           return 1;
    366368  return 0;
     
    579581        unilist = factorize2(g,Extension,mipo);
    580582      }
    581       if (unilist.length() <= minfactors ) {
     583      if (unilist.length() <= minfactors )
     584      {
    582585        minfactors=unilist.length();
    583586        minEvaluation=Substitutionlist;
     
    586589      else samefactors +=1;
    587590
    588       if (unilist.length() == 1 ){ // wow! we found f is irreducible!
     591      if (unilist.length() == 1 ) // wow! we found f is irreducible!
     592      {
    589593        BestEvaluationpoint=minEvaluation;
    590594        BestFactorisation=minFactorisation;
     
    592596      }
    593597
    594       if ( samefactors >= sametries ){ // now we stop ( maybe polynomial *has*
    595                                        // minfactors factors? )
     598      if ( samefactors >= sametries ) // now we stop ( maybe polynomial *has*
     599                                      // minfactors factors? )
     600      {
    596601        BestEvaluationpoint=minEvaluation;
    597602        BestFactorisation=minFactorisation;
     
    600605
    601606    }
    602     else failedfactor += 1;
    603 
    604     if ( failedfactor >= failtries ){ // now we stop ( perhaps Extension isn't
    605                                       // big enough )
     607    else
     608      failedfactor += 1;
     609
     610    if ( failedfactor >= failtries ) // now we stop ( perhaps Extension isn't
     611                                     // big enough )
     612    {
    606613      if ( tried == 0 )
    607614        return 0;
    608       else{
     615      else
     616      {
    609617        BestEvaluationpoint=minEvaluation;
    610618        BestFactorisation=minFactorisation;
     
    612620      }
    613621    }
    614 
    615622  }
    616623  BestEvaluationpoint=minEvaluation;
     
    725732  // Check special cases
    726733  for ( int i=1; i<=level(F); i++)
    727     if ( degree(f,Variable(i) ) == 1 ) { //test trivial case; only true iff F is primitiv w.r.t every variable; else check (if F=ax+b) gcd(a,b)=1 ?
     734  {
     735    if ( degree(f,Variable(i) ) == 1 )
     736    //test trivial case; only true iff F is primitiv w.r.t every variable; else check (if F=ax+b) gcd(a,b)=1 ?
     737    {
    728738      DEBOUTLN(CERR, "Trivial case: ", F);
    729739      Outputlist.append(CFFactor(F,1));
    730740      return Outputlist;
    731741    }
     742  }
    732743
    733744  // Look at the leading term:
    734745  lt = LC(f);
    735746  DEBOUTLN(CERR, "Leading term: ", lt);
    736   if ( lt != f.genOne() )
     747  //if ( lt != f.genOne() )
     748  if ( !lt.isOne() )
    737749  {
    738750    // make the polynomial monic in the main variable
     
    836848    // INTERRUPTHANDLER
    837849
    838     if ( lt != f.genOne() )
     850    //if ( lt != f.genOne() )
     851    if ( !lt.isOne() )
    839852    {
    840853      Outputlist = not_monic(Outputlist,lt,ff,level(ff));
     
    13181331/*
    13191332$Log: not supported by cvs2svn $
     1333Revision 1.37  2007/10/25 14:45:41  Singular
     1334*hannes: homgfactor for alg.ext of Q
     1335
    13201336Revision 1.36  2007/10/15 18:03:11  Singular
    13211337*hannes: // debug stuff
  • libfac/factor/SqrFree.cc

    r1e6de6 raa7480c  
    22///////////////////////////////////////////////////////////////////////////////
    33// emacs edit mode for this file is -*- C++ -*-
    4 static char * rcsid = "$Id: SqrFree.cc,v 1.11 2007-05-15 14:46:49 Singular Exp $";
     4static char * rcsid = "$Id: SqrFree.cc,v 1.12 2008-01-07 13:34:56 Singular Exp $";
    55static char * errmsg = "\nYou found a bug!\nPlease inform (Michael Messollen) michael@math.uni-sb.de .\n Please include above information and your input (the ideal/polynomial and characteristic) in your bug-report.\nThank you.";
    66///////////////////////////////////////////////////////////////////////////////
     
    304304    return Outputlist ;
    305305  }
    306   else { // we can split into two nontrivial pieces
     306  else  // we can split into two nontrivial pieces
     307  {
    307308    f /= h; // Now we have split the poly into f and h
    308309    g = lc(f);
    309     if ( g != f.genOne() && getNumVars(g) == 0 ){
     310    //if ( g != f.genOne() && getNumVars(g) == 0 ){
     311    if ( (!g.isOne()) && getNumVars(g) == 0 )
     312    {
    310313       Outputlist= myappend(Outputlist,CFFactor(g,1)) ;
    311314       f /= g;
     
    415418/*
    416419$Log: not supported by cvs2svn $
     420Revision 1.11  2007/05/15 14:46:49  Singular
     421*hannes: factorize in Zp(a)[x...]
     422
    417423Revision 1.10  2006/05/16 14:46:50  Singular
    418424*hannes: gcc 4.1 fixes
  • libfac/factor/Truefactor.cc

    r1e6de6 raa7480c  
    22///////////////////////////////////////////////////////////////////////////////
    33// emacs edit mode for this file is -*- C++ -*-
    4 //static char * rcsid = "@(#) $Id: Truefactor.cc,v 1.10 2006-05-16 14:46:50 Singular Exp $";
     4//static char * rcsid = "@(#) $Id: Truefactor.cc,v 1.11 2008-01-07 13:34:56 Singular Exp $";
    55///////////////////////////////////////////////////////////////////////////////
    66// Factory - Includes
     
    278278  onemore=1;
    279279// steps 3 to 6
    280   while (1){
     280  while (1)
     281  {
    281282    // step 3 iff onemore == 1
    282283    if ( onemore ) M+= 1;  else onemore = 1;
    283284    // step 4
    284     if ( U == U.genOne() ) break; // Return FAC
    285     if ( ( r == 1 ) || ( M >= ( r-1 ) ) || ( M > degU ) ) {
     285    if ( U.isOne() ) break; // Return FAC
     286    if ( ( r == 1 ) || ( M >= ( r-1 ) ) || ( M > degU ) )
     287    {
    286288      FAC.append( CFFactor(U,1) );
    287289      break; // Return FAC union {U}
     
    293295    E_all = Rightdegree( E_all, degU, levelU );
    294296    DEBOUTLN(CERR,"Truefactors: (step5) E_all(Rightdegree)= ", E_all);
    295     if ( E_all.length() == 0 ){
     297    if ( E_all.length() == 0 )
     298    {
    296299      FAC.append( CFFactor(U,1) );
    297300      break; // Return FAC union {U}
    298301    }
    299     for ( i=E_all; i.hasItem(); i++){
     302    for ( i=E_all; i.hasItem(); i++)
     303    {
    300304      factor = i.getItem();
    301305      Y = Multmod_power( factor.factor(), SubstitutionList, h, levelU);
     
    303307      c = mydivremt(U,Y,a,b);
    304308      //      if (  c  && b == U.genZero()) { // Y divides U
    305       if ( c && b.isZero() ){
     309      if ( c && b.isZero() )
     310      {
    306311        DEBOUT(CERR,"Truefactors: (step6): ",Y );
    307312        DEBOUTLN(CERR, "  divides  ",U);
     
    320325    }
    321326  }
    322 
    323327  return FAC;
    324328}
     
    327331// Check if poly f is in Fp (returns true) or in Fp(a)       //
    328332///////////////////////////////////////////////////////////////
    329 static bool
    330 is_in_Fp( const CanonicalForm & f ){
     333static bool is_in_Fp( const CanonicalForm & f )
     334{
    331335  if ( f.inCoeffDomain() )
    332336    return f.inBaseDomain() ;
    333   else {
     337  else
     338  {
    334339    CFIterator i=f;
    335340    bool ok=true;
    336     while ( ok && i.hasTerms() ){
     341    while ( ok && i.hasTerms() )
     342    {
    337343      ok = is_in_Fp( i.coeff() );
    338344      i++ ;
     
    348354// of) multiplying by other elements.                        //
    349355///////////////////////////////////////////////////////////////
    350 CFFList
    351 TakeNorms(const CFFList & PiList){
     356CFFList TakeNorms(const CFFList & PiList)
     357{
    352358  CFFList CopyPossibleFactors, PossibleFactors, TrueFactors;
    353359  CFFListIterator i;
     
    359365
    360366  // First check if the factors in PiList already lie in Fp-Domain
    361   for ( i=PiList; i.hasItem(); i++ ){
     367  for ( i=PiList; i.hasItem(); i++ )
     368  {
    362369    Factor = i.getItem();
    363370    if ( is_in_Fp( Factor.factor() ) )
     
    368375  // Now we have to check if combinations of the remaining factors
    369376  // (now in PossibleFactors) do lie in Fp-Domain
    370   if ( PossibleFactors.length() > 0 ){ // there are (at least two) items
     377  if ( PossibleFactors.length() > 0 ) // there are (at least two) items
     378  {
    371379    int n=2;
    372     if ( PossibleFactors.length() < n ) { // a little check
     380    if ( PossibleFactors.length() < n )  // a little check
     381    {
    373382#ifdef HAVE_SINGULAR_ERROR
    374383      WerrorS("libfac: ERROR: TakeNorms less then two items remaining!");
     
    382391#endif
    383392    }
    384     while ( n < PossibleFactors.length() ){
     393    while ( n < PossibleFactors.length() )
     394    {
    385395      // generate all combinations of n elements
    386396      combinat(n, PossibleFactors.length(), CombinatList);
    387       for ( j=CombinatList ; j.hasItem(); j++ ){
     397      for ( j=CombinatList ; j.hasItem(); j++ )
     398      {
    388399        intermediate=1;
    389400        for ( k=j.getItem(); k.hasItem(); k++ )
    390401          intermediate *= getItemNr( k.getItem(), PossibleFactors );
    391         if ( is_in_Fp( intermediate ) ){
     402        if ( is_in_Fp( intermediate ) )
     403        {
    392404          TrueFactors.append(intermediate); // found a true factor
    393405          CopyPossibleFactors=PossibleFactors; // save list
     
    399411          break;
    400412        }
    401         else {
     413        else
     414        {
    402415          //CERR << "Schade!" << "\n";
    403416        }
     
    409422  // All remaining factors in PossibleFactors multiplied
    410423  // should lie in Fp domain
    411     if ( PossibleFactors.length() >=1 ){
     424    if ( PossibleFactors.length() >=1 )
     425    {
    412426      for ( i=PossibleFactors; i.hasItem(); i++ )
    413427        intermediate *= i.getItem().factor();
    414428      // a last check:
    415       if ( is_in_Fp(intermediate) ){
     429      if ( is_in_Fp(intermediate) )
     430      {
    416431        TrueFactors.append(CFFactor(intermediate,1));
    417432      }
    418       else{
     433      else
     434      {
    419435#ifdef HAVE_SINGULAR_ERROR
    420436        WerrorS("libfac: TakeNorms: somethings wrong with remaining factors!");
     
    434450/*
    435451$Log: not supported by cvs2svn $
     452Revision 1.10  2006/05/16 14:46:50  Singular
     453*hannes: gcc 4.1 fixes
     454
    436455Revision 1.9  2001/08/08 14:26:56  Singular
    437456*hannes: Dan's HAVE_SINGULAR_ERROR
Note: See TracChangeset for help on using the changeset viewer.