Changeset bf29a4 in git for Singular/modulop.cc
- Timestamp:
- Dec 21, 2000, 2:22:01 PM (23 years ago)
- Branches:
- (u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
- Children:
- 5dab69d5a393466d9560045523c22692fb9c1323
- Parents:
- bfbc32c19cef318430013cfd78dc6aa9af738067
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/modulop.cc
rbfbc32 rbf29a4 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: modulop.cc,v 1.2 3 2000-12-15 18:49:34 SingularExp $ */4 /* $Id: modulop.cc,v 1.24 2000-12-21 13:22:01 pohl Exp $ */ 5 5 /* 6 6 * ABSTRACT: numbers modulo p (<=32003) … … 15 15 #include "numbers.h" 16 16 #include "longrat.h" 17 #include "mpr_complex.h" 17 18 #include "ring.h" 18 19 #include "modulop.h" … … 289 290 } 290 291 291 292 292 #ifdef LDEBUG 293 293 BOOLEAN npDBTest (number a, char *f, int l) … … 316 316 i%=npPrimeM; 317 317 return (number)i; 318 } 319 320 static number npMapLongR(number from) 321 { 322 gmp_float *ff=(gmp_float*)from; 323 mpf_t *f=ff->_mpfp(); 324 number res; 325 lint *dest,*ndest; 326 int size,i; 327 int e,al,bl,iz,in; 328 mp_ptr qp,dd,nn; 329 330 size = (*f)[0]._mp_size; 331 if (size == 0) 332 return npInit(0); 333 if(size<0) 334 size = -size; 335 336 qp = (*f)[0]._mp_d; 337 while(qp[0]==0) 338 { 339 qp++; 340 size--; 341 } 342 343 if(npPrimeM>2) 344 e=(*f)[0]._mp_exp-size; 345 else 346 e=0; 347 res = (number)omAllocBin(rnumber_bin); 348 #if defined(LDEBUG) 349 res->debug=123456; 350 #endif 351 dest = &(res->z); 352 353 if (e<0) 354 { 355 al = dest->_mp_size = size; 356 if (al<2) al = 2; 357 dd = (mp_ptr)omAlloc(sizeof(mp_limb_t)*al); 358 for (i=0;i<size;i++) dd[i] = qp[i]; 359 bl = 1-e; 360 nn = (mp_ptr)omAlloc(sizeof(mp_limb_t)*bl); 361 nn[bl-1] = 1; 362 for (i=bl-2;i>=0;i--) nn[i] = 0; 363 ndest = &(res->n); 364 ndest->_mp_d = nn; 365 ndest->_mp_alloc = ndest->_mp_size = bl; 366 res->s = 0; 367 in=mpz_mmod_ui(NULL,ndest,npPrimeM); 368 mpz_clear(ndest); 369 } 370 else 371 { 372 al = dest->_mp_size = size+e; 373 if (al<2) al = 2; 374 dd = (mp_ptr)omAlloc(sizeof(mp_limb_t)*al); 375 for (i=0;i<size;i++) dd[i+e] = qp[i]; 376 for (i=0;i<e;i++) dd[i] = 0; 377 res->s = 3; 378 } 379 380 dest->_mp_d = dd; 381 dest->_mp_alloc = al; 382 iz=mpz_mmod_ui(NULL,dest,npPrimeM); 383 mpz_clear(dest); 384 omFreeBin((ADDRESS)res, rnumber_bin); 385 if(res->s==0) 386 iz=(int)npDiv((number)iz,(number)in); 387 return (number)iz; 318 388 } 319 389 … … 336 406 } 337 407 } 408 if (rField_is_long_R(src)) 409 { 410 return npMapLongR; 411 } 338 412 return NULL; /* default */ 339 413 }
Note: See TracChangeset
for help on using the changeset viewer.