Changeset 0486a3 in git
- Timestamp:
- Dec 14, 2012, 4:47:41 PM (10 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a657104b677b4c461d018cbf3204d72d34ad66a9')
- Children:
- 2e85a17b690d4918b676bac33fbbe5a019e58dad
- Parents:
- f489beab9ee2066d042d018e9e5db927bdfe99a4
- Location:
- libpolys/coeffs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/rmodulon.cc
rf489bea r0486a3 25 25 /// Our Type! 26 26 static const n_coeffType ID = n_Zn; 27 static const n_coeffType ID2 = n_Znm; 27 28 28 29 extern omBin gmp_nrz_bin; … … 32 33 long l = (long)mpz_sizeinbase(r->modBase, 10) + 2; 33 34 char* s = (char*) omAlloc(l); 34 if (nCoeff_is_Ring_ModN(r)) Print("// Z/%s\n", s); 35 else if (nCoeff_is_Ring_PtoM(r)) Print("// Z/%s^%lu\n", s, r->modExponent); 35 s= mpz_get_str (s, 10, r->modBase); 36 if (nCoeff_is_Ring_ModN(r)) Print("// coeff. ring is : Z/%s\n", s); 37 else if (nCoeff_is_Ring_PtoM(r)) Print("// coeff. ring is : Z/%s^%lu\n", s, r->modExponent); 36 38 omFreeSize((ADDRESS)s, l); 37 39 } … … 47 49 BOOLEAN nrnInitChar (coeffs r, void* p) 48 50 { 49 assume( getCoeffType(r) == ID ); 50 nrnInitExp((int)(long)(p), r); 51 r->ringtype = 2; 52 51 assume( (getCoeffType(r) == ID) || (getCoeffType (r) == ID2) ); 52 ZnmInfo * info= (ZnmInfo *) p; 53 r->modBase = (int_number) omAlloc(sizeof(mpz_t)); 54 mpz_init_set (r->modBase, info->base); 55 56 nrnInitExp (info->exp, r); 57 58 if (info->exp > 1) 59 r->ringtype= 3; 60 else 61 r->ringtype= 2; 53 62 /* next computation may yield wrong characteristic as r->modNumber 54 63 is a GMP number */ … … 564 573 */ 565 574 566 void nrnSetExp( intm, coeffs r)575 void nrnSetExp(unsigned long m, coeffs r) 567 576 { 568 577 /* clean up former stuff */ 569 if (r->modBase != NULL) mpz_clear(r->modBase);578 //if (r->modBase != NULL) mpz_clear(r->modBase); 570 579 if (r->modNumber != NULL) mpz_clear(r->modNumber); 571 580 581 r->modExponent= m; 572 582 /* this is Z/m = Z/(m^1), hence set modBase = m, modExponent = 1: */ 573 r->modBase = (int_number)omAllocBin(gmp_nrz_bin); 574 mpz_init(r->modBase); 575 mpz_set_ui(r->modBase, (unsigned long)m); 576 r->modExponent = 1; 583 //r->modBase = (int_number)omAllocBin(gmp_nrz_bin); 584 //mpz_init(r->modBase); 585 //mpz_set_ui(r->modBase, (unsigned long)m); 577 586 r->modNumber = (int_number)omAllocBin(gmp_nrz_bin); 578 mpz_init(r->modNumber); 579 mpz_set(r->modNumber, r->modBase); 580 /* mpz_pow_ui(r->modNumber, r->modNumber, r->modExponent); */ 581 } 582 583 /* We expect this ring to be Z/m for some m > 2 which is not a prime. */ 584 void nrnInitExp(int m, coeffs r) 585 { 586 if (m <= 2) WarnS("nrnInitExp failed (m in Z/m too small)"); 587 mpz_init_set (r->modNumber, r->modBase); 588 mpz_pow_ui (r->modNumber, r->modNumber, m); 589 } 590 591 /* We expect this ring to be Z/n^m for some m > 0 and for some n > 2 which is not a prime. */ 592 void nrnInitExp(unsigned long m, coeffs r) 593 { 587 594 nrnSetExp(m, r); 595 assume (r->modNumber != NULL); 596 if (mpz_cmp_ui(r->modNumber,2) <= 0) 597 WarnS("nrnInitExp failed (m in Z/m too small)"); 588 598 } 589 599 -
libpolys/coeffs/rmodulon.h
rf489bea r0486a3 14 14 #define NATNUMBER unsigned long 15 15 #endif 16 17 typedef struct { int_number base; NATNUMBER exp; } ZnmInfo; 16 18 17 19 BOOLEAN nrnInitChar (coeffs r, void*); … … 50 52 BOOLEAN nrnDBTest (number a, const char *f, const int l, const coeffs r); 51 53 #endif 52 void nrnSetExp( intc, const coeffs r);53 void nrnInitExp( intc, const coeffs r);54 void nrnSetExp(unsigned long c, const coeffs r); 55 void nrnInitExp(unsigned long c, const coeffs r); 54 56 55 57 #endif
Note: See TracChangeset
for help on using the changeset viewer.