Changeset dad0bc5 in git
- Timestamp:
- Dec 9, 2005, 9:35:38 AM (18 years ago)
- Branches:
- (u'spielwiese', 'a7324b6e0b44a1a8ed3fa4d9ca3e2ff210ddd52c')
- Children:
- 172b7ae49955a6c96c685cbe68ee3f257d89bd46
- Parents:
- 1b82a2e051a986276fd759237c823aecfb97b2be
- Location:
- factory
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/NTLconvert.cc
r1b82a2 rdad0bc5 1 /* $Id: NTLconvert.cc,v 1.1 3 2004-01-19 11:26:19Singular Exp $ */1 /* $Id: NTLconvert.cc,v 1.14 2005-12-09 08:35:37 Singular Exp $ */ 2 2 #include <config.h> 3 3 … … 419 419 } 420 420 421 int NTLcmpCF( const CFFactor & f, const CFFactor & g )422 {423 if (f.exp() > g.exp()) return 1;424 if (f.exp() < g.exp()) return 0;425 if (f.factor() > g.factor()) return 1;426 return 0;427 }428 429 421 //////////////////////////////////////////////////////////////////////////////// 430 422 // NAME: convertNTLvec_pair_ZZpX_long2FacCFFList // … … 468 460 rueckgabe.append(CFFactor(convertNTLZZpX2CF(e[i].a,x),e[i].b)); 469 461 } 470 if(isOn(SW_USE_NTL_SORT)) rueckgabe.sort(NTLcmpCF);471 462 // the multiplicity at pos 1 472 463 if (!IsOne(multi)) … … 495 486 rueckgabe.append(CFFactor(convertNTLzzpX2CF(e[i].a,x),e[i].b)); 496 487 } 497 if(isOn(SW_USE_NTL_SORT)) rueckgabe.sort(NTLcmpCF);498 488 // the multiplicity at pos 1 499 489 if (!IsOne(multi)) … … 556 546 rueckgabe.append(CFFactor(bigone,exponent)); 557 547 } 558 if(isOn(SW_USE_NTL_SORT)) rueckgabe.sort(NTLcmpCF);559 548 return rueckgabe; 560 549 } … … 777 766 rueckgabe.append(CFFactor(bigone,exponent)); 778 767 } 779 if(isOn(SW_USE_NTL_SORT)) rueckgabe.sort(NTLcmpCF);780 768 // the multiplicity at pos 1 781 769 //if (!IsOne(multi)) … … 869 857 rueckgabe.append(CFFactor(bigone,exponent)); 870 858 } 871 if(isOn(SW_USE_NTL_SORT)) rueckgabe.sort(NTLcmpCF);872 859 // Start by appending the multiplicity 873 860 if (!IsOne(multi)) … … 914 901 rueckgabe.append(CFFactor(bigone,exponent)); 915 902 } 916 if(isOn(SW_USE_NTL_SORT)) rueckgabe.sort(NTLcmpCF);917 903 // Start by appending the multiplicity 918 904 if (!IsOne(multi)) … … 1007 993 1008 994 } 1009 if(isOn(SW_USE_NTL_SORT)) rueckgabe.sort(NTLcmpCF);1010 995 // return the computed CFFList 1011 996 return rueckgabe; -
factory/canonicalform.cc
r1b82a2 rdad0bc5 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: canonicalform.cc,v 1.3 5 2005-10-18 12:33:00Singular Exp $ */2 /* $Id: canonicalform.cc,v 1.36 2005-12-09 08:35:37 Singular Exp $ */ 3 3 4 4 #include <config.h> … … 12 12 #include "int_cf.h" 13 13 #include "cf_factory.h" 14 #include "cf_algorithm.h" 14 15 #include "imm.h" 15 16 #include "gfops.h" … … 181 182 return value->isUnivariate(); 182 183 } 184 185 // is_homogeneous returns 1 iff f is homogeneous, 0 otherwise// 186 bool 187 CanonicalForm::isHomogeneous() const 188 { 189 if (this->isZero()) return true; 190 else if (this->inCoeffDomain()) return true; 191 else 192 { 193 #if 0 194 CFIterator i; 195 int cdeg = -2, dummy; 196 for ( i = *this; i.hasTerms(); i++ ) 197 { 198 if (!(i.coeff().isHomogeneous())) return false; 199 if ( (dummy = totaldegree( i.coeff() ) + i.exp()) != cdeg ) 200 { 201 if (cdeg == -2) cdeg = dummy; 202 else return false; 203 } 204 } 205 return true; 206 #else 207 CFList termlist= get_Terms(*this); 208 CFListIterator i; 209 int deg= totaldegree(termlist.getFirst()); 210 211 for ( i=termlist; i.hasItem(); i++ ) 212 if ( totaldegree(i.getItem()) != deg ) return false; 213 return true; 214 #endif 215 } 216 } 217 183 218 //}}} 184 219 -
factory/canonicalform.h
r1b82a2 rdad0bc5 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: canonicalform.h,v 1. 29 2005-10-18 13:16:14Singular Exp $ */2 /* $Id: canonicalform.h,v 1.30 2005-12-09 08:35:37 Singular Exp $ */ 3 3 4 4 #ifndef INCL_CANONICALFORM_H … … 89 89 bool isFFinGF() const; 90 90 bool isUnivariate() const; 91 bool isHomogeneous() const; 91 92 92 93 // conversion functions -
factory/cf_algorithm.cc
r1b82a2 rdad0bc5 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_algorithm.cc,v 1. 9 2003-05-31 12:35:05Singular Exp $ */2 /* $Id: cf_algorithm.cc,v 1.10 2005-12-09 08:35:37 Singular Exp $ */ 3 3 4 4 //{{{ docu … … 119 119 else { l = 1; } 120 120 d= dr-dv+1; 121 while ( ( dv <= dr ) && ( r != r.genZero()) ){ 121 while ( ( dv <= dr ) && ( r != r.genZero()) ) 122 { 122 123 test = power(x,dr-dv)*v*LC(r,x); 123 124 if ( dr == 0 ) { r= CanonicalForm(0); } -
factory/cf_algorithm.h
r1b82a2 rdad0bc5 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_algorithm.h,v 1.1 1 1998-06-30 16:31:24 schmidtExp $ */2 /* $Id: cf_algorithm.h,v 1.12 2005-12-09 08:35:37 Singular Exp $ */ 3 3 4 4 #ifndef INCL_CF_ALGORITHM_H … … 61 61 62 62 bool isSqrFree ( const CanonicalForm & f ); 63 64 CanonicalForm homogenize( const CanonicalForm & f, const Variable & x); 65 Variable get_max_degree_Variable(const CanonicalForm & f); 66 CFList get_Terms( const CanonicalForm & f ); 67 void getTerms( const CanonicalForm & f, const CanonicalForm & t, CFList & result ); 68 69 63 70 //}}} 64 71 -
factory/cf_factor.cc
r1b82a2 rdad0bc5 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_factor.cc,v 1.2 6 2005-08-22 17:24:01Singular Exp $ */2 /* $Id: cf_factor.cc,v 1.27 2005-12-09 08:35:38 Singular Exp $ */ 3 3 4 4 //{{{ docu … … 172 172 } 173 173 174 /////////////////////////////////////////////////////////////// 175 // get_max_degree_Variable returns Variable with // 176 // highest degree. We assume f is *not* a constant! // 177 /////////////////////////////////////////////////////////////// 178 Variable 179 get_max_degree_Variable(const CanonicalForm & f) 180 { 181 ASSERT( ( ! f.inCoeffDomain() ), "no constants" ); 182 int max=0, maxlevel=0, n=level(f); 183 for ( int i=1; i<=n; i++ ) 184 { 185 if (degree(f,Variable(i)) >= max) 186 { 187 max= degree(f,Variable(i)); maxlevel= i; 188 } 189 } 190 return Variable(maxlevel); 191 } 192 193 /////////////////////////////////////////////////////////////// 194 // get_Terms: Split the polynomial in the containing terms. // 195 // getTerms: the real work is done here. // 196 /////////////////////////////////////////////////////////////// 197 void 198 getTerms( const CanonicalForm & f, const CanonicalForm & t, CFList & result ) 199 { 200 if ( getNumVars(f) == 0 ) result.append(f*t); 201 else{ 202 Variable x(level(f)); 203 for ( CFIterator i=f; i.hasTerms(); i++ ) 204 getTerms( i.coeff(), t*power(x,i.exp()), result); 205 } 206 } 207 CFList 208 get_Terms( const CanonicalForm & f ){ 209 CFList result,dummy,dummy2; 210 CFIterator i; 211 CFListIterator j; 212 213 if ( getNumVars(f) == 0 ) result.append(f); 214 else{ 215 Variable _x(level(f)); 216 for ( i=f; i.hasTerms(); i++ ){ 217 getTerms(i.coeff(), 1, dummy); 218 for ( j=dummy; j.hasItem(); j++ ) 219 result.append(j.getItem() * power(_x, i.exp())); 220 221 dummy= dummy2; // have to initalize new 222 } 223 } 224 return result; 225 } 226 227 228 /////////////////////////////////////////////////////////////// 229 // homogenize homogenizes f with Variable x // 230 /////////////////////////////////////////////////////////////// 231 232 CanonicalForm 233 homogenize( const CanonicalForm & f, const Variable & x) 234 { 235 #if 0 236 int maxdeg=totaldegree(f), deg; 237 CFIterator i; 238 CanonicalForm elem, result=f.genZero(); 239 240 for (i=f; i.hasTerms(); i++) 241 { 242 elem= i.coeff()*power(f.mvar(),i.exp()); 243 deg = totaldegree(elem); 244 if ( deg < maxdeg ) 245 result += elem * power(x,maxdeg-deg); 246 else 247 result+=elem; 248 } 249 return result; 250 #else 251 CFList Newlist, Termlist= get_Terms(f); 252 int maxdeg=totaldegree(f), deg; 253 CFListIterator i; 254 CanonicalForm elem, result=f.genZero(); 255 256 for (i=Termlist; i.hasItem(); i++){ 257 elem= i.getItem(); 258 deg = totaldegree(elem); 259 if ( deg < maxdeg ) 260 Newlist.append(elem * power(x,maxdeg-deg)); 261 else 262 Newlist.append(elem); 263 } 264 for (i=Newlist; i.hasItem(); i++) // rebuild 265 result += i.getItem(); 266 267 return result; 268 #endif 269 } 270 271 #ifdef SINGULAR 272 extern int singular_homog_flag; 273 #else 274 #define singular_homog_flag 1 275 #endif 276 static int cmpCF( const CFFactor & f, const CFFactor & g ) 277 { 278 if (f.exp() > g.exp()) return 1; 279 if (f.exp() < g.exp()) return 0; 280 if (f.factor() > g.factor()) return 1; 281 return 0; 282 } 283 174 284 CFFList factorize ( const CanonicalForm & f, bool issqrfree ) 175 285 { 176 286 if ( f.inCoeffDomain() ) 177 287 return CFFList( f ); 178 //out_cf("factorize:",f,"==================================\n");179 288 int mv=f.level(); 180 289 int org_v=mv; 290 //out_cf("factorize:",f,"==================================\n"); 181 291 if (! f.isUnivariate() ) 182 292 { 293 if ( singular_homog_flag && f.isHomogeneous()) 294 { 295 Variable xn = get_max_degree_Variable(f); 296 int d_xn = degree(f,xn); 297 CFMap n; 298 CanonicalForm F = compress(f(1,xn),n); 299 CFFList Intermediatelist; 300 Intermediatelist = factorize(F); 301 CFFList Homoglist; 302 CFFListIterator j; 303 for ( j=Intermediatelist; j.hasItem(); j++ ) 304 { 305 Homoglist.append( 306 CFFactor( n(j.getItem().factor()), j.getItem().exp()) ); 307 } 308 CFFList Unhomoglist; 309 CanonicalForm unhomogelem; 310 for ( j=Homoglist; j.hasItem(); j++ ) 311 { 312 unhomogelem= homogenize(j.getItem().factor(),xn); 313 Unhomoglist.append(CFFactor(unhomogelem,j.getItem().exp())); 314 d_xn -= (degree(unhomogelem,xn)*j.getItem().exp()); 315 } 316 if ( d_xn != 0 ) // have to append xn^(d_xn) 317 Unhomoglist.append(CFFactor(CanonicalForm(xn),d_xn)); 318 if(isOn(SW_USE_NTL_SORT)) Unhomoglist.sort(cmpCF); 319 return Unhomoglist; 320 } 183 321 mv=find_mvar(f); 184 322 if ( getCharacteristic() == 0 ) … … 365 503 } 366 504 //out_cff(F); 505 if(isOn(SW_USE_NTL_SORT)) F.sort(cmpCF); 367 506 return F; 368 507 } -
factory/fac_cantzass.cc
r1b82a2 rdad0bc5 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: fac_cantzass.cc,v 1. 7 2004-10-11 10:49:20Singular Exp $ */2 /* $Id: fac_cantzass.cc,v 1.8 2005-12-09 08:35:38 Singular Exp $ */ 3 3 4 4 #include <config.h> … … 105 105 if ( numext > 0 ) 106 106 mpz_clear( &qq ); 107 #ifdef HAVE_NTL108 extern int NTLcmpCF( const CFFactor & f, const CFFactor & g );109 if(isOn(SW_USE_NTL_SORT)) H.sort(NTLcmpCF);110 #endif111 107 return H; 112 108 }
Note: See TracChangeset
for help on using the changeset viewer.