Changeset a507140 in git for libpolys/coeffs/rmodulon.cc
- Timestamp:
- May 10, 2020, 5:39:11 PM (4 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- f050a38f7d4a93811fa78a1a7cebd7b3a35fc044fe09a23b169ca576a8128e614973bc79bcfec5d7
- Parents:
- 6dd33c01a9c354dd3b89fe045bffa9b635e23954
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/rmodulon.cc
r6dd33c ra507140 32 32 33 33 EXTERN_VAR omBin gmp_nrz_bin; 34 35 static void nrnCoeffWrite (const coeffs r, BOOLEAN /*details*/)36 {37 size_t l = (size_t)mpz_sizeinbase(r->modBase, 10) + 2;38 char* s = (char*) omAlloc(l);39 s= mpz_get_str (s, 10, r->modBase);40 41 #ifdef TEST_ZN_AS_ZP42 if (l<10)43 {44 if (nCoeff_is_Zn(r)) Print("ZZ/%s", s);45 else if (nCoeff_is_Ring_PtoM(r)) Print("ZZ/(%s^%lu)", s, r->modExponent);46 }47 else48 #endif49 {50 if (nCoeff_is_Zn(r)) Print("ZZ/bigint(%s)", s);51 else if (nCoeff_is_Ring_PtoM(r)) Print("ZZ/(bigint(%s)^%lu)", s, r->modExponent);52 }53 54 omFreeSize((ADDRESS)s, l);55 }56 34 57 35 coeffs nrnInitCfByName(char *s,n_coeffType n) … … 89 67 size_t l = (size_t)mpz_sizeinbase(r->modBase, 10) + 2; 90 68 char* s = (char*) omAlloc(l); 91 l+=2 2;69 l+=24; 92 70 nrnCoeffName_buff=(char*)omAlloc(l); 93 71 s= mpz_get_str (s, 10, r->modBase); 94 72 int ll; 95 73 if (nCoeff_is_Zn(r)) 96 ll=snprintf(nrnCoeffName_buff,l,"ZZ/bigint(%s)",s); 74 { 75 if (strlen(s)<10) 76 ll=snprintf(nrnCoeffName_buff,l,"ZZ/(%s)",s); 77 else 78 ll=snprintf(nrnCoeffName_buff,l,"ZZ/bigint(%s)",s); 79 } 97 80 else if (nCoeff_is_Ring_PtoM(r)) 98 ll=snprintf(nrnCoeffName_buff,l,"ZZ/ bigint(%s)^%lu",s,r->modExponent);81 ll=snprintf(nrnCoeffName_buff,l,"ZZ/(bigint(%s)^%lu)",s,r->modExponent); 99 82 assume(ll<(int)l); // otherwise nrnCoeffName_buff too small 100 83 omFreeSize((ADDRESS)s, l-22); … … 108 91 return (n==r->type) && (r->modExponent==info->exp) 109 92 && (mpz_cmp(r->modBase,info->base)==0); 110 }111 112 static char* nrnCoeffString(const coeffs r)113 {114 size_t l = (size_t)mpz_sizeinbase(r->modBase, 10) +2;115 char* b = (char*) omAlloc(l);116 b= mpz_get_str (b, 10, r->modBase);117 char* s = (char*) omAlloc(15+l);118 if (nCoeff_is_Zn(r)) sprintf(s,"ZZ/%s",b);119 else /*if (nCoeff_is_Ring_PtoM(r))*/ sprintf(s,"ZZ/(bigint(%s)^%lu)",b,r->modExponent);120 omFreeSize(b,l);121 return s;122 93 } 123 94 … … 1014 985 r->rep=n_rep_gmp; 1015 986 1016 1017 r->cfCoeffString = nrnCoeffString;1018 1019 987 r->cfInit = nrnInit; 1020 988 r->cfDelete = nrnDelete; … … 1052 1020 r->cfQuotRem = nrnQuotRem; 1053 1021 r->cfCoeffName = nrnCoeffName; 1054 r->cfCoeffWrite = nrnCoeffWrite;1055 1022 r->nCoeffIsEqual = nrnCoeffIsEqual; 1056 1023 r->cfKillChar = nrnKillChar;
Note: See TracChangeset
for help on using the changeset viewer.