- Timestamp:
- Oct 25, 2007, 4:45:41 PM (16 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- e520c56ea1ed45204b85b9d87163d60d99556985
- Parents:
- 4a4d6fc2217aa5457f704ed86513b02ed28c11f2
- Location:
- libfac/factor
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libfac/factor/Factor.cc
r4a4d6fc ra38d45 1 1 /* Copyright 1996 Michael Messollen. All rights reserved. */ 2 2 /////////////////////////////////////////////////////////////////////////////// 3 static char * rcsid = "$Id: Factor.cc,v 1.3 6 2007-10-15 18:03:11 Singular Exp $ ";3 static char * rcsid = "$Id: Factor.cc,v 1.37 2007-10-25 14:45:41 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 /////////////////////////////////////////////////////////////////////////////// … … 29 29 30 30 #include "alg_factor.h" 31 void out_cf(char *s1,const CanonicalForm &f,char *s2); 32 void out_cff(CFFList &L); 33 31 34 32 35 #ifdef SINGULAR … … 53 56 TIMING_DEFINE_PRINT(hensel_time); 54 57 TIMING_DEFINE_PRINT(truefactor_time); 55 56 void out_cf(char *s1,const CanonicalForm &f,char *s2);57 58 58 59 /* … … 1123 1124 Factorize(const CanonicalForm & F, const CanonicalForm & minpoly, int is_SqrFree ) 1124 1125 { 1126 //out_cf("Factorize: F=",F,"\n"); 1127 //out_cf(" minpoly:",minpoly,"\n"); 1125 1128 CFFList Outputlist,SqrFreeList,Intermediatelist,Outputlist2; 1126 1129 ListIterator<CFFactor> i,j; … … 1147 1150 if (minpoly!=0) 1148 1151 { 1149 CFList as(minpoly); 1150 CFFList sqF=sqrFree(F); // sqrFreeZ 1151 CFFList G,H; 1152 CanonicalForm fac; 1153 int d; 1154 ListIterator<CFFactor> i,k; 1155 for ( i = sqF; i.hasItem(); ++i ) 1152 if ( F.isHomogeneous() ) 1156 1153 { 1157 d = i.getItem().exp(); 1158 fac = i.getItem().factor(); 1159 G = newfactoras( fac, as, 1); 1160 for ( k = G; k.hasItem(); ++k ) 1154 DEBOUTLN(CERR, "Poly is homogeneous! : ", F); 1155 // Now we can substitute one variable to 1, factorize and then 1156 // look on the resulting factors and their monomials for 1157 // backsubstitution of the substituted variable. 1158 Outputlist=HomogFactor(F, minpoly, 0); 1159 } 1160 else 1161 { 1162 CFList as(minpoly); 1163 CFFList sqF=sqrFree(F); // sqrFreeZ 1164 CFFList G,H; 1165 CanonicalForm fac; 1166 int d; 1167 ListIterator<CFFactor> i,k; 1168 for ( i = sqF; i.hasItem(); ++i ) 1161 1169 { 1162 fac = k.getItem().factor(); 1163 int dd = k.getItem().exp(); 1164 H.append( CFFactor( fac , d*dd ) ); 1170 d = i.getItem().exp(); 1171 fac = i.getItem().factor(); 1172 G = newfactoras( fac, as, 1); 1173 for ( k = G; k.hasItem(); ++k ) 1174 { 1175 fac = k.getItem().factor(); 1176 int dd = k.getItem().exp(); 1177 H.append( CFFactor( fac , d*dd ) ); 1178 } 1165 1179 } 1166 }1167 //Outputlist = newfactoras( F, as, 1);1168 Outputlist = H;1180 //Outputlist = newfactoras( F, as, 1); 1181 Outputlist = H; 1182 } 1169 1183 } 1170 1184 else … … 1178 1192 DEBDECLEVEL(CERR, "Factorize"); 1179 1193 TIMING_PRINT(factorize_time, "\ntime used for factorization : "); 1194 //out_cff(Outputlist); 1180 1195 return Outputlist; 1181 1196 } … … 1297 1312 if(isOn(SW_USE_NTL_SORT)) Outputlist2.sort(cmpCF); 1298 1313 1314 //out_cff(Outputlist2); 1299 1315 return Outputlist2; 1300 1316 } … … 1302 1318 /* 1303 1319 $Log: not supported by cvs2svn $ 1320 Revision 1.36 2007/10/15 18:03:11 Singular 1321 *hannes: // debug stuff 1322 1304 1323 Revision 1.35 2007/06/14 14:16:35 Singular 1305 1324 *hannes: Factorize2 etc. -
libfac/factor/homogfactor.cc
r4a4d6fc ra38d45 1 1 /* Copyright 1997 Michael Messollen. All rights reserved. */ 2 2 //////////////////////////////////////////////////////////// 3 // static char * rcsid = "$Id: homogfactor.cc,v 1. 7 2006-05-16 14:46:50Singular Exp $ ";3 // static char * rcsid = "$Id: homogfactor.cc,v 1.8 2007-10-25 14:45:41 Singular Exp $ "; 4 4 //////////////////////////////////////////////////////////// 5 5 // FACTORY - Includes … … 25 25 #include "homogfactor.h" 26 26 27 void out_cf(char *s1,const CanonicalForm &f,char *s2); 28 29 CFFList Factorize2(CanonicalForm F, const CanonicalForm & minpoly ); 30 27 31 #ifdef HFACTORDEBUG 28 32 # define DEBUGOUTPUT … … 134 138 // we assume g is square-free 135 139 CFFList 136 HomogFactor( const CanonicalForm & g, const CanonicalForm & minpoly, const int Mainvar ){ 140 HomogFactor( const CanonicalForm & g, const CanonicalForm & minpoly, const int Mainvar ) 141 { 137 142 DEBINCLEVEL(CERR, "HomogFactor"); 138 143 Variable xn = get_max_degree_Variable(g); 139 144 int d_xn = degree(g,xn); 140 CFMap n; 141 CanonicalForm F = compress(g(1,xn),n); // must compress F! 145 CanonicalForm F = g(1,xn); 142 146 143 147 DEBOUTLN(CERR, "xn= ", xn); … … 148 152 // 149 153 CFFList Intermediatelist; 150 if ( getCharacteristic() > 0 )151 Intermediatelist = Factorized(F, minpoly, Mainvar);152 else153 Intermediatelist = factorize(F); // what support for char==0 ?154 154 CFFList Homoglist; 155 155 CFFListIterator j; 156 for ( j=Intermediatelist; j.hasItem(); j++ ) 157 Homoglist.append(CFFactor( n(j.getItem().factor()), j.getItem().exp()) ); 156 if ( getCharacteristic() > 0 ) 157 { 158 CFMap n; 159 Intermediatelist = Factorized(compress(F,n), minpoly, Mainvar); 160 for ( j=Intermediatelist; j.hasItem(); j++ ) 161 Homoglist.append(CFFactor( n(j.getItem().factor()), j.getItem().exp()) ); 162 } 163 else 164 Homoglist = Factorize2(F, minpoly); 158 165 // Now we have uncompressed factors in Homoglist 159 166 DEBOUTLN(CERR, "F factors as: ", Homoglist); 160 167 CFFList Unhomoglist; 161 168 CanonicalForm unhomogelem; 162 for ( j=Homoglist; j.hasItem(); j++ ){ 163 DEBOUTLN(CERR, "Homogenizing ",j.getItem().factor()); 164 unhomogelem= homogenize(j.getItem().factor(),xn); 165 DEBOUTLN(CERR, " that is ", unhomogelem); 166 Unhomoglist.append(CFFactor(unhomogelem,j.getItem().exp())); 167 d_xn -= degree(unhomogelem,xn)*j.getItem().exp(); 169 if ((!minpoly.isZero()) &&(getCharacteristic() == 0) ) 170 { 171 for ( j=Homoglist; j.hasItem(); j++ ) 172 { 173 // assume that minpoly.level() < level of all "real" variables of g 174 DEBOUTLN(CERR, "Homogenizing ",j.getItem().factor()); 175 unhomogelem= homogenize(j.getItem().factor(),xn, 176 Variable(minpoly.level()+1),g.mvar()); 177 DEBOUTLN(CERR, " that is ", unhomogelem); 178 Unhomoglist.append(CFFactor(unhomogelem,j.getItem().exp())); 179 d_xn -= degree(unhomogelem,xn)*j.getItem().exp(); 180 } 181 } 182 else 183 { 184 for ( j=Homoglist; j.hasItem(); j++ ) 185 { 186 DEBOUTLN(CERR, "Homogenizing ",j.getItem().factor()); 187 unhomogelem= homogenize(j.getItem().factor(),xn); 188 DEBOUTLN(CERR, " that is ", unhomogelem); 189 Unhomoglist.append(CFFactor(unhomogelem,j.getItem().exp())); 190 d_xn -= degree(unhomogelem,xn)*j.getItem().exp(); 191 } 168 192 } 169 193 DEBOUTLN(CERR, "Power of xn to append is ", d_xn); … … 177 201 /* 178 202 $Log: not supported by cvs2svn $ 203 Revision 1.7 2006/05/16 14:46:50 Singular 204 *hannes: gcc 4.1 fixes 205 179 206 Revision 1.6 2005/12/09 08:36:11 Singular 180 207 *hannes: stuff for homog. polys ->factory
Note: See TracChangeset
for help on using the changeset viewer.