Changeset 16f8f1 in git
- Timestamp:
- Mar 3, 2011, 2:26:34 PM (12 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- f47f569bdf07891fa2a30df0f1c5315e6fe1f5d1
- Parents:
- fb0a6994525982ae391932afdd4d24384a163fda
- git-author:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2011-03-03 14:26:34+01:00
- git-committer:
- Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:01:04+01:00
- Location:
- libpolys
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/coeffs.h
rfb0a699 r16f8f1 248 248 /// in case of an error return NULL 249 249 coeffs nInitChar(n_coeffType t, void * parameter); 250 250 251 /// undo all initialisations 251 252 void nKillChar(coeffs r); 253 252 254 /// initialisations after each ring change 253 255 static inline void nSetChar(const coeffs r) … … 257 259 } 258 260 259 // nach einer heissen Diskussion260 261 void nNew(number * a); 261 262 #define n_New(n, r) nNew(n) … … 267 268 static inline number n_Copy(number n, const coeffs r) 268 269 { return r->cfCopy(n, r); } 270 269 271 static inline void n_Delete(number* p, const coeffs r) 270 272 { r->cfDelete(p, r); } … … 272 274 static inline BOOLEAN n_Equal(number a, number b, const coeffs r) 273 275 { return r->cfEqual(a, b, r); } 276 274 277 static inline BOOLEAN n_IsZero(number n, const coeffs r) 275 278 { return r->cfIsZero(n,r); } 279 276 280 static inline BOOLEAN n_IsOne(number n, const coeffs r) 277 281 { return r->cfIsOne(n,r); } 282 278 283 static inline BOOLEAN n_IsMOne(number n, const coeffs r) 279 284 { return r->cfIsMOne(n,r); } 285 280 286 static inline BOOLEAN n_GreaterZero(number n, const coeffs r) 281 287 { return r->cfGreaterZero(n,r); } 282 288 // cfGreater? 289 283 290 #ifdef HAVE_RINGS 284 291 static inline BOOLEAN n_IsUnit(number n, const coeffs r) 285 292 { return r->cfIsUnit(n,r); } 293 286 294 static inline number n_GetUnit(number n, const coeffs r) 287 295 { return r->cfGetUnit(n,r); } 296 288 297 static inline BOOLEAN n_DivBy(number a, number b, const coeffs r) 289 298 { return r->cfDivBy(a,b,r); } -
libpolys/coeffs/numbers.cc
rfb0a699 r16f8f1 146 146 //n->cfGetUnit = (nMapFunc)NULL; 147 147 #endif 148 #if 0 /*vertagt*/149 if (nField_is_Extension(r))150 {151 //ntInitChar(c,TRUE,r);152 n->cfDelete = ntDelete;153 n->nNormalize = ntNormalize;154 n->cfInit = ntInit;155 n->nPar = ntPar;156 n->nParDeg = ntParDeg;157 n->n_Int = ntInt;158 n->nAdd = ntAdd;159 n->nSub = ntSub;160 n->nMult = ntMult;161 n->nDiv = ntDiv;162 n->nExactDiv = ntDiv;163 n->nIntDiv = ntIntDiv;164 n->nNeg = ntNeg;165 n->nInvers = ntInvers;166 //n->nCopy = ntCopy;167 n->cfCopy = nt_Copy;168 n->nGreater = ntGreater;169 n->nEqual = ntEqual;170 n->nIsZero = ntIsZero;171 n->nIsOne = ntIsOne;172 n->nIsMOne = ntIsMOne;173 n->nGreaterZero = ntGreaterZero;174 n->cfWrite = ntWrite;175 n->nRead = ntRead;176 n->nPower = ntPower;177 n->nGcd = ntGcd;178 n->nLcm = ntLcm;179 n->cfSetMap = ntSetMap;180 n->nName = ntName;181 n->nSize = ntSize;182 n->cfGetDenom = napGetDenom;183 n->cfGetNumerator = napGetNumerator;184 #ifdef LDEBUG185 n->nDBTest = naDBTest;186 #endif187 }188 #endif189 148 190 149 BOOLEAN nOK=TRUE; -
libpolys/coeffs/test.cc
rfb0a699 r16f8f1 25 25 #pragma GCC diagnostic ignored "-Wwrite-strings" 26 26 27 bool Test(const coeffs r) 27 void Print(/*const*/ number a, const coeffs r, BOOLEAN eoln = TRUE) 28 { 29 n_Test(a,r); 30 31 StringSetS(""); 32 n_Write(a, r); 33 34 char* s = NULL; 35 36 if( eoln ) 37 s = StringAppend("\n"); 38 else 39 s = StringAppend(""); 40 41 PrintS(s); 42 43 // free s? 44 } 45 46 47 void PrintSized(/*const*/ number a, const coeffs r, BOOLEAN eoln = TRUE) 48 { 49 Print(a, r, FALSE); 50 Print(", of size: %d", n_Size(a, r)); 51 52 if( eoln ) 53 PrintLn(); 54 } 55 56 57 58 bool TestArith(const coeffs r) 28 59 { 29 60 number a = n_Init(66666, r); 30 61 31 StringSetS("a: "); 32 n_Test(a,r); 33 n_Write(a, r); 34 PrintS(StringAppend("\n")); 62 PrintS("a: "); PrintSized(a, r); 35 63 36 64 number two = n_Init(2, r); 37 65 38 StringSetS("two: "); 39 n_Test(two,r); 40 n_Write(two, r); 41 PrintS(StringAppend("\n")); 66 PrintS("two: "); PrintSized(two, r); 42 67 43 68 if (getCoeffType(r) == n_GF) //some special test for GF 44 69 { 45 number z = nfPar (0, r); // also any integer instead of 0 46 StringSetS("Generator: "); 47 n_Test(z,r); n_Write (z,r);48 PrintS(StringAppend("\n"));70 number z = nfPar (0, r); // also any integer instead of 0//? 71 72 PrintS("Generator: "); PrintSized(z, r); 73 49 74 n_Delete(&z, r); 50 75 } … … 52 77 number aa = n_Add(a, a, r); 53 78 54 StringSetS("aa = a + a: "); 55 n_Test(aa,r); n_Write(aa, r); 56 PrintS(StringAppend("\n")); 79 PrintS("aa = a + a: "); PrintSized(aa, r); 57 80 58 81 number aa2 = n_Mult(a, two, r); 59 82 60 StringSetS("aa2 = a * 2: "); 61 n_Test(aa2, r); n_Write(aa2, r); 62 PrintS(StringAppend("\n")); 83 PrintS("aa2 = a * 2: "); PrintSized(aa2, r); 63 84 64 85 number aa1 = n_Mult(two, a, r); 65 86 66 StringSetS("aa1 = 2 * a: "); 67 n_Test(aa1,r); n_Write(aa1, r); 68 PrintS(StringAppend("\n")); 69 87 PrintS("aa1 = 2 * a: "); PrintSized(aa1, r); 70 88 71 89 n_Delete(&a, r); … … 75 93 a = n_Sub( aa, aa1, r ); 76 94 77 StringSetS("a = aa - aa1: "); 78 n_Test(a,r); n_Write(a, r); 79 PrintS(StringAppend("\n")); 95 PrintS("a = aa - aa1: "); PrintSized(a, r); 80 96 81 97 if( !n_IsZero(a, r) ) 82 WarnS(" ERROR: a != 0 !!!\n");98 WarnS("TestArith: ERROR: a != 0 !!!\n"); 83 99 84 100 n_Delete(&a, r); 85 101 86 87 88 102 a = n_Sub( aa, aa2, r ); 89 103 90 StringSetS("a = aa - aa2: "); 91 n_Test(a,r); n_Write(a, r); 92 PrintS(StringAppend("\n")); 104 PrintS("a = aa - aa2: "); PrintSized(a, r); 93 105 94 106 if( !n_IsZero(a, r) ) 95 WarnS(" ERROR: a != 0 !!!\n");107 WarnS("TestArith: ERROR: a != 0 !!!\n"); 96 108 97 109 n_Delete(&a, r); … … 100 112 a = n_Sub( aa1, aa2, r ); 101 113 102 StringSetS("a = aa1 - aa2: "); 103 n_Test(a,r); n_Write(a, r); 104 PrintS(StringAppend("\n")); 114 PrintS("a = aa1 - aa2: "); PrintSized(a, r); 105 115 106 116 if( !n_IsZero(a, r) ) 107 WarnS(" ERROR: a != 0 !!!\n");117 WarnS("TestArith: ERROR: a != 0 !!!\n"); 108 118 109 119 n_Delete(&a, r); … … 112 122 113 123 if( !n_Equal(aa, aa1, r) ) 114 WarnS(" ERROR: aa != aa1 !!!\n");124 WarnS("TestArith: ERROR: aa != aa1 !!!\n"); 115 125 116 126 if( !n_Equal(aa, aa2, r) ) 117 WarnS(" ERROR: aa != aa2 !!!\n");127 WarnS("TestArith: ERROR: aa != aa2 !!!\n"); 118 128 119 129 if( !n_Equal(aa1, aa2, r) ) 120 WarnS(" ERROR: aa1 != aa2 !!!\n");130 WarnS("TestArith: ERROR: aa1 != aa2 !!!\n"); 121 131 122 132 … … 235 245 } 236 246 237 bool ret = Test ( r );247 bool ret = TestArith( r ); 238 248 239 249 nKillChar( r ); … … 251 261 n_coeffType type; 252 262 253 // rings needed for: n_Zp_a, n_Q_a ? 254 #ifdef HAVE_RINGS 255 TODO(Frank, Segmentation fault! (if used wihout omalloc???). Please_ investigate!); 256 /* 263 264 #ifdef HAVE_RINGS 265 // TODO(Frank, Segmentation fault! (if used wihout omalloc???). Please_ investigate!); 266 type = nRegister( n_Z2m, nr2mInitChar); assume( type == n_Z2m ); 267 if( Test(type, (void*) 4) ) 268 c ++; 269 #endif 270 271 type = nRegister( n_Zp, npInitChar); assume( type == n_Zp ); 272 if( Test(type, (void*) 101) ) 273 c ++; 274 275 #ifdef HAVE_RINGS 276 // TODO(Frank, memmory corruption_ if used wihout omalloc??? Please_ investigate!); 277 278 type = nRegister( n_Z2m, nr2mInitChar); assume( type == n_Z2m ); 279 if( Test(type, (void*) 8) ) 280 c ++; 281 282 #endif 283 284 285 type = nRegister( n_Q, nlInitChar); assume( type == n_Q ); 286 if( Test(type) ) 287 c ++; 288 289 type = nRegister( n_R, nrInitChar); assume( type == n_R ); 290 if( Test(type) ) 291 c ++; 292 293 #ifdef HAVE_RINGS 294 type = nRegister( n_Z, nrzInitChar); assume( type == n_Z ); // No need in GMP? 295 if( Test(type) ) 296 c ++; 297 #endif 298 type = nRegister( n_GF, nfInitChar); assume( type == n_GF ); 299 300 301 GFInfo* param = new GFInfo(); 302 303 param->GFChar= 5; 304 param->GFDegree= 12; 305 param->GFPar_name= (const char*)"q"; 306 307 if( Test(type, (void*) param) ) 308 c ++; 309 310 // it should not be used by numbers... right? 311 // TODO: what is our policy wrt param-pointer-ownership? 312 delete param; 313 // Q: no way to deRegister a type? 314 315 param = new GFInfo(); 316 317 param->GFChar= 5; 318 param->GFDegree= 2; 319 param->GFPar_name= (const char*)"Q"; 320 321 if( Test(type, (void*) param) ) 322 c ++; 323 324 delete param; 325 326 327 328 329 #ifdef HAVE_RINGS 330 // TODO(Somebody, This will result in memory corruption at Z_2^m later on (due to the succs. setGMPFloatDigits?)...!?); // ???? 331 332 type = nRegister( n_Zn, nrnInitChar); assume( type == n_Zn ); 333 334 if( Test(type, (void*) 3) ) 335 c ++; 336 337 #endif 338 339 TODO(Somebody, floating arithmetics via GMP rely on two global variables (see setGMPFloatDigits). Please fix it!); 340 setGMPFloatDigits( 10, 5 ); // Init global variables in mpr_complex.cc for gmp_float's... // Note that this seems also to be required for Z_2^m (and Zn?)!???? 341 342 343 type = nRegister( n_long_C, ngcInitChar); assume( type == n_long_C ); 344 if( Test(type) ) 345 c ++; 346 347 type = nRegister( n_long_R, ngfInitChar); assume( type == n_long_R ); 348 if( Test(type) ) 349 c ++; 350 351 #ifdef HAVE_RINGS 257 352 type = nRegister( n_Z2m, nr2mInitChar); assume( type == n_Z2m ); 258 353 if( Test(type, (void*) 2) ) 259 354 c ++; 260 */ 261 #endif 262 263 type = nRegister( n_Zp, npInitChar); assume( type == n_Zp ); 264 if( Test(type, (void*) 11) ) 265 c ++; 266 267 #ifdef HAVE_RINGS 268 TODO(Frank, memmory corruption_ if used wihout omalloc??? Please_ investigate!); 269 /* 270 type = nRegister( n_Z2m, nr2mInitChar); assume( type == n_Z2m ); 271 if( Test(type, (void*) 2) ) 272 c ++; 273 */ 274 #endif 275 276 277 type = nRegister( n_Q, nlInitChar); assume( type == n_Q ); 278 if( Test(type) ) 279 c ++; 280 281 type = nRegister( n_R, nrInitChar); assume( type == n_R ); 282 if( Test(type) ) 283 c ++; 284 285 #ifdef HAVE_RINGS 286 type = nRegister( n_Z, nrzInitChar); assume( type == n_Z ); // No need in GMP? 287 if( Test(type) ) 288 c ++; 289 #endif 290 GFInfo param; 291 type = nRegister( n_GF, nfInitChar); assume( type == n_GF ); 292 293 294 param.GFChar= 5; 295 param.GFDegree= 12; 296 param.GFPar_name= (const char*)"q"; 297 298 if( Test(type, (void*) ¶m) ) 299 c ++; 300 301 302 param.GFChar= 5; 303 param.GFDegree= 2; 304 param.GFPar_name= (const char*)"Q"; 305 306 if( Test(type, (void*) ¶m) ) 307 c ++; 308 309 310 TODO(Somebody, floating arithmetics via GMP rely on two global variables (see setGMPFloatDigits). Please fix it!); 311 312 313 314 #ifdef HAVE_RINGS 315 TODO(Somebody, This will result in memory corruption at Z_2^m later on (due to the succs. setGMPFloatDigits?)...!?); 316 /* 355 #endif 356 357 358 #ifdef HAVE_RINGS 317 359 type = nRegister( n_Zn, nrnInitChar); assume( type == n_Zn ); 318 360 319 361 if( Test(type, (void*) 3) ) 320 362 c ++; 321 */ 322 #endif 323 324 setGMPFloatDigits( 10, 5 ); // Init global variables in mpr_complex.cc for gmp_float's... // Note that this seems also to be required for Z_2^m (and Zn?)!???? 325 326 327 type = nRegister( n_long_C, ngcInitChar); assume( type == n_long_C ); 328 if( Test(type) ) 329 c ++; 330 331 type = nRegister( n_long_R, ngfInitChar); assume( type == n_long_R ); 332 if( Test(type) ) 333 c ++; 334 335 #ifdef HAVE_RINGS 336 type = nRegister( n_Z2m, nr2mInitChar); assume( type == n_Z2m ); 337 if( Test(type, (void*) 2) ) 338 c ++; 339 #endif 340 341 342 #ifdef HAVE_RINGS 343 type = nRegister( n_Zn, nrnInitChar); assume( type == n_Zn ); 344 345 if( Test(type, (void*) 3) ) 346 c ++; 347 #endif 348 363 #endif 364 365 // polynomial rings needed for: n_Zp_a, n_Q_a ? 349 366 350 367 return c; -
libpolys/polys/ext_fields/longtrans.cc
rfb0a699 r16f8f1 33 33 int ntParsToCopy; 34 34 int ntNumbOfPar; 35 36 37 #if 0 /*vertagt*/ 38 if (nField_is_Extension(r)) 39 { 40 //ntInitChar(c,TRUE,r); 41 n->cfDelete = ntDelete; 42 n->nNormalize = ntNormalize; 43 n->cfInit = ntInit; 44 n->nPar = ntPar; 45 n->nParDeg = ntParDeg; 46 n->n_Int = ntInt; 47 n->nAdd = ntAdd; 48 n->nSub = ntSub; 49 n->nMult = ntMult; 50 n->nDiv = ntDiv; 51 n->nExactDiv = ntDiv; 52 n->nIntDiv = ntIntDiv; 53 n->nNeg = ntNeg; 54 n->nInvers = ntInvers; 55 //n->nCopy = ntCopy; 56 n->cfCopy = nt_Copy; 57 n->nGreater = ntGreater; 58 n->nEqual = ntEqual; 59 n->nIsZero = ntIsZero; 60 n->nIsOne = ntIsOne; 61 n->nIsMOne = ntIsMOne; 62 n->nGreaterZero = ntGreaterZero; 63 n->cfWrite = ntWrite; 64 n->nRead = ntRead; 65 n->nPower = ntPower; 66 n->nGcd = ntGcd; 67 n->nLcm = ntLcm; 68 n->cfSetMap = ntSetMap; 69 n->nName = ntName; 70 n->nSize = ntSize; 71 n->cfGetDenom = napGetDenom; 72 n->cfGetNumerator = napGetNumerator; 73 #ifdef LDEBUG 74 n->nDBTest = ntDBTest; 75 #endif 76 } 77 #endif 78 35 79 36 80 numberfunc nacMult, nacSub, nacAdd, nacDiv, nacIntDiv;
Note: See TracChangeset
for help on using the changeset viewer.