Changeset aadd442 in git


Ignore:
Timestamp:
Jan 25, 2008, 3:19:40 PM (15 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a657104b677b4c461d018cbf3204d72d34ad66a9')
Children:
bfe72e2bcb7632d5cf79dc5196713a5fba2bafb5
Parents:
6bbc8e2c339d1928744e2f67b390389567caa462
Message:
*hannes: SqrFreeTest -> isSqrFree


git-svn-id: file:///usr/local/Singular/svn/trunk@10524 2c84dea3-7e68-4137-9b89-c4e89433aadc
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • factory/cf_factor.cc

    r6bbc8e raadd442  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: cf_factor.cc,v 1.38 2008-01-22 09:28:22 Singular Exp $ */
     2/* $Id: cf_factor.cc,v 1.39 2008-01-25 14:17:59 Singular Exp $ */
    33
    44//{{{ docu
     
    726726}
    727727
    728 bool isSqrFree ( const CanonicalForm & f )
    729 {
    730 //    ASSERT( f.isUnivariate(), "multivariate factorization not implemented" );
    731     if ( getCharacteristic() == 0 )
    732         return isSqrFreeZ( f );
     728///////////////////////////////////////////////////////////////
     729// A uni/multivariate SqrFreeTest routine.                   //
     730// Cheaper to run if all you want is a test.                 //
     731// Works for charcteristic 0 and q=p^m                       //
     732// Returns 1 if poly r is SqrFree, 0 if SqrFree will do some //
     733// kind of factorization.                                    //
     734// Would be much more effcient iff we had *good*             //
     735//  uni/multivariate gcd's and/or gcdtest's                  //
     736///////////////////////////////////////////////////////////////
     737bool isSqrFree ( const CanonicalForm & r )
     738{
     739  CanonicalForm f=r, g;
     740  int n=level(f);
     741
     742  if (getNumVars(f)==0) return 1 ; // a constant is SqrFree
     743  if ( f.isUnivariate() )
     744  {
     745    g= f.deriv();
     746    if ( getCharacteristic() > 0 && g.isZero() ) return 0 ;
     747    // Next: it would be best to have a *univariate* gcd-test which returns
     748    // 0 iff gcdtest(f,g) == 1 or a constant ( for real Polynomials )
     749    g = gcd(f,g);
     750    if ( g.isOne() || (-g).isOne() ) return 1;
    733751    else
    734         return isSqrFreeFp( f );
    735 }
    736 
     752      if ( getNumVars(g) == 0 ) return 1;// <- totaldegree!!!
     753      else return 0 ;
     754  }
     755  else
     756  { // multivariate case
     757    for ( int k=1; k<=n; k++ )
     758    {
     759      g = swapvar(f,k,n); g = content(g);
     760      // g = 1 || -1 : sqr-free, g poly : not sqr-free, g number : ..
     761      if ( ! (g.isOne() || (-g).isOne() || getNumVars(g)==0 ) )
     762      {
     763        if ( isSqrFree(g) == 0 ) return 0;
     764        g = swapvar(g,k,n);
     765        f /=g ;
     766      }
     767    }
     768    // Now f is primitive
     769    n = level(f); // maybe less indeterminants
     770    //    if ( totaldegree(f) <= 1 ) return 1;
     771
     772    // Let`s look if it is a Pth root
     773    if ( getCharacteristic() > 0 )
     774      for (int k=1; k<=n; k++ )
     775      {
     776        g=swapvar(f,k,n); g=g.deriv();
     777        if ( ! g.isZero() ) break ;
     778        else if ( k==n) return 0 ; // really is Pth root
     779      }
     780    g = f.deriv() ;
     781    // Next: it would be best to have a *multivariate* gcd-test which returns
     782    // 0 iff gcdtest(f,g) == 1 or a constant ( for real Polynomials )
     783    g= gcd(f,g);
     784    if ( g.isOne() || (-g).isOne() || (g==f) || (getNumVars(g)==0) ) return 1 ;
     785    else return 0 ;
     786  }
     787#ifdef HAVE_SINGULAR_ERROR
     788  WerrorS("libfac: ERROR: isSqrFree: we should never fall trough here!");
     789#else
     790#ifndef NOSTREAMIO
     791  CERR << "\nlibfac: ERROR: isSqrFree: we should never fall trough here!\n"
     792       << rcsid << errmsg << "\n";
     793#endif
     794#endif
     795  return 0;
     796}
     797
  • factory/fac_sqrfree.cc

    r6bbc8e raadd442  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: fac_sqrfree.cc,v 1.8 2008-01-22 09:30:31 Singular Exp $ */
     2/* $Id: fac_sqrfree.cc,v 1.9 2008-01-25 14:17:59 Singular Exp $ */
    33
    44#include <config.h>
     
    343343}
    344344
    345 bool isSqrFreeFp( const CanonicalForm & f )
    346 {
    347   CFFList F = sqrFreeFp( f );
    348   return ( F.length() == 1 && F.getFirst().exp() == 1 );
    349 }
    350 
    351 bool isSqrFreeZ ( const CanonicalForm & f )
    352 {
    353     return gcd( f, f.deriv() ).degree() == 0;
    354 }
    355 
    356345/*
    357346
  • factory/fac_sqrfree.h

    r6bbc8e raadd442  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: fac_sqrfree.h,v 1.4 2008-01-22 09:30:31 Singular Exp $ */
     2/* $Id: fac_sqrfree.h,v 1.5 2008-01-25 14:18:56 Singular Exp $ */
    33
    44#ifndef INCL_FAC_SQRFREE_H
     
    2323CFFList sqrFreeFp ( const CanonicalForm & r, const CanonicalForm &mipo=0 );
    2424
    25 bool isSqrFreeFp ( const CanonicalForm & f );
    26 
    2725CFFList sqrFreeZ ( const CanonicalForm & f, const CanonicalForm &mipo=0 );
    2826
    29 bool isSqrFreeZ ( const CanonicalForm & f );
    30 
    3127#endif /* ! INCL_FAC_SQRFREE_H */
  • factory/fac_univar.cc

    r6bbc8e raadd442  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: fac_univar.cc,v 1.20 2008-01-22 09:30:31 Singular Exp $ */
     2/* $Id: fac_univar.cc,v 1.21 2008-01-25 14:17:59 Singular Exp $ */
    33
    44#include <config.h>
     
    214214
    215215
    216 static int
    217 choosePrimes ( int * p, const CanonicalForm & f )
     216static int choosePrimes ( int * p, const CanonicalForm & f )
    218217{
    219218    int ptr = 0;
     
    222221    int prime;
    223222
    224     while ( ptr < maxp && i < max_fp_fac ) {
     223    while ( ptr < maxp && i < max_fp_fac )
     224    {
    225225        prime = cf_getPrime( ptr );
    226         if ( mod( lc( f ), prime ) != 0 ) {
     226        if ( mod( lc( f ), prime ) != 0 )
     227        {
    227228            setCharacteristic( prime );
    228             if ( isSqrFreeFp( mapinto( f ) ) ) {
     229            if ( isSqrFree( mapinto( f ) ) )
     230            {
    229231                p[i] = prime;
    230232                i++;
  • libfac/charset/alg_factor.cc

    r6bbc8e raadd442  
    33// emacs edit mode for this file is -*- C++ -*-
    44////////////////////////////////////////////////////////////
    5 static char * rcsid = "$Id: alg_factor.cc,v 1.18 2008-01-22 09:51:36 Singular Exp $";
     5static char * rcsid = "$Id: alg_factor.cc,v 1.19 2008-01-25 14:19:39 Singular Exp $";
    66////////////////////////////////////////////////////////////
    77// FACTORY - Includes
     
    199199    }
    200200    else{
    201       DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!");
    202       // Look at SqrFreeTest!
     201      DEBOUTMSG(CERR, "Starting isSqrFree(R)!");
     202      // Look at isSqrFree!
    203203      // (z+a^5+w)^4 with z<w<a should not give sqfreetest=1 !
    204204      // for now we use this workaround with Factorize...
     
    219219      for ( i=testlist; i.hasItem(); i++)
    220220        if ( i.getItem().exp() > 1 && degree(i.getItem().factor(), R.mvar()) > 0) { sqfreetest=0; break; }
    221       DEBOUTLN(CERR, "SqrFreeTest(R)= ", sqfreetest);
     221      DEBOUTLN(CERR, "isSqrFree(R)= ", sqfreetest);
    222222    }
    223223    if ( ! sqfreetest ){
     
    264264    }
    265265    else{
    266       DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!");
    267       // Look at SqrFreeTest!
     266      DEBOUTMSG(CERR, "Starting isSqrFree(R)!");
     267      // Look at isSqrFree!
    268268      // (z+a^5+w)^4 with z<w<a should not give sqfreetest=1 !
    269269      // for now we use this workaround with Factorize...
     
    284284      for ( i=testlist; i.hasItem(); i++)
    285285        if ( i.getItem().exp() > 1 && degree(i.getItem().factor(), R.mvar()) > 0) { sqfreetest=0; break; }
    286       DEBOUTLN(CERR, "SqrFreeTest(R)= ", sqfreetest);
     286      DEBOUTLN(CERR, "isSqrFree(R)= ", sqfreetest);
    287287    }
    288288    if ( ! sqfreetest ){
     
    830830/*
    831831$Log: not supported by cvs2svn $
     832Revision 1.18  2008/01/22 09:51:36  Singular
     833*hannes: sqrFree/InternalSqrFree -> factory
     834
    832835Revision 1.17  2007/05/15 14:46:48  Singular
    833836*hannes: factorize in Zp(a)[x...]
  • libfac/factor/Factor.cc

    r6bbc8e raadd442  
    11/* Copyright 1996 Michael Messollen. All rights reserved. */
    22///////////////////////////////////////////////////////////////////////////////
    3 static char * rcsid = "$Id: Factor.cc,v 1.39 2008-01-22 09:51:37 Singular Exp $ ";
     3static char * rcsid = "$Id: Factor.cc,v 1.40 2008-01-25 14:19:40 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///////////////////////////////////////////////////////////////////////////////
     
    363363  if ( degree(g) == deg ) // degrees match
    364364    if ( level(compress(g,m)) == (vars_left) ) // exactly one variable less
    365       if ( SqrFreeTest(g,1) ) // poly is sqrfree
     365      if ( isSqrFree(g) ) // poly is sqrfree
    366366        if ( gcd(g,g.deriv()).isOne() ) // Discriminante != 0
    367367           return 1;
     
    924924  // (If gcd is fast...)
    925925  ///////
    926   //  if ( ! SqrFreeTest(F) ){
     926  //  if ( ! isSqrFree(F) ){
    927927  if ( ! is_SqrFree )
    928928  {
     
    12231223  // (If gcd is fast...)
    12241224  ///////
    1225   //  if ( ! SqrFreeTest(F) ){
     1225  //  if ( ! isSqrFree(F) ){
    12261226  if ( ! is_SqrFree )
    12271227  {
     
    13291329/*
    13301330$Log: not supported by cvs2svn $
     1331Revision 1.39  2008/01/22 09:51:37  Singular
     1332*hannes: sqrFree/InternalSqrFree -> factory
     1333
    13311334Revision 1.38  2008/01/07 13:34:56  Singular
    13321335*hannes: omse optiomzations(isOne)
  • libfac/factor/SqrFree.cc

    r6bbc8e raadd442  
    22///////////////////////////////////////////////////////////////////////////////
    33// emacs edit mode for this file is -*- C++ -*-
    4 static char * rcsid = "$Id: SqrFree.cc,v 1.13 2008-01-22 09:51:37 Singular Exp $";
     4static char * rcsid = "$Id: SqrFree.cc,v 1.14 2008-01-25 14:19:40 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///////////////////////////////////////////////////////////////////////////////
     
    130130
    131131///////////////////////////////////////////////////////////////
    132 // A uni/multivariate SqrFreeTest routine.                   //
    133 // Cheaper to run if all you want is a test.                 //
    134 // Works for charcteristic 0 and q=p^m                       //
    135 // Returns 1 if poly r is SqrFree, 0 if SqrFree will do some //
    136 // kind of factorization.                                    //
    137 // Would be much more effcient iff we had *good*             //
    138 //  uni/multivariate gcd's and/or gcdtest's                  //
    139 ///////////////////////////////////////////////////////////////
    140 int
    141 SqrFreeTest( const CanonicalForm & r, int opt){
    142   CanonicalForm f=r, g;
    143   int n=level(f);
    144 
    145   if (getNumVars(f)==0) return 1 ; // a constant is SqrFree
    146   if ( f.isUnivariate() ) {
    147     g= f.deriv();
    148     if ( getCharacteristic() > 0 && g.isZero() ) return 0 ;
    149     // Next: it would be best to have a *univariate* gcd-test which returns
    150     // 0 iff gcdtest(f,g) == 1 or a constant ( for real Polynomials )
    151     g = gcd(f,g);
    152     if ( g.isOne() || (-g).isOne() ) return 1;
    153     else
    154       if ( getNumVars(g) == 0 ) return 1;// <- totaldegree!!!
    155       else return 0 ;
    156   }
    157   else { // multivariate case
    158     for ( int k=1; k<=n; k++ ) {
    159       g = swapvar(f,k,n); g = content(g);
    160       // g = 1 || -1 : sqr-free, g poly : not sqr-free, g number : opt helps
    161       if ( ! (g.isOne() || (-g).isOne() || getNumVars(g)==0 ) ) {
    162         if ( opt==0 ) return 0;
    163         else {
    164           if ( SqrFreeTest(g,1) == 0 ) return 0;
    165           g = swapvar(g,k,n);
    166           f /=g ;
    167         }
    168       }
    169     }
    170     // Now f is primitive
    171     n = level(f); // maybe less indeterminants
    172     //    if ( totaldegree(f) <= 1 ) return 1;
    173 
    174     // Let`s look if it is a Pth root
    175     if ( getCharacteristic() > 0 )
    176       for (int k=1; k<=n; k++ ) {
    177         g=swapvar(f,k,n); g=g.deriv();
    178         if ( ! g.isZero() ) break ;
    179         else if ( k==n) return 0 ; // really is Pth root
    180       }
    181     g = f.deriv() ;
    182     // Next: it would be best to have a *multivariate* gcd-test which returns
    183     // 0 iff gcdtest(f,g) == 1 or a constant ( for real Polynomials )
    184     g= gcd(f,g);
    185     if ( g.isOne() || (-g).isOne() || (g==f) || (getNumVars(g)==0) ) return 1 ;
    186     else return 0 ;
    187   }
    188 #ifdef HAVE_SINGULAR_ERROR
    189   WerrorS("libfac: ERROR: SqrFreeTest: we should never fall trough here!");
    190 #else
    191 #ifndef NOSTREAMIO
    192   CERR << "\nlibfac: ERROR: SqrFreeTest: we should never fall trough here!\n"
    193        << rcsid << errmsg << "\n";
    194 #endif
    195 #endif
    196   return 0;
    197 }
    198 
    199 ///////////////////////////////////////////////////////////////
    200132// A uni/multivariate SqrFree routine.Works for polynomials  //
    201133// which don\'t have a constant as the content.              //
     
    239171/*
    240172$Log: not supported by cvs2svn $
     173Revision 1.13  2008/01/22 09:51:37  Singular
     174*hannes: sqrFree/InternalSqrFree -> factory
     175
    241176Revision 1.12  2008/01/07 13:34:56  Singular
    242177*hannes: omse optiomzations(isOne)
  • libfac/factor/SqrFree.h

    r6bbc8e raadd442  
    22////////////////////////////////////////////////////////////
    33// emacs edit mode for this file is -*- C++ -*-
    4 // $Id: SqrFree.h,v 1.5 2008-01-22 09:51:37 Singular Exp $
     4// $Id: SqrFree.h,v 1.6 2008-01-25 14:19:40 Singular Exp $
    55///////////////////////////////////////////////////////////////////////////////
    66#ifndef SQRFREE_H
     
    1010// CFFList SqrFree( const CanonicalForm & f ) ;
    1111/*ENDPUBLIC*/
    12 //CFFList InternalSqrFree( const CanonicalForm & f , const CanonicalForm & mipo=0) ;
    13 int     SqrFreeTest( const CanonicalForm & r, int opt=1) ;
    1412CFFList SqrFree( const CanonicalForm & f ) ;
    1513#endif /* SQRFREE_H */
     
    1816/*
    1917$Log: not supported by cvs2svn $
     18Revision 1.5  2008/01/22 09:51:37  Singular
     19*hannes: sqrFree/InternalSqrFree -> factory
     20
    2021Revision 1.4  2002/08/19 11:11:34  Singular
    2122* hannes/pfister: alg_gcd etc.
Note: See TracChangeset for help on using the changeset viewer.