Changeset 5812c69 in git
- Timestamp:
- Sep 24, 1998, 11:59:51 AM (25 years ago)
- Branches:
- (u'spielwiese', '8d54773d6c9e2f1d2593a28bc68b7eeab54ed529')
- Children:
- 56c52a7879fbc6de62cefba1da86b2edf2aadd4c
- Parents:
- 073d2edeb03013a5c6ed0913687b024305a1427d
- Location:
- Singular
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/primdec.lib
r073d2e r5812c69 1 // $Id: primdec.lib,v 1.2 5 1998-08-05 11:12:32Singular Exp $1 // $Id: primdec.lib,v 1.26 1998-09-24 09:59:51 Singular Exp $ 2 2 //////////////////////////////////////////////////////////////////////////////// 3 3 // primdec.lib // … … 11 11 //////////////////////////////////////////////////////////////////////////////// 12 12 13 version="$Id: primdec.lib,v 1.2 5 1998-08-05 11:12:32Singular Exp $";13 version="$Id: primdec.lib,v 1.26 1998-09-24 09:59:51 Singular Exp $"; 14 14 info=" 15 15 LIBRARY: primdec.lib: PROCEDURE FOR PRIMARY DECOMPOSITION … … 383 383 if(size(k1)==size(k2)) 384 384 { 385 for(j= 1;j<=size(k1);j++)385 for(j=size(k1);j>0;j--) 386 386 { 387 387 if(leadexp(k1[j])!=leadexp(k2[j])) … … 401 401 if(size(k1)==size(k2)) 402 402 { 403 for(j= 1;j<=size(k1);j++)403 for(j=size(k1);j>0;j--) 404 404 { 405 405 if(leadexp(k1[j])!=leadexp(k2[j])) -
Singular/clapconv.cc
r073d2e r5812c69 3 3 * Computer Algebra System SINGULAR * 4 4 ****************************************/ 5 // $Id: clapconv.cc,v 1.1 7 1998-04-27 14:47:01Singular Exp $5 // $Id: clapconv.cc,v 1.18 1998-09-24 09:59:34 Singular Exp $ 6 6 /* 7 7 * ABSTRACT: convert data between Singular and factory … … 164 164 { 165 165 result = pAdd( result, term ); 166 } 166 } 167 167 } 168 168 } -
Singular/claptmpl.cc
r073d2e r5812c69 3 3 * Computer Algebra System SINGULAR * 4 4 ****************************************/ 5 // $Id: claptmpl.cc,v 1.1 7 1998-06-30 16:30:05 schmidtExp $5 // $Id: claptmpl.cc,v 1.18 1998-09-24 09:59:35 Singular Exp $ 6 6 /* 7 7 * ABSTRACT - instantiation of all templates … … 94 94 { 95 95 if ( this != &f ) { 96 97 96 _factor = f._factor; 97 _exp = f._exp; 98 98 } 99 99 return *this; -
Singular/cntrlc.cc
r073d2e r5812c69 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: cntrlc.cc,v 1. 19 1998-07-30 17:49:15Singular Exp $ */4 /* $Id: cntrlc.cc,v 1.20 1998-09-24 09:59:36 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT - interupt handling … … 62 62 BOOLEAN siCntrlc = FALSE; 63 63 64 typedef void (*si_hdl_typ)(int); 65 64 66 /*0 implementation*/ 65 67 #ifndef MSDOS … … 67 69 #ifndef macintosh 68 70 /* signals are not right implemented in macintosh */ 69 typedef void (*si_hdl_typ)(int);70 71 void sigint_handler(int sig); 71 72 #endif … … 124 125 } 125 126 #endif 126 #ifdef HAVE_FEREAD127 fe_reset_input_mode();128 #endif129 127 #ifndef __OPTIMIZE__ 130 128 if (sig!=SIGINT) debug(INTERACTIVE); … … 216 214 PrintS("cannot set signal handler for IOT\n"); 217 215 } 216 #ifndef macintosh 218 217 if (SIG_ERR==signal(SIGINT ,sigint_handler)) 219 218 { 220 219 PrintS("cannot set signal handler for INT\n"); 221 220 } 221 #endif 222 222 } 223 223 … … 245 245 longjmp(si_start_jmpbuf,1); 246 246 } 247 #endif248 #ifdef HAVE_FEREAD249 fe_reset_input_mode(0,NULL);250 247 #endif 251 248 #ifndef __OPTIMIZE__ … … 292 289 longjmp(si_start_jmpbuf,1); 293 290 } 294 #endif295 #ifdef HAVE_FEREAD296 #ifdef HAVE_ATEXIT297 fe_reset_input_mode();298 #else299 fe_reset_input_mode(0,NULL);300 #endif301 291 #endif 302 292 #ifdef unix … … 439 429 //} 440 430 //#endif 441 442 #ifndef MSDOS443 // /*2444 // * test for SIGINT, start an interpreter445 // */446 // void test_int_std(leftv v)447 // {448 // #ifndef macintosh449 // //#ifdef macintosh450 // // beachball();451 // //#endif452 // if (siCntrlc>1)453 // {454 // int saveecho = si_echo;455 // siCntrlc = FALSE;456 // signal(SIGINT ,sigint_handler);457 // //#ifdef macintosh458 // // flush_intr();459 // //#endif460 // //si_echo = 2;461 // printf("\n//inside a computation, continue with `exit;`\n");462 // iiPStart("STDIN","STDIN",NULL);463 // si_echo = saveecho;464 // }465 // #endif466 // }467 #endif468 431 469 432 #ifndef MSDOS -
Singular/comm.cc
r073d2e r5812c69 52 52 delete(res); 53 53 } 54 54 55 55 Free((ADDRESS)Warteliste,(Wartelistemax)*sizeof(LObject)); 56 56 } … … 135 135 // PrintS("Restore\n"); 136 136 if(DEBUG) PrintS("Restore\n"); 137 137 138 138 int i = 0; 139 139 int l = 0; … … 141 141 { 142 142 while(i<aktuell) 143 144 145 146 147 143 { 144 l = strat->posInL(strat->L,strat->Ll,Warteliste[i],strat); 145 enterL(&(strat->L),&(strat->Ll),&(strat->Lmax),Warteliste[i++],l); 146 } 147 148 148 aktuell=0; 149 149 return TRUE; … … 180 180 lv->rtyp = INTVEC_CMD; 181 181 switch(msg) 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 { 199 200 201 202 203 204 205 206 207 208 209 210 182 { 183 184 case MsgTupel: 185 for(i=0; i<pVariables; i++) 186 exp[i+1]=pGetExp(strat->P.p, i+1); 187 break; 188 189 case MsgTupelPosition: 190 for(i=0; i<pVariables; i++) 191 exp[i+1]=0; 192 193 // Neue Position von strat->P.p bestimmen 194 pos=-1; 195 for(i=strat->Ll-1; i>=0; i--) 196 { 197 if((strat->L[i].p1 == strat->P.p1) && (strat->L[i].p2 == strat->P.p2)) 198 { 199 pos = i; 200 continue; 201 } 202 } 203 exp[1]=pos; 204 break; 205 206 default: 207 for(i=0; i<pVariables; i++) 208 exp[i+1]=0; 209 break; 210 } 211 211 lv->data=ivCopy(&exp); 212 212 if(li==-1) 213 214 215 216 217 213 { 214 for(i=0; i< procnum; i++) 215 if((*links)[i]!=NULL) 216 slWrite((*links)[i], lv); 217 } 218 218 else 219 220 221 219 { 220 slWrite((*links)[li], lv); 221 } 222 222 lv->CleanUp(); 223 223 Free(lv,sizeof(sleftv)); … … 235 235 intvec *rec = NULL; 236 236 if(DEBUG) PrintS("ReceiveMsg\n"); 237 237 238 238 leftv lv = NULL; 239 239 for(int i=0; i<procnum;i++) 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 240 { 241 lv=slRead((*links)[i]); 242 rec=ivCopy((intvec *) lv->Data()); 243 if((*res)[i]!=NULL) 244 { 245 delete (*res)[i]; 246 (*res)[i]=NULL; 247 } 248 (*msg)[i] = (*rec)[0]; 249 if((stdMsg)(*msg)[i]==MsgTupel) 250 { 251 (*res)[i] = new intvec(pVariables,1,0); 252 for(int j = 0; j<pVariables ; j++) 253 (*(*res)[i])[j]=(*rec)[j+1]; 254 } 255 } 256 256 lv->CleanUp(); 257 257 Free(lv, sizeof(sleftv)); … … 259 259 delete rec; 260 260 if(DEBUG) PrintS("ReceiveMsg Ende\n"); 261 return TRUE; 261 return TRUE; 262 262 } 263 263 } … … 286 286 case ModWrite: 287 287 case ModRun: // Berechne und sende Tupel 288 Verwaltung = TRUE; 289 Receive = FALSE; 290 TupelL = TRUE; 291 SPoly = TRUE; 292 Reduzieren = TRUE; 293 TupelMelden = TRUE; 294 TupelTesten = FALSE; 288 Verwaltung = TRUE; 289 Receive = FALSE; 290 TupelL = TRUE; 291 SPoly = TRUE; 292 Reduzieren = TRUE; 293 TupelMelden = TRUE; 294 TupelTesten = FALSE; 295 295 TupelPosition = TRUE; 296 ResultSend = FALSE; 297 TupelStore = FALSE; 296 ResultSend = FALSE; 297 TupelStore = FALSE; 298 298 break; 299 299 case ModStep: // Warte auf MsgStep, berechne und sende 300 Verwaltung = TRUE; 301 Receive = TRUE; 302 TupelL = TRUE; 303 SPoly = TRUE; 304 Reduzieren = TRUE; 305 TupelMelden = TRUE; 300 Verwaltung = TRUE; 301 Receive = TRUE; 302 TupelL = TRUE; 303 SPoly = TRUE; 304 Reduzieren = TRUE; 305 TupelMelden = TRUE; 306 306 TupelPosition = TRUE; 307 TupelTesten = FALSE; 308 ResultSend = TRUE; 309 TupelStore = FALSE; 307 TupelTesten = FALSE; 308 ResultSend = TRUE; 309 TupelStore = FALSE; 310 310 break; 311 311 case ModCalc: // Warte auf Tupel und berechne 312 Verwaltung = TRUE; 313 Receive = TRUE; 314 TupelL = TRUE; 315 TupelMelden = FALSE; 312 Verwaltung = TRUE; 313 Receive = TRUE; 314 TupelL = TRUE; 315 TupelMelden = FALSE; 316 316 TupelPosition = FALSE; 317 317 ResultSend = TRUE; 318 318 TupelStore = (*msg)[0]==MsgTupelisZero; 319 319 if(TupelStore) 320 321 SPoly = FALSE;322 323 324 320 { 321 SPoly = FALSE; 322 Reduzieren = FALSE; 323 TupelTesten = FALSE; 324 } 325 325 else 326 327 SPoly = TRUE; 328 Reduzieren = TRUE; 329 330 326 { 327 SPoly = TRUE; 328 Reduzieren = TRUE; 329 TupelTesten = TRUE; 330 } 331 331 break; 332 332 case ModPosition: // Tupel neu positionieren 333 Verwaltung = TRUE; 334 Receive = TRUE; 335 TupelL = TRUE; 336 TupelMelden = FALSE; 333 Verwaltung = TRUE; 334 Receive = TRUE; 335 TupelL = TRUE; 336 TupelMelden = FALSE; 337 337 TupelPosition = FALSE; 338 338 ResultSend = TRUE; … … 345 345 Restore(strat); 346 346 if(strat->Ll>=0) 347 348 349 350 351 TupelStore = FALSE; 352 353 354 355 356 357 358 347 { 348 Verwaltung = TRUE; 349 Receive = FALSE; 350 TupelL = TRUE; 351 TupelStore = FALSE; 352 SPoly = TRUE; 353 TupelMelden = FALSE; 354 TupelPosition = FALSE; 355 TupelTesten = FALSE; 356 ResultSend = TRUE; 357 Reduzieren = TRUE; 358 } 359 359 else 360 361 362 360 { 361 SetModus(ModEnde,strat); 362 } 363 363 break; 364 364 case ModEnde: //sofort beenden 365 365 Verwaltung = FALSE; 366 Receive = FALSE; 367 TupelWarte = FALSE; 368 TupelL = FALSE; 369 TupelStore = FALSE; 370 TupelTesten = FALSE; 371 SPoly = FALSE; 372 Reduzieren = FALSE; 373 TupelMelden = FALSE; 374 ResultSend = FALSE; 366 Receive = FALSE; 367 TupelWarte = FALSE; 368 TupelL = FALSE; 369 TupelStore = FALSE; 370 TupelTesten = FALSE; 371 SPoly = FALSE; 372 Reduzieren = FALSE; 373 TupelMelden = FALSE; 374 ResultSend = FALSE; 375 375 break; 376 376 } … … 396 396 case ModCalc: // Beenden erst dann, wenn Calc2 erreicht ist. 397 397 SetModus(ModCalc); 398 if(strat->Ll<0) 399 400 401 402 398 if(strat->Ll<0) 399 { 400 if(BTEST1(OPT_INTERRUPT)) 401 return TRUE; 402 if(TEST_OPT_PROT) 403 403 { 404 404 PrintS("\n<C>\n"); 405 405 writeTime("used time: #"); 406 406 } 407 408 409 407 SetModus(ModCheck,strat); 408 } 409 return FALSE; 410 410 break; 411 411 case ModCheck: … … 436 436 { 437 437 if(strat->Ll != oldLl ) 438 439 440 441 442 } 443 438 { 439 SendMsg(strat, MsgTupelPosition); 440 TupelMelden = FALSE; 441 } 442 } 443 444 444 } 445 445 … … 460 460 // PrintS("ParseMessage\n"); 461 461 if(DEBUG) PrintS("ParseMessage\n"); 462 BOOLEAN err=FALSE; 462 BOOLEAN err=FALSE; 463 463 // Testen, ob alle Nachrichten korrekt sind, 464 464 // wenn ja, dann ParseMessageFinal 465 465 // sonst die richtige finden, andere Prozesse killen 466 466 467 467 // Ist nur ein proc vorhanden, dann automatisch weiter 468 for(int i=1; i< procnum; i++) 468 for(int i=1; i< procnum; i++) 469 469 err = err || ((*msg)[i] != (*msg)[0]); 470 470 if(!err) … … 477 477 // Unterschiedliche Tupel : In TupelDifferent alle abweichler killen 478 478 for(int i=0; i<procnum; i++) 479 480 481 482 483 479 if(((stdMsg)(*msg)[i]) == MsgTupelisZero) 480 { 481 PrintS(" AAA "); 482 KillChild(strat,i); 483 } 484 484 ParseMessageFinal(strat); 485 485 } … … 493 493 // PrintS("ParseMessageFinal\n"); 494 494 if(DEBUG) PrintS("ParseMessageFinal\n"); 495 495 496 496 switch(((stdMsg) (*msg)[i])) 497 497 { 498 case MsgTupel: // In Step-Modus schalten bzw. bleiben. 498 case MsgTupel: // In Step-Modus schalten bzw. bleiben. 499 499 case MsgTupelisZero: 500 500 501 501 if(procnum>0) 502 503 504 502 { 503 SetModus(ModCalc,strat); 504 } 505 505 else 506 507 508 506 { 507 SetModus(ModCheck,strat); 508 } 509 509 break; 510 510 case MsgTupelPosition: 511 511 // aktuelles Tupel neu positionieren 512 512 if(TEST_OPT_PROT) 513 513 PrintS("P"); 514 514 SetModus(ModPosition); 515 515 break; 516 case MsgEnd: // In Calc1-Modus schalten bzw. bleiben. 516 case MsgEnd: // In Calc1-Modus schalten bzw. bleiben. 517 517 SetModus(ModCheck,strat); 518 518 if (TEST_OPT_PROT) PrintS("\n<E>"); … … 534 534 { 535 535 if(strat->P.p==NULL) 536 537 538 539 536 { 537 PrintS(" BBB "); 538 KillChild(strat,i); 539 } 540 540 else 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 541 { 542 if((*res)[i]==NULL) 543 { 544 PrintS(" CCC "); 545 KillChild(strat,i); 546 } 547 else 548 { 549 Different = FALSE; 550 for(int j=0; j< pVariables; j++) 551 { 552 Different = Different || ((*(*res)[i])[j]!=pGetExp(strat->P.p,j+1)); 553 } 554 if(Different) 555 { 556 PrintS(" DDD "); 557 KillChild(strat,i); 558 } 559 } 560 } 561 561 } 562 562 if(procnum<=0) … … 587 587 { 588 588 if(procnum>=2) 589 590 591 592 593 594 595 596 597 589 { 590 si_link swaplink = (*links)[li]; 591 intvec *swapres = (*res)[li]; 592 (*msg)[li] = (*msg)[procnum-1]; 593 (*links)[li] = (*links)[procnum-1]; 594 (*res)[li] = (*res)[procnum-1]; 595 (*links)[procnum-1] = swaplink; 596 (*res)[procnum-1] = swapres; 597 } 598 598 else 599 600 601 602 603 604 605 606 599 { 600 if(TEST_OPT_PROT) 601 { 602 PrintS("\n<K>\n"); 603 writeTime("used time: #"); 604 } 605 SetModus(ModCheck,strat); 606 } 607 607 procnum--; 608 608 } … … 610 610 { 611 611 for(int i=procnum - 1 ; i>=0 ; i--) 612 612 KillChild(strat,i,Cancled); 613 613 } 614 614 } … … 620 620 if(lnModus==lnRead) 621 621 { 622 622 SetModus(ModCalc); 623 623 } 624 624 else 625 625 { 626 626 SetModus(ModRun ); 627 627 } 628 628 } … … 646 646 l->Init(aktuell); 647 647 for(i=0; i<aktuell; i++) 648 649 650 651 652 653 654 655 656 657 658 659 660 661 648 { 649 I=idInit(2,1); 650 l->m[i].rtyp = IDEAL_CMD; 651 if(Warteliste[i].p1==NULL) 652 I->m[0]=NULL; 653 else 654 I->m[0]=pCopy(Warteliste[i].p1); 655 if(Warteliste[i].p2==NULL) 656 I->m[1]=NULL; 657 else 658 I->m[1]=pCopy(Warteliste[i].p2); 659 l->m[i].data = (void *) idCopy(I); 660 idDelete(&I); 661 } 662 662 return l; 663 663 } … … 667 667 return l; 668 668 } 669 669 670 670 } 671 671 … … 677 677 // Print("r(%.5i) Msg =",-1); 678 678 switch(msg) { 679 case MsgTupelisZero: // In Step-Modus schalten bzw. bleiben. 680 681 682 case MsgTupel: // In Step-Modus schalten bzw. bleiben. 683 684 679 case MsgTupelisZero: // In Step-Modus schalten bzw. bleiben. 680 PrintS("MsgTupelisZero "); 681 break; 682 case MsgTupel: // In Step-Modus schalten bzw. bleiben. 683 PrintS("MsgTupel "); 684 break; 685 685 case MsgEnd: 686 687 686 PrintS("MsgEnd "); 687 break; 688 688 } 689 689 } 690 690 } 691 691 692 692 void skstdLink::DispMod(int i) 693 693 { … … 695 695 { 696 696 Print("r(%.5i) Mod = ",-1); 697 697 698 698 switch(Modus) { 699 699 case ModCheck: 700 701 700 PrintS("Check "); 701 break; 702 702 case ModRun: 703 704 703 PrintS("Run "); 704 break; 705 705 case ModStep: 706 707 706 PrintS("Step "); 707 break; 708 708 case ModCalc: 709 710 709 PrintS("Calc "); 710 break; 711 711 case ModRead: 712 713 712 PrintS("Read "); 713 break; 714 714 case ModWrite: 715 716 715 PrintS("Write "); 716 break; 717 717 } 718 718 PrintS("\n"); -
Singular/comm.h
r073d2e r5812c69 86 86 if(vec!=NULL) 87 87 { 88 89 90 91 92 93 88 for(int i=0; i<nr; i++) 89 { 90 if((vec[i])!=NULL) 91 delete (vec[i]); 92 vec[i]=NULL; 93 } 94 94 } 95 95 Free((ADDRESS)vec,sizeof(intvec*)*nr); -
Singular/fglmcomb.cc
r073d2e r5812c69 1 1 // emacs edit mode for this file is -*- C++ -*- 2 // $Id: fglmcomb.cc,v 1.1 2 1998-06-04 13:38:48 wichmannExp $2 // $Id: fglmcomb.cc,v 1.13 1998-09-24 09:59:38 Singular Exp $ 3 3 4 4 /**************************************** … … 192 192 // pSetExpV( m[k], temp->exp ); 193 193 // pSetm( m[k] ); 194 195 196 194 m[k]= pNew(); 195 pCopy2( m[k], temp ); 196 pSetCoeff( m[k], nInit(1) ); 197 197 pIter( temp ); 198 198 } … … 242 242 int b; 243 243 while ( temp != NULL ) 244 244 { 245 245 BOOLEAN found = FALSE; 246 246 for ( b= 0; (b < basisSize) && (found == FALSE); b++ ) 247 247 { 248 248 if ( pEqual( temp, basis[b] ) ) 249 249 { 250 250 found= TRUE; 251 251 } 252 252 } 253 253 if ( found == FALSE ) 254 254 { 255 255 if ( basisSize == basisMax ) 256 256 { 257 257 // Expand the basis 258 258 basis= (polyset)ReAlloc( basis, basisMax * sizeof( poly ), (basisMax + basisBS ) * sizeof( poly ) ); … … 262 262 // pSetExpV( basis[basisSize], temp->exp ); 263 263 // pSetm( basis[basisSize] ); 264 265 266 264 basis[basisSize]= pNew(); 265 pCopy2( basis[basisSize], temp ); 266 pSetCoeff( basis[basisSize], nInit(1) ); 267 267 basisSize++; 268 268 } … … 280 280 for ( k= 0; k < numMonoms; k++ ) { 281 281 STICKYPROT( "." ); 282 282 283 283 #ifndef HAVE_EXPLICIT_CONSTR 284 284 v[k].mac_constr_i( basisSize ); … … 352 352 } 353 353 #ifndef HAVE_EXPLICIT_CONSTR 354 354 v[best-1].clearelems(); 355 355 #else 356 356 v[best-1].~fglmVector(); -
Singular/fglmgauss.cc
r073d2e r5812c69 1 1 // emacs edit mode for this file is -*- C++ -*- 2 // $Id: fglmgauss.cc,v 1. 9 1998-06-04 13:39:21 wichmannExp $2 // $Id: fglmgauss.cc,v 1.10 1998-09-24 09:59:38 Singular Exp $ 3 3 4 4 /**************************************** 5 5 * Computer Algebra System SINGULAR * 6 6 ****************************************/ 7 /* 7 /* 8 8 * ABSTRACT - class gaussReducer. Used in fglmzero.cc and fglmhom.cc 9 9 * to find linear dependecies of fglmVectors. … … 27 27 number pdenom; 28 28 number fac; 29 gaussElem( const fglmVector newv, const fglmVector newp, number & newpdenom, number & newfac ) : v( newv ), p( newp ), pdenom( newpdenom ), fac( newfac ) 29 gaussElem( const fglmVector newv, const fglmVector newp, number & newpdenom, number & newfac ) : v( newv ), p( newp ), pdenom( newpdenom ), fac( newfac ) 30 30 { 31 32 31 newpdenom= NULL; 32 newfac= NULL; 33 33 } 34 34 … … 42 42 pdenom=newpdenom; 43 43 fac=newfac; 44 45 46 } 47 #endif 48 49 ~gaussElem() 44 newpdenom= NULL; 45 newfac= NULL; 46 } 47 #endif 48 49 ~gaussElem() 50 50 { 51 52 51 nDelete( & pdenom ); 52 nDelete( & fac ); 53 53 } 54 54 }; 55 55 56 gaussReducer::gaussReducer( int dimen ) 56 gaussReducer::gaussReducer( int dimen ) 57 57 { 58 58 int k; … … 65 65 #endif 66 66 isPivot= (BOOLEAN *)Alloc( (max+1)*sizeof( BOOLEAN ) ); 67 for ( k= max; k > 0; k-- ) 68 67 for ( k= max; k > 0; k-- ) 68 isPivot[k]= FALSE; 69 69 perm= (int *)Alloc( (max+1)*sizeof( int ) ); 70 70 } 71 71 72 gaussReducer::~gaussReducer() 72 gaussReducer::~gaussReducer() 73 73 { 74 74 int k; … … 77 77 delete [] elems; 78 78 #else 79 for ( k= size; k > 0; k-- ) 80 79 for ( k= size; k > 0; k-- ) 80 elems[k].~gaussElem(); 81 81 Free( (ADDRESS)elems, (max+1)*sizeof( gaussElem ) ); 82 82 #endif … … 87 87 88 88 BOOLEAN 89 gaussReducer::reduce( fglmVector thev ) 89 gaussReducer::reduce( fglmVector thev ) 90 90 { 91 91 number fac1, fac2; … … 98 98 number vdenom = v.clearDenom(); 99 99 if ( ! nIsOne( vdenom ) && ! nIsZero( vdenom ) ) { 100 100 p.setelem( p.size(), vdenom ); 101 101 } 102 102 else { 103 103 nDelete( & vdenom ); 104 104 } 105 105 number gcd = v.gcd(); 106 106 if ( ! nIsOne( gcd ) && ! nIsZero( gcd ) ) { 107 108 109 110 107 v /= gcd; 108 number temp= nMult( pdenom, gcd ); 109 nDelete( & pdenom ); 110 pdenom= temp; 111 111 } 112 112 nDelete( & gcd ); 113 113 114 114 int k; 115 115 for ( k= 1; k <= size; k++ ) { 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 116 if ( ! v.elemIsZero( perm[k] ) ) { 117 fac1= elems[k].fac; 118 fac2= nCopy( v.getconstelem( perm[k] ) ); 119 v.nihilate( fac1, fac2, elems[k].v ); 120 fac1= nMult( fac1, elems[k].pdenom ); 121 temp= nMult( fac2, pdenom ); 122 nDelete( & fac2 ); 123 fac2= temp; 124 p.nihilate( fac1, fac2, elems[k].p ); 125 temp= nMult( pdenom, elems[k].pdenom ); 126 nDelete( & pdenom ); 127 pdenom= temp; 128 129 nDelete( & fac1 ); 130 nDelete( & fac2 ); 131 number gcd = v.gcd(); 132 if ( ! nIsOne( gcd ) && ! nIsZero( gcd ) ) { 133 v/= gcd; 134 number temp = nMult( pdenom, gcd ); 135 nDelete( & pdenom ); 136 pdenom= temp; 137 } 138 nDelete( & gcd ); 139 gcd= p.gcd(); 140 temp= nGcd( pdenom, gcd ); 141 nDelete( & gcd ); 142 gcd= temp; 143 if ( ! nIsZero( gcd ) && ! nIsOne( gcd ) ) { 144 p/= gcd; 145 temp= nDiv( pdenom, gcd ); 146 nDelete( & pdenom ); 147 pdenom= temp; 148 nNormalize( pdenom ); 149 } 150 nDelete( & gcd ); 151 } 152 152 } 153 153 return ( v.isZero() ); 154 154 } 155 155 156 void 157 gaussReducer::store() 156 void 157 gaussReducer::store() 158 158 { 159 159 // fglmASSERT( size < max ); 160 160 number fac; 161 161 // find the pivot-element in v: 162 162 163 163 size++; 164 164 int k= 1; 165 165 while ( nIsZero(v.getconstelem(k)) || isPivot[k] ) { 166 166 k++; 167 167 } 168 168 // fglmASSERT( k <= dimen, "Error(1) in fglmDdata::pivot-search"); … … 171 171 k++; 172 172 while ( k <= max ) { 173 174 175 176 177 178 179 173 if ( ! nIsZero( v.getconstelem(k) ) && ! isPivot[k] ) { 174 if ( nGreater( v.getconstelem( k ), pivot ) ) { 175 pivot= v.getconstelem( k ); 176 pivotcol= k; 177 } 178 } 179 k++; 180 180 } 181 181 // fglmASSERT( ! nIsZero( pivot ), "Error(2) fglmDdata::Pivotelement ist Null" ); 182 182 isPivot[ pivotcol ]= TRUE; 183 183 perm[size]= pivotcol; 184 184 185 185 pivot= nCopy( v.getconstelem( pivotcol ) ); 186 186 #ifndef HAVE_EXPLICIT_CONSTR … … 191 191 } 192 192 193 fglmVector 194 gaussReducer::getDependence() 193 fglmVector 194 gaussReducer::getDependence() 195 195 { 196 196 nDelete( & pdenom ); -
Singular/fglmhom.cc
r073d2e r5812c69 1 1 // emacs edit mode for this file is -*- C++ -*- 2 // $Id: fglmhom.cc,v 1.1 0 1998-06-15 14:30:06Singular Exp $2 // $Id: fglmhom.cc,v 1.11 1998-09-24 09:59:39 Singular Exp $ 3 3 4 4 /**************************************** 5 5 * Computer Algebra System SINGULAR * 6 6 ****************************************/ 7 /* 7 /* 8 8 * ABSTRACT - The FGLM-Algorithm extended for homogeneous ideals. 9 9 * Calculates via the hilbert-function a groebner basis. … … 18 18 #include "tok.h" 19 19 #include "structs.h" 20 #include "subexpr.h" 20 #include "subexpr.h" 21 21 #include "polys.h" 22 22 #include "ideals.h" … … 62 62 homogElem() : v(), dv(), basis(0), destbasis(0), inDest(FALSE) {} 63 63 homogElem( poly m, int b, BOOLEAN ind ) : 64 basis(b), inDest(ind) 64 basis(b), inDest(ind) 65 65 { 66 67 66 mon.dm= m; 67 mon.sm= NULL; 68 68 } 69 69 }; 70 70 71 struct homogData 71 struct homogData 72 72 { 73 73 ideal sourceIdeal; … … 83 83 int overall; // nur zum testen. 84 84 int numberofdestbasismonoms; 85 // homogData() : sourceHeads(NULL), numSourceHeads(0), monlist(NULL), 86 // 85 // homogData() : sourceHeads(NULL), numSourceHeads(0), monlist(NULL), 86 // numMonoms(0), basisSize(0) {} 87 87 }; 88 88 89 89 int 90 hfglmNextdegree( intvec * source, ideal current, int & deg ) 90 hfglmNextdegree( intvec * source, ideal current, int & deg ) 91 91 { 92 92 int numelems; 93 93 intvec * newhilb = hHstdSeries( current, NULL, currQuotient ); 94 94 95 loop 95 loop 96 96 { 97 if ( deg < newhilb->length() ) 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 if (numelems != 0) 115 116 117 } 97 if ( deg < newhilb->length() ) 98 { 99 if ( deg < source->length() ) 100 numelems= (*newhilb)[deg]-(*source)[deg]; 101 else 102 numelems= (*newhilb)[deg]; 103 } 104 else 105 { 106 if (deg < source->length()) 107 numelems= -(*source)[deg]; 108 else 109 { 110 deg= 0; 111 return 0; 112 } 113 } 114 if (numelems != 0) 115 return numelems; 116 deg++; 117 } 118 118 delete newhilb; 119 119 } 120 120 121 void 121 void 122 122 generateMonoms( poly m, int var, int deg, homogData * dat ) 123 123 { 124 124 if ( var == pVariables ) { 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 if ( !inDest ) 147 148 149 150 151 for ( k= dat->monlistmax; k < (dat->monlistmax+dat->monlistblock); k++ ) 152 153 154 155 156 157 158 159 160 161 162 163 164 125 BOOLEAN inSource = FALSE; 126 BOOLEAN inDest = FALSE; 127 poly mon = pCopy( m ); 128 pSetExp( mon, var, deg ); 129 pSetm( mon ); 130 ++dat->overall; 131 int i; 132 for ( i= dat->numSourceHeads - 1; (i >= 0) && (inSource==FALSE); i-- ) { 133 if ( pDivisibleBy( dat->sourceHeads[i].dm, mon ) ) { 134 inSource= TRUE; 135 } 136 } 137 for ( i= dat->numDestPolys - 1; (i >= 0) && (inDest==FALSE); i-- ) { 138 if ( pDivisibleBy( (dat->destIdeal->m)[i], mon ) ) { 139 inDest= TRUE; 140 } 141 } 142 if ( (!inSource) || (!inDest) ) { 143 int basis = 0; 144 if ( !inSource ) 145 basis= ++(dat->basisSize); 146 if ( !inDest ) 147 ++dat->numberofdestbasismonoms; 148 if ( dat->numMonoms == dat->monlistmax ) { 149 dat->monlist= (homogElem * )ReAlloc( dat->monlist, (dat->monlistmax)*sizeof( homogElem ), (dat->monlistmax+dat->monlistblock) * sizeof( homogElem ) ); 150 int k; 151 for ( k= dat->monlistmax; k < (dat->monlistmax+dat->monlistblock); k++ ) 152 dat->monlist[k].homogElem(); 153 dat->monlistmax+= dat->monlistblock; 154 } 155 dat->monlist[dat->numMonoms]= homogElem( mon, basis, inDest ); 156 dat->numMonoms++; 157 if ( inSource && ! inDest ) PROT( "\\" ); 158 if ( ! inSource && inDest ) PROT( "/" ); 159 if ( ! inSource && ! inDest ) PROT( "." ); 160 } 161 else { 162 pDelete( & mon ); 163 } 164 return; 165 165 } 166 166 else { 167 168 169 170 171 172 173 174 167 poly newm = pCopy( m ); 168 while ( deg >= 0 ) { 169 generateMonoms( newm, var+1, deg, dat ); 170 pIncrExp( newm, var ); 171 pSetm( newm ); 172 deg--; 173 } 174 pDelete( & newm ); 175 175 } 176 176 return; … … 178 178 179 179 void 180 mapMonoms( ring oldRing, homogData & dat ) 180 mapMonoms( ring oldRing, homogData & dat ) 181 181 { 182 182 int * vperm = (int *)Alloc( (currRing->N + 1)*sizeof(int) ); … … 185 185 int s; 186 186 for ( s= dat.numMonoms - 1; s >= 0; s-- ) { 187 // 187 // dat.monlist[s].mon.sm= pPermPoly( dat.monlist[s].mon.dm, vperm, currRing->N, NULL, 0 ); 188 188 // obachman: changed the folowing to reflect the new calling interface of 189 189 // pPermPoly -- Tim please check whether this is correct! 190 dat.monlist[s].mon.sm= pPermPoly( dat.monlist[s].mon.dm, vperm, oldRing, NULL, 0 ); 190 dat.monlist[s].mon.sm= pPermPoly( dat.monlist[s].mon.dm, vperm, oldRing, NULL, 0 ); 191 191 } 192 192 } 193 193 194 194 void 195 getVectorRep( homogData & dat ) 195 getVectorRep( homogData & dat ) 196 196 { 197 197 // Calculate the NormalForms 198 198 int s; 199 199 for ( s= 0; s < dat.numMonoms; s++ ) { 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 200 if ( dat.monlist[s].inDest == FALSE ) { 201 fglmVector v; 202 if ( dat.monlist[s].basis == 0 ) { 203 v= fglmVector( dat.basisSize ); 204 // now the monom is in L(source) 205 PROT( "(" ); 206 poly nf = kNF( dat.sourceIdeal, NULL, dat.monlist[s].mon.sm ); 207 PROT( ")" ); 208 poly temp = nf; 209 while (temp != NULL ) { 210 int t; 211 for ( t= dat.numMonoms - 1; t >= 0; t-- ) { 212 if ( dat.monlist[t].basis > 0 ) { 213 if ( pEqual( dat.monlist[t].mon.sm, temp ) ) { 214 number coeff= nCopy( pGetCoeff( temp ) ); 215 v.setelem( dat.monlist[t].basis, coeff ); 216 } 217 } 218 } 219 pIter(temp); 220 } 221 pDelete( & nf ); 222 } 223 else { 224 PROT( "." ); 225 v= fglmVector( dat.basisSize, dat.monlist[s].basis ); 226 } 227 dat.monlist[s].v= v; 228 } 229 229 } 230 230 } 231 231 232 232 void 233 remapVectors( ring oldring, homogData & dat ) 233 remapVectors( ring oldring, homogData & dat ) 234 234 { 235 235 nSetMap( oldring->ch, oldring->parameter, oldring->P, oldring->minpoly ); 236 236 int s; 237 237 for ( s= dat.numMonoms - 1; s >= 0; s-- ) { 238 239 240 241 242 243 244 245 246 238 if ( dat.monlist[s].inDest == FALSE ) { 239 int k; 240 fglmVector newv( dat.basisSize ); 241 for ( k= dat.basisSize; k > 0; k-- ){ 242 number newnum= nMap( dat.monlist[s].v.getelem( k ) ); 243 newv.setelem( k, newnum ); 244 } 245 dat.monlist[s].dv= newv; 246 } 247 247 } 248 248 } 249 249 250 250 void 251 gaussreduce( homogData & dat, int maxnum, int BS ) 251 gaussreduce( homogData & dat, int maxnum, int BS ) 252 252 { 253 253 int s; … … 256 256 int destbasisSize = 0; 257 257 gaussReducer gauss( dat.basisSize ); 258 258 259 259 for ( s= 0; (s < dat.numMonoms) && (found < maxnum); s++ ) { 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 while ( dat.monlist[l].destbasis != k ) 276 277 278 279 280 281 282 283 // 284 285 286 287 288 289 290 291 292 293 294 295 260 if ( dat.monlist[s].inDest == FALSE ) { 261 if ( gauss.reduce( dat.monlist[s].dv ) == FALSE ) { 262 destbasisSize++; 263 dat.monlist[s].destbasis= destbasisSize; 264 gauss.store(); 265 PROT( "." ); 266 } 267 else { 268 fglmVector p= gauss.getDependence(); 269 poly result = pCopy( dat.monlist[s].mon.dm ); 270 pSetCoeff( result, nCopy( p.getconstelem( p.size() ) ) ); 271 int l = 0; 272 int k; 273 for ( k= 1; k < p.size(); k++ ) { 274 if ( ! p.elemIsZero( k ) ) { 275 while ( dat.monlist[l].destbasis != k ) 276 l++; 277 poly temp = pCopy( dat.monlist[l].mon.dm ); 278 pSetCoeff( temp, nCopy( p.getconstelem( k ) ) ); 279 result= pAdd( result, temp ); 280 } 281 } 282 if ( ! nGreaterZero( pGetCoeff( result ) ) ) result= pNeg( result ); 283 // PROT2( "(%s)", pString( result ) ); 284 PROT( "+" ); 285 found++; 286 (dat.destIdeal->m)[dat.numDestPolys]= result; 287 dat.numDestPolys++; 288 if ( IDELEMS(dat.destIdeal) == dat.numDestPolys ) { 289 pEnlargeSet( & dat.destIdeal->m, IDELEMS( dat.destIdeal ), BS ); 290 IDELEMS( dat.destIdeal )+= BS; 291 } 292 293 } 294 295 } 296 296 } 297 297 PROT2( "(%i", s ); … … 313 313 ring sourceRing = currRing; 314 314 315 intvec * hilb = hHstdSeries( sourceIdeal, NULL, currQuotient ); 315 intvec * hilb = hHstdSeries( sourceIdeal, NULL, currQuotient ); 316 316 int s; 317 317 dat.sourceIdeal= sourceIdeal; 318 318 dat.sourceHeads= (doublepoly *)Alloc( IDELEMS( sourceIdeal ) * sizeof( doublepoly ) ); 319 319 for ( s= IDELEMS( sourceIdeal ) - 1; s >= 0; s-- ) { 320 320 dat.sourceHeads[s].sm= pHead( (sourceIdeal->m)[s] ); 321 321 } 322 322 dat.numSourceHeads= IDELEMS( sourceIdeal ); … … 329 329 nSetMap( sourceRing->ch, sourceRing->parameter, sourceRing->P, sourceRing->minpoly ); 330 330 for ( s= IDELEMS( sourceIdeal ) - 1; s >= 0; s-- ) { 331 331 dat.sourceHeads[s].dm= pPermPoly( dat.sourceHeads[s].sm, vperm, sourceRing, NULL, 0 ); 332 332 } 333 333 … … 336 336 337 337 while ( (numGBelems= hfglmNextdegree( hilb, dat.destIdeal, deg )) != 0 ) { 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 338 int num = 0; // the number of monoms of degree deg 339 PROT2( "deg= %i ", deg ); 340 PROT2( "num= %i\ngen>", numGBelems ); 341 dat.monlistblock= 512; 342 dat.monlistmax= dat.monlistblock; 343 dat.monlist= (homogElem *)Alloc( dat.monlistmax*sizeof( homogElem ) ); 344 int j; 345 for ( j= dat.monlistmax - 1; j >= 0; j-- ) dat.monlist[j].homogElem(); 346 dat.numMonoms= 0; 347 dat.basisSize= 0; 348 dat.overall= 0; 349 dat.numberofdestbasismonoms= 0; 350 351 poly start= pOne(); 352 generateMonoms( start, 1, deg, &dat ); 353 pDelete( & start ); 354 355 PROT2( "(%i/", dat.basisSize ); 356 PROT2( "%i)\nvec>", dat.overall ); 357 // switch to sourceRing and map monoms 358 rSetHdl( sourceRingHdl, TRUE ); 359 mapMonoms( destRing, dat ); 360 getVectorRep( dat ); 361 362 // switch to destination Ring and remap the vectors 363 rSetHdl( destRingHdl, TRUE ); 364 remapVectors( sourceRing, dat ); 365 366 PROT( "<\nred>" ); 367 // now do gaussian reduction 368 gaussreduce( dat, numGBelems, groebnerBS ); 369 370 Free( (ADDRESS)dat.monlist, dat.monlistmax*sizeof( homogElem ) ); 371 PROT( "<\n" ); 372 372 } 373 373 PROT( "\n" ); -
Singular/fglmvec.cc
r073d2e r5812c69 1 1 // emacs edit mode for this file is -*- C++ -*- 2 // $Id: fglmvec.cc,v 1.1 0 1998-06-04 13:39:14 wichmannExp $2 // $Id: fglmvec.cc,v 1.11 1998-09-24 09:59:40 Singular Exp $ 3 3 4 4 /**************************************** 5 5 * Computer Algebra System SINGULAR * 6 6 ****************************************/ 7 /* 7 /* 8 8 * ABSTRACT - The FGLM-Algorithm 9 9 * Implementation of number-vectors for the fglm algorithm. 10 10 * (See fglm.cc). Based on a letter-envelope implementation, mainly 11 * written to be used by the fglm algorithm. Hence they are 11 * written to be used by the fglm algorithm. Hence they are 12 12 * specialized for this purpose. 13 13 */ … … 17 17 #ifdef HAVE_FGLM 18 18 #include "mmemory.h" 19 #include "tok.h" 19 #include "tok.h" 20 20 #include "structs.h" 21 21 #include "numbers.h" … … 38 38 fglmVectorRep() : ref_count(1), N(0), elems(0) {} 39 39 fglmVectorRep( int n, number * e ) : ref_count(1), N(n), elems(e) {} 40 fglmVectorRep( int n ) : ref_count(1), N(n) 41 { 42 43 if ( N == 0 ) 44 45 46 47 48 49 40 fglmVectorRep( int n ) : ref_count(1), N(n) 41 { 42 fglmASSERT( N >= 0, "illegal Vector representation" ); 43 if ( N == 0 ) 44 elems= 0; 45 else { 46 elems= (number *)Alloc( N*sizeof( number ) ); 47 for ( int i= N-1; i >= 0; i-- ) 48 elems[i]= nInit( 0 ); 49 } 50 50 } 51 51 ~fglmVectorRep() 52 52 { 53 54 55 56 57 53 if ( N > 0 ) { 54 for ( int i= N-1; i >= 0; i-- ) 55 nDelete( elems + i ); 56 Free( (ADDRESS)elems, N*sizeof( number ) ); 57 } 58 58 } 59 59 60 60 fglmVectorRep* clone() const 61 61 { 62 63 64 65 66 67 68 69 62 if ( N > 0 ) { 63 number * elems_clone; 64 elems_clone= (number *)Alloc( N*sizeof( number ) ); 65 for ( int i= N-1; i >= 0; i-- ) 66 elems_clone[i] = nCopy( elems[i] ); 67 return new fglmVectorRep( N, elems_clone ); 68 } else 69 return new fglmVectorRep( N, 0 ); 70 70 } 71 71 BOOLEAN deleteObject() { return --ref_count == 0; } … … 75 75 76 76 int size() const { return N; } 77 int isZero() const 78 { 79 80 81 82 83 84 } 85 int numNonZeroElems() const 86 { 87 88 89 90 91 77 int isZero() const 78 { 79 int k; 80 for ( k= N; k > 0; k-- ) 81 if ( ! nIsZero( getconstelem( k ) ) ) 82 return 0; 83 return 1; 84 } 85 int numNonZeroElems() const 86 { 87 int num = 0; 88 int k; 89 for ( k= N; k > 0; k-- ) 90 if ( ! nIsZero( getconstelem( k ) ) ) num++; 91 return num; 92 92 } 93 93 void setelem( int i, number n ) 94 94 { 95 96 97 98 } 99 number ejectelem( int i, number n ) 100 { 101 102 103 104 95 fglmASSERT( 0 < i && i <= N, "setelem: wrong index" ); 96 nDelete( elems + i-1 ); 97 elems[i-1]= n; 98 } 99 number ejectelem( int i, number n ) 100 { 101 fglmASSERT( isUnique(), "should only be called if unique!" ); 102 number temp= elems[i-1]; 103 elems[i-1]= n; 104 return temp; 105 105 } 106 106 number & getelem( int i ) 107 107 { 108 109 108 fglmASSERT( 0 < i && i <= N, "getelem: wrong index" ); 109 return elems[i-1]; 110 110 } 111 111 const number getconstelem( int i) const 112 112 { 113 114 113 fglmASSERT( 0 < i && i <= N, "getconstelem: wrong index" ); 114 return elems[i-1]; 115 115 } 116 116 friend class fglmVector; … … 141 141 { 142 142 if ( rep->deleteObject() ) 143 143 delete rep; 144 144 } 145 145 … … 158 158 159 159 void 160 fglmVector::clearelems() 160 fglmVector::clearelems() 161 161 { 162 162 if ( rep->deleteObject() ) … … 165 165 #endif 166 166 167 void 167 void 168 168 fglmVector::makeUnique() 169 169 { 170 170 if ( rep->refcount() != 1 ) { 171 172 173 } 174 } 175 176 int 171 rep->deleteObject(); 172 rep= rep->clone(); 173 } 174 } 175 176 int 177 177 fglmVector::size() const 178 178 { … … 187 187 188 188 void 189 fglmVector::nihilate( const number fac1, const number fac2, const fglmVector v ) 189 fglmVector::nihilate( const number fac1, const number fac2, const fglmVector v ) 190 190 { 191 191 int i; … … 194 194 fglmASSERT( vsize <= rep->size(), "v has to be smaller oder equal" ); 195 195 if ( rep->isUnique() ) { 196 197 198 199 200 201 202 203 204 205 206 } 207 else 208 { 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 } 224 } 225 226 fglmVector & 196 for ( i= vsize; i > 0; i-- ) { 197 term1= nMult( fac1, rep->getconstelem( i ) ); 198 term2= nMult( fac2, v.rep->getconstelem( i ) ); 199 rep->setelem( i, nSub( term1, term2 ) ); 200 nDelete( &term1 ); 201 nDelete( &term2 ); 202 } 203 for ( i= rep->size(); i > vsize; i-- ) { 204 rep->setelem( i, nMult( fac1, rep->getconstelem( i ) ) ); 205 } 206 } 207 else 208 { 209 number* newelems; 210 newelems= (number *)Alloc( rep->size()*sizeof( number ) ); 211 for ( i= vsize; i > 0; i-- ) { 212 term1= nMult( fac1, rep->getconstelem( i ) ); 213 term2= nMult( fac2, v.rep->getconstelem( i ) ); 214 newelems[i-1]= nSub( term1, term2 ); 215 nDelete( &term1 ); 216 nDelete( &term2 ); 217 } 218 for ( i= rep->size(); i > vsize; i-- ) { 219 newelems[i-1]= nMult( fac1, rep->getconstelem( i ) ); 220 } 221 rep->deleteObject(); 222 rep= new fglmVectorRep( rep->size(), newelems ); 223 } 224 } 225 226 fglmVector & 227 227 fglmVector::operator = ( const fglmVector & v ) 228 228 { 229 229 if ( this != &v ) { 230 231 232 230 if ( rep->deleteObject() ) 231 delete rep; 232 rep = v.rep->copyObject(); 233 233 } 234 234 return *this; … … 239 239 { 240 240 if ( rep->size() == v.rep->size() ) { 241 242 243 244 245 246 247 248 241 if ( rep == v.rep ) return 1; 242 else { 243 int i; 244 for ( i= rep->size(); i > 0; i-- ) 245 if ( ! nEqual( rep->getconstelem( i ), v.rep->getconstelem( i ) ) ) 246 return 0; 247 return 1; 248 } 249 249 } 250 250 return 0; … … 257 257 } 258 258 259 int 259 int 260 260 fglmVector::isZero() 261 261 { … … 263 263 } 264 264 265 int 265 int 266 266 fglmVector::elemIsZero( int i ) 267 267 { … … 276 276 int i; 277 277 if ( rep->isUnique() ) { 278 for ( i= rep->size(); i > 0; i-- ) 279 280 } 281 else 282 { 283 284 285 286 287 288 289 278 for ( i= rep->size(); i > 0; i-- ) 279 rep->setelem( i, nAdd( rep->getconstelem( i ), v.rep->getconstelem( i ) ) ); 280 } 281 else 282 { 283 int n = rep->size(); 284 number* newelems; 285 newelems= (number *)Alloc( n*sizeof( number ) ); 286 for ( i= n; i > 0; i-- ) 287 newelems[i-1]= nAdd( rep->getconstelem( i ), v.rep->getconstelem( i ) ); 288 rep->deleteObject(); 289 rep= new fglmVectorRep( n, newelems ); 290 290 } 291 291 return *this; … … 298 298 int i; 299 299 if ( rep->isUnique() ) { 300 for ( i= rep->size(); i > 0; i-- ) 301 302 } 303 else 304 { 305 306 307 308 309 310 311 300 for ( i= rep->size(); i > 0; i-- ) 301 rep->setelem( i, nSub( rep->getconstelem( i ), v.rep->getconstelem( i ) ) ); 302 } 303 else 304 { 305 int n = rep->size(); 306 number* newelems; 307 newelems= (number *)Alloc( n*sizeof( number ) ); 308 for ( i= n; i > 0; i-- ) 309 newelems[i-1]= nSub( rep->getconstelem( i ), v.rep->getconstelem( i ) ); 310 rep->deleteObject(); 311 rep= new fglmVectorRep( n, newelems ); 312 312 } 313 313 return *this; … … 320 320 int i; 321 321 if ( ! rep->isUnique() ) { 322 323 324 for ( i= s; i > 0; i-- ) 325 326 327 328 } 329 else 330 { 331 for (i= s; i > 0; i-- ) 332 322 number * temp; 323 temp= (number *)Alloc( s*sizeof( number ) ); 324 for ( i= s; i > 0; i-- ) 325 temp[i-1]= nMult( rep->getconstelem( i ), n ); 326 rep->deleteObject(); 327 rep= new fglmVectorRep( s, temp ); 328 } 329 else 330 { 331 for (i= s; i > 0; i-- ) 332 rep->setelem( i, nMult( rep->getconstelem( i ), n ) ); 333 333 } 334 334 return *this; … … 341 341 int i; 342 342 if ( ! rep->isUnique() ) { 343 344 345 346 347 348 349 350 351 } 352 else 353 { 354 355 356 357 343 number * temp; 344 temp= (number *)Alloc( s*sizeof( number ) ); 345 for ( i= s; i > 0; i-- ) { 346 temp[i-1]= nDiv( rep->getconstelem( i ), n ); 347 nNormalize( temp[i-1] ); 348 } 349 rep->deleteObject(); 350 rep= new fglmVectorRep( s, temp ); 351 } 352 else 353 { 354 for (i= s; i > 0; i-- ) { 355 rep->setelem( i, nDiv( rep->getconstelem( i ), n ) ); 356 nNormalize( rep->getelem( i ) ); 357 } 358 358 } 359 359 return *this; 360 360 } 361 361 362 fglmVector 363 operator - ( const fglmVector & v ) 362 fglmVector 363 operator - ( const fglmVector & v ) 364 364 { 365 365 fglmVector temp( v.size() ); … … 367 367 number n ; 368 368 for ( i= v.size(); i > 0; i-- ) { 369 370 371 369 n= nCopy( v.getconstelem( i ) ); 370 n= nNeg( n ); 371 temp.setelem( i, n ); 372 372 } 373 373 return temp; 374 374 } 375 375 376 fglmVector 377 operator + ( const fglmVector & lhs, const fglmVector & rhs ) 376 fglmVector 377 operator + ( const fglmVector & lhs, const fglmVector & rhs ) 378 378 { 379 379 fglmVector temp= lhs; … … 382 382 } 383 383 384 fglmVector 384 fglmVector 385 385 operator - ( const fglmVector & lhs, const fglmVector & rhs ) 386 386 { … … 390 390 } 391 391 392 fglmVector 392 fglmVector 393 393 operator * ( const fglmVector & v, const number n ) 394 394 { … … 413 413 } 414 414 415 const number 415 const number 416 416 fglmVector::getconstelem( int i ) const 417 417 { … … 427 427 } 428 428 429 number 429 number 430 430 fglmVector::gcd() const 431 { 431 { 432 432 int i= rep->size(); 433 433 BOOLEAN found = FALSE; … … 436 436 number current; 437 437 while( i > 0 && ! found ) { 438 439 440 441 442 443 444 445 446 447 438 current= rep->getconstelem( i ); 439 if ( ! nIsZero( current ) ) { 440 theGcd= nCopy( current ); 441 found= TRUE; 442 if ( ! nGreaterZero( theGcd ) ) { 443 theGcd= nNeg( theGcd ); 444 } 445 if ( nIsOne( theGcd ) ) gcdIsOne= TRUE; 446 } 447 i--; 448 448 } 449 449 if ( found ) { 450 451 452 453 454 455 456 457 458 459 460 } 461 else 462 450 while ( i > 0 && ! gcdIsOne ) { 451 current= rep->getconstelem( i ); 452 if ( ! nIsZero( current ) ) { 453 number temp= nGcd( theGcd, current ); 454 nDelete( &theGcd ); 455 theGcd= temp; 456 if ( nIsOne( theGcd ) ) gcdIsOne= TRUE; 457 } 458 i--; 459 } 460 } 461 else 462 theGcd= nInit( 0 ); 463 463 return theGcd; 464 464 } 465 465 466 466 number 467 fglmVector::clearDenom() 467 fglmVector::clearDenom() 468 468 { 469 469 number theLcm = nInit( 1 ); … … 472 472 int i; 473 473 for ( i= size(); i > 0; i-- ) { 474 475 476 477 478 479 474 if ( ! nIsZero( rep->getconstelem(i) ) ) { 475 isZero= FALSE; 476 number temp= nLcm( theLcm, rep->getconstelem( i ) ); 477 nDelete( &theLcm ); 478 theLcm= temp; 479 } 480 480 } 481 481 if ( isZero ) { 482 483 482 nDelete( &theLcm ); 483 theLcm= nInit( 0 ); 484 484 } 485 485 else { 486 487 488 489 490 491 486 if ( ! nIsOne( theLcm ) ) { 487 *this *= theLcm; 488 for ( i= size(); i > 0; i-- ) { 489 nNormalize( rep->getelem( i ) ); 490 } 491 } 492 492 } 493 493 return theLcm; -
Singular/fglmzero.cc
r073d2e r5812c69 1 1 // emacs edit mode for this file is -*- C++ -*- 2 // $Id: fglmzero.cc,v 1.1 7 1998-06-03 15:25:20 obachmanExp $2 // $Id: fglmzero.cc,v 1.18 1998-09-24 09:59:40 Singular Exp $ 3 3 4 4 /**************************************** 5 5 * Computer Algebra System SINGULAR * 6 6 ****************************************/ 7 /* 7 /* 8 8 * ABSTRACT - The FGLM-Algorithm 9 9 * Implementation of the fglm algorithm for 0-dimensional ideals, 10 10 * based on an idea by Faugere/Gianni/Lazard and Mora. 11 * The procedure CalculateFunctionals calculates the functionals 11 * The procedure CalculateFunctionals calculates the functionals 12 12 * which define the given ideal in the source ring. They build the 13 13 * input for GroebnerViaFunctionals, which defines the reduced … … 35 35 #include "fglmgauss.h" 36 36 // assumes, that NOSTREAMIO is set in factoryconf.h, which is included 37 // by templates/list.h. 37 // by templates/list.h. 38 38 #include <templates/ftmpl_list.h> 39 39 #define PROT(msg) … … 46 46 // internal Version: 1.3.1.12 47 47 // ============================================================ 48 //! The idealFunctionals 48 //! The idealFunctionals 49 49 // ============================================================ 50 50 … … 71 71 int * currentSize; 72 72 matHeader ** func; 73 matHeader * grow( int var ); 73 matHeader * grow( int var ); 74 74 public: 75 75 idealFunctionals( int blockSize, int numFuncs ); 76 76 ~idealFunctionals(); 77 77 78 int dimen() const { fglmASSERT( _size>0, "called to early"); return _size; } 78 int dimen() const { fglmASSERT( _size>0, "called to early"); return _size; } 79 79 void endofConstruction(); 80 80 void map( ring source ); … … 85 85 }; 86 86 87 idealFunctionals::idealFunctionals( int blockSize, int numFuncs ) 87 idealFunctionals::idealFunctionals( int blockSize, int numFuncs ) 88 88 { 89 89 int k; … … 94 94 95 95 currentSize= (int *)Alloc( _nfunc*sizeof( int ) ); 96 for ( k= _nfunc-1; k >= 0; k-- ) 97 96 for ( k= _nfunc-1; k >= 0; k-- ) 97 currentSize[k]= 0; 98 98 99 99 func= (matHeader **)Alloc( _nfunc*sizeof( matHeader * ) ); 100 for ( k= _nfunc-1; k >= 0; k-- ) 101 100 for ( k= _nfunc-1; k >= 0; k-- ) 101 func[k]= (matHeader *)Alloc( _max*sizeof( matHeader ) ); 102 102 } 103 103 … … 110 110 matElem * elemp; 111 111 for ( k= _nfunc-1; k >= 0; k-- ) { 112 113 114 115 116 117 118 119 112 for ( l= _size-1, colp= func[k]; l >= 0; l--, colp++ ) { 113 if ( ( colp->owner == TRUE ) && ( colp->size > 0 ) ) { 114 for ( row= colp->size-1, elemp= colp->elems; row >= 0; row--, elemp++ ) 115 nDelete( & elemp->elem ); 116 Free( (ADDRESS)colp->elems, colp->size*sizeof( matElem ) ); 117 } 118 } 119 Free( (ADDRESS)func[k], _max*sizeof( matHeader ) ); 120 120 } 121 121 Free( (ADDRESS)func, _nfunc*sizeof( matHeader * ) ); … … 124 124 125 125 void 126 idealFunctionals::endofConstruction() 126 idealFunctionals::endofConstruction() 127 127 { 128 128 _size= currentSize[0]; … … 130 130 131 131 void 132 idealFunctionals::map( ring source ) 132 idealFunctionals::map( ring source ) 133 133 { 134 134 // maps from ring source to currentRing. … … 141 141 maFindPerm( source->names, source->N, NULL, 0, currRing->names, currRing->N, NULL, 0, perm, NULL ); 142 142 nSetMap( source->ch, source->parameter, source->P, source->minpoly ); 143 143 144 144 matHeader ** temp = (matHeader **)Alloc( _nfunc*sizeof( matHeader * )); 145 145 for ( var= 0; var < _nfunc; var ++ ) { 146 147 148 149 150 151 152 153 154 155 146 for ( col= 0, colp= func[var]; col < _size; col++, colp++ ) { 147 if ( colp->owner == TRUE ) { 148 for ( row= colp->size-1, elemp= colp->elems; row >= 0; row--, elemp++ ) { 149 newelem= nMap( elemp->elem ); 150 nDelete( & elemp->elem ); 151 elemp->elem= newelem; 152 } 153 } 154 } 155 temp[ perm[var+1]-1 ]= func[var]; 156 156 } 157 157 Free( (ADDRESS)func, _nfunc*sizeof( matHeader * ) ); … … 161 161 162 162 matHeader * 163 idealFunctionals::grow( int var ) 163 idealFunctionals::grow( int var ) 164 164 { 165 165 if ( currentSize[var-1] == _max ) { 166 167 168 169 166 int k; 167 for ( k= _nfunc; k > 0; k-- ) 168 func[k-1]= (matHeader *)ReAlloc( func[k-1], _max*sizeof( matHeader ), (_max + _block)*sizeof( matHeader ) ); 169 _max+= _block; 170 170 } 171 171 currentSize[var-1]++; 172 return func[var-1] + currentSize[var-1] - 1; 172 return func[var-1] + currentSize[var-1] - 1; 173 173 } 174 174 … … 183 183 elems->elem= nInit( 1 ); 184 184 for ( k= divisors[0]; k > 0; k-- ) { 185 186 187 188 189 190 191 } 192 } 193 194 185 fglmASSERT( 0 < divisors[k] && divisors[k] <= _nfunc, "wrong divisor" ); 186 matHeader * colp = grow( divisors[k] ); 187 colp->size= 1; 188 colp->elems= elems; 189 colp->owner= owner; 190 owner= FALSE; 191 } 192 } 193 194 195 195 void 196 196 idealFunctionals::insertCols( int * divisors, const fglmVector to ) … … 204 204 BOOLEAN owner = TRUE; 205 205 if ( numElems > 0 ) { 206 207 208 209 210 211 212 206 elems= (matElem *)Alloc( numElems * sizeof( matElem ) ); 207 for ( k= 1, l= 1, elemp= elems; k <= numElems; k++, elemp++ ) { 208 while ( nIsZero( to.getconstelem(l) ) ) l++; 209 elemp->row= l; 210 elemp->elem= nCopy( to.getconstelem( l ) ); 211 l++; // hochzaehlen, damit wir nicht noch einmal die gleiche Stelle testen 212 } 213 213 } 214 214 else 215 215 elems= NULL; 216 216 for ( k= divisors[0]; k > 0; k-- ) { 217 218 219 220 221 222 217 fglmASSERT( 0 < divisors[k] && divisors[k] <= _nfunc, "wrong divisor" ); 218 matHeader * colp = grow( divisors[k] ); 219 colp->size= numElems; 220 colp->elems= elems; 221 colp->owner= owner; 222 owner= FALSE; 223 223 } 224 224 } … … 236 236 fglmASSERT( currentSize[var-1]+1 >= vsize, "wrong v.size()" ); 237 237 for ( k= 1, colp= func[var-1]; k <= vsize; k++, colp++ ) { 238 239 240 241 242 243 244 245 246 } 247 238 factor= v.getconstelem( k ); 239 if ( ! nIsZero( factor ) ) { 240 for ( l= colp->size-1, elemp= colp->elems; l >= 0; l--, elemp++ ) { 241 temp= nMult( factor, elemp->elem ); 242 number newelem= nAdd( result.getconstelem( elemp->row ), temp ); 243 nDelete( & temp ); 244 nNormalize( newelem ); 245 result.setelem( elemp->row, newelem ); 246 } 247 } 248 248 } 249 249 return result; … … 260 260 int k, l; 261 261 for ( k= 1, colp= func[var-1]; k <= _size; k++, colp++ ) { 262 263 264 265 266 267 268 269 270 271 262 factor= v.getconstelem( k ); 263 if ( ! nIsZero( factor ) ) { 264 for ( l= colp->size-1, elemp= colp->elems; l >= 0; l--, elemp++ ) { 265 temp= nMult( factor, elemp->elem ); 266 number newelem= nAdd( result.getconstelem( elemp->row ), temp ); 267 nDelete( & temp ); 268 nNormalize( newelem ); 269 result.setelem( elemp->row, newelem ); 270 } 271 } 272 272 } 273 273 return result; … … 275 275 276 276 // ============================================================ 277 //! The old basis 277 //! The old basis 278 278 // ============================================================ 279 279 … … 283 283 // the basis when the normalForm was computed. 284 284 // monom gets deleted when borderElem comes out of scope. 285 class borderElem 285 class borderElem 286 286 { 287 287 public: … … 292 292 ~borderElem() { pDelete1( &monom ); } 293 293 #ifndef HAVE_EXPLICIT_CONSTR 294 void insertElem( poly p, fglmVector n ) 294 void insertElem( poly p, fglmVector n ) 295 295 { 296 297 296 monom= p; 297 nf= n; 298 298 } 299 299 #endif … … 303 303 // The declaration of class fglmSelem is found in fglm.h 304 304 305 fglmSelem::fglmSelem( poly p, int var ) : numVars( 0 ), monom( p ) 306 { 307 for ( int k = pVariables; k > 0; k-- ) 308 if ( pGetExp( monom, k ) > 0 ) 309 305 fglmSelem::fglmSelem( poly p, int var ) : numVars( 0 ), monom( p ) 306 { 307 for ( int k = pVariables; k > 0; k-- ) 308 if ( pGetExp( monom, k ) > 0 ) 309 numVars++; 310 310 divisors= (int *)Alloc( (numVars+1)*sizeof( int ) ); 311 311 divisors[0]= 0; … … 313 313 } 314 314 315 void 315 void 316 316 fglmSelem::cleanup() 317 317 { … … 355 355 }; 356 356 357 fglmSdata::fglmSdata( const ideal thisIdeal ) 357 fglmSdata::fglmSdata( const ideal thisIdeal ) 358 358 { 359 359 // An dieser Stelle kann die BlockSize ( =BS ) noch sinnvoller berechnet … … 365 365 basisMax= basisBS; 366 366 basisSize= 0; 367 basis= (polyset)Alloc( basisMax*sizeof( poly ) ); 367 basis= (polyset)Alloc( basisMax*sizeof( poly ) ); 368 368 369 369 borderBS= 100; … … 382 382 { 383 383 for ( int k = basisSize; k > 0; k-- ) 384 384 pDelete1( basis + k ); //. rem: basis runs from basis[1]..basis[basisSize] 385 385 Free( (ADDRESS)basis, basisMax*sizeof( poly ) ); 386 386 #ifndef HAVE_EXPLICIT_CONSTR … … 388 388 #else 389 389 for ( int l = borderSize; l > 0; l-- ) 390 391 390 // rem: the polys of borderElem are deleted via ~borderElem() 391 border[l].~borderElem(); 392 392 Free( (ADDRESS)border, borderMax*sizeof( borderElem ) ); 393 393 #endif 394 394 } 395 395 396 // Inserts poly p without copying into basis, reAllocs Memory if necessary, 396 // Inserts poly p without copying into basis, reAllocs Memory if necessary, 397 397 // increases basisSize and returns the new basisSize. 398 398 // Remember: The elements of basis are deleted via pDelete in ~fglmSdata! 399 399 // Sets m= NULL to indicate that now basis is ow(e?)ing the poly. 400 400 int 401 fglmSdata::newBasisElem( poly & m ) 401 fglmSdata::newBasisElem( poly & m ) 402 402 { 403 403 basisSize++; 404 404 if ( basisSize == basisMax ) { 405 406 405 basis= (polyset)ReAlloc( basis, basisMax*sizeof( poly ), (basisMax + basisBS)*sizeof( poly ) ); 406 basisMax+= basisBS; 407 407 } 408 408 basis[basisSize]= m; … … 411 411 } 412 412 413 // Inserts poly p and fglmvector v without copying into border, reAllocs Memory 413 // Inserts poly p and fglmvector v without copying into border, reAllocs Memory 414 414 // if necessary, and increases borderSize. 415 415 // Remember: The poly of border is deleted via ~borderElem in ~fglmSdata! … … 421 421 if ( borderSize == borderMax ) { 422 422 #ifndef HAVE_EXPLICIT_CONSTR 423 424 425 426 427 428 429 423 borderElem * tempborder = new borderElem[ borderMax+borderBS ]; 424 for ( int k = 0; k < borderMax; k++ ) { 425 tempborder[k]= border[k]; 426 border[k].insertElem( NULL, fglmVector() ); 427 } 428 delete [] border; 429 border= tempborder; 430 430 #else 431 431 border= (borderElem *)ReAlloc( border, borderMax*sizeof( borderElem ), (borderMax + borderBS)*sizeof( borderElem ) ); 432 432 #endif 433 433 borderMax+= borderBS; 434 434 } 435 435 #ifndef HAVE_EXPLICIT_CONSTR … … 449 449 } 450 450 451 // Multiplies basis[basisSize] with all ringvariables and inserts the new monomials 451 // Multiplies basis[basisSize] with all ringvariables and inserts the new monomials 452 452 // into the list of candidates, according to the given order. If a monomial already 453 // exists, then "insertions" and "divisors" are updated. 454 // Assumes that ringvar(k) < ringvar(l) for k > l 453 // exists, then "insertions" and "divisors" are updated. 454 // Assumes that ringvar(k) < ringvar(l) for k > l 455 455 void 456 456 fglmSdata::updateCandidates() … … 464 464 int state = 0; 465 465 while ( k >= 1 ) { 466 newmonom = pCopy( m ); 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 466 newmonom = pCopy( m ); 467 pIncrExp( newmonom, k ); 468 pSetm( newmonom ); 469 done= FALSE; 470 while ( list.hasItem() && (done == FALSE) ) { 471 if ( (state= pComp( list.getItem().monom, newmonom )) < 0 ) 472 list++; 473 else done= TRUE; 474 } 475 if ( done == FALSE ) { 476 nlist.append( fglmSelem( newmonom, k ) ); 477 break; 478 } 479 if ( state == 0 ) { 480 list.getItem().newDivisor( k ); 481 pDelete1( &newmonom ); 482 } 483 else { 484 list.insert( fglmSelem( newmonom, k ) ); 485 } 486 k--; 487 487 } 488 488 while ( --k >= 1 ) { 489 490 491 492 489 newmonom= pCopy( m ); // HIER 490 pIncrExp( newmonom, k ); 491 pSetm( newmonom ); 492 nlist.append( fglmSelem( newmonom, k ) ); 493 493 } 494 494 } … … 498 498 // coefficients.) 499 499 int 500 fglmSdata::getEdgeNumber( const poly m ) const 501 { 502 for ( int k = idelems; k > 0; k-- ) 503 504 500 fglmSdata::getEdgeNumber( const poly m ) const 501 { 502 for ( int k = idelems; k > 0; k-- ) 503 if ( pEqual( m, (theIdeal->m)[k-1] ) ) 504 return k; 505 505 return 0; 506 506 } 507 507 508 // Returns the fglmVector v, s.t. 508 // Returns the fglmVector v, s.t. 509 509 // p = v[1]*basis(1) + .. + v[basisSize]*basis(basisSize) 510 510 // So the size of v depends on the current size of the basis. … … 512 512 // smaller than basis[basisSize] and that basis[k] < basis[l] for k < l. 513 513 fglmVector 514 fglmSdata::getVectorRep( const poly p ) 514 fglmSdata::getVectorRep( const poly p ) 515 515 { 516 516 fglmVector temp( basisSize ); … … 518 518 int num = basisSize; 519 519 while ( m != NULL ) { 520 521 522 523 524 525 526 527 528 else { 529 530 531 532 533 534 535 536 537 538 539 540 520 int comp = pComp( m, basis[num] ); 521 if ( comp == 0 ) { 522 fglmASSERT( num > 0, "Error(1) in fglmSdata::getVectorRep" ); 523 number newelem = nCopy( pGetCoeff( m ) ); 524 temp.setelem( num, newelem ); 525 num--; 526 pIter( m ); 527 } 528 else { 529 if ( comp < 0 ) { 530 num--; 531 } 532 else { 533 // This is the place where we can detect if the sourceIdeal 534 // is not reduced. In this case m is not in basis[]. Since basis[] 535 // is ordered this is then and only then the case, if basis[i]<m 536 // and basis[j]>m for all j>i 537 _state= FALSE; 538 return temp; 539 } 540 } 541 541 } 542 542 return temp; … … 545 545 // Searches through the border for a monomoial bm which devides m and returns 546 546 // its normalform in vector representation. 547 // var contains the number of the variable v, s.t. bm = m * v 547 // var contains the number of the variable v, s.t. bm = m * v 548 548 fglmVector 549 549 fglmSdata::getBorderDiv( const poly m, int & var ) const … … 551 551 // int num2 = borderSize; 552 552 // while ( num2 > 0 ) { 553 // 554 // 555 // 556 // 557 // 558 // 559 // 560 // 561 // 553 // poly temp = border[num2].monom; 554 // if ( pDivisibleBy( temp, m ) ) { 555 // poly divisor = pDivideM( m, temp ); 556 // int var = pIsPurePower( divisor ); 557 // if ( (var != 0) && (pGetCoeff( divisor, var ) == 1) ) { 558 // Print( "poly %s divides poly %s", pString( temp ), pString( m ) ); 559 // } 560 // } 561 // num2--; 562 562 // } 563 563 int num = borderSize; 564 564 while ( num > 0 ) { 565 566 567 568 569 if ( (pGetExp( m, var ) - pGetExp( temp, var )) == 1 ) 570 571 572 573 574 565 poly temp = border[num].monom; 566 if ( pDivisibleBy( temp, m ) ) { 567 var = pVariables; 568 while ( var > 0 ) { 569 if ( (pGetExp( m, var ) - pGetExp( temp, var )) == 1 ) 570 return border[num].nf; 571 var--; 572 } 573 } 574 num--; 575 575 } 576 576 return fglmVector(); 577 577 } 578 578 579 // Calculates the defining Functionals for the ideal "theIdeal" and 579 // Calculates the defining Functionals for the ideal "theIdeal" and 580 580 // returns them in "l". 581 581 // The ideal has to be zero-dimensional and reduced and has to be a 582 582 // real subset of the polynomal ring. 583 // In any case it has to be zero-dimensional and minimal (check this 583 // In any case it has to be zero-dimensional and minimal (check this 584 584 // via fglmIdealcheck). Any minimal but not reduced ideal is detected. 585 585 // In this case it returns FglmNotReduced. … … 600 600 STICKYPROT("."); 601 601 while ( data.candidatesLeft() == TRUE ) { 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 602 fglmSelem candidate = data.nextCandidate(); 603 if ( candidate.isBasisOrEdge() == TRUE ) { 604 int edge = data.getEdgeNumber( candidate.monom ); 605 if ( edge != 0 ) { 606 // now candidate is an edge, i.e. we know its normalform: 607 // NF(p) = - ( tail(p)/LC(p) ) 608 poly nf = data.getSpanPoly( edge ); 609 pNorm( nf ); 610 pDelete1( &nf ); //. deletes the leadingmonomial 611 nf= pNeg( nf ); 612 fglmVector nfv = data.getVectorRep( nf ); 613 l.insertCols( candidate.divisors, nfv ); 614 data.newBorderElem( candidate.monom, nfv ); 615 pDelete( &nf ); 616 STICKYPROT( "+" ); 617 } 618 else { 619 int basis= data.newBasisElem( candidate.monom ); 620 data.updateCandidates(); 621 l.insertCols( candidate.divisors, basis ); 622 STICKYPROT( "." ); 623 } 624 } 625 else { 626 int var = 0; 627 fglmVector temp = data.getBorderDiv( candidate.monom, var ); 628 fglmASSERT( var > 0, "this should never happen" ); 629 fglmVector nfv = l.addCols( var, data.getBasisSize(), temp ); 630 data.newBorderElem( candidate.monom, nfv ); 631 l.insertCols( candidate.divisors, nfv ); 632 STICKYPROT( "-" ); 633 } 634 candidate.cleanup(); 635 635 } //. while ( data.candidatesLeft() == TRUE ) 636 636 l.endofConstruction(); … … 645 645 // The declaration of class fglmDelem is found in fglm.h 646 646 647 fglmDelem::fglmDelem( poly & m, fglmVector mv, int v ) : insertions( 0 ), v( mv ), var( v ) 648 { 649 monom= m; 647 fglmDelem::fglmDelem( poly & m, fglmVector mv, int v ) : insertions( 0 ), v( mv ), var( v ) 648 { 649 monom= m; 650 650 m= NULL; 651 651 for ( int k = pVariables; k > 0; k-- ) 652 653 652 if ( pGetExp( monom, k ) > 0 ) 653 insertions++; 654 654 // Wir gehen davon aus, dass ein fglmDelem direkt bei der Erzeugung 655 655 // auch in eine Liste eingefuegt wird. Daher wird hier automatisch … … 662 662 { 663 663 if ( monom != NULL ) { 664 664 pDelete1( &monom ); 665 665 } 666 666 } … … 679 679 oldGaussElem( const fglmVector newv, const fglmVector newp, number & newpdenom, number & newfac ) : v( newv ), p( newp ), pdenom( newpdenom ), fac( newfac ) 680 680 { 681 682 681 newpdenom= NULL; 682 newfac= NULL; 683 683 } 684 684 ~oldGaussElem(); 685 685 #ifndef HAVE_EXPLICIT_CONSTR 686 void insertElem( const fglmVector newv, const fglmVector newp, number & newpdenom, number & newfac ) 686 void insertElem( const fglmVector newv, const fglmVector newp, number & newpdenom, number & newfac ) 687 687 { 688 689 690 691 692 693 688 v= newv; 689 p= newp; 690 pdenom= newpdenom; 691 fac= newfac; 692 newpdenom= NULL; 693 newfac= NULL; 694 694 } 695 695 #endif … … 703 703 704 704 705 class fglmDdata 705 class fglmDdata 706 706 { 707 707 private: … … 712 712 int basisSize; //. the CURRENT basisSize, i.e. basisSize <= dimen 713 713 polyset basis; // [1]..[dimen]. The monoms of the new Vectorspace-basis 714 714 715 715 int groebnerBS; 716 716 int groebnerSize; … … 729 729 void newGroebnerPoly( fglmVector & v, poly & p ); 730 730 void gaussreduce( fglmVector & v, fglmVector & p, number & denom ); 731 ideal buildIdeal() 731 ideal buildIdeal() 732 732 { 733 734 733 idSkipZeroes( destId ); 734 return destId; 735 735 } 736 736 }; … … 763 763 delete [] gauss; 764 764 #else 765 for ( k= dimen; k > 0; k-- ) 766 765 for ( k= dimen; k > 0; k-- ) 766 gauss[k].~oldGaussElem(); 767 767 Free( (ADDRESS)gauss, (dimen+1)*sizeof( oldGaussElem ) ); 768 768 #endif … … 771 771 //. Remember: There is no poly in basis[0], thus k > 0 772 772 for ( k= dimen; k > 0; k-- ) 773 773 pDelete1( basis + k ); 774 774 Free( (ADDRESS)basis, (dimen+1)*sizeof( poly ) ); 775 775 } 776 776 777 777 fglmDelem 778 fglmDdata::nextCandidate() 778 fglmDdata::nextCandidate() 779 779 { 780 780 fglmDelem result = nlist.getFirst(); … … 783 783 } 784 784 785 void 785 void 786 786 fglmDdata::newBasisElem( poly & m, fglmVector v, fglmVector p, number & denom ) 787 787 { … … 793 793 int k= 1; 794 794 while ( nIsZero(v.getconstelem(k)) || isPivot[k] ) { 795 795 k++; 796 796 } 797 797 fglmASSERT( k <= dimen, "Error(1) in fglmDdata::pivot-search"); … … 800 800 k++; 801 801 while ( k <= dimen ) { 802 803 804 805 806 807 808 802 if ( ! nIsZero( v.getconstelem(k) ) && ! isPivot[k] ) { 803 if ( nGreater( v.getconstelem( k ), pivot ) ) { 804 pivot= v.getconstelem( k ); 805 pivotcol= k; 806 } 807 } 808 k++; 809 809 } 810 810 fglmASSERT( ! nIsZero( pivot ), "Error(2) fglmDdata::Pivotelement ist Null" ); 811 811 isPivot[ pivotcol ]= TRUE; 812 812 perm[basisSize]= pivotcol; 813 813 814 814 pivot= nCopy( v.getconstelem( pivotcol ) ); 815 815 #ifndef HAVE_EXPLICIT_CONSTR … … 829 829 int state = 0; 830 830 while ( k >= 1 ) { 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 831 newmonom = pCopy( m ); 832 pIncrExp( newmonom, k ); 833 pSetm( newmonom ); 834 done= FALSE; 835 while ( list.hasItem() && (done == FALSE) ) { 836 if ( (state= pComp( list.getItem().monom, newmonom )) < 0 ) 837 list++; 838 else done= TRUE; 839 } 840 if ( done == FALSE ) { 841 nlist.append( fglmDelem( newmonom, v, k ) ); 842 break; 843 } 844 if ( state == 0 ) { 845 list.getItem().newDivisor(); 846 pDelete1( & newmonom ); 847 } 848 else { 849 list.insert( fglmDelem( newmonom, v, k ) ); 850 } 851 k--; 852 852 } 853 853 while ( --k >= 1 ) { 854 855 856 857 858 } 859 } 860 861 void 862 fglmDdata::newGroebnerPoly( fglmVector & p, poly & m ) 854 newmonom= pCopy( m ); 855 pIncrExp( newmonom, k ); 856 pSetm( newmonom ); 857 nlist.append( fglmDelem( newmonom, v, k ) ); 858 } 859 } 860 861 void 862 fglmDdata::newGroebnerPoly( fglmVector & p, poly & m ) 863 863 // Inserts gp = p[1]*basis(1)+..+p[basisSize]*basis(basisSize)+p[basisSize+1]*m as 864 864 // a new groebner polynomial for the ideal. … … 873 873 m= NULL; 874 874 if ( nGetChar() > 0 ) { 875 876 p /= lead; 877 875 number lead = nCopy( p.getconstelem( basisSize+1 ) ); 876 p /= lead; 877 nDelete( & lead ); 878 878 } 879 879 if ( nGetChar() == 0 ) { 880 881 882 if ( ! nIsOne( gcd ) ) 883 884 880 number gcd= p.gcd(); 881 fglmASSERT( ! nIsZero( gcd ), "FATAL: gcd and thus p is zero" ); 882 if ( ! nIsOne( gcd ) ) 883 p /= gcd; 884 nDelete( & gcd ); 885 885 } 886 886 pSetCoeff( result, nCopy( p.getconstelem( basisSize+1 ) ) ); 887 887 for ( k= basisSize; k > 0; k-- ) { 888 889 890 891 892 888 if ( ! nIsZero( p.getconstelem( k ) ) ) { 889 temp->next= pCopy( basis[k] ); 890 pIter( temp ); 891 pSetCoeff( temp, nCopy( p.getconstelem( k ) ) ); 892 } 893 893 } 894 894 pSetm( result ); 895 895 if ( ! nGreaterZero( pGetCoeff( result ) ) ) result= pNeg( result ); 896 896 if ( groebnerSize == IDELEMS( destId ) ) { 897 898 897 pEnlargeSet( & destId->m, IDELEMS( destId ), groebnerBS ); 898 IDELEMS( destId )+= groebnerBS; 899 899 } 900 900 (destId->m)[groebnerSize]= result; … … 903 903 904 904 void 905 fglmDdata::gaussreduce( fglmVector & v, fglmVector & p, number & pdenom ) 905 fglmDdata::gaussreduce( fglmVector & v, fglmVector & p, number & pdenom ) 906 906 { 907 907 int k; … … 912 912 number vdenom = v.clearDenom(); 913 913 if ( ! nIsOne( vdenom ) && ! nIsZero( vdenom ) ) { 914 914 p.setelem( p.size(), vdenom ); 915 915 } 916 916 else { 917 917 nDelete( &vdenom ); 918 918 } 919 919 number gcd = v.gcd(); 920 920 if ( ! nIsOne( gcd ) && ! nIsZero( gcd ) ) { 921 922 923 924 921 v /= gcd; 922 number temp= nMult( pdenom, gcd ); 923 nDelete( &pdenom ); 924 pdenom= temp; 925 925 } 926 926 nDelete( & gcd ); … … 928 928 for ( k= 1; k <= basisSize; k++ ) { 929 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 930 if ( ! v.elemIsZero( perm[k] ) ) { 931 fac1= gauss[k].fac; 932 fac2= nCopy( v.getconstelem( perm[k] ) ); 933 v.nihilate( fac1, fac2, gauss[k].v ); 934 fac1= nMult( fac1, gauss[k].pdenom ); 935 temp= nMult( fac2, pdenom ); 936 nDelete( &fac2 ); 937 fac2= temp; 938 p.nihilate( fac1, fac2, gauss[k].p ); 939 temp= nMult( pdenom, gauss[k].pdenom ); 940 nDelete( &pdenom ); 941 pdenom= temp; 942 943 nDelete( & fac1 ); 944 nDelete( & fac2 ); 945 number gcd = v.gcd(); 946 if ( ! nIsOne( gcd ) && ! nIsZero( gcd ) ) { 947 v /= gcd; 948 number temp= nMult( pdenom, gcd ); 949 nDelete( &pdenom ); 950 pdenom= temp; 951 } 952 nDelete( & gcd ); 953 gcd= p.gcd(); 954 temp= nGcd( pdenom, gcd ); 955 nDelete( &gcd ); 956 gcd= temp; 957 if ( ! nIsZero( gcd ) && ! nIsOne( gcd ) ) { 958 p /= gcd; 959 temp= nDiv( pdenom, gcd ); 960 nDelete( & pdenom ); 961 pdenom= temp; 962 nNormalize( pdenom ); 963 } 964 nDelete( & gcd ); 965 } 966 966 } 967 967 } … … 971 971 // Calculates the groebnerBasis for the ideal which is defined by l. 972 972 // The dimension of l has to be finite. 973 // The result is in reduced form. 973 // The result is in reduced form. 974 974 { 975 975 fglmDdata data( l.dimen() ); 976 976 977 977 // insert pOne() and update workinglist: 978 978 poly one = pOne(); … … 982 982 STICKYPROT( "." ); 983 983 while ( data.candidatesLeft() == TRUE ) { 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 984 fglmDelem candidate = data.nextCandidate(); 985 if ( candidate.isBasisOrEdge() == TRUE ) { 986 // Now we have the chance to find a new groebner polynomial 987 988 // v is the vector-representation of candidate.monom 989 // some elements of v are zeroed in data.gaussreduce(). Which 990 // ones and how this was done is stored in p. 991 // originalV containes the unchanged v, which is later inserted 992 // into the working list (via data.updateCandidates(). 993 fglmVector v = l.multiply( candidate.v, candidate.var ); 994 fglmVector originalV = v; 995 fglmVector p( data.getBasisSize()+1, data.getBasisSize()+1 ); 996 number pdenom = NULL; 997 data.gaussreduce( v, p, pdenom ); 998 if ( v.isZero() ) { 999 // Now v is linear dependend to the already found basis elements. 1000 // This means that v (rsp. candidate.monom) is the leading 1001 // monomial of the next groebner-basis polynomial. 1002 data.newGroebnerPoly( p, candidate.monom ); 1003 nDelete( & pdenom ); 1004 STICKYPROT( "+" ); 1005 } 1006 else { 1007 // no linear dependence could be found, so v ( rsp. monom ) 1008 // is a basis monomial. We store the zeroed version ( i.e. v 1009 // and not originalV ) as well as p, the denomiator and all 1010 // the other stuff. 1011 // erst updateCandidates, dann newBasisELem!!! 1012 data.updateCandidates( candidate.monom, originalV ); 1013 data.newBasisElem( candidate.monom, v, p, pdenom ); 1014 STICKYPROT( "." ); 1015 } 1016 } 1017 else { 1018 STICKYPROT( "-" ); 1019 candidate.cleanup(); 1020 } 1021 1021 } //. while data.candidatesLeft() 1022 1022 STICKYPROT( "\n" ); … … 1031 1031 fglmVector p; 1032 1032 ideal destIdeal = idInit( pVariables, 1 ); 1033 1033 1034 1034 int i; 1035 1035 BOOLEAN isZero; 1036 1036 for ( i= 1; i <= pVariables; i++ ) { 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1037 // main loop 1038 STICKYPROT2( "(%i)", i ); 1039 gaussReducer gauss( l.dimen() ); 1040 isZero= FALSE; 1041 v= fglmVector( l.dimen(), 1 ); 1042 while ( isZero == FALSE ) { 1043 if ( (isZero= gauss.reduce( v )) == TRUE ) { 1044 STICKYPROT( "+" ); 1045 p= gauss.getDependence(); 1046 number gcd= p.gcd(); 1047 if ( ! nIsOne( gcd ) ) { 1048 p /= gcd; 1049 } 1050 nDelete( & gcd ); 1051 int k; 1052 poly temp = NULL; 1053 poly result; 1054 for ( k= p.size(); k > 0; k-- ) { 1055 number n = nCopy( p.getconstelem( k ) ); 1056 if ( ! nIsZero( n ) ) { 1057 if ( temp == NULL ) { 1058 result= pOne(); 1059 temp= result; 1060 } 1061 else { 1062 temp->next= pOne(); 1063 pIter( temp ); 1064 } 1065 pSetCoeff( temp, n ); 1066 pSetExp( temp, i, k-1 ); 1067 pSetm( temp ); 1068 } 1069 } 1070 if ( ! nGreaterZero( pGetCoeff( result ) ) ) result= pNeg( result ); 1071 (destIdeal->m)[i-1]= result; 1072 } 1073 else { 1074 STICKYPROT( "." ); 1075 gauss.store(); 1076 v= l.multiply( v, i ); 1077 } 1078 } 1079 1079 } 1080 1080 STICKYPROT( "\n" ); … … 1088 1088 idhdl initialRingHdl = currRingHdl; 1089 1089 BOOLEAN fglmok; 1090 1090 1091 1091 if ( currRingHdl != sourceRingHdl ) 1092 1092 rSetHdl( sourceRingHdl, TRUE ); 1093 1093 idealFunctionals L( 100, pVariables ); 1094 1094 fglmok = CalculateFunctionals( sourceIdeal, L ); 1095 1095 if ( deleteIdeal == TRUE ) 1096 1096 idDelete( & sourceIdeal ); 1097 1097 rSetHdl( destRingHdl, TRUE ); 1098 1098 if ( fglmok == TRUE ) { 1099 1100 1099 L.map( IDRING( sourceRingHdl ) ); 1100 destIdeal= GroebnerViaFunctionals( L ); 1101 1101 } 1102 1102 if ( (switchBack == TRUE) && (currRingHdl != initialRingHdl) ) 1103 1103 rSetHdl( initialRingHdl, TRUE ); 1104 1104 return fglmok; 1105 1105 } 1106 1106 1107 1107 BOOLEAN 1108 FindUnivariateWrapper( ideal source, ideal & destIdeal ) 1108 FindUnivariateWrapper( ideal source, ideal & destIdeal ) 1109 1109 { 1110 1110 BOOLEAN fglmok; 1111 1111 1112 1112 idealFunctionals L( 100, pVariables ); 1113 1113 fglmok = CalculateFunctionals( source, L ); 1114 1114 if ( fglmok == TRUE ) { 1115 1116 1117 } 1118 else 1119 1115 destIdeal= FindUnivariatePolys( L ); 1116 return TRUE; 1117 } 1118 else 1119 return FALSE; 1120 1120 } 1121 1121 -
Singular/getopt.h
r073d2e r5812c69 19 19 #define _GETOPT_H 1 20 20 21 #ifdef 21 #ifdef __cplusplus 22 22 extern "C" { 23 23 #endif … … 60 60 61 61 The field `has_arg' is: 62 no_argument 63 required_argument 64 optional_argument 62 no_argument (or 0) if the option does not take an argument, 63 required_argument (or 1) if the option requires an argument, 64 optional_argument (or 2) if the option takes an optional argument. 65 65 66 66 If the field `flag' is not NULL, it points to a variable that is set … … 77 77 struct option 78 78 { 79 #if 79 #if __STDC__ 80 80 const char *name; 81 81 #else … … 91 91 /* Names for the values of the `has_arg' field of `struct option'. */ 92 92 93 #define no_argument094 #define required_argument 95 #define optional_argument 93 #define no_argument 0 94 #define required_argument 1 95 #define optional_argument 2 96 96 97 97 #if __STDC__ || defined(PROTO) || defined(__MWERKS__) … … 103 103 #endif /* not __GNU_LIBRARY__ */ 104 104 extern int getopt_long (int argc, char *const *argv, const char *shortopts, 105 105 const struct option *longopts, int *longind); 106 106 extern int getopt_long_only (int argc, char *const *argv, 107 108 107 const char *shortopts, 108 const struct option *longopts, int *longind); 109 109 110 110 /* Internal only. Users should not call this directly. */ 111 111 extern int _getopt_internal (int argc, char *const *argv, 112 113 114 112 const char *shortopts, 113 const struct option *longopts, int *longind, 114 int long_only); 115 115 #else /* not __STDC__ */ 116 116 extern int getopt (); … … 121 121 #endif /* not __STDC__ */ 122 122 123 #ifdef 123 #ifdef __cplusplus 124 124 } 125 125 #endif -
Singular/hdegree.cc
r073d2e r5812c69 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: hdegree.cc,v 1.1 2 1998-04-08 10:01:58 pohlExp $ */4 /* $Id: hdegree.cc,v 1.13 1998-09-24 09:59:42 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT - dimension, multiplicity, HC, kbase … … 1158 1158 if (stc[i] && (stc[i][Nvar] >= y)) 1159 1159 { 1160 1161 1160 Istc--; 1161 stc[i] = NULL; 1162 1162 } 1163 1163 } … … 1267 1267 { 1268 1268 Istc--; 1269 1269 sn[i] = NULL; 1270 1270 } 1271 1271 } … … 1282 1282 if (sn[i]) 1283 1283 { 1284 1285 1284 sn[j] = sn[i]; 1285 j++; 1286 1286 } 1287 1287 } … … 1328 1328 { 1329 1329 Istc--; 1330 1330 sn[i] = NULL; 1331 1331 } 1332 1332 } … … 1338 1338 if (sn[i]) 1339 1339 { 1340 1341 1340 sn[j] = sn[i]; 1341 j++; 1342 1342 } 1343 1343 } -
Singular/hutil.cc
r073d2e r5812c69 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: hutil.cc,v 1. 7 1998-04-27 10:19:04 pohlExp $ */4 /* $Id: hutil.cc,v 1.8 1998-09-24 09:59:43 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: Utilities for staircase operations … … 117 117 } 118 118 119 119 120 120 void hComp(scfmon exist, int Nexist, Exponent_t ak, scfmon stc, int *Nstc) 121 121 { … … 224 224 g -= o; 225 225 else 226 226 g = o - g; 227 227 if (g > h) 228 228 h = g; -
Singular/intvec.cc
r073d2e r5812c69 2 2 * Computer Algebra System SINGULAR * 3 3 *****************************************/ 4 /* $Id: intvec.cc,v 1. 9 1998-05-24 09:51:50 obachmanExp $ */4 /* $Id: intvec.cc,v 1.10 1998-09-24 09:59:43 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: class intvec: lists/vectors of integers … … 110 110 } 111 111 } 112 if (j+1<row) 112 if (j+1<row) 113 113 { 114 114 StringAppend("\n"); 115 115 if (spaces>0) StringAppend("%-*.*s",spaces,spaces," "); 116 } 116 } 117 117 } 118 118 } … … 158 158 if (intop == 0) return; 159 159 if (intop<0) intop*=(-1); 160 for (int i=0; i<row*col; i++) 160 for (int i=0; i<row*col; i++) 161 161 { v[i] %= intop; if (v[i]<0) v[i] += intop; } 162 162 } … … 164 164 int intvec::compare(intvec* op) 165 165 { 166 if ((col!=1) ||(op->cols()!=1)) 166 if ((col!=1) ||(op->cols()!=1)) 167 167 { 168 168 if((col!=op->cols()) 169 169 || (row!=op->rows())) 170 170 return -2; 171 } 171 } 172 172 int i; 173 173 for (i=0; i<min(length(),op->length()); i++) -
Singular/ipconv.cc
r073d2e r5812c69 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ipconv.cc,v 1.1 0 1998-05-28 16:50:49Singular Exp $ */4 /* $Id: ipconv.cc,v 1.11 1998-09-24 09:59:44 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: automatic type conversions … … 171 171 static void * iiR2L(void * data) 172 172 { 173 return (void *)syConvRes((syStrategy)data); 173 return (void *)syConvRes((syStrategy)data); 174 174 } 175 175 176 176 static void * iiL2R(void * data) 177 177 { 178 return (void *)syConvList((lists)data); 178 return (void *)syConvList((lists)data); 179 179 } 180 180 #else … … 237 237 // link 238 238 { STRING_CMD, LINK_CMD, iiS2Link }, 239 // resolution -> list 239 // resolution -> list 240 240 { RESOLUTION_CMD, LIST_CMD, iiR2L }, 241 241 // list -> resolution -
Singular/ipid.cc
r073d2e r5812c69 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ipid.cc,v 1.1 6 1998-09-09 13:10:26Singular Exp $ */4 /* $Id: ipid.cc,v 1.17 1998-09-24 09:59:44 Singular Exp $ */ 5 5 6 6 /* … … 126 126 case PROC_CMD: 127 127 len=sizeof(procinfo); 128 128 break; 129 129 //other types: without init (int,script,poly,def,package) 130 130 } … … 421 421 else Print("=======>%s(%x)<====\n", IDID(h), IDID(h)); 422 422 #endif 423 423 424 424 FreeL((ADDRESS)IDID(h)); 425 425 //IDID(h)=NULL; … … 722 722 #if 0 723 723 if(init && ns->isroot) { 724 idhdl pl = enterid( mstrdup("Top"),0, PACKAGE_CMD, 724 idhdl pl = enterid( mstrdup("Top"),0, PACKAGE_CMD, 725 725 &NSROOT(namespaceroot), TRUE ); 726 726 if(pl != NULL) { -
Singular/ipid.h
r073d2e r5812c69 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: ipid.h,v 1.1 5 1998-08-25 13:33:18 krueger Exp $ */6 /* $Id: ipid.h,v 1.16 1998-09-24 09:59:45 Singular Exp $ */ 7 7 /* 8 8 * ABSTRACT: identfier handling … … 150 150 #define NSROOT(a) ((a)->pack->idroot) 151 151 #define NSPACK(a) ((a)->pack) 152 152 153 153 154 154 namerec() { memset(this,0,sizeof(*this)); } -
Singular/khstd.cc
r073d2e r5812c69 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: khstd.cc,v 1. 6 1998-05-14 13:04:15Singular Exp $ */4 /* $Id: khstd.cc,v 1.7 1998-09-24 09:59:46 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT:utils for hilbert driven kStd … … 75 75 PrintS("h"); 76 76 mflush(); 77 } 77 } 78 78 deleteInL(strat->L,&strat->Ll,strat->Ll,strat); 79 79 } … … 93 93 PrintS("h"); 94 94 mflush(); 95 } 95 } 96 96 deleteInL(strat->L,&strat->Ll,strat->Ll,strat); 97 97 } -
Singular/lists.cc
r073d2e r5812c69 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: lists.cc,v 1.1 0 1998-06-18 08:17:41Singular Exp $ */4 /* $Id: lists.cc,v 1.11 1998-09-24 09:59:46 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: handling of the list type … … 217 217 { 218 218 L->m[i].rtyp=typ0; 219 220 221 222 223 224 225 226 219 int j=IDELEMS(r[0])-1; 220 while ((j>0) && (r[0]->m[j]==NULL)) j--; 221 j++; 222 if (j!=IDELEMS(r[0])) 223 { 224 pEnlargeSet(&(r[0]->m),IDELEMS(r[0]),j-IDELEMS(r[0])); 225 IDELEMS(r[0])=j; 226 } 227 227 } 228 228 else -
Singular/longalg.cc
r073d2e r5812c69 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: longalg.cc,v 1.2 4 1998-04-23 09:52:14Singular Exp $ */4 /* $Id: longalg.cc,v 1.25 1998-09-24 09:59:47 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: algebraic numbers … … 1017 1017 if (!naIsChar0) x = napInit(1); 1018 1018 else x = napGcd0(g,h); 1019 //int huhu=0;1020 1019 for (i=(naNumbOfPar-1); i>=0; i--) 1021 1020 { 1022 1021 x->e[i] = napExpi(i,a,b); 1023 //huhu+=x->e[i]; 1024 } 1025 //if (huhu!=0) 1026 //{ 1027 // Print("{%d}",huhu); 1028 //} 1022 } 1029 1023 return x; 1030 1024 } -
Singular/maps.cc
r073d2e r5812c69 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: maps.cc,v 1.1 0 1998-05-14 13:04:20Singular Exp $ */4 /* $Id: maps.cc,v 1.11 1998-09-24 09:59:49 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT - the mapping of polynomials to other rings … … 42 42 int i,modulComp; 43 43 int varnum = preimage_r->N; 44 44 45 45 // for(i=1; i<=varnum; i++) 46 46 // { -
Singular/mmalloc.c
r073d2e r5812c69 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: mmalloc.c,v 1. 5 1998-01-24 17:22:06Singular Exp $ */4 /* $Id: mmalloc.c,v 1.6 1998-09-24 09:59:49 Singular Exp $ */ 5 5 6 6 /* … … 92 92 void _memcpyW(void* p1, void* p2, long l) 93 93 { 94 long _i = l; 95 long* _s1 = (long*) p1; 96 const long* _s2 = (long*) p2; 97 98 for (;;) 99 { 100 *_s1 = *_s2; 101 _i--; 102 if (_i == 0) break; 103 _s1++; 104 _s2++; 105 } 106 } 107 #endif 94 long _i = l; 95 long* _s1 = (long*) p1; 96 const long* _s2 = (long*) p2; 108 97 98 for (;;) 99 { 100 *_s1 = *_s2; 101 _i--; 102 if (_i == 0) break; 103 _s1++; 104 _s2++; 105 } 106 } 107 #endif 108
Note: See TracChangeset
for help on using the changeset viewer.