Changeset 08a6ebb in git
- Timestamp:
- Sep 26, 2007, 4:31:12 PM (16 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- f4b18020f64669b26ca1cbe58482a4d2d8178a49
- Parents:
- 8b388e1e07f2e848edfe629e622f372c9b16c0ea
- Location:
- factory
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/cf_chinese.cc
r8b388e r08a6ebb 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_chinese.cc,v 1.1 1 2007-09-26 09:17:39Singular Exp $ */2 /* $Id: cf_chinese.cc,v 1.12 2007-09-26 14:31:12 Singular Exp $ */ 3 3 4 4 //{{{ docu … … 162 162 { 163 163 //assume(P>0); 164 if (N<0){N=N+P;} 164 // assume !isOn(SW_RATIONAL): mod is a no-op otherwise 165 if (N<0) N +=P; 165 166 CanonicalForm A,B,C,D,E; 166 167 E=P; 167 168 B=1; 168 while ( N!=0)169 while (!N.isZero()) 169 170 { 170 171 if (2*N*N<P) 171 172 { 172 return(N/B); 173 } 174 D=E % N; 175 C=A-(E-E % N)/N*B; 173 On(SW_RATIONAL); 174 N /=B; 175 Off(SW_RATIONAL); 176 return(N); 177 } 178 D=mod(E , N); 179 C=A-(E-mod(E , N))/N*B; 176 180 E=N; 177 181 N=D; … … 184 188 CanonicalForm Farey ( const CanonicalForm & f, const CanonicalForm & q ) 185 189 { 190 int is_rat=isOn(SW_RATIONAL); 191 Off(SW_RATIONAL); 186 192 Variable x = f.mvar(); 187 193 CanonicalForm result = 0; … … 198 204 result += power( x, i.exp() ) * Farey(c,q); 199 205 } 206 if (is_rat) On(SW_RATIONAL); 200 207 return result; 201 208 } -
factory/cf_gcd.cc
r8b388e r08a6ebb 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_gcd.cc,v 1.5 0 2007-09-26 09:17:39Singular Exp $ */2 /* $Id: cf_gcd.cc,v 1.51 2007-09-26 14:31:12 Singular Exp $ */ 3 3 4 4 #include <config.h> … … 983 983 984 984 #define GCD_CHINES_MIN_TRIES 3 985 #define GCD_CHINES_MAX_TRIES 7986 985 CanonicalForm chinrem_gcd ( const CanonicalForm & FF, const CanonicalForm & GG ) 987 986 { … … 992 991 f=cd*FF; 993 992 f /=vcontent(f,Variable(1)); 994 cd = bCommonDen( f ); f *=cd;995 f /=vcontent(f,Variable(1));993 //cd = bCommonDen( f ); f *=cd; 994 //f /=vcontent(f,Variable(1)); 996 995 997 996 cd = bCommonDen( GG ); 998 997 g=cd*GG; 999 998 g /=vcontent(g,Variable(1)); 1000 cd = bCommonDen( g ); g *=cd;1001 g /=vcontent(g,Variable(1));999 //cd = bCommonDen( g ); g *=cd; 1000 //g /=vcontent(g,Variable(1)); 1002 1001 1003 1002 q = 0; … … 1018 1017 n--; 1019 1018 Dp = gcd( mapinto( f ), mapinto( g ) ); 1019 Dp /=Dp.lc(); 1020 1020 setCharacteristic( 0 ); 1021 1021 dp_deg=totaldegree(Dp); … … 1036 1036 D = newD; 1037 1037 } 1038 else if ( dp_deg <d_deg )1038 else if ( dp_deg > d_deg ) 1039 1039 { 1040 1040 n=GCD_CHINES_MIN_TRIES; … … 1044 1044 d_deg=dp_deg; 1045 1045 } 1046 //else 1047 // printf("bad prime\n"); 1048 // else p is a bad prime 1049 } 1050 if (( i >= 0 ) && (n >= GCD_CHINES_MIN_TRIES-GCD_CHINES_MAX_TRIES)) 1046 //else dp_deg < d_deg: bad prime 1047 } 1048 if ( i >= 0 ) 1051 1049 { 1052 1050 if (n<=0) 1053 1051 { 1054 // now balance D mod q 1055 //CanonicalForm Dn = balance_p( D, q ); 1056 //out_cf("test ",Dn,"\n"); 1057 //if ( fdivides( Dn, f ) && fdivides( Dn, g ) ) 1058 //{ 1059 // //printf("does divide\n"); 1060 // return Dn; 1061 //} 1062 CanonicalForm Dn= Farey(D,q); 1063 CanonicalForm cd = bCommonDen( Dn ); 1064 Dn *=cd; 1065 Dn /=vcontent(Dn,Variable(1)); 1066 if ( fdivides( Dn, f ) && fdivides( Dn, g ) ) 1067 { 1068 //printf("does divide\n"); 1069 return Dn; 1052 CanonicalForm Dn= Farey(D,q); 1053 int is_rat=isOn(SW_RATIONAL); 1054 On(SW_RATIONAL); 1055 CanonicalForm cd = bCommonDen( Dn ); // we need On(SW_RATIONAL) 1056 if (!is_rat) Off(SW_RATIONAL); 1057 Dn *=cd; 1058 //Dn /=vcontent(Dn,Variable(1)); 1059 if ( fdivides( Dn, f ) && fdivides( Dn, g ) ) 1060 { 1061 return Dn; 1062 } 1063 //else: try more primes 1070 1064 } 1071 //else 1072 // printf("does not divide\n"); 1073 } 1074 } 1075 else 1076 { 1077 #if 0 1078 printf("primes left:%d, tries left:%d, gcd-deg:%d\n",i,n,d_deg); 1079 out_cf("f= ",f,"\n"); 1080 out_cf("g= ",g,"\n"); 1081 CanonicalForm Dn= Farey(D,q); 1082 CanonicalForm cd = bCommonDen( Dn ); 1083 Dn *=cd; 1084 Dn /=vcontent(Dn,Variable(1)); 1085 out_cf("farey: ",Dn,"\n"); 1086 #endif 1065 } 1066 else 1067 { 1087 1068 Off(SW_USE_CHINREM_GCD); 1088 1069 D=gcd_poly( f, g ); 1089 1070 On(SW_USE_CHINREM_GCD); 1090 #if 01091 out_cf("gcd: ",D,"\n");1092 #endif1093 1071 return D; 1094 1072 }
Note: See TracChangeset
for help on using the changeset viewer.