Changeset aadd442 in git
- Timestamp:
- Jan 25, 2008, 3:19:40 PM (15 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a657104b677b4c461d018cbf3204d72d34ad66a9')
- Children:
- bfe72e2bcb7632d5cf79dc5196713a5fba2bafb5
- Parents:
- 6bbc8e2c339d1928744e2f67b390389567caa462
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/cf_factor.cc
r6bbc8e raadd442 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_factor.cc,v 1.3 8 2008-01-22 09:28:22Singular Exp $ */2 /* $Id: cf_factor.cc,v 1.39 2008-01-25 14:17:59 Singular Exp $ */ 3 3 4 4 //{{{ docu … … 726 726 } 727 727 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 /////////////////////////////////////////////////////////////// 737 bool 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; 733 751 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 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: fac_sqrfree.cc,v 1. 8 2008-01-22 09:30:31Singular Exp $ */2 /* $Id: fac_sqrfree.cc,v 1.9 2008-01-25 14:17:59 Singular Exp $ */ 3 3 4 4 #include <config.h> … … 343 343 } 344 344 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 356 345 /* 357 346 -
factory/fac_sqrfree.h
r6bbc8e raadd442 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: fac_sqrfree.h,v 1. 4 2008-01-22 09:30:31Singular Exp $ */2 /* $Id: fac_sqrfree.h,v 1.5 2008-01-25 14:18:56 Singular Exp $ */ 3 3 4 4 #ifndef INCL_FAC_SQRFREE_H … … 23 23 CFFList sqrFreeFp ( const CanonicalForm & r, const CanonicalForm &mipo=0 ); 24 24 25 bool isSqrFreeFp ( const CanonicalForm & f );26 27 25 CFFList sqrFreeZ ( const CanonicalForm & f, const CanonicalForm &mipo=0 ); 28 26 29 bool isSqrFreeZ ( const CanonicalForm & f );30 31 27 #endif /* ! INCL_FAC_SQRFREE_H */ -
factory/fac_univar.cc
r6bbc8e raadd442 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: fac_univar.cc,v 1.2 0 2008-01-22 09:30:31Singular Exp $ */2 /* $Id: fac_univar.cc,v 1.21 2008-01-25 14:17:59 Singular Exp $ */ 3 3 4 4 #include <config.h> … … 214 214 215 215 216 static int 217 choosePrimes ( int * p, const CanonicalForm & f ) 216 static int choosePrimes ( int * p, const CanonicalForm & f ) 218 217 { 219 218 int ptr = 0; … … 222 221 int prime; 223 222 224 while ( ptr < maxp && i < max_fp_fac ) { 223 while ( ptr < maxp && i < max_fp_fac ) 224 { 225 225 prime = cf_getPrime( ptr ); 226 if ( mod( lc( f ), prime ) != 0 ) { 226 if ( mod( lc( f ), prime ) != 0 ) 227 { 227 228 setCharacteristic( prime ); 228 if ( isSqrFreeFp( mapinto( f ) ) ) { 229 if ( isSqrFree( mapinto( f ) ) ) 230 { 229 231 p[i] = prime; 230 232 i++; -
libfac/charset/alg_factor.cc
r6bbc8e raadd442 3 3 // emacs edit mode for this file is -*- C++ -*- 4 4 //////////////////////////////////////////////////////////// 5 static char * rcsid = "$Id: alg_factor.cc,v 1.1 8 2008-01-22 09:51:36Singular Exp $";5 static char * rcsid = "$Id: alg_factor.cc,v 1.19 2008-01-25 14:19:39 Singular Exp $"; 6 6 //////////////////////////////////////////////////////////// 7 7 // FACTORY - Includes … … 199 199 } 200 200 else{ 201 DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!");202 // Look at SqrFreeTest!201 DEBOUTMSG(CERR, "Starting isSqrFree(R)!"); 202 // Look at isSqrFree! 203 203 // (z+a^5+w)^4 with z<w<a should not give sqfreetest=1 ! 204 204 // for now we use this workaround with Factorize... … … 219 219 for ( i=testlist; i.hasItem(); i++) 220 220 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); 222 222 } 223 223 if ( ! sqfreetest ){ … … 264 264 } 265 265 else{ 266 DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!");267 // Look at SqrFreeTest!266 DEBOUTMSG(CERR, "Starting isSqrFree(R)!"); 267 // Look at isSqrFree! 268 268 // (z+a^5+w)^4 with z<w<a should not give sqfreetest=1 ! 269 269 // for now we use this workaround with Factorize... … … 284 284 for ( i=testlist; i.hasItem(); i++) 285 285 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); 287 287 } 288 288 if ( ! sqfreetest ){ … … 830 830 /* 831 831 $Log: not supported by cvs2svn $ 832 Revision 1.18 2008/01/22 09:51:36 Singular 833 *hannes: sqrFree/InternalSqrFree -> factory 834 832 835 Revision 1.17 2007/05/15 14:46:48 Singular 833 836 *hannes: factorize in Zp(a)[x...] -
libfac/factor/Factor.cc
r6bbc8e raadd442 1 1 /* Copyright 1996 Michael Messollen. All rights reserved. */ 2 2 /////////////////////////////////////////////////////////////////////////////// 3 static char * rcsid = "$Id: Factor.cc,v 1. 39 2008-01-22 09:51:37Singular Exp $ ";3 static char * rcsid = "$Id: Factor.cc,v 1.40 2008-01-25 14:19:40 Singular Exp $ "; 4 4 static 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."; 5 5 /////////////////////////////////////////////////////////////////////////////// … … 363 363 if ( degree(g) == deg ) // degrees match 364 364 if ( level(compress(g,m)) == (vars_left) ) // exactly one variable less 365 if ( SqrFreeTest(g,1) ) // poly is sqrfree365 if ( isSqrFree(g) ) // poly is sqrfree 366 366 if ( gcd(g,g.deriv()).isOne() ) // Discriminante != 0 367 367 return 1; … … 924 924 // (If gcd is fast...) 925 925 /////// 926 // if ( ! SqrFreeTest(F) ){926 // if ( ! isSqrFree(F) ){ 927 927 if ( ! is_SqrFree ) 928 928 { … … 1223 1223 // (If gcd is fast...) 1224 1224 /////// 1225 // if ( ! SqrFreeTest(F) ){1225 // if ( ! isSqrFree(F) ){ 1226 1226 if ( ! is_SqrFree ) 1227 1227 { … … 1329 1329 /* 1330 1330 $Log: not supported by cvs2svn $ 1331 Revision 1.39 2008/01/22 09:51:37 Singular 1332 *hannes: sqrFree/InternalSqrFree -> factory 1333 1331 1334 Revision 1.38 2008/01/07 13:34:56 Singular 1332 1335 *hannes: omse optiomzations(isOne) -
libfac/factor/SqrFree.cc
r6bbc8e raadd442 2 2 /////////////////////////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 static char * rcsid = "$Id: SqrFree.cc,v 1.1 3 2008-01-22 09:51:37Singular Exp $";4 static char * rcsid = "$Id: SqrFree.cc,v 1.14 2008-01-25 14:19:40 Singular Exp $"; 5 5 static 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."; 6 6 /////////////////////////////////////////////////////////////////////////////// … … 130 130 131 131 /////////////////////////////////////////////////////////////// 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 int141 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 SqrFree146 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 returns150 // 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 else154 if ( getNumVars(g) == 0 ) return 1;// <- totaldegree!!!155 else return 0 ;156 }157 else { // multivariate case158 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 helps161 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 primitive171 n = level(f); // maybe less indeterminants172 // if ( totaldegree(f) <= 1 ) return 1;173 174 // Let`s look if it is a Pth root175 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 root180 }181 g = f.deriv() ;182 // Next: it would be best to have a *multivariate* gcd-test which returns183 // 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_ERROR189 WerrorS("libfac: ERROR: SqrFreeTest: we should never fall trough here!");190 #else191 #ifndef NOSTREAMIO192 CERR << "\nlibfac: ERROR: SqrFreeTest: we should never fall trough here!\n"193 << rcsid << errmsg << "\n";194 #endif195 #endif196 return 0;197 }198 199 ///////////////////////////////////////////////////////////////200 132 // A uni/multivariate SqrFree routine.Works for polynomials // 201 133 // which don\'t have a constant as the content. // … … 239 171 /* 240 172 $Log: not supported by cvs2svn $ 173 Revision 1.13 2008/01/22 09:51:37 Singular 174 *hannes: sqrFree/InternalSqrFree -> factory 175 241 176 Revision 1.12 2008/01/07 13:34:56 Singular 242 177 *hannes: omse optiomzations(isOne) -
libfac/factor/SqrFree.h
r6bbc8e raadd442 2 2 //////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 // $Id: SqrFree.h,v 1. 5 2008-01-22 09:51:37Singular Exp $4 // $Id: SqrFree.h,v 1.6 2008-01-25 14:19:40 Singular Exp $ 5 5 /////////////////////////////////////////////////////////////////////////////// 6 6 #ifndef SQRFREE_H … … 10 10 // CFFList SqrFree( const CanonicalForm & f ) ; 11 11 /*ENDPUBLIC*/ 12 //CFFList InternalSqrFree( const CanonicalForm & f , const CanonicalForm & mipo=0) ;13 int SqrFreeTest( const CanonicalForm & r, int opt=1) ;14 12 CFFList SqrFree( const CanonicalForm & f ) ; 15 13 #endif /* SQRFREE_H */ … … 18 16 /* 19 17 $Log: not supported by cvs2svn $ 18 Revision 1.5 2008/01/22 09:51:37 Singular 19 *hannes: sqrFree/InternalSqrFree -> factory 20 20 21 Revision 1.4 2002/08/19 11:11:34 Singular 21 22 * hannes/pfister: alg_gcd etc.
Note: See TracChangeset
for help on using the changeset viewer.