Changeset 3ccafbf in git for kernel/longrat.cc
- Timestamp:
- Apr 12, 2007, 6:58:38 PM (17 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 7ba9fe121c436f581536f3d3a05ab906f5cbe6cc
- Parents:
- 11fa81ef71e21f2b1f252178f3df714e3326215f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/longrat.cc
r11fa81 r3ccafbf 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: longrat.cc,v 1.1 5 2007-04-12 16:33:52Singular Exp $ */4 /* $Id: longrat.cc,v 1.16 2007-04-12 16:58:38 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: computation with long rational numbers (Hubert Grassmann) … … 1161 1161 } 1162 1162 } 1163 if (x->s==0) 1164 { 1165 //BOOLEAN divided=FALSE; 1166 MP_INT gcd; 1167 mpz_init(&gcd); 1168 mpz_gcd(&gcd,&x->z,&x->n); 1169 x->s=1; 1170 if (mpz_cmp_si(&gcd,(long)1)!=0) 1171 { 1172 MP_INT r; 1173 mpz_init(&r); 1174 MPZ_EXACTDIV(&r,&x->z,&gcd); 1175 mpz_set(&x->z,&r); 1176 MPZ_EXACTDIV(&r,&x->n,&gcd); 1177 mpz_set(&x->n,&r); 1178 mpz_clear(&r); 1179 //divided=TRUE; 1180 if (mpz_cmp_si(&x->n,(long)1)==0) 1181 { 1182 mpz_clear(&x->n); 1183 if (mpz_size1(&x->z)<=MP_SMALL) 1184 { 1185 int ui=(int)mpz_get_si(&x->z); 1186 if ((((ui<<3)>>3)==ui) 1187 && (mpz_cmp_si(&x->z,(long)ui)==0)) 1163 else if (x->s==0) 1164 { 1165 if (mpz_cmp_si(&x->n,(long)1)==0) 1166 { 1167 mpz_clear(&x->n); 1168 if (mpz_size1(&x->z)<=MP_SMALL) 1169 { 1170 int ui=(int)mpz_get_si(&x->z); 1171 if ((((ui<<3)>>3)==ui) 1172 && (mpz_cmp_si(&x->z,(long)ui)==0)) 1173 { 1174 mpz_clear(&x->z); 1175 #if defined(LDEBUG) 1176 x->debug=654324; 1177 #endif 1178 omFreeBin((ADDRESS)x, rnumber_bin); 1179 x=INT_TO_SR(ui); 1180 return; 1181 } 1182 } 1183 x->s=3; 1184 } 1185 else 1186 { 1187 MP_INT gcd; 1188 mpz_init(&gcd); 1189 mpz_gcd(&gcd,&x->z,&x->n); 1190 x->s=1; 1191 if (mpz_cmp_si(&gcd,(long)1)!=0) 1192 { 1193 MP_INT r; 1194 mpz_init(&r); 1195 MPZ_EXACTDIV(&r,&x->z,&gcd); 1196 mpz_set(&x->z,&r); 1197 MPZ_EXACTDIV(&r,&x->n,&gcd); 1198 mpz_set(&x->n,&r); 1199 mpz_clear(&r); 1200 if (mpz_cmp_si(&x->n,(long)1)==0) 1201 { 1202 mpz_clear(&x->n); 1203 if (mpz_size1(&x->z)<=MP_SMALL) 1188 1204 { 1189 mpz_clear(&x->z); 1190 #if defined(LDEBUG) 1191 x->debug=654324; 1192 #endif 1193 omFreeBin((ADDRESS)x, rnumber_bin); 1194 x=INT_TO_SR(ui); 1195 return; 1205 int ui=(int)mpz_get_si(&x->z); 1206 if ((((ui<<3)>>3)==ui) 1207 && (mpz_cmp_si(&x->z,(long)ui)==0)) 1208 { 1209 mpz_clear(&x->z); 1210 #if defined(LDEBUG) 1211 x->debug=654324; 1212 #endif 1213 omFreeBin((ADDRESS)x, rnumber_bin); 1214 x=INT_TO_SR(ui); 1215 return; 1216 } 1196 1217 } 1197 } 1198 x->s=3; 1199 } 1200 } 1201 mpz_clear(&gcd); 1202 #if 0 1203 else if (divided) 1204 { 1205 #define mpz_alloc1(A) ((A)->_mp_alloc) 1206 int l; 1207 if ((mpz_alloc1(&x->n)>>1) >= (l=mpz_size1(&x->n))) 1208 { 1209 _mpz_realloc(&x->n,l /* mpz_size1(&x->n)*/); 1210 } 1211 } 1212 if (divided) 1213 { 1214 int l; 1215 if ((mpz_alloc1(&x->z)>>1) >= (l=mpz_size1(&x->z))) 1216 { 1217 _mpz_realloc(&x->z,l /*mpz_size1(&x->z)*/); 1218 } 1219 } 1220 #endif 1218 x->s=3; 1219 } 1220 } 1221 mpz_clear(&gcd); 1222 } 1221 1223 } 1222 1224 #ifdef LDEBUG
Note: See TracChangeset
for help on using the changeset viewer.