Changeset a99e31 in git
- Timestamp:
- Mar 8, 2002, 11:31:46 AM (21 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'f875bbaccd0831e36aaed09ff6adeb3eb45aeb94')
- Children:
- 82e3b397cda580b0eb004f22f8298631937fcccb
- Parents:
- 7248478bf4e1532750f6423799de6cebde8d2657
- Location:
- factory
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/GNUmakefile.in
r7248478 ra99e31 1 1 # @configure_input@ 2 # $Id: GNUmakefile.in,v 1.4 1 1999-02-16 18:31:14 schmidtExp $2 # $Id: GNUmakefile.in,v 1.42 2002-03-08 10:31:44 Singular Exp $ 3 3 4 4 # … … 172 172 sm_sparsemod.cc \ 173 173 sm_util.cc \ 174 variable.cc 174 variable.cc \ 175 NTLconvert.cc 176 175 177 singfactorysrc := \ 176 178 singext.cc … … 240 242 sm_util.h \ 241 243 timing.h \ 242 variable.h 244 variable.h \ 245 NTLconvert.h 246 243 247 singfactoryincl := \ 244 248 singext.h -
factory/cf_char.cc
r7248478 ra99e31 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_char.cc,v 1. 6 1997-06-19 12:27:27 schmidtExp $ */2 /* $Id: cf_char.cc,v 1.7 2002-03-08 10:31:45 Singular Exp $ */ 3 3 4 4 #include <config.h> … … 62 62 } 63 63 64 int getExp() 65 { 66 return InternalPrimePower::getk(); 67 } 68 69 64 70 int getGFDegree() 65 71 { -
factory/cf_defs.h
r7248478 ra99e31 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_defs.h,v 1. 6 1997-07-30 07:59:21 schmidtExp $ */2 /* $Id: cf_defs.h,v 1.7 2002-03-08 10:31:46 Singular Exp $ */ 3 3 4 4 #ifndef INCL_CF_DEFS_H … … 35 35 const int SW_USE_EZGCD = 6; 36 36 const int SW_USE_SPARSEMOD = 7; 37 const int SW_USE_NTL=8; 37 38 //}}} 38 39 -
factory/cf_factor.cc
r7248478 ra99e31 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_factor.cc,v 1.1 1 2001-08-22 14:20:47Singular Exp $ */2 /* $Id: cf_factor.cc,v 1.12 2002-03-08 10:31:46 Singular Exp $ */ 3 3 4 4 //{{{ docu … … 28 28 #include "cf_algorithm.h" 29 29 30 #include "int_int.h" 31 #if 0 32 #include "NTLconvert.h" 33 #endif 34 35 int getExp(); /* cf_char.cc */ 36 30 37 static bool isUnivariateBaseDomain( const CanonicalForm & f ) 31 38 { … … 71 78 CFFList factorize ( const CanonicalForm & f, bool issqrfree ) 72 79 { 73 if ( f.inCoeffDomain() ) 74 return CFFList( f ); 75 if ( getCharacteristic() > 0 ) { 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() ); 81 } 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 } 92 CanonicalForm cd = bCommonDen( f ); 93 CanonicalForm fz = f * cd; 94 CFFList F; 95 bool on_rational = isOn(SW_RATIONAL); 96 Off(SW_RATIONAL); 97 if ( f.isUnivariate() ) 98 F = ZFactorizeUnivariate( fz, issqrfree ); 99 else 100 F = ZFactorizeMultivariate( fz, issqrfree ); 101 if ( on_rational ) 102 On(SW_RATIONAL); 103 if ( ! cd.isOne() ) { 104 if ( F.getFirst().factor().inCoeffDomain() ) { 105 CFFactor new_first( F.getFirst().factor() / cd ); 106 F.removeFirst(); 107 F.insert( new_first ); 108 } 109 else { 110 F.insert( CFFactor( 1/cd ) ); 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()); 121 } 122 return F; 123 } 80 if ( f.inCoeffDomain() ) 81 return CFFList( f ); 82 int mv=f.level(); 83 if (! f.isUnivariate() ) 84 { 85 mv=find_mvar(f); 86 if (mv!=f.level()) 87 { 88 swapvar(f,Variable(mv),f.mvar()); 89 } 90 } 91 CFFList F; 92 if ( getCharacteristic() > 0 ) 93 { 94 ASSERT( f.isUnivariate(), "multivariate factorization not implemented" ); 95 #if 0 96 if (isOn(SW_USE_NTL) && (getExp()==1)) 97 { 98 printf("start ntl...\n"); 99 // USE NTL 100 if (getCharacteristic()!=2) 101 { 102 // set remainder 103 ZZ r; 104 r=getCharacteristic(); 105 ZZ_pContext ccc(r); 106 ccc.restore(); 107 // convert to NTL 108 ZZ_pX f1=convertFacCF2NTLZZpX(f); 109 ZZ_p leadcoeff = LeadCoeff(f1); 110 //make monic 111 f1=f1 / LeadCoeff(f1); 112 113 // factorize 114 vec_pair_ZZ_pX_long factors; 115 CanZass(factors,f1); 116 117 // convert back to factory 118 F=convertNTLvec_pair_ZZpX_long2FacCFFList(factors,leadcoeff,f.mvar()); 119 } 120 else 121 { 122 // Specialcase characteristic==2 123 124 // remainder is 2 --> nothing to set 125 126 // convert to NTL using the faster conversion routine for characteristic 2 127 GF2X f1=convertFacCF2NTLGF2X(f); 128 129 // no make monic necessary in GF2 130 131 //factorize 132 vec_pair_GF2X_long factors; 133 CanZass(factors,f1); 134 135 // convert back to factory again using the faster conversion routine for vectors over GF2X 136 F=convertNTLvec_pair_GF2X_long2FacCFFList(factors,LeadCoeff(f1),f.mvar()); 137 } 138 printf("... end ntl\n"); 139 } 140 else 141 #endif 142 { // Use Factory without NTL 143 if ( isOn( SW_BERLEKAMP ) ) 144 F=FpFactorizeUnivariateB( f, issqrfree ); 145 else 146 F=FpFactorizeUnivariateCZ( f, issqrfree, 0, Variable(), Variable() ); 147 } 148 } 149 else 150 { 151 CanonicalForm cd = bCommonDen( f ); 152 CanonicalForm fz = f * cd; 153 bool on_rational = isOn(SW_RATIONAL); 154 Off(SW_RATIONAL); 155 if ( f.isUnivariate() ) 156 { 157 #if 0 158 if (isOn(SW_USE_NTL)) 159 { 160 printf("start ntl...\n"); 161 //USE NTL 162 ZZ c; 163 vec_pair_ZZX_long factors; 164 //factorize the converted polynomial 165 factor(c,factors,convertFacCF2NTLZZX(fz)); 166 167 //convert the result back to Factory 168 F=convertNTLvec_pair_ZZX_long2FacCFFList(factors,c,fz.mvar()); 169 printf("... end ntl\n"); 170 } 171 else 172 #endif 173 { 174 //Use Factory without NTL 175 F = ZFactorizeUnivariate( fz, issqrfree ); 176 } 177 } 178 else 179 F = ZFactorizeMultivariate( fz, issqrfree ); 180 181 if ( on_rational ) 182 On(SW_RATIONAL); 183 if ( ! cd.isOne() ) 184 { 185 if ( F.getFirst().factor().inCoeffDomain() ) 186 { 187 CFFactor new_first( F.getFirst().factor() / cd ); 188 F.removeFirst(); 189 F.insert( new_first ); 190 } 191 else 192 { 193 F.insert( CFFactor( 1/cd ) ); 194 } 195 } 196 } 197 198 if ((mv!=f.level()) && (! f.isUnivariate() )) 199 { 200 CFFListIterator J=F; 201 for ( ; J.hasItem(); J++) 202 { 203 swapvar(J.getItem().factor(),Variable(mv),f.mvar()); 204 } 205 swapvar(f,Variable(mv),f.mvar()); 206 } 207 return F; 124 208 } 125 209 … … 129 213 ASSERT( f.isUnivariate(), "multivariate factorization not implemented" ); 130 214 ASSERT( getCharacteristic() > 0, "char 0 factorization not implemented" ); 131 return FpFactorizeUnivariateCZ( f, false, 1, alpha, Variable() ); 215 #if 0 216 if (isOn(SW_USE_NTL)) 217 { 218 //USE NTL 219 if (getCharacteristic()!=2) 220 { 221 // First all cases with characteristic !=2 222 // set remainder 223 ZZ r; 224 r=getCharacteristic(); 225 ZZ_pContext ccc(r); 226 ccc.restore(); 227 228 // set minimal polynomial in NTL 229 ZZ_pX minPo=convertFacCF2NTLZZpX(getMipo(alpha,f.mvar())); 230 ZZ_pEContext c(minPo); 231 c.restore(); 232 233 // convert to NTL 234 ZZ_pEX f1=to_ZZ_pEX(convertFacCF2NTLZZpX(f)); 235 236 //make monic 237 ZZ_pE leadcoeff= LeadCoeff(f1); 238 f1=f1 / leadcoeff; 239 240 // factorize using NTL 241 vec_pair_ZZ_pEX_long factors; 242 CanZass(factors,f1); 243 244 // return converted result 245 return convertNTLvec_pair_ZZpEX_long2FacCFFList(factors,leadcoeff,f.mvar(),alpha); 246 } 247 else 248 { 249 // special case : GF2 250 251 // remainder is two ==> nothing to do 252 253 // set minimal polynomial in NTL using the optimized conversion routines for characteristic 2 254 GF2X minPo=convertFacCF2NTLGF2X(getMipo(alpha,f.mvar())); 255 GF2EContext c(minPo); 256 c.restore(); 257 258 // convert to NTL again using the faster conversion routines 259 GF2EX f1=to_GF2EX(convertFacCF2NTLGF2X(f)); 260 261 // no make monic necessary in GF2 262 263 // factorize using NTL 264 vec_pair_GF2EX_long factors; 265 CanZass(factors,f1); 266 267 // return converted result 268 return convertNTLvec_pair_GF2EX_long2FacCFFList(factors,LeadCoeff(f1),f.mvar(),alpha); 269 } 270 271 } 272 else 273 #endif 274 { 275 return FpFactorizeUnivariateCZ( f, false, 1, alpha, Variable() ); 276 } 277 132 278 } 133 279 … … 138 284 139 285 if ( getCharacteristic() == 0 ) 140 286 result = sqrFreeZ( f ); 141 287 else 142 288 result = sqrFreeFp( f ); 143 289 144 290 return ( sort ? sortCFFList( result ) : result ); … … 149 295 // ASSERT( f.isUnivariate(), "multivariate factorization not implemented" ); 150 296 if ( getCharacteristic() == 0 ) 151 297 return isSqrFreeZ( f ); 152 298 else 153 return isSqrFreeFp( f ); 154 } 299 return isSqrFreeFp( f ); 300 } 301
Note: See TracChangeset
for help on using the changeset viewer.