Changeset 045efb in git
- Timestamp:
- Aug 10, 2011, 7:43:14 PM (12 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 5ff1d31f3d80f972b5abf4d4435d01cb9b033ffb
- Parents:
- b1ca9992c1a4e67c4f6161015c9bb3efd24c96f4
- git-author:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2011-08-10 19:43:14+02:00
- git-committer:
- Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 13:19:14+01:00
- Location:
- libpolys/coeffs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/coeffs.h
rb1ca999 r045efb 116 116 // general stuff 117 117 numberfunc cfMult, cfSub ,cfAdd ,cfDiv, cfIntDiv, cfIntMod, cfExactDiv; 118 118 119 /// init with an integer 119 120 number (*cfInit)(int i,const coeffs r); 121 122 /// init with a GMP integer 123 number (*cfInitMPZ)(mpz_t i, const coeffs r); 124 120 125 /// how complicated, (0) => 0, or positive 121 126 int (*cfSize)(number n, const coeffs r); 122 /// convertion, 0 if impossible 127 128 /// convertion to int, 0 if impossible 123 129 int (*cfInt)(number &n, const coeffs r); 124 130 131 /// Converts a non-negative number n into a GMP number, 0 if impossible 132 void (*cfMPZ)(mpz_t result, number &n, const coeffs r); 133 125 134 #ifdef HAVE_RINGS 126 135 int (*cfDivComp)(number a,number b,const coeffs r); … … 374 383 { assume(r != NULL); assume(r->cfInit!=NULL); return r->cfInit(i,r); } 375 384 385 /// conversion of a GMP integer to number 386 static inline number n_Init(mpz_t n, const coeffs r) 387 { assume(r != NULL); assume(r->cfInitMPZ != NULL); return r->cfInitMPZ(n,r); } 388 376 389 /// conversion of n to an int; 0 if not possible 377 390 /// in Z/pZ: the representing int lying in (-p/2 .. p/2] 378 391 static inline int n_Int(number &n, const coeffs r) 379 392 { assume(r != NULL); assume(r->cfInt!=NULL); return r->cfInt(n,r); } 393 394 /// conversion of n to a GMP integer; 0 if not possible 395 static inline void n_MPZ(mpz_t result, number &n, const coeffs r) 396 { assume(r != NULL); assume(r->cfMPZ!=NULL); r->cfMPZ(result, n, r); } 397 380 398 381 399 /// in-place negation of n -
libpolys/coeffs/longrat.cc
rb1ca999 r045efb 542 542 } 543 543 544 void nlMPZ(mpz_t m, number &n, const coeffs r) 545 { 546 assume( getCoeffType(r) == ID ); 547 548 nlTest(n, r); 549 nlNormalize(n, r); 550 if (SR_HDL(n) & SR_INT) mpz_init_set_si(m, SR_TO_INT(n)); /* n fits in an int */ 551 else mpz_init_set(m, (mpz_ptr)n->z); 552 } 553 554 544 555 /*2 545 556 * convert number to int … … 2091 2102 } 2092 2103 2093 2094 2104 LINLINE number nlInit (int i, const coeffs r) 2095 2105 { … … 2102 2112 } 2103 2113 2114 2115 number nlInitMPZ(mpz_t m, const coeffs r) 2116 { 2117 number z = ALLOC_RNUMBER(); 2118 mpz_init_set(z->z, m); 2119 mpz_init_set_ui(z->n, 1); 2120 z->s = 3; 2121 return z; 2122 } 2104 2123 2105 2124 /*2 … … 2596 2615 r->cfExactDiv= nlExactDiv; 2597 2616 r->cfInit = nlInit; 2617 r->cfInitMPZ = nlInitMPZ; 2598 2618 r->cfSize = nlSize; 2599 2619 r->cfInt = nlInt; 2620 r->cfMPZ = nlMPZ; 2621 2600 2622 r->cfChineseRemainder=nlChineseRemainder; 2601 2623 r->cfFarey=nlFarey; -
libpolys/coeffs/longrat.h
rb1ca999 r045efb 90 90 number nlChineseRemainder(number *x, number *q,int rl, const coeffs C); 91 91 number nlFarey(number nN, number nP, const coeffs CF); 92 92 93 #ifdef LDEBUG 93 94 BOOLEAN nlDBTest(number a, const char *f, const int l); -
libpolys/coeffs/numbers.cc
rb1ca999 r045efb 144 144 Werror("no conversion from bigint to this field"); 145 145 return NULL; 146 } 147 148 /**< [in, out] a bigint number >= 0 */ 149 /**< [out] the GMP equivalent */ 150 /// Converts a non-negative bigint number into a GMP number. 151 void ndMPZ(mpz_t result, number &n, const coeffs r) 152 { 153 mpz_init_set_si( result, n_Int(n, r) ); 154 } 155 156 number ndInitMPZ(mpz_t m, const coeffs r) 157 { 158 return n_Init( mpz_get_si(m), r); 146 159 } 147 160 … … 215 228 n->cfLcm = ndGcd; /* tricky, isn't it ?*/ 216 229 n->cfInit_bigint = ndInit_bigint; 230 n->cfInitMPZ = ndInitMPZ; 231 n->cfMPZ = ndMPZ; 232 217 233 //n->cfKillChar = ndKillChar; /* dummy */ 218 234 // temp. removed to catch all the coeffs which miss to implement this! … … 266 282 assume(n->cfExactDiv!=NULL); 267 283 assume(n->cfInit!=NULL); 284 assume(n->cfInitMPZ!=NULL); 268 285 assume(n->cfSize!=NULL); 269 286 assume(n->cfInt!=NULL); 287 assume(n->cfMPZ!=NULL); 270 288 //assume(n->n->cfDivComp!=NULL); 271 289 //assume(n->cfIsUnit!=NULL); … … 295 313 assume(n->cfName!=NULL); 296 314 assume(n->cfInpMult!=NULL); 297 //assume(n->cfInit_bigint!=NULL);315 // assume(n->cfInit_bigint!=NULL); 298 316 assume(n->cfCoeffWrite != NULL); 299 317 #ifdef LDEBUG
Note: See TracChangeset
for help on using the changeset viewer.