Changeset e77676 in git for libpolys/coeffs/modulop.cc
- Timestamp:
- Jan 6, 2012, 9:43:08 PM (12 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 4b38e3cc9992129dd4ef044c1d2cc7e55f93b134
- Parents:
- 40e88db63c509564c2b00b7142b39ef6b846f72e
- git-author:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-01-06 21:43:08+01:00
- git-committer:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-01-06 21:59:37+01:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/modulop.cc
r40e88db re77676 57 57 58 58 int h = (int)((long) k); 59 return ((int)h !=0) && (h <= (r-> npPrimeM>>1));60 } 61 62 //unsigned long npMultMod(unsigned long a, unsigned long b )59 return ((int)h !=0) && (h <= (r->ch>>1)); 60 } 61 62 //unsigned long npMultMod(unsigned long a, unsigned long b, int npPrimeM) 63 63 //{ 64 64 // unsigned long c = a*b; 65 65 // c = c % npPrimeM; 66 // assume(c == (unsigned long) npMultM((number) a, (number) b ));66 // assume(c == (unsigned long) npMultM((number) a, (number) b, npPrimeM)); 67 67 // return c; 68 68 //} … … 167 167 168 168 #ifdef USE_NTL_XGCD 169 XGCD(d, s, t, a, R-> npPrimeM);169 XGCD(d, s, t, a, R->ch); 170 170 assume (d == 1); 171 171 #else … … 174 174 assume(a>0); 175 175 u1=1; u2=0; 176 u = a; v = R-> npPrimeM;176 u = a; v = R->ch; 177 177 178 178 while (v != 0) … … 191 191 #endif 192 192 if (s < 0) 193 return s + R-> npPrimeM;193 return s + R->ch; 194 194 else 195 195 return s; … … 222 222 223 223 //#ifdef NV_OPS 224 // if ( npPrimeM>NV_MAX_PRIME)224 // if (r->ch>NV_MAX_PRIME) 225 225 // return nvDiv(a,b); 226 226 //#endif … … 339 339 ii *= 10; 340 340 ii += *s++ - '0'; 341 if (ii >= (MAX_INT_VAL / 10)) ii = ii % r-> npPrimeM;341 if (ii >= (MAX_INT_VAL / 10)) ii = ii % r->ch; 342 342 } 343 343 while (((*s) >= '0') && ((*s) <= '9')); 344 if (ii >= r-> npPrimeM) ii = ii % r->npPrimeM;344 if (ii >= r->ch) ii = ii % r->ch; 345 345 *i=(int)ii; 346 346 } … … 368 368 { 369 369 #ifdef NV_OPS 370 if (r-> npPrimeM>NV_MAX_PRIME)370 if (r->ch>NV_MAX_PRIME) 371 371 *a = nvDiv((number)z,(number)n,r); 372 372 else … … 387 387 #ifdef HAVE_DIV_MOD 388 388 if (r->npInvTable!=NULL) 389 omFreeSize( (void *)r->npInvTable, r-> npPrimeM*sizeof(unsigned short) );389 omFreeSize( (void *)r->npInvTable, r->ch*sizeof(unsigned short) ); 390 390 r->npInvTable=NULL; 391 391 #else 392 392 if (r->npExpTable!=NULL) 393 393 { 394 omFreeSize( (void *)r->npExpTable, r-> npPrimeM*sizeof(unsigned short) );395 omFreeSize( (void *)r->npLogTable, r-> npPrimeM*sizeof(unsigned short) );394 omFreeSize( (void *)r->npExpTable, r->ch*sizeof(unsigned short) ); 395 omFreeSize( (void *)r->npLogTable, r->ch*sizeof(unsigned short) ); 396 396 r->npExpTable=NULL; r->npLogTable=NULL; 397 397 } … … 407 407 CanonicalForm npConvSingNFactoryN( number n, BOOLEAN setChar, const coeffs r ) 408 408 { 409 if (setChar) setCharacteristic( r-> npPrimeM);409 if (setChar) setCharacteristic( r->ch ); 410 410 CanonicalForm term(npInt( n,r )); 411 411 return term; … … 436 436 int i, w; 437 437 438 r-> npPrimeM= c;439 r->npPminus1M = c /*r-> npPrimeM*/ - 1;438 r->ch = c; 439 r->npPminus1M = c /*r->ch*/ - 1; 440 440 441 441 //r->cfInitChar=npInitChar; … … 514 514 // the tables 515 515 #ifdef NV_OPS 516 if (r-> npPrimeM<=NV_MAX_PRIME)516 if (r->ch <=NV_MAX_PRIME) 517 517 #endif 518 518 { 519 519 #if !defined(HAVE_DIV_MOD) || !defined(HAVE_MULT_MOD) 520 r->npExpTable=(unsigned short *)omAlloc( r-> npPrimeM*sizeof(unsigned short) );521 r->npLogTable=(unsigned short *)omAlloc( r-> npPrimeM*sizeof(unsigned short) );520 r->npExpTable=(unsigned short *)omAlloc( r->ch*sizeof(unsigned short) ); 521 r->npLogTable=(unsigned short *)omAlloc( r->ch*sizeof(unsigned short) ); 522 522 r->npExpTable[0] = 1; 523 523 r->npLogTable[0] = 0; 524 if (r-> npPrimeM> 2)524 if (r->ch > 2) 525 525 { 526 526 w = 1; … … 534 534 i++; 535 535 r->npExpTable[i] =(int)(((long)w * (long)r->npExpTable[i-1]) 536 % r-> npPrimeM);536 % r->ch); 537 537 r->npLogTable[r->npExpTable[i]] = i; 538 if (/*(i == npPrimeM- 1 ) ||*/ (r->npExpTable[i] == 1))538 if (/*(i == r->ch - 1 ) ||*/ (r->npExpTable[i] == 1)) 539 539 break; 540 540 } 541 if (i == r-> npPrimeM- 1)541 if (i == r->ch - 1) 542 542 break; 543 543 } … … 550 550 #endif 551 551 #ifdef HAVE_DIV_MOD 552 r->npInvTable=(unsigned short*)omAlloc0( r-> npPrimeM*sizeof(unsigned short) );552 r->npInvTable=(unsigned short*)omAlloc0( r->ch*sizeof(unsigned short) ); 553 553 #endif 554 554 } … … 559 559 BOOLEAN npDBTest (number a, const char *f, const int l, const coeffs r) 560 560 { 561 if (((long)a<0) || ((long)a>r-> npPrimeM))561 if (((long)a<0) || ((long)a>r->ch)) 562 562 { 563 563 Print("wrong mod p number %ld at %s,%d\n",(long)a,f,l); … … 571 571 { 572 572 long i = (long)from; 573 if (i>src-> npPrimeM/2)574 { 575 i-=src-> npPrimeM;576 while (i < 0) i+=dst_r-> npPrimeM;577 } 578 i%=dst_r-> npPrimeM;573 if (i>src->ch/2) 574 { 575 i-=src->ch; 576 while (i < 0) i+=dst_r->ch; 577 } 578 i%=dst_r->ch; 579 579 return (number)i; 580 580 } … … 604 604 } 605 605 606 if(dst_r-> npPrimeM>2)606 if(dst_r->ch>2) 607 607 e=(*f)[0]._mp_exp-size; 608 608 else … … 629 629 ndest->_mp_alloc = ndest->_mp_size = bl; 630 630 res->s = 0; 631 in=mpz_fdiv_ui(ndest,dst_r-> npPrimeM);631 in=mpz_fdiv_ui(ndest,dst_r->ch); 632 632 mpz_clear(ndest); 633 633 } … … 644 644 dest->_mp_d = dd; 645 645 dest->_mp_alloc = al; 646 iz=mpz_fdiv_ui(dest,dst_r-> npPrimeM);646 iz=mpz_fdiv_ui(dest,dst_r->ch); 647 647 mpz_clear(dest); 648 648 if(res->s==0) … … 661 661 mpz_init(erg); 662 662 663 mpz_mod_ui(erg, (int_number) from, dst-> npPrimeM);663 mpz_mod_ui(erg, (int_number) from, dst->ch); 664 664 number r = (number) mpz_get_si(erg); 665 665 … … 674 674 number npMapMachineInt(number from, const coeffs /*src*/,const coeffs dst) 675 675 { 676 long i = (long) (((unsigned long) from) % dst-> npPrimeM);676 long i = (long) (((unsigned long) from) % dst->ch); 677 677 return (number) i; 678 678 } … … 682 682 number npMapCanonicalForm (number a, const coeffs /*src*/, const coeffs dst) 683 683 { 684 setCharacteristic (dst -> npPrimeM);684 setCharacteristic (dst ->ch); 685 685 CanonicalForm f= CanonicalForm ((InternalCF*)(a)); 686 686 return (number) (f.intval()); … … 756 756 u1=1; v1=0; 757 757 u2=0; v2=1; 758 u = a; v = R-> npPrimeM;758 u = a; v = R->ch; 759 759 760 760 while (v != 0) … … 775 775 //t = v1; 776 776 if (s < 0) 777 return s + R-> npPrimeM;777 return s + R->ch; 778 778 else 779 779 return s; … … 831 831 void npCoeffWrite (const coeffs r, BOOLEAN /*details*/) 832 832 { 833 Print("// characteristic : %d\n",r-> npPrimeM);834 } 835 833 Print("// characteristic : %d\n",r->ch); 834 } 835
Note: See TracChangeset
for help on using the changeset viewer.