Changeset 28ffaa in git
- Timestamp:
- Aug 22, 2001, 4:20:47 PM (22 years ago)
- Branches:
- (u'spielwiese', '91fdef05f09f54b8d58d92a472e9c4a43aa4656f')
- Children:
- b6249e47ee58f2e950b5e85af745e7f054b42516
- Parents:
- a90dc01e741c2f1ba1d72b616559669433395640
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/cf_factor.cc
ra90dc0 r28ffaa 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_factor.cc,v 1.1 0 1998-03-12 10:27:41 schmidtExp $ */2 /* $Id: cf_factor.cc,v 1.11 2001-08-22 14:20:47 Singular Exp $ */ 3 3 4 4 //{{{ docu … … 37 37 } 38 38 39 void find_exp(const CanonicalForm & f, int * exp_f) 40 { 41 if ( ! f.inCoeffDomain() ) 42 { 43 int e=f.level(); 44 CFIterator i = f; 45 if (i.exp() > exp_f[e]) exp_f[e]=i.exp(); 46 for (; i.hasTerms(); i++ ) 47 { 48 find_exp(i.coeff(), exp_f); 49 } 50 } 51 } 52 53 int find_mvar(const CanonicalForm & f) 54 { 55 int mv=f.level(); 56 int *exp_f=new int[mv+1]; 57 int i; 58 for(i=mv;i>0;i--) exp_f[i]=0; 59 find_exp(f,exp_f); 60 for(i=mv;i>0;i--) 61 { 62 if ((exp_f[i]>0) && (exp_f[i]<exp_f[mv])) 63 { 64 mv=i; 65 } 66 } 67 delete[] exp_f; 68 return mv; 69 } 70 39 71 CFFList factorize ( const CanonicalForm & f, bool issqrfree ) 40 72 { 41 73 if ( f.inCoeffDomain() ) 42 74 return CFFList( f ); 43 75 if ( getCharacteristic() > 0 ) { 44 45 46 47 48 76 ASSERT( f.isUnivariate(), "multivariate factorization not implemented" ); 77 if ( isOn( SW_BERLEKAMP ) ) 78 return FpFactorizeUnivariateB( f, issqrfree ); 79 else 80 return FpFactorizeUnivariateCZ( f, issqrfree, 0, Variable(), Variable() ); 49 81 } 50 82 else { 83 int mv=f.level(); 84 if (! f.isUnivariate() ) 85 { 86 mv=find_mvar(f); 87 if (mv!=f.level()) 88 { 89 swapvar(f,Variable(mv),f.mvar()); 90 } 91 } 51 92 CanonicalForm cd = bCommonDen( f ); 52 93 CanonicalForm fz = f * cd; … … 54 95 bool on_rational = isOn(SW_RATIONAL); 55 96 Off(SW_RATIONAL); 56 57 58 59 97 if ( f.isUnivariate() ) 98 F = ZFactorizeUnivariate( fz, issqrfree ); 99 else 100 F = ZFactorizeMultivariate( fz, issqrfree ); 60 101 if ( on_rational ) 61 102 On(SW_RATIONAL); … … 69 110 F.insert( CFFactor( 1/cd ) ); 70 111 } 112 } 113 if ((mv!=f.level()) && (! f.isUnivariate() )) 114 { 115 CFFListIterator J=F; 116 for ( ; J.hasItem(); J++) 117 { 118 swapvar(J.getItem().factor(),Variable(mv),f.mvar()); 119 } 120 swapvar(f,Variable(mv),f.mvar()); 71 121 } 72 122 return F; … … 88 138 89 139 if ( getCharacteristic() == 0 ) 90 140 result = sqrFreeZ( f ); 91 141 else 92 142 result = sqrFreeFp( f ); 93 143 94 144 return ( sort ? sortCFFList( result ) : result ); … … 99 149 // ASSERT( f.isUnivariate(), "multivariate factorization not implemented" ); 100 150 if ( getCharacteristic() == 0 ) 101 151 return isSqrFreeZ( f ); 102 152 else 103 153 return isSqrFreeFp( f ); 104 154 }
Note: See TracChangeset
for help on using the changeset viewer.