Changeset 58aa457 in git
- Timestamp:
- May 10, 2010, 3:56:38 PM (14 years ago)
- Branches:
- (u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
- Children:
- f945d2b0105e7e765829a443b2044990186c9f2e
- Parents:
- e3c02d2b15d64dbff4ac5fe4ef2227cbaeb5a216
- git-author:
- Andreas Steenpass <steenpass@mathematik.uni-kl.de>2010-05-10 15:56:38+02:00
- git-committer:
- Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 11:52:54+01:00
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
re3c02d2 r58aa457 5 5 *.og 6 6 *.exe 7 *.swp 7 8 depend 8 9 tags … … 11 12 config.status 12 13 config.log 14 tags 13 15 stamp-h 14 16 ix86-Linux/* -
coeffs/gnumpfl.cc
re3c02d2 r58aa457 9 9 */ 10 10 11 #include <kernel/mod2.h>12 #include <kernel/structs.h>13 #include < kernel/febase.h>14 #include <omalloc /omalloc.h>15 #include <kernel/numbers.h>16 #include <kernel/modulop.h>17 #include <kernel/longrat.h>18 19 #include < kernel/gnumpfl.h>20 #include < kernel/mpr_complex.h>11 #include "config.h" 12 #include "coeffs.h" 13 #include <output.h> 14 #include <omalloc.h> 15 #include "numbers.h" 16 #include "modulop.h" 17 #include "longrat.h" 18 19 #include <gnumpfl.h> 20 #include <mpr_complex.h> 21 21 22 22 extern size_t gmp_output_digits; 23 ring ngfMapRing; // to be used also in gnumpc.cc24 25 static number ngfMapP(number from )26 { 27 return ngfInit(npInt(from, ngfMapRing), currRing);28 } 29 number ngfMapQ(number from )23 //ring ngfMapRing; // to be used also in gnumpc.cc 24 25 static number ngfMapP(number from, const coeffs src, const coeffs dst) 26 { 27 return ngfInit(npInt(from,src), dst); 28 } 29 number ngfMapQ(number from, const coeffs src, const coeffs dst) 30 30 { 31 31 gmp_float *res=new gmp_float(numberFieldToFloat(from,QTOF)); … … 41 41 number N() const {return _n;} 42 42 }; 43 static number ngfMapR(number from )43 static number ngfMapR(number from, const coeffs src, const coeffs dst) 44 44 { 45 45 gmp_float *res=new gmp_float((double)nf(from).F()); 46 46 return (number)res; 47 47 } 48 static number ngfMapC(number from )48 static number ngfMapC(number from, const coeffs src, const coeffs dst) 49 49 { 50 50 gmp_float *res=new gmp_float(((gmp_complex*)from)->real()); … … 81 81 * n := i 82 82 */ 83 number ngfInit (int i, const ringr)83 number ngfInit (int i, const coeffs r) 84 84 { 85 85 gmp_float* n= new gmp_float( (double)i ); … … 90 90 * convert number to int 91 91 */ 92 int ngfInt(number &i, const ringr)92 int ngfInt(number &i, const coeffs r) 93 93 { 94 94 double d=(double)*(gmp_float*)i; … … 99 99 } 100 100 101 int ngfSize(number n )102 { 103 int i = ngfInt(n, currRing);101 int ngfSize(number n, const coeffs r) 102 { 103 int i = ngfInt(n, r); 104 104 /* basically return the largest integer in n; 105 105 only if this happens to be zero although n != 0, … … 113 113 * delete a 114 114 */ 115 void ngfDelete (number * a, const ringr)115 void ngfDelete (number * a, const coeffs r) 116 116 { 117 117 if ( *a != NULL ) … … 125 125 * copy a to b 126 126 */ 127 number ngfCopy(number a )127 number ngfCopy(number a, const coeffs r) 128 128 { 129 129 gmp_float* b= new gmp_float( *(gmp_float*)a ); … … 131 131 } 132 132 133 number ngf_Copy(number a, ring r)134 {135 gmp_float* b= new gmp_float( *(gmp_float*)a );136 return (number)b;137 }138 139 133 /*2 140 134 * za:= - za 141 135 */ 142 number ngfNeg (number a )136 number ngfNeg (number a, const coeffs r) 143 137 { 144 138 *(gmp_float*)a= -(*(gmp_float*)a); … … 149 143 * 1/a 150 144 */ 151 number ngfInvers(number a )145 number ngfInvers(number a, const coeffs R) 152 146 { 153 147 gmp_float* r= NULL; … … 158 152 else 159 153 { 160 r= new gmp_float( (gmp_float)1/ (*(gmp_float*)a) );161 } 162 return (number) r;154 f= new gmp_float( gmp_float(1) / (*(gmp_float*)a) ); 155 } 156 return (number)f; 163 157 } 164 158 … … 166 160 * u:= a + b 167 161 */ 168 number ngfAdd (number a, number b )162 number ngfAdd (number a, number b, const coeffs R) 169 163 { 170 164 gmp_float* r= new gmp_float( (*(gmp_float*)a) + (*(gmp_float*)b) ); … … 175 169 * u:= a - b 176 170 */ 177 number ngfSub (number a, number b )171 number ngfSub (number a, number b, const coeffs R) 178 172 { 179 173 gmp_float* r= new gmp_float( (*(gmp_float*)a) - (*(gmp_float*)b) ); … … 184 178 * u := a * b 185 179 */ 186 number ngfMult (number a, number b )180 number ngfMult (number a, number b, const coeffs R) 187 181 { 188 182 gmp_float* r= new gmp_float( (*(gmp_float*)a) * (*(gmp_float*)b) ); … … 193 187 * u := a / b 194 188 */ 195 number ngfDiv (number a, number b )189 number ngfDiv (number a, number b, const coeffs r) 196 190 { 197 191 if ( ((gmp_float*)b)->isZero() ) … … 201 195 return NULL; 202 196 } 203 gmp_float* r= new gmp_float( (*(gmp_float*)a) / (*(gmp_float*)b) );204 return (number) r;197 gmp_float* f= new gmp_float( (*(gmp_float*)a) / (*(gmp_float*)b) ); 198 return (number)f; 205 199 } 206 200 … … 208 202 * u:= x ^ exp 209 203 */ 210 void ngfPower ( number x, int exp, number * u)204 number ngfPower (number x, int exp, const coeffs r) 211 205 { 212 206 if ( exp == 0 ) … … 218 212 else if ( ngfIsZero(x) ) // 0^e, e>0 219 213 { 220 *u=ngfInit(0, currRing);214 *u=ngfInit(0, r); 221 215 return; 222 216 } 223 217 else if ( exp == 1 ) 224 218 { 225 n New(u);219 n_New(u, r); 226 220 gmp_float* n = new gmp_float(); 227 221 *n= *(gmp_float*)x; … … 229 223 return; 230 224 } 231 ngfPower(x,exp-1,u); 232 233 gmp_float *n=new gmp_float(); 234 *n=*(gmp_float*)x; 235 *(gmp_float*)(*u) *= *(gmp_float*)n; 236 delete (gmp_float*)n; 237 } 238 239 BOOLEAN ngfIsZero (number a) 225 f = new gmp_float(); 226 f = (*(gmp_float*)x)^exp; 227 return (number)f; 228 } 229 230 /* kept for compatibility reasons, to be deleted */ 231 void ngfPower ( number x, int exp, number * u, const coeffs r ) 232 { 233 *u = ngfPower(x, exp, r); 234 } 235 236 BOOLEAN ngfIsZero (number a, const coeffs r) 240 237 { 241 238 return ( ((gmp_float*)a)->isZero() ); … … 243 240 244 241 /*2 245 * za > =0 ?246 */ 247 BOOLEAN ngfGreaterZero (number a )248 { 249 return ( (*(gmp_float*)a) >= (gmp_float)0.0);242 * za > 0 ? 243 */ 244 BOOLEAN ngfGreaterZero (number a, const coeffs r) 245 { 246 return (((gmp_float*)a)->sign() > 0); 250 247 } 251 248 … … 253 250 * a > b ? 254 251 */ 255 BOOLEAN ngfGreater (number a, number b )252 BOOLEAN ngfGreater (number a, number b, const coeffs r) 256 253 { 257 254 return ( (*(gmp_float*)a) > (*(gmp_float*)b) ); … … 261 258 * a = b ? 262 259 */ 263 BOOLEAN ngfEqual (number a, number b )260 BOOLEAN ngfEqual (number a, number b, const coeffs r) 264 261 { 265 262 return ( (*(gmp_float*)a) == (*(gmp_float*)b) ); … … 269 266 * a == 1 ? 270 267 */ 271 BOOLEAN ngfIsOne (number a )268 BOOLEAN ngfIsOne (number a, const coeffs r) 272 269 { 273 270 return ((gmp_float*)a)->isOne(); … … 277 274 * a == -1 ? 278 275 */ 279 BOOLEAN ngfIsMOne (number a )276 BOOLEAN ngfIsMOne (number a, const coeffs r) 280 277 { 281 278 return ((gmp_float*)a)->isMOne(); 282 }283 284 /*2285 * result =gcd(a,b)286 * dummy, returns 1287 */288 number ngfGcd(number a, number b)289 {290 gmp_float *result= new gmp_float( 1 );291 return (number)result;292 279 } 293 280 … … 318 305 * extracts the number a from s, returns the rest 319 306 */ 320 const char * ngfRead (const char * start, number * a )307 const char * ngfRead (const char * start, number * a, const coeffs r) 321 308 { 322 309 char *s= (char *)start; … … 375 362 * write a floating point number 376 363 */ 377 void ngfWrite (number &a, const ringr)364 void ngfWrite (number &a, const coeffs r) 378 365 { 379 366 char *out; … … 391 378 } 392 379 393 #ifdef LDEBUG394 //BOOLEAN ngfDBTest(number a, const char *f, const int l)395 //{396 // return TRUE;397 //}398 #endif399 400 // local Variables: ***401 // folded-file: t ***402 // compile-command: "make installg" ***403 // End: *** -
coeffs/gnumpfl.h
re3c02d2 r58aa457 30 30 void ngfWrite(number &a, const coeffs r); 31 31 32 #ifdef LDEBUG33 BOOLEAN ngfDBTest(number a, const char *f, const int l);34 #endif35 32 void ngfDelete(number *a, const coeffs r); 36 33 -
coeffs/mpr_complex.h
re3c02d2 r58aa457 104 104 friend gmp_float operator * ( const gmp_float & a, const gmp_float & b ); 105 105 friend gmp_float operator / ( const gmp_float & a, const gmp_float & b ); 106 107 inline gmp_float operator ^ ( const gmp_float & a, const int exp ) 108 { 109 mpf_t b; 110 mpf_init(b); 111 mpf_pow( b, a.t, (unsigned long)exp ); 112 return (gmp_float)b; 113 }; 106 114 107 115 friend bool operator == ( const gmp_float & a, const gmp_float & b );
Note: See TracChangeset
for help on using the changeset viewer.