Changeset c12222 in git
- Timestamp:
- May 20, 2010, 12:18:26 PM (14 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- e1fdcd8ea460f8c28c868c05c0d259c7c4ccb596
- Parents:
- 2f8028c574b7c94d009a6d3ad022799721ce8341
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/gnumpfl.cc
r2f8028 rc12222 25 25 static number ngfMapP(number from) 26 26 { 27 if ( from != NULL) 28 return ngfInit(npInt(from,ngfMapRing), currRing); 29 else 30 return NULL; 27 return ngfInit(npInt(from,ngfMapRing), currRing); 31 28 } 32 29 number ngfMapQ(number from) 33 30 { 34 if ( from != NULL ) 35 { 36 gmp_float *res=new gmp_float(numberFieldToFloat(from,QTOF)); 37 return (number)res; 38 } 39 else 40 return NULL; 31 gmp_float *res=new gmp_float(numberFieldToFloat(from,QTOF)); 32 return (number)res; 41 33 } 42 34 union nf … … 51 43 static number ngfMapR(number from) 52 44 { 53 if ( from != NULL ) 54 { 55 gmp_float *res=new gmp_float((double)nf(from).F()); 56 return (number)res; 57 } 58 else 59 return NULL; 45 gmp_float *res=new gmp_float((double)nf(from).F()); 46 return (number)res; 60 47 } 61 48 static number ngfMapC(number from) 62 49 { 63 if ( (from != NULL) || ((gmp_complex*)from)->real().isZero() ) 64 { 65 gmp_float *res=new gmp_float(((gmp_complex*)from)->real()); 66 return (number)res; 67 } 68 else 69 return NULL; 50 gmp_float *res=new gmp_float(((gmp_complex*)from)->real()); 51 return (number)res; 70 52 } 71 53 … … 101 83 number ngfInit (int i, const ring r) 102 84 { 103 gmp_float* n= NULL; 104 if ( i != 0 ) 105 { 106 n= new gmp_float( (double)i ); 107 } 85 gmp_float* n= new gmp_float( (double)i ); 108 86 return (number)n; 109 87 } … … 114 92 int ngfInt(number &i, const ring r) 115 93 { 116 if ( i == NULL ) return 0;117 94 double d=(double)*(gmp_float*)i; 118 95 if (d<0.0) … … 139 116 number ngfCopy(number a) 140 117 { 141 gmp_float* b= NULL; 142 if ( a != NULL ) 143 { 144 b= new gmp_float( *(gmp_float*)a ); 145 } 118 gmp_float* b= new gmp_float( *(gmp_float*)a ); 146 119 return (number)b; 147 120 } … … 149 122 number ngf_Copy(number a, ring r) 150 123 { 151 gmp_float* b= NULL; 152 if ( a != NULL ) 153 { 154 b= new gmp_float( *(gmp_float*)a ); 155 } 124 gmp_float* b= new gmp_float( *(gmp_float*)a ); 156 125 return (number)b; 157 126 } … … 162 131 number ngfNeg (number a) 163 132 { 164 if ( a == NULL ) return NULL;165 133 *(gmp_float*)a= -(*(gmp_float*)a); 166 134 return (number)a; … … 173 141 { 174 142 gmp_float* r= NULL; 175 if ( (a==NULL) ||((gmp_float*)a)->isZero() )143 if (((gmp_float*)a)->isZero() ) 176 144 { 177 145 WerrorS(nDivBy0); … … 189 157 number ngfAdd (number a, number b) 190 158 { 191 gmp_float* r= NULL; 192 if ( a==NULL && b==NULL ) 193 { 194 return NULL; 195 } 196 else if ( a == NULL ) 197 { 198 r= new gmp_float( *(gmp_float*)b ); 199 } 200 else if ( b == NULL ) 201 { 202 r= new gmp_float( *(gmp_float*)a ); 203 } 204 else 205 { 206 r= new gmp_float( (*(gmp_float*)a) + (*(gmp_float*)b) ); 207 } 159 gmp_float* r= new gmp_float( (*(gmp_float*)a) + (*(gmp_float*)b) ); 208 160 return (number)r; 209 161 } … … 214 166 number ngfSub (number a, number b) 215 167 { 216 gmp_float* r= NULL; 217 if ( a==NULL && b==NULL ) 218 { 219 return NULL; 220 } 221 else if ( a == NULL ) 222 { 223 r= new gmp_float( -(*(gmp_float*)b) ); 224 } 225 else if ( b == NULL ) 226 { 227 r= new gmp_float( *(gmp_float*)a ); 228 } 229 else 230 { 231 r= new gmp_float( (*(gmp_float*)a) - (*(gmp_float*)b) ); 232 } 168 gmp_float* r= new gmp_float( (*(gmp_float*)a) - (*(gmp_float*)b) ); 233 169 return (number)r; 234 170 } … … 239 175 number ngfMult (number a, number b) 240 176 { 241 gmp_float* r= NULL; 242 if ( a==NULL || b==NULL ) 243 { 244 return NULL; 245 } 246 else 247 { 248 r= new gmp_float( (*(gmp_float*)a) * (*(gmp_float*)b) ); 249 } 177 gmp_float* r= new gmp_float( (*(gmp_float*)a) * (*(gmp_float*)b) ); 250 178 return (number)r; 251 179 } … … 256 184 number ngfDiv (number a, number b) 257 185 { 258 if ( a==NULL ) 259 { 260 // 0/b = 0 261 return NULL; 262 } 263 else if ( b==NULL || ((gmp_float*)b)->isZero() ) 186 if ( ((gmp_float*)b)->isZero() ) 264 187 { 265 188 // a/0 = error … … 284 207 else if ( ngfIsZero(x) ) // 0^e, e>0 285 208 { 286 gmp_float* n = NULL; 209 *u=ngfInit(0, currRing); 210 return; 211 } 212 else if ( exp == 1 ) 213 { 214 nNew(u); 215 gmp_float* n = new gmp_float(); 216 *n= *(gmp_float*)x; 287 217 *u=(number)n; 288 return;289 }290 else if ( exp == 1 )291 {292 nNew(u);293 if ( x == NULL )294 {295 gmp_float* n = new gmp_float();296 *u=(number)n;297 }298 else299 {300 gmp_float* n = new gmp_float();301 *n= *(gmp_float*)x;302 *u=(number)n;303 }304 218 return; 305 219 } … … 314 228 BOOLEAN ngfIsZero (number a) 315 229 { 316 if ( a == NULL ) return TRUE;317 230 return ( ((gmp_float*)a)->isZero() ); 318 231 } … … 323 236 BOOLEAN ngfGreaterZero (number a) 324 237 { 325 if ( a == NULL ) return TRUE;326 238 return ( (*(gmp_float*)a) >= (gmp_float)0.0 ); 327 239 } … … 332 244 BOOLEAN ngfGreater (number a, number b) 333 245 { 334 if ( a==NULL )335 {336 return (((gmp_float*)b)->sign() < 0);337 }338 if ( b==NULL )339 {340 return (((gmp_float*)a)->sign() > 0);341 }342 246 return ( (*(gmp_float*)a) > (*(gmp_float*)b) ); 343 247 } … … 348 252 BOOLEAN ngfEqual (number a, number b) 349 253 { 350 if ( a == NULL && b == NULL )351 {352 return TRUE;353 }354 else if ( a == NULL || b == NULL )355 {356 return FALSE;357 }358 254 return ( (*(gmp_float*)a) == (*(gmp_float*)b) ); 359 255 } … … 364 260 BOOLEAN ngfIsOne (number a) 365 261 { 366 if ( a == NULL ) return FALSE;367 262 return ((gmp_float*)a)->isOne(); 368 263 } … … 373 268 BOOLEAN ngfIsMOne (number a) 374 269 { 375 if ( a == NULL ) return FALSE;376 270 return ((gmp_float*)a)->isMOne(); 377 271 }
Note: See TracChangeset
for help on using the changeset viewer.