Changeset 8c42949 in git
 Timestamp:
 Jun 23, 1999, 10:26:04 AM (24 years ago)
 Branches:
 (u'jengelhdatetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
 Children:
 6c4df47b1b5423a0f53e3966bbe7a5e8d3465e59
 Parents:
 b812717056c5c464010194aa51d1f90376dfa977
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Singular/gnumpc.cc
rb81271 r8c42949 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: gnumpc.cc,v 1. 1 19990511 15:42:38 SingularExp $ */4 /* $Id: gnumpc.cc,v 1.2 19990623 08:26:04 wenk Exp $ */ 5 5 /* 6 6 * ABSTRACT: computations with GMP complex floatingpoint numbers … … 68 68 number ngcPar(int i) 69 69 { 70 complex* n= newcomplex( (long)0, (long)1 );70 gmp_complex* n= new gmp_complex( (long)0, (long)1 ); 71 71 return (number)n; 72 72 } … … 82 82 number ngcInit (int i) 83 83 { 84 complex* n= NULL;84 gmp_complex* n= NULL; 85 85 if ( i != 0 ) 86 86 { 87 n= new complex( (long)i, (long)0 );87 n= new gmp_complex( (long)i, (long)0 ); 88 88 } 89 89 return (number)n; … … 96 96 { 97 97 if ( i == NULL ) return 0; 98 return (int)(( complex*)i)>real();98 return (int)((gmp_complex*)i)>real(); 99 99 } 100 100 … … 109 109 { 110 110 if ( *a != NULL ) { 111 delete *( complex**)a;111 delete *(gmp_complex**)a; 112 112 *a=NULL; 113 113 } … … 119 119 number ngcCopy(number a) 120 120 { 121 complex* b= NULL;121 gmp_complex* b= NULL; 122 122 if ( a != NULL ) 123 123 { 124 b= new complex( *(complex*)a );124 b= new gmp_complex( *(gmp_complex*)a ); 125 125 } 126 126 return (number)b; … … 143 143 number ngcInvers(number a) 144 144 { 145 complex* r= NULL;146 if ( (a==NULL) /* (( complex*)a)>isZero()*/ )145 gmp_complex* r= NULL; 146 if ( (a==NULL) /* ((gmp_complex*)a)>isZero()*/ ) 147 147 { 148 148 WerrorS("div. 1/0"); … … 150 150 else 151 151 { 152 r= new complex( (complex)1 / (*(complex*)a) );152 r= new gmp_complex( (gmp_complex)1 / (*(gmp_complex*)a) ); 153 153 } 154 154 return (number)r; … … 160 160 number ngcAdd (number a, number b) 161 161 { 162 complex* r= NULL;162 gmp_complex* r= NULL; 163 163 if ( a==NULL && b==NULL ) 164 164 { … … 167 167 else if ( a == NULL ) 168 168 { 169 r= new complex( *(complex*)b );169 r= new gmp_complex( *(gmp_complex*)b ); 170 170 } 171 171 else if ( b == NULL ) 172 172 { 173 r= new complex( *(complex*)a );174 } 175 else 176 { 177 r= new complex( (*(complex*)a) + (*(complex*)b) );173 r= new gmp_complex( *(gmp_complex*)a ); 174 } 175 else 176 { 177 r= new gmp_complex( (*(gmp_complex*)a) + (*(gmp_complex*)b) ); 178 178 } 179 179 return (number)r; … … 185 185 number ngcSub (number a, number b) 186 186 { 187 complex* r= NULL;187 gmp_complex* r= NULL; 188 188 if ( a==NULL && b==NULL ) 189 189 { … … 192 192 else if ( a == NULL ) 193 193 { 194 r= new complex( (*(complex*)b) );195 r= ( complex *)ngcNeg((number)r);194 r= new gmp_complex( (*(gmp_complex*)b) ); 195 r= (gmp_complex *)ngcNeg((number)r); 196 196 } 197 197 else if ( b == NULL ) 198 198 { 199 r= new complex( *(complex*)a );200 } 201 else 202 { 203 r= new complex( (*(complex*)a)  (*(complex*)b) );199 r= new gmp_complex( *(gmp_complex*)a ); 200 } 201 else 202 { 203 r= new gmp_complex( (*(gmp_complex*)a)  (*(gmp_complex*)b) ); 204 204 } 205 205 return (number)r; … … 211 211 number ngcMult (number a, number b) 212 212 { 213 complex* r= NULL;213 gmp_complex* r= NULL; 214 214 if ( a==NULL  b==NULL ) 215 215 { … … 218 218 else 219 219 { 220 r= new complex( (*(complex*)a) * (*(complex*)b) );220 r= new gmp_complex( (*(gmp_complex*)a) * (*(gmp_complex*)b) ); 221 221 } 222 222 return (number)r; … … 239 239 return NULL; 240 240 } 241 complex* r= new complex( (*(complex*)a) / (*(complex*)b) );241 gmp_complex* r= new gmp_complex( (*(gmp_complex*)a) / (*(gmp_complex*)b) ); 242 242 return (number)r; 243 243 } … … 250 250 if ( exp == 0 ) 251 251 { 252 *( complex*)u=1.0;252 *(gmp_complex*)u= (gmp_complex)1.0; 253 253 return; 254 254 } … … 257 257 if ( x == NULL ) 258 258 { 259 *( complex*)u=0.0;259 *(gmp_complex*)u= (gmp_complex)0.0; 260 260 } 261 261 else 262 262 { 263 *( complex*)u= *(complex*)x;263 *(gmp_complex*)u= *(gmp_complex*)x; 264 264 } 265 265 return; 266 266 } 267 267 ngcPower(x,exp1,u); 268 *( complex*)u*= *(complex*)x;268 *(gmp_complex*)u*= *(gmp_complex*)x; 269 269 } 270 270 … … 272 272 { 273 273 if ( a == NULL ) return TRUE; 274 return ( (( complex*)a)>real().isZero() && ((complex*)a)>imag().isZero());274 return ( ((gmp_complex*)a)>real().isZero() && ((gmp_complex*)a)>imag().isZero()); 275 275 } 276 276 … … 290 290 if ( a==NULL ) 291 291 { 292 return ((( complex*)b)>real().sign() < 0);292 return (((gmp_complex*)b)>real().sign() < 0); 293 293 } 294 294 if ( b==NULL ) 295 295 { 296 return ((( complex*)a)>real().sign() < 0);296 return (((gmp_complex*)a)>real().sign() < 0); 297 297 } 298 298 return FALSE; … … 312 312 return FALSE; 313 313 } 314 return ( (*( complex*)a) == (*(complex*)b) );314 return ( (*(gmp_complex*)a) == (*(gmp_complex*)b) ); 315 315 } 316 316 … … 321 321 { 322 322 if ( a == NULL ) return FALSE; 323 return ((( complex*)a)>real().isOne() && ((complex*)a)>imag().isZero());323 return (((gmp_complex*)a)>real().isOne() && ((gmp_complex*)a)>imag().isZero()); 324 324 } 325 325 … … 330 330 { 331 331 if ( a == NULL ) return FALSE; 332 return ((( complex*)a)>real().isMOne() && ((complex*)a)>imag().isZero());332 return (((gmp_complex*)a)>real().isMOne() && ((gmp_complex*)a)>imag().isZero()); 333 333 } 334 334 … … 343 343 gmp_float *re=NULL; 344 344 s=ngfRead(s,(number *)&re); 345 complex *aa=newcomplex(*re);345 gmp_complex *aa=new gmp_complex(*re); 346 346 *a=(number)aa; 347 347 delete re; … … 350 350 { 351 351 s+=strlen(currRing>parameter[0]); 352 complex *aa=newcomplex((long)0,(long)1);352 gmp_complex *aa=new gmp_complex((long)0,(long)1); 353 353 *a=(number)aa; 354 354 } … … 366 366 { 367 367 char *out; 368 out= complexToStr(*( complex*)a,gmp_output_digits);368 out= complexToStr(*(gmp_complex*)a,gmp_output_digits); 369 369 StringAppend(out); 370 Free((ADDRESS)out, (strlen(out)+1)* sizeof(char) ); 370 // Free((ADDRESS)out, (strlen(out)+1)* sizeof(char) ); 371 FreeL( (ADDRESS)out ); 371 372 } 372 373 }
Note: See TracChangeset
for help on using the changeset viewer.