Changeset 077e9c in git
- Timestamp:
- Apr 18, 1997, 5:49:41 PM (26 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 87e1dea02069a0384ad19ed8f56dbff5d465e597
- Parents:
- 5ec6957bea2ca39b00d7f174d456bba93f41ea83
- Location:
- Singular
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/ffields.cc
r5ec695 r077e9c 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ffields.cc,v 1. 7 1997-04-16 18:38:06Singular Exp $ */4 /* $Id: ffields.cc,v 1.8 1997-04-18 15:49:40 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: finite fields with a none-prime number of elements (via tables) … … 26 26 4, 8, 16, 32, 64, 128, 256, 512,1024,2048,4096,8192,16384, 27 27 /*2^2 2^3 2^4 2^5 2^6 2^7 2^8 2^9 2^10 2^11 2^12 2^13 2^14*/ 28 9, 27, 81,243,729,2187, 6561,19683,28 9, 27, 81,243,729,2187, 6561,19683, 29 29 /*3^2 3^3 3^4 3^5 3^6 3^7 3^8 3^9*/ 30 30 25,125,625,3125,15625, … … 32 32 49,343,2401,16807, 33 33 /*7^2 7^3 7^4 7^5*/ 34 121,1331, 14641,34 121,1331, 14641, 35 35 /*11^2 11^3 11^4*/ 36 169, 2197, 28561,36 169, 2197, 28561, 37 37 /*13^2 13^3 13^4*/ 38 38 289, 4913, … … 117 117 */ 118 118 119 #ifdef LDEBUG 120 /*2 121 * debugging: is a a valid representation of a number ? 122 */ 123 BOOLEAN nfDBTest (number a, char *f, int l) 124 { 125 if (((int)a<0) || ((int)a>nfCharQ)) 126 { 127 Print("wrong %d in %s:%d\n",(int)a,f,l); 128 return FALSE; 129 } 130 int i=0; 131 do 132 { 133 if (nfPlus1Table[i]>nfCharQ) 134 { 135 Print("wrong table %d=%d in %s:%d\n",i,nfPlus1Table[i],f,l); 136 return FALSE; 137 } 138 i++; 139 } while (i<nfCharQ); 140 return TRUE; 141 } 142 #define nfTest(N) nfDBTest(N,__FILE__,__LINE__) 143 #endif 144 119 145 /*2 120 146 * k >= 0 ? … … 122 148 BOOLEAN nfGreaterZero (number k) 123 149 { 150 #ifdef LDEBUG 151 nfTest(k); 152 #endif 124 153 return !nfIsZero(k); 125 154 } … … 130 159 number nfMult (number a,number b) 131 160 { 161 #ifdef LDEBUG 162 nfTest(a); 163 nfTest(b); 164 #endif 132 165 if (((int)a == nfCharQ) || ((int)b == nfCharQ)) 133 166 return (number)nfCharQ; … … 135 168 int i=(int)a+(int)b; 136 169 if (i>=nfCharQ1) i-=nfCharQ1; 170 #ifdef LDEBUG 171 nfTest((number)i); 172 #endif 137 173 return (number)i; 138 174 } … … 152 188 i--; 153 189 } 190 #ifdef LDEBUG 191 nfTest((number)c); 192 #endif 154 193 return (number)c; 155 194 } … … 168 207 int nfParDeg(number n) 169 208 { 209 #ifdef LDEBUG 210 nfTest(n); 211 #endif 170 212 if(nfCharQ == (int)n) return -1; 171 213 return (int)n; … … 183 225 * copy a number 184 226 */ 185 number nfCopy (number k1) 186 { 187 return k1; 227 number nfCopy (number k) 228 { 229 #ifdef LDEBUG 230 nfTest(k); 231 #endif 232 return k; 188 233 } 189 234 … … 195 240 /*4 z^a+z^b=z^b*(z^(a-b)+1), if a>=b; * 196 241 * =z^a*(z^(b-a)+1) if a<b */ 242 #ifdef LDEBUG 243 nfTest(a); 244 nfTest(b); 245 #endif 197 246 int zb,zab,r; 198 247 if ((int)a >= (int)b) … … 206 255 zab = (int)b-(int)a; 207 256 } 257 #ifdef LDEBUG 258 nfTest((number)zab); 259 #endif 208 260 if (nfPlus1Table[zab]==nfCharQ) r=nfCharQ; /*if z^(a-b)+1 =0*/ 209 261 else … … 212 264 if(r>=nfCharQ1) r-=nfCharQ1; 213 265 } 266 #ifdef LDEBUG 267 nfTest((number)r); 268 #endif 214 269 return (number)r; 215 270 } … … 229 284 BOOLEAN nfIsZero (number a) 230 285 { 286 #ifdef LDEBUG 287 nfTest(a); 288 #endif 231 289 return nfCharQ == (int)a; 232 290 } … … 237 295 BOOLEAN nfIsOne (number a) 238 296 { 297 #ifdef LDEBUG 298 nfTest(a); 299 #endif 239 300 return 0 == (int)a; 240 301 } … … 245 306 BOOLEAN nfIsMOne (number a) 246 307 { 308 #ifdef LDEBUG 309 nfTest(a); 310 #endif 247 311 return nfM1 == (int)a; 248 312 } … … 253 317 number nfDiv (number a,number b) 254 318 { 319 #ifdef LDEBUG 320 nfTest(b); 321 #endif 255 322 if ((int)b==nfCharQ) 256 323 { … … 258 325 return (number)nfCharQ; 259 326 } 327 #ifdef LDEBUG 328 nfTest(a); 329 #endif 260 330 if ((int)a==nfCharQ) 261 331 return (number)nfCharQ; … … 264 334 if (s < 0) 265 335 s += nfCharQ1; 336 #ifdef LDEBUG 337 nfTest((number)s); 338 #endif 266 339 return (number)s; 267 340 } … … 272 345 number nfInvers (number c) 273 346 { 347 #ifdef LDEBUG 348 nfTest(c); 349 #endif 274 350 if ((int)c==nfCharQ) 275 351 { … … 277 353 return (number)nfCharQ; 278 354 } 355 #ifdef LDEBUG 356 nfTest(((number)(nfCharQ1-(int)c))); 357 #endif 279 358 return (number)(nfCharQ1-(int)c); 280 359 } … … 286 365 { 287 366 /*4 -z^c=z^c*(-1)=z^c*nfM1*/ 367 #ifdef LDEBUG 368 nfTest(c); 369 #endif 288 370 int i=(int)c+nfM1; 289 371 if (i>=nfCharQ1) i-=nfCharQ1; 372 #ifdef LDEBUG 373 nfTest((number)i); 374 #endif 290 375 return (number)i; 291 376 } … … 296 381 BOOLEAN nfGreater (number a,number b) 297 382 { 383 #ifdef LDEBUG 384 nfTest(a); 385 nfTest(b); 386 #endif 298 387 return (int)a != (int)b; 299 388 } … … 304 393 BOOLEAN nfEqual (number a,number b) 305 394 { 395 #ifdef LDEBUG 396 nfTest(a); 397 nfTest(b); 398 #endif 306 399 return (int)a == (int)b; 307 400 } … … 312 405 void nfWrite (number &a) 313 406 { 407 #ifdef LDEBUG 408 nfTest(a); 409 #endif 314 410 if ((int)a==nfCharQ) StringAppendS("0"); 315 411 else if ((int)a==0) StringAppendS("1"); … … 330 426 char * nfName(number a) 331 427 { 428 #ifdef LDEBUG 429 nfTest(a); 430 #endif 332 431 char *s; 333 432 if (((int)a==nfCharQ) || ((int)a==0)) return NULL; … … 348 447 void nfPower (number a, int i, number * result) 349 448 { 449 #ifdef LDEBUG 450 nfTest(a); 451 #endif 350 452 if (i==0) 351 453 { 352 454 //*result=nfInit(1); 353 * (int *)result =0;455 *result = (number)0; 354 456 } 355 457 else if (i==1) … … 363 465 *result = nfMult(a,*result); 364 466 } 467 #ifdef LDEBUG 468 nfTest(*result); 469 #endif 365 470 } 366 471 … … 418 523 *a=nfMult(*a,z); 419 524 } 525 #ifdef LDEBUG 526 nfTest(*a); 527 #endif 420 528 return s; 421 529 } … … 442 550 } 443 551 444 static int convertback62 ( char * p, int n )552 static int convertback62 ( char * p, int n , int q) 445 553 { 446 554 int r = 0; … … 451 559 #endif 452 560 453 int nfMinPoly[ ]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};561 int nfMinPoly[16]; 454 562 455 563 void nfShowMipo() … … 461 569 j++; 462 570 if (nfMinPoly[j]!=0) 463 Print("%d*%s^%d",nfMinPoly[j],nfParameter,i);571 StringAppend("%d*%s^%d",nfMinPoly[j],nfParameter,i); 464 572 i--; 465 573 if(i<0) break; 466 574 if (nfMinPoly[j]!=0) 467 PrintS("+");468 } 575 StringAppendS("+"); 576 } 469 577 } 470 578 … … 512 620 if (c>1) nfCharQ = c; 513 621 else nfCharQ = -c; 514 char buf[ 80];622 char buf[100]; 515 623 sprintf(buf,"gftables/%d",nfCharQ); 516 624 FILE * fp = feFopen(buf,"r",NULL,FALSE); … … 552 660 { 553 661 nfPlus1Table[i] = convertback62( bufptr, digs ); 662 if(nfPlus1Table[i]>nfCharQ) 663 { 664 Print("wrong entry %d: %d(%c%c%c)\n",i,nfPlus1Table[i],bufptr[0],bufptr[1],bufptr[2]); 665 } 554 666 bufptr += digs; 667 if (nfPlus1Table[i]==nfCharQ) 668 { 669 if(i==nfCharQ1) 670 { 671 nfM1=0; 672 } 673 else 674 { 675 nfM1=i; 676 } 677 } 555 678 i++; k++; 556 679 } 557 nfPlus1Table[0]=nfPlus1Table[nfCharQ1];558 680 } 681 nfPlus1Table[0]=nfPlus1Table[nfCharQ1]; 559 682 } 560 683 else 561 684 nfCharQ=0; 685 #ifdef LDEBUG 686 nfTest((number)0); 687 #endif 562 688 return; 563 689 err: … … 565 691 } 566 692 567 #ifdef LDEBUG568 /*2569 * debugging: is a a valid representation of a number ?570 */571 BOOLEAN nfDBTest (number a, char *f, int l)572 {573 if (((int)a<0) || ((int)a>nfCharQ))574 {575 return FALSE;576 }577 return TRUE;578 }579 #endif580 581 693 /*2 582 694 * map Z/p -> GF(p,n) -
Singular/ring.cc
r5ec695 r077e9c 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ring.cc,v 1. 7 1997-04-17 17:52:21Singular Exp $ */4 /* $Id: ring.cc,v 1.8 1997-04-18 15:49:40 Singular Exp $ */ 5 5 6 6 /* … … 715 715 if (r==currRing) 716 716 { 717 PrintS("// minpoly : ");718 nfShowMipo();Print Ln();717 StringSetS("// minpoly : "); 718 nfShowMipo();PrintS(StringAppend("\n")); 719 719 } 720 720 } -
Singular/subexpr.cc
r5ec695 r077e9c 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: subexpr.cc,v 1.1 3 1997-04-18 11:25:03 obachmanExp $ */4 /* $Id: subexpr.cc,v 1.14 1997-04-18 15:49:41 Singular Exp $ */ 5 5 6 6 /* … … 30 30 #include "timer.h" 31 31 #include "ring.h" 32 #include "ffields.h" 32 33 #include "numbers.h" 33 34 #include "ipshell.h" … … 632 633 data=(char *)n; 633 634 } 635 else if((rtyp==VMINPOLY)&&(currRing->ch>2)) 636 { 637 nfShowMipo(); 638 } 634 639 else 635 640 { … … 805 810 case TRACE: return (void *)traceit; 806 811 case VSHORTOUT: return (void *)pShortOut; 807 case VMINPOLY: if (currRing->minpoly!=NULL) 812 case VMINPOLY: if ((currRing->minpoly!=NULL)&&(currRing->ch<2)) 813 /* Q(a), Fp(a), but not GF(q) */ 808 814 return (void *)currRing->minpoly; 809 815 else
Note: See TracChangeset
for help on using the changeset viewer.