Changeset dfc6b54 in git
- Timestamp:
- Jul 9, 1997, 5:54:08 PM (27 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 77168428dc3943ad729d2be2f3c095351c9100f2
- Parents:
- 402a6760232836c6ed13a5b716f5a6e618f0c85b
- Location:
- Singular
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/ChangeLog
r402a67 rdfc6b54 1 Wed Jul 9 17:50:23 MET DST 1997: hannes/siebert 2 * added new type (resolution) 3 -> extra.cc, ipid.cc, iparith.cc, ipconv.cc, syz.h, syz1.cc 4 1 5 Fri Jun 20 12:18:10 1997 Olaf Bachmann <obachman@ratchwum.mathematik.uni-kl.de (Olaf Bachmann)> 2 6 -
Singular/extra.cc
r402a67 rdfc6b54 2 2 * Computer Algebra System SINGULAR * 3 3 *****************************************/ 4 /* $Id: extra.cc,v 1.1 3 1997-07-01 15:41:48Singular Exp $ */4 /* $Id: extra.cc,v 1.14 1997-07-09 15:53:51 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: general interface to internals of Singular ("system" command) … … 46 46 #include "ideals.h" 47 47 #include "kstd1.h" 48 #include "syz.h" 48 49 49 50 #ifdef HAVE_FACTORY … … 236 237 if (strcmp((char*)(h->Data()),"tty")==0) 237 238 { 238 239 240 241 242 243 244 if ((h->next!=NULL)&&(h->next->Typ()==INT_CMD))245 {246 fe_use_fgets=(int)h->next->Data();247 fe_set_input_mode();248 }249 #elif HAVE_READLINE250 system("stty sane");251 #endif239 #ifdef HAVE_FEREAD 240 #ifdef HAVE_ATEXIT 241 fe_reset_input_mode(); 242 #else 243 fe_reset_input_mode(0,NULL); 244 #endif 245 #elif defined(HAVE_READLINE) 246 system("stty sane"); 247 #endif 248 if ((h->next!=NULL)&&(h->next->Typ()==INT_CMD)) 249 { 250 fe_use_fgets=(int)h->next->Data(); 251 fe_set_input_mode(); 252 } 252 253 return FALSE; 253 254 } … … 278 279 else 279 280 WerrorS("int expected"); 281 } 282 else 283 /*==================== LaScala ==================================*/ 284 if(strcmp((char*)(h->Data()),"LaScala")==0) 285 { 286 if ((h->next!=NULL) 287 &&((h->next->Typ()==IDEAL_CMD)||(h->next->Typ()==MODUL_CMD))) 288 { 289 int dummy; 290 res->data=(void *)syLaScala3((ideal)h->next->Data(),&dummy); 291 mmTest(res->data,sizeof(ssyStrategy)); 292 syStrategy s=(syStrategy)res->data; 293 for (int i=s->length;i>=0;i--) 294 { 295 if (s->res[i]!=NULL) 296 idTest(s->res[i]); 297 } 298 res->rtyp=RESOLUTION_CMD; 299 return FALSE; 300 } 301 else 302 WerrorS("ideal/module expected"); 280 303 } 281 304 else -
Singular/feread.cc
r402a67 rdfc6b54 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: feread.cc,v 1. 4 1997-04-25 15:03:57 obachmanExp $ */4 /* $Id: feread.cc,v 1.5 1997-07-09 15:53:52 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: input from ttys, simulating fgets … … 585 585 #endif 586 586 587 #include "febase.h" 587 588 #include "ipshell.h" 588 589 … … 651 652 rl_readline_name = "Singular"; 652 653 653 /* Tell the completer that we want a crack first. */ 654 rl_attempted_completion_function = (CPPFunction *)singular_completion; 655 656 /* set the output stream */ 657 if(!isatty(STDOUT_FILENO)) 658 { 659 #ifdef atarist 660 rl_outstream = fopen( "/dev/tty", "w" ); 661 #else 662 rl_outstream = fopen( ttyname(fileno(stdin)), "w" ); 663 #endif 664 } 654 if(!fe_use_fgets) 655 { 656 /* Tell the completer that we want a crack first. */ 657 rl_attempted_completion_function = (CPPFunction *)singular_completion; 658 659 /* set the output stream */ 660 if(!isatty(STDOUT_FILENO)) 661 { 662 #ifdef atarist 663 rl_outstream = fopen( "/dev/tty", "w" ); 664 #else 665 rl_outstream = fopen( ttyname(fileno(stdin)), "w" ); 666 #endif 667 } 668 } 665 669 } 666 670 667 671 char * fe_fgets_stdin_rl(char *pr,char *s, int size) 668 672 { 673 if(fe_use_fgets) 674 { 675 PrintS(pr);mflush(); 676 return fgets(s,size,stdin); 677 } 678 669 679 char *line; 670 680 -
Singular/grammar.y
r402a67 rdfc6b54 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: grammar.y,v 1.1 5 1997-06-25 14:26:24Singular Exp $ */4 /* $Id: grammar.y,v 1.16 1997-07-09 15:53:56 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: SINGULAR shell grammatik … … 137 137 %token <i> NUMBER_CMD 138 138 %token <i> POLY_CMD 139 %token <i> RESOLUTION_CMD 139 140 %token <i> VECTOR_CMD 140 141 /* end types */ -
Singular/iparith.cc
r402a67 rdfc6b54 244 244 { "res", 0, RES_CMD , CMD_23}, 245 245 { "reservedName",0, RESERVEDNAME_CMD , CMD_M}, 246 { "resolution", 0, RESOLUTION_CMD , RING_DECL}, 246 247 { "resultant", 0, RESULTANT_CMD, CMD_3}, 247 248 { "return", 0, RETURN , RETURN}, … … 2182 2183 return FALSE; 2183 2184 } 2185 //static BOOLEAN jjBETTI_R(leftv res, leftv v) 2186 //{ 2187 // res->data=(char *)syBettiOfComputation((syStrategy)v->Data()); 2188 // return FALSE; 2189 //} 2184 2190 static BOOLEAN jjCALL1MANY(leftv res, leftv u) 2185 2191 { … … 2230 2236 return FALSE; 2231 2237 } 2238 //static BOOLEAN jjCOUNT_R(leftv res, leftv v) 2239 //{ 2240 // res->data=(char *)syLength((syStrategy)v->Data()); 2241 // return FALSE; 2242 //} 2232 2243 static BOOLEAN jjDEG(leftv res, leftv v) 2233 2244 { … … 2301 2312 return FALSE; 2302 2313 } 2314 //static BOOLEAN jjDIM_R(leftv res, leftv v) 2315 //{ 2316 // res->data = (char *)syDim((syStrategy)v->Data()); 2317 // return FALSE; 2318 //} 2303 2319 static BOOLEAN jjDUMP(leftv res, leftv v) 2304 2320 { … … 2455 2471 } 2456 2472 #endif 2473 static BOOLEAN jjL2R(leftv res, leftv v) 2474 { 2475 res->data=(char *)syConvList((lists)v->Data()); 2476 return FALSE; 2477 } 2457 2478 static BOOLEAN jjLEADCOEF(leftv res, leftv v) 2458 2479 { … … 2505 2526 #endif 2506 2527 } 2528 //static BOOLEAN jjMINRES_R(leftv res, leftv v) 2529 //{ 2530 // res->data=(char *)syMinimize((syStrategy)v->Data()); 2531 // return FALSE; 2532 //} 2507 2533 static BOOLEAN jjMONITOR1(leftv res, leftv v) 2508 2534 { … … 2746 2772 case PACKAGE_CMD: res->data=mstrdup("package"); break; 2747 2773 case LINK_CMD: res->data=mstrdup("link"); break; 2774 case RESOLUTION_CMD:res->data=mstrdup("resolution");break; 2748 2775 case DEF_CMD: 2749 2776 case NONE: res->data=mstrdup("none"); break; … … 2816 2843 #define jjrParStr (proc1)19 2817 2844 #define jjidMinEmbedding (proc1)20 2845 #define jjBETTI_R (proc1)21 2846 #define jjCOUNT_R (proc1)22 2847 #define jjDIM_R (proc1)23 2848 #define jjMINRES_R (proc1)24 2818 2849 2819 2850 extern struct sValCmd1 dArith1[]; … … 2850 2881 case (int)jjrParStr: dArith1[i].p=(proc1)rParStr; break; 2851 2882 case (int)jjidMinEmbedding: dArith1[i].p=(proc1)idMinEmbedding; break; 2883 case (int)jjBETTI_R: dArith1[i].p=(proc1)syBettiOfComputation; break; 2884 case (int)jjCOUNT_R: dArith1[i].p=(proc1)syLength; break; 2885 case (int)jjDIM_R: dArith1[i].p=(proc1)syDim; break; 2886 case (int)jjMINRES_R: dArith1[i].p=(proc1)syMinimize; break; 2852 2887 #ifdef GENTABLE 2853 2888 default: Werror("missing proc1-definition for %d",(int)dArith1[i].p); … … 2879 2914 #define jjrParStr (proc1)rParStr 2880 2915 #define jjidMinEmbedding (proc1)idMinEmbedding 2916 #define jjBETTI_R (proc1)syBettiOfComputation 2917 #define jjCOUNT_R (proc1)syLength 2918 #define jjDIM_R (proc1)syDim 2919 #define jjMINRES_R (proc1)syMinimize 2881 2920 #endif 2882 2921 BOOLEAN jjnInt(leftv res, leftv u) … … 2913 2952 ,{jjBAREISS, BAREISS_CMD, MATRIX_CMD, MATRIX_CMD } 2914 2953 ,{jjBETTI, BETTI_CMD, INTMAT_CMD, LIST_CMD } 2954 ,{jjBETTI_R, BETTI_CMD, -((s)INTMAT_CMD),RESOLUTION_CMD } 2915 2955 ,{jjCHAR, CHARACTERISTIC_CMD, INT_CMD, RING_CMD } 2916 2956 ,{jjCHAR, CHARACTERISTIC_CMD, INT_CMD, QRING_CMD } … … 2932 2972 ,{jjCONTENT, CONTENT_CMD, VECTOR_CMD, VECTOR_CMD } 2933 2973 ,{jjCOUNT_N, COUNT_CMD, INT_CMD, NUMBER_CMD } 2974 ,{jjCOUNT_R, COUNT_CMD, -((s)INT_CMD), RESOLUTION_CMD } 2934 2975 ,{jjstrlen, COUNT_CMD, -((s)INT_CMD), STRING_CMD } 2935 2976 ,{jjpLength, COUNT_CMD, -((s)INT_CMD), POLY_CMD } … … 2957 2998 ,{jjDIM, DIM_CMD, INT_CMD, IDEAL_CMD } 2958 2999 ,{jjDIM, DIM_CMD, INT_CMD, MODUL_CMD } 3000 ,{jjDIM_R, DIM_CMD, -((s)INT_CMD), RESOLUTION_CMD } 2959 3001 ,{jjDUMP, DUMP_CMD, NONE, LINK_CMD } 2960 3002 ,{jjE, E_CMD, VECTOR_CMD, INT_CMD } … … 3022 3064 ,{jjidMinBase, MINBASE_CMD, -((s)MODUL_CMD), MODUL_CMD } 3023 3065 ,{jjMINRES, MINRES_CMD, LIST_CMD, LIST_CMD } 3066 ,{jjMINRES_R, MINRES_CMD, -((s)RESOLUTION_CMD), RESOLUTION_CMD } 3024 3067 ,{jjDUMMY, MODUL_CMD, MODUL_CMD, MODUL_CMD } 3025 3068 ,{jjMONITOR1, MONITOR_CMD, NONE, STRING_CMD } … … 3064 3107 ,{jjREGULARITY, REGULARITY_CMD, INT_CMD, LIST_CMD } 3065 3108 ,{jjRESERVEDNAME,RESERVEDNAME_CMD, INT_CMD, STRING_CMD } 3109 ,{jjL2R, RESOLUTION_CMD, RESOLUTION_CMD, LIST_CMD } 3066 3110 ,{jjWRONG, ROWS_CMD, 0, POLY_CMD } 3067 3111 ,{jjpMaxComp, ROWS_CMD, -((s)INT_CMD), VECTOR_CMD } … … 3954 3998 int sl=0; 3955 3999 if (v!=NULL) sl = v->listLength(); 3956 lists L=(lists)Alloc(sizeof(slists)); 3957 leftv h=NULL; 3958 int i; 3959 int rt; 3960 3961 L->Init(sl); 3962 for (i=0;i<sl;i++) 3963 { 3964 if (h!=NULL) { /* e.g. not in the first step: 3965 * h is the pointer to the old sleftv, 3966 * v is the pointer to the next sleftv 3967 * (in this moment) */ 3968 h->next=v; 3969 } 3970 h=v; 3971 v=v->next; 3972 h->next=NULL; 3973 rt=h->Typ(); 3974 if (rt==0) 3975 { 3976 L->Clean(); 3977 Werror("`%s` is undefined",h->Name()); 3978 return TRUE; 3979 } 3980 if ((rt==RING_CMD)||(rt==QRING_CMD)) 3981 { 3982 L->m[i].rtyp=rt; 3983 L->m[i].data=h->Data(); 3984 ((ring)L->m[i].data)->ref++; 3985 } 3986 else 3987 L->m[i].Copy(h); 3988 } 4000 lists L; 4001 if((sl==1)&&(v->Typ()==RESOLUTION_CMD)) 4002 { 4003 L=syConvRes((syStrategy)v->Data()); 4004 } 4005 else 4006 { 4007 L=(lists)Alloc(sizeof(slists)); 4008 leftv h=NULL; 4009 int i; 4010 int rt; 4011 4012 L->Init(sl); 4013 for (i=0;i<sl;i++) 4014 { 4015 if (h!=NULL) { /* e.g. not in the first step: 4016 * h is the pointer to the old sleftv, 4017 * v is the pointer to the next sleftv 4018 * (in this moment) */ 4019 h->next=v; 4020 } 4021 h=v; 4022 v=v->next; 4023 h->next=NULL; 4024 rt=h->Typ(); 4025 if (rt==0) 4026 { 4027 L->Clean(); 4028 Werror("`%s` is undefined",h->Name()); 4029 return TRUE; 4030 } 4031 if ((rt==RING_CMD)||(rt==QRING_CMD)) 4032 { 4033 L->m[i].rtyp=rt; 4034 L->m[i].data=h->Data(); 4035 ((ring)L->m[i].data)->ref++; 4036 } 4037 else 4038 L->m[i].Copy(h); 4039 } 4040 } 3989 4041 res->data=(char *)L; 3990 4042 return FALSE; -
Singular/ipassign.cc
r402a67 rdfc6b54 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ipassign.cc,v 1.1 5 1997-07-02 16:44:10Singular Exp $ */4 /* $Id: ipassign.cc,v 1.16 1997-07-09 15:53:59 Singular Exp $ */ 5 5 6 6 /* … … 344 344 return FALSE; 345 345 } 346 static BOOLEAN jiA_RESOLUTION(leftv res, leftv a, Subexpr e) 347 { 348 if (res->data!=NULL) syKillComputation((syStrategy)res->data); 349 res->data=(void *)a->CopyD(RESOLUTION_CMD); 350 jiAssignAttr(res,a); 351 return FALSE; 352 } 346 353 static BOOLEAN jiA_MODUL_P(leftv res, leftv a, Subexpr e) 347 354 { … … 455 462 // proc res arg 456 463 {jiA_IDEAL, IDEAL_CMD, IDEAL_CMD } 464 ,{jiA_RESOLUTION,RESOLUTION_CMD,RESOLUTION_CMD } 457 465 ,{jiA_IDEAL_M, IDEAL_CMD, MATRIX_CMD } 458 466 ,{jiA_INT, INT_CMD, INT_CMD } -
Singular/ipconv.cc
r402a67 rdfc6b54 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ipconv.cc,v 1. 5 1997-05-02 15:10:15Singular Exp $ */4 /* $Id: ipconv.cc,v 1.6 1997-07-09 15:54:00 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: automatic type conversions … … 19 19 #include "matpol.h" 20 20 #include "silink.h" 21 //#include "ipshell.h"21 #include "syz.h" 22 22 #include "ipconv.h" 23 23 … … 166 166 slInit(l, (char *) data); 167 167 return (void *)l; 168 } 169 170 static void * iiR2L(void * data) 171 { 172 return (void *)syConvRes((syStrategy)data); 168 173 } 169 174 … … 222 227 // link 223 228 { STRING_CMD, LINK_CMD, iiS2Link }, 229 // resolution -> list 230 { RESOLUTION_CMD, LIST_CMD, iiR2L }, 224 231 // end of list 225 232 { 0, 0, NULL } -
Singular/ipid.cc
r402a67 rdfc6b54 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ipid.cc,v 1. 6 1997-07-02 16:44:11 Singular Exp $ */4 /* $Id: ipid.cc,v 1.7 1997-07-09 15:54:01 Singular Exp $ */ 5 5 6 6 /* … … 24 24 #include "attrib.h" 25 25 #include "silink.h" 26 #include "syz.h" 26 27 #include "ipid.h" 27 28 … … 119 120 len = sizeof(ip_package); 120 121 break; 122 case RESOLUTION_CMD: 123 len=sizeof(ssyStrategy); 124 break; 121 125 //other types: without init (int,script,poly,def,package) 122 126 } … … 355 359 { 356 360 slKill(IDLINK(h)); 361 } 362 else if((IDTYP(h)==RESOLUTION_CMD)&&(IDDATA(h)!=NULL)) 363 { 364 syKillComputation((syStrategy)IDDATA(h)); 357 365 } 358 366 #ifdef TEST -
Singular/iplib.cc
r402a67 rdfc6b54 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: iplib.cc,v 1. 6 1997-05-02 15:10:15Singular Exp $ */4 /* $Id: iplib.cc,v 1.7 1997-07-09 15:54:01 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: interpreter: LIB and help … … 499 499 } 500 500 501 BOOLEAN iiLibCmd( char *newlib )501 BOOLEAN iiLibCmd( char *newlib, BOOLEAN tellerror ) 502 502 { 503 503 char buf[256]; 504 504 char libnamebuf[128]; 505 505 idhdl h,hl; 506 FILE * fp = feFopen( newlib, "r", libnamebuf, TRUE);506 FILE * fp = feFopen( newlib, "r", libnamebuf, tellerror ); 507 507 if (fp==NULL) 508 508 { -
Singular/ipshell.h
r402a67 rdfc6b54 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: ipshell.h,v 1. 7 1997-07-02 16:44:12 Singular Exp $ */6 /* $Id: ipshell.h,v 1.8 1997-07-09 15:54:02 Singular Exp $ */ 7 7 /* 8 8 * ABSTRACT … … 50 50 char * iiProcName(char *buf, char & ct, char* &e); 51 51 char * iiProcArgs(char *e,BOOLEAN withParenth); 52 BOOLEAN iiLibCmd( char *newlib );52 BOOLEAN iiLibCmd( char *newlib, BOOLEAN tellerror=TRUE ); 53 53 leftv iiMap(map theMap, char * what); 54 54 void iiMakeResolv(resolvente r, int length, int rlen, char * name, int typ0, -
Singular/structs.h
r402a67 rdfc6b54 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: structs.h,v 1. 3 1997-04-09 12:20:13Singular Exp $ */6 /* $Id: structs.h,v 1.4 1997-07-09 15:54:04 Singular Exp $ */ 7 7 /* 8 8 * ABSTRACT … … 33 33 class sattr; 34 34 class skStrategy; 35 class ssyStrategy; 35 36 36 37 struct sip_sring; … … 77 78 typedef ip_package * package; 78 79 typedef struct s_si_link_extension *si_link_extension; 80 typedef ssyStrategy * syStrategy; 79 81 80 82 struct _scmdnames -
Singular/subexpr.cc
r402a67 rdfc6b54 34 34 #include "attrib.h" 35 35 #include "silink.h" 36 #include "syz.h" 36 37 #include "subexpr.h" 37 38 … … 134 135 pWrite0((poly)d); 135 136 break; 137 case RESOLUTION_CMD: 138 syPrint((syStrategy)d); 139 break; 136 140 case STRING_CMD: 137 141 ::Print("%-*.*s%s",spaces,spaces," ",(char *)d); … … 274 278 break; 275 279 } 280 case RESOLUTION_CMD: 281 { 282 syKillComputation((syStrategy)data); 283 break; 284 } 276 285 #ifdef TEST 277 286 // the following types do not take memory … … 369 378 } 370 379 371 void * slInternalCopy(leftv source) 372 { 373 void *d=source->data; 374 switch (source->rtyp) 380 void * slInternalCopy(leftv source, int t, void *d, Subexpr e) 381 { 382 switch (t) 375 383 { 376 384 case INTVEC_CMD: … … 383 391 return (void *)idCopy((ideal)d); 384 392 case STRING_CMD: 393 if ((e==NULL) 394 || (source->rtyp==LIST_CMD) 395 || ((source->rtyp==IDHDL)&&(IDTYP((idhdl)source->data)==LIST_CMD))) 396 return (void *)mstrdup((char *)d); 397 else if (e->next==NULL) 398 { 399 char *s=(char *)AllocL(2); 400 s[0]=*(char *)d; 401 s[1]='\0'; 402 return s; 403 } 404 #ifdef TEST 405 else 406 { 407 Werror("not impl. string-op in `%s`",my_yylinebuf); 408 return NULL; 409 } 410 #endif 385 411 case PROC_CMD: 386 412 return (void *)mstrdup((char *)d); … … 405 431 return d; 406 432 } 433 case RESOLUTION_CMD: 434 return (void*)syCopy((syStrategy)d); 407 435 #ifdef TEST 408 436 case DEF_CMD: … … 506 534 if (rtyp==VNOETHER) x=(void *)pCopy(ppNoether); 507 535 else if (rtyp==LIB_CMD) 508 x=(void *)mstrdup( Data());536 x=(void *)mstrdup((char *)Data()); 509 537 else if ((rtyp==VMINPOLY)&& (currRing->minpoly!=NULL)&&(currRing->ch<2)) 510 538 x=(void *)nCopy(currRing->minpoly); … … 513 541 } 514 542 void *d=Data(); 515 if (!errorreported) 516 switch (t) 517 { 518 case INTVEC_CMD: 519 case INTMAT_CMD: 520 return (void *)ivCopy((intvec *)d); 521 case MATRIX_CMD: 522 return (void *)mpCopy((matrix)d); 523 case IDEAL_CMD: 524 case MODUL_CMD: 525 return (void *)idCopy((ideal)d); 526 case STRING_CMD: 527 case PROC_CMD: 528 case BINARY_CMD: 529 if ((e==NULL) 530 || (rtyp==LIST_CMD) 531 || ((rtyp==IDHDL)&&(IDTYP((idhdl)data)==LIST_CMD))) 532 return (void *)mstrdup((char *)d); 533 else if (e->next==NULL) 534 { 535 char *s=(char *)AllocL(2); 536 s[0]=*(char *)d; 537 s[1]='\0'; 538 return s; 539 } 540 #ifdef TEST 541 else 542 { 543 Werror("not impl. string-op in `%s`",my_yylinebuf); 544 return NULL; 545 } 546 #endif 547 break; 548 case POLY_CMD: 549 case VECTOR_CMD: 550 return (void *)pCopy((poly)d); 551 case INT_CMD: 552 return d; 553 case NUMBER_CMD: 554 return (void *)nCopy((number)d); 555 case MAP_CMD: 556 return (void *)maCopy((map)d); 557 case LIST_CMD: 558 return (void *)lCopy((lists)d); 559 case LINK_CMD: 560 return (void *)slCopy((si_link) d); 561 case RING_CMD: 562 case QRING_CMD: 563 { 564 ring r=(ring)d; 565 r->ref++; 566 return d; 567 } 568 case 0: 569 case DEF_CMD: 570 break; 571 #ifdef TEST 572 //case COMMAND: 573 default: 574 Warn("CopyD: cannot copy type %s(%d)",Tok2Cmdname(t),t); 575 #endif 576 } 543 if (!errorreported) return slInternalCopy(this,t,d,e); 577 544 return NULL; 578 545 } … … 835 802 case LIB_CMD: { 836 803 idhdl h = ggetid( "LIB" ); 837 if(h==NULL) return sNoName;804 if(h==NULL) return (void *)sNoName; 838 805 return IDSTRING(h); 839 806 } -
Singular/syz.h
r402a67 rdfc6b54 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: syz.h,v 1. 4 1997-04-09 12:20:16 Singular Exp $ */6 /* $Id: syz.h,v 1.5 1997-07-09 15:54:06 Singular Exp $ */ 7 7 /* 8 * ABSTRACT: resolutions8 * ABSTRACT: Resolutions 9 9 */ 10 10 #include "structs.h" … … 16 16 poly syz; /*- the syzygy associated to p1,p2 -*/ 17 17 int ind1,ind2; /*- the indeces of p1,p2 -*/ 18 int isNotMinimal; 19 int order; 18 poly isNotMinimal; 19 int syzind; 20 int order; 20 21 }; 21 22 typedef struct sSObject SObject; 22 23 typedef SObject * SSet; 23 24 typedef SSet * SRes; 25 26 class ssyStrategy; 27 typedef ssyStrategy * syStrategy; 28 class ssyStrategy{ 29 public: 30 int length; 31 int ** truecomponents; 32 int ** backcomponents; 33 int ** Howmuch; 34 int ** Firstelem; 35 resolvente res; 36 resolvente orderedRes; 37 SRes resPairs; 38 intvec * Tl; 39 resolvente fullres; 40 resolvente minres; 41 int references; 42 int * binom; 43 int highdeg_1; 44 intvec * resolution; 45 }; 24 46 25 47 void sySchreyersSyzygiesM(polyset F,int Fmax,polyset* Shdl,int* Smax, … … 48 70 void syReOrderResolventFB(resolvente res,int length, int initial=1); 49 71 50 resolvente syLaScala(ideal arg,int * length);51 72 resolvente syLaScala1(ideal arg,int * length); 73 syStrategy syLaScala3(ideal arg,int * length); 52 74 75 void syKillComputation(syStrategy syzstr); 76 intvec * syBettiOfComputation(syStrategy syzstr); 77 int syLength(syStrategy syzstr); 78 int sySize(syStrategy syzstr); 79 int syDim(syStrategy syzstr); 80 syStrategy syCopy(syStrategy syzstr); 81 void syPrint(syStrategy syzstr); 82 lists syConvRes(syStrategy syzstr); 83 syStrategy syConvList(lists li); 84 syStrategy syForceMin(lists li); 85 syStrategy syMinimize(syStrategy syzstr); 53 86 #endif -
Singular/syz1.cc
r402a67 rdfc6b54 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: syz1.cc,v 1.1 0 1997-06-18 16:09:20Singular Exp $ */4 /* $Id: syz1.cc,v 1.11 1997-07-09 15:54:06 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: resolutions … … 25 25 #include "tok.h" 26 26 #include "numbers.h" 27 #include "modulop.h" 27 28 #include "ideals.h" 28 29 #include "intvec.h" 29 30 #include "ring.h" 31 #include "lists.h" 30 32 #include "syz.h" 31 33 32 34 /*--------------static variables------------------------*/ 33 35 /*---contains the real components wrt. cdp--------------*/ 34 static int ** truecomponents=NULL;35 static int ** backcomponents=NULL;36 static int ** Howmuch=NULL;37 static int ** Firstelem=NULL;36 //static int ** truecomponents=NULL; 37 //static int ** backcomponents=NULL; 38 //static int ** Howmuch=NULL; 39 //static int ** Firstelem=NULL; 38 40 /*---points to the real components of the actual module-*/ 39 41 static int * currcomponents=NULL; … … 64 66 (*so).ind1 = 0; 65 67 (*so).ind2 = 0; 68 (*so).syzind = -1; 66 69 (*so).order = 0; 67 (*so).isNotMinimal = 0;70 (*so).isNotMinimal = NULL; 68 71 } 69 72 … … 73 76 static void syCopyPair(SObject * argso, SObject * imso) 74 77 { 75 (*imso).p = (*argso).p; 76 (*imso).p1 = (*argso).p1; 77 (*imso).p2 = (*argso).p2; 78 (*imso).lcm = (*argso).lcm; 79 (*imso).syz = (*argso).syz; 80 (*imso).ind1 = (*argso).ind1; 81 (*imso).ind2 = (*argso).ind2; 82 (*imso).order = (*argso).order; 83 (*imso).isNotMinimal = (*argso).isNotMinimal; 78 *imso=*argso; 79 //(*imso).p = (*argso).p; 80 //(*imso).p1 = (*argso).p1; 81 //(*imso).p2 = (*argso).p2; 82 //(*imso).lcm = (*argso).lcm; 83 //(*imso).syz = (*argso).syz; 84 //(*imso).ind1 = (*argso).ind1; 85 //(*imso).ind2 = (*argso).ind2; 86 //(*imso).syzind = (*argso).syzind; 87 //(*imso).order = (*argso).order; 88 //(*imso).isNotMinimal = (*argso).isNotMinimal; 84 89 (*argso).p = NULL; 85 90 (*argso).p1 = NULL; … … 89 94 (*argso).ind1 = 0; 90 95 (*argso).ind2 = 0; 91 (*argso).isNotMinimal = 0; 96 (*argso).syzind = -1; 97 (*argso).order = 0; 98 (*argso).isNotMinimal = NULL; 92 99 } 93 100 … … 808 815 } 809 816 810 poly syRedtail (poly p, ideal redWith, int index)817 poly syRedtail (poly p, syStrategy syzstr, int index) 811 818 { 812 819 poly h, hn; 813 820 int j,pos; 821 ideal redWith=syzstr->orderedRes[index]; 814 822 815 823 h = p; … … 817 825 while(hn != NULL) 818 826 { 819 j = Firstelem[index-1][pGetComp(hn)]-1;827 j = syzstr->Firstelem[index-1][pGetComp(hn)]-1; 820 828 if (j>=0) 821 829 { 822 pos = j+ Howmuch[index-1][pGetComp(hn)];830 pos = j+syzstr->Howmuch[index-1][pGetComp(hn)]; 823 831 while (j < pos) 824 832 { … … 854 862 return p; 855 863 } 856 j = Firstelem[index-1][pGetComp(hn)]-1;857 pos = j+ Howmuch[index-1][pGetComp(hn)];864 j = syzstr->Firstelem[index-1][pGetComp(hn)]-1; 865 pos = j+syzstr->Howmuch[index-1][pGetComp(hn)]; 858 866 } 859 867 else … … 884 892 for (i=0;i<IDELEMS(arg);i++) 885 893 { 886 (resPairs[0])[i].syz = pCopy(arg->m[(*iv)[i]-1]); 894 (resPairs[0])[i].syz = /*pCopy*/(arg->m[(*iv)[i]-1]); 895 arg->m[(*iv)[i]-1] = NULL; 896 (resPairs[0])[i].order = pTotaldegree((resPairs[0])[i].syz); 887 897 } 888 898 delete iv; … … 895 905 * set the vectors of truecomponents 896 906 */ 897 static void syOrder(poly p, resolvente res,resolvente orderedRes,int index,907 static void syOrder(poly p,syStrategy syzstr,int index, 898 908 int realcomp) 899 909 { 900 int i=IDELEMS(res[index-1])+1,j=0,k,tc,orc,ie=realcomp-1; 901 int *trind1=truecomponents[index-1],*trind=truecomponents[index]; 902 int *bc=backcomponents[index],*F1=Firstelem[index-1]; 903 int *H1=Howmuch[index-1]; 910 int i=IDELEMS(syzstr->res[index-1])+1,j=0,k,tc,orc,ie=realcomp-1; 911 int *trind1=syzstr->truecomponents[index-1]; 912 int *trind=syzstr->truecomponents[index]; 913 int *bc=syzstr->backcomponents[index]; 914 int *F1=syzstr->Firstelem[index-1]; 915 int *H1=syzstr->Howmuch[index-1]; 904 916 poly pp; 905 polyset or=orderedRes[index]->m,or1=orderedRes[index-1]->m; 917 polyset or=syzstr->orderedRes[index]->m; 918 polyset or1=syzstr->orderedRes[index-1]->m; 906 919 907 920 if (p==NULL) return; … … 950 963 //Print("poly: ");pWrite(p); 951 964 //Print("in module %d as %d -th element\n",index,j); 952 for (k=0;k<IDELEMS( res[index]);k++)965 for (k=0;k<IDELEMS((syzstr->res)[index]);k++) 953 966 { 954 967 if (trind[k]>j) 955 968 trind[k] += 1; 956 969 } 957 for (k=IDELEMS( res[index])-1;k>realcomp;k--)970 for (k=IDELEMS((syzstr->res)[index])-1;k>realcomp;k--) 958 971 trind[k] = trind[k-1]; 959 972 trind[realcomp] = j+1; … … 965 978 * the truncated std 966 979 */ 967 static void syRedPairsOfCurrDeg(SRes resPairs, resolvente res, resolvente orderedRes, 968 int deg, int index, intvec * Tl, intvec ** minGen) 969 { 970 int i=0,j,k=IDELEMS(res[index]),kk; 980 static void syRedNextPairs(SSet nextPairs, syStrategy syzstr, 981 int howmuch, int index) 982 { 983 int i=howmuch-1,j,k=IDELEMS(syzstr->res[index]); 984 int ks=IDELEMS(syzstr->res[index+1]),kk,l,ll; 985 int ** Fin=syzstr->Firstelem; 986 int ** Hin=syzstr->Howmuch; 987 int ** bin=syzstr->backcomponents; 971 988 number coefgcd,n; 972 poly p=NULL; 973 974 if (resPairs[index]==NULL) return; 975 while ((k>0) && (res[index]->m[k-1]==NULL)) k--; 976 while ((i<(*Tl)[index]) && ((resPairs[index])[i].lcm!=NULL) 977 && (pGetOrder((resPairs[index])[i].lcm)<deg)) i++; 978 if ((i>=(*Tl)[index]) || ((resPairs[index])[i].lcm==NULL) 979 || (pGetOrder((resPairs[index])[i].lcm)>deg)) return; 980 while ((i<(*Tl)[index]) && ((resPairs[index])[i].lcm!=NULL) 981 && (pGetOrder((resPairs[index])[i].lcm)==deg)) 982 { 983 (resPairs[index])[i].p = 984 spSpolyCreate((resPairs[index])[i].p2, (resPairs[index])[i].p1,NULL); 985 coefgcd = 986 nGcd(pGetCoeff((resPairs[index])[i].p1),pGetCoeff((resPairs[index])[i].p1)); 987 if ((*minGen[index])[(resPairs[index])[i].ind2]==0) 988 { 989 (resPairs[index])[i].syz = pHead((resPairs[index])[i].lcm); 990 p = (resPairs[index])[i].syz; 991 pSetCoeff(p,nDiv(pGetCoeff((resPairs[index])[i].p1),coefgcd)); 992 pGetCoeff(p) = nNeg(pGetCoeff(p)); 993 pSetComp(p,(resPairs[index])[i].ind2+1); 994 } 995 if ((*minGen[index])[(resPairs[index])[i].ind1]==0) 996 { 997 if ((resPairs[index])[i].syz==NULL) 998 { 999 (resPairs[index])[i].syz = pHead((resPairs[index])[i].lcm); 1000 p = (resPairs[index])[i].syz; 1001 } 1002 else 1003 { 1004 pNext(p) = pHead((resPairs[index])[i].lcm); 1005 pIter(p); 1006 } 1007 pSetComp(p,(resPairs[index])[i].ind1+1); 1008 pSetCoeff(p,nDiv(pGetCoeff((resPairs[index])[i].p2),coefgcd)); 1009 } 1010 nDelete(&coefgcd); 1011 j = k-1; 1012 while ((j>=0) && (res[index]->m[j]!=NULL) 1013 && ((resPairs[index])[i].p!=NULL)) 1014 { 1015 if (syDivisibleBy(res[index]->m[j],(resPairs[index])[i].p)) 1016 { 1017 if ((*minGen[index])[j]==0) 1018 { 1019 if ((resPairs[index])[i].syz==NULL) 1020 { 1021 (resPairs[index])[i].syz = pHead((resPairs[index])[i].p); 1022 p = (resPairs[index])[i].syz; 1023 } 1024 else 1025 { 1026 pNext(p) = pHead((resPairs[index])[i].p); 1027 pIter(p); 1028 } 1029 pSetComp(p,j+1); 1030 pGetCoeff(p) = nNeg(pGetCoeff(p)); 1031 } 1032 (resPairs[index])[i].p = 1033 spSpolyRed(res[index]->m[j],(resPairs[index])[i].p,NULL); 1034 j = k-1; 1035 } 1036 else 1037 { 1038 j--; 1039 } 1040 } 1041 if ((resPairs[index])[i].p != NULL) 1042 { 1043 if (TEST_OPT_PROT) Print("g"); 1044 if (k==IDELEMS(res[index])) 1045 { 1046 pEnlargeSet(&(res[index]->m),IDELEMS(res[index]),16); 1047 truecomponents[index]=(int*)ReAlloc((ADDRESS)truecomponents[index], 1048 (IDELEMS(res[index])+1)*sizeof(int), 1049 (IDELEMS(res[index])+17)*sizeof(int)); 1050 backcomponents[index]=(int*)ReAlloc((ADDRESS)backcomponents[index], 1051 (IDELEMS(res[index])+1)*sizeof(int), 1052 (IDELEMS(res[index])+17)*sizeof(int)); 1053 Howmuch[index]=(int*)ReAlloc((ADDRESS)Howmuch[index], 1054 (IDELEMS(res[index])+1)*sizeof(int), 1055 (IDELEMS(res[index])+17)*sizeof(int)); 1056 Firstelem[index]=(int*)ReAlloc((ADDRESS)Firstelem[index], 1057 (IDELEMS(res[index])+1)*sizeof(int), 1058 (IDELEMS(res[index])+17)*sizeof(int)); 1059 int mk; 1060 for (mk=IDELEMS(res[index])+1;mk<IDELEMS(res[index])+17;mk++) 1061 { 1062 Howmuch[index][mk] = 0; 1063 Firstelem[index][mk] = 0; 1064 } 1065 //Print("sort %d has now size %d\n",index,IDELEMS(res[index])+17); 1066 IDELEMS(res[index]) += 16; 1067 pEnlargeSet(&(orderedRes[index]->m),IDELEMS(orderedRes[index]),16); 1068 IDELEMS(orderedRes[index]) += 16; 1069 intvec * temp = new intvec(minGen[index]->length()+16); 1070 for (kk=minGen[index]->length()-1;kk>=0;kk--) 1071 (*temp)[kk] = (*minGen[index])[kk]; 1072 delete minGen[index]; 1073 minGen[index] = temp; 1074 } 1075 if ((resPairs[index])[i].syz==NULL) 1076 { 1077 (resPairs[index])[i].syz = pHead((resPairs[index])[i].p); 1078 p = (resPairs[index])[i].syz; 1079 } 1080 else 1081 { 1082 pNext(p) = pHead(resPairs[index][i].p); 1083 pIter(p); 1084 } 1085 if (p!=NULL) 1086 { 1087 k++; 1088 pSetComp(p,k); 1089 pGetCoeff(p) = nNeg(pGetCoeff(p)); 1090 } 1091 if (resPairs[index][i].p!=NULL) 1092 { 1093 res[index]->m[k] = resPairs[index][i].p; 1094 pNorm(res[index]->m[k]); 1095 syOrder(res[index]->m[k-1],res,orderedRes,index,k); 1096 } 1097 resPairs[index][i].isNotMinimal = 1; 1098 resPairs[index][i].p =NULL; 1099 } 1100 else 1101 if (TEST_OPT_PROT) Print("."); 1102 p = NULL; 1103 i++; 1104 } 1105 } 1106 1107 /*3 1108 * reduces all pairs of degree deg in the module index 1109 * put the reduced generators to the resolvente which contains 1110 * the truncated std 1111 */ 1112 static void syRedNextPairs(SSet nextPairs, resolvente res, resolvente orderedRes, 1113 int howmuch, int index) 1114 { 1115 int i=howmuch-1,j,k=IDELEMS(res[index]),ks=IDELEMS(res[index+1]),kk,l,ll; 1116 number coefgcd,n; 1117 polyset redset=orderedRes[index]->m; 989 ideal or=syzstr->orderedRes[index+1]; 990 polyset redset=syzstr->orderedRes[index]->m; 1118 991 poly p=NULL,q; 1119 992 BOOLEAN isDivisible; 993 SObject tso; 1120 994 1121 995 if ((nextPairs==NULL) || (howmuch==0)) return; 1122 while ((k>0) && ( res[index]->m[k-1]==NULL)) k--;1123 while ((ks>0) && ( res[index+1]->m[ks-1]==NULL)) ks--;996 while ((k>0) && (syzstr->res[index]->m[k-1]==NULL)) k--; 997 while ((ks>0) && (syzstr->res[index+1]->m[ks-1]==NULL)) ks--; 1124 998 while (i>=0) 1125 999 { 1000 tso = nextPairs[i]; 1126 1001 isDivisible = FALSE; 1127 if ( res[index+1]!=NULL)1128 { 1129 l = Fi rstelem[index][pGetComp(nextPairs[i].lcm)]-1;1002 if (syzstr->res[index+1]!=NULL) 1003 { 1004 l = Fin[index][pGetComp(tso.lcm)]-1; 1130 1005 if (l>=0) 1131 1006 { 1132 ll = l+H owmuch[index][pGetComp(nextPairs[i].lcm)];1007 ll = l+Hin[index][pGetComp(tso.lcm)]; 1133 1008 while ((l<ll) && (!isDivisible)) 1134 1009 { 1135 if ( res[index+1]->m[l]!=NULL)1010 if (or->m[l]!=NULL) 1136 1011 { 1137 1012 isDivisible = isDivisible || 1138 syDivisibleBy1(or deredRes[index+1]->m[l],nextPairs[i].lcm);1013 syDivisibleBy1(or->m[l],tso.lcm); 1139 1014 } 1140 1015 l++; … … 1144 1019 if (!isDivisible) 1145 1020 { 1146 nextPairs[i].p =1147 sySPoly( nextPairs[i].p1, nextPairs[i].p2,nextPairs[i].lcm);1021 tso.p = 1022 sySPoly(tso.p1, tso.p2,tso.lcm); 1148 1023 coefgcd = 1149 nGcd(pGetCoeff( nextPairs[i].p1),pGetCoeff(nextPairs[i].p1));1150 nextPairs[i].syz = pHead(nextPairs[i].lcm);1151 pSetm( nextPairs[i].syz);1152 p = nextPairs[i].syz;1153 pSetCoeff(p,nDiv(pGetCoeff( nextPairs[i].p1),coefgcd));1024 nGcd(pGetCoeff(tso.p1),pGetCoeff(tso.p1)); 1025 tso.syz = pHead(tso.lcm); 1026 pSetm(tso.syz); 1027 p = tso.syz; 1028 pSetCoeff(p,nDiv(pGetCoeff(tso.p1),coefgcd)); 1154 1029 pGetCoeff(p) = nNeg(pGetCoeff(p)); 1155 pSetComp(p, nextPairs[i].ind2+1);1156 pNext(p) = pHead( nextPairs[i].lcm);1030 pSetComp(p,tso.ind2+1); 1031 pNext(p) = pHead(tso.lcm); 1157 1032 pIter(p); 1158 1033 pSetm(p); 1159 pSetComp(p, nextPairs[i].ind1+1);1160 pSetCoeff(p,nDiv(pGetCoeff( nextPairs[i].p2),coefgcd));1034 pSetComp(p,tso.ind1+1); 1035 pSetCoeff(p,nDiv(pGetCoeff(tso.p2),coefgcd)); 1161 1036 nDelete(&coefgcd); 1162 if ( nextPairs[i].p != NULL)1163 { 1164 q = nextPairs[i].p;1165 j = Fi rstelem[index-1][pGetComp(q)]-1;1166 int pos = j+H owmuch[index-1][pGetComp(q)];1037 if (tso.p != NULL) 1038 { 1039 q = tso.p; 1040 j = Fin[index-1][pGetComp(q)]-1; 1041 int pos = j+Hin[index-1][pGetComp(q)]; 1167 1042 loop 1168 1043 { … … 1188 1063 pNext(p) = pHead(q); 1189 1064 pIter(p); 1190 pSetComp(p,b ackcomponents[index][j]+1);1065 pSetComp(p,bin[index][j]+1); 1191 1066 pGetCoeff(p) = nNeg(pGetCoeff(p)); 1192 1067 q = sySPolyRed(q,redset[j]); 1193 1068 if (q==NULL) break; 1194 j = Fi rstelem[index-1][pGetComp(q)]-1;1195 pos = j+H owmuch[index-1][pGetComp(q)];1069 j = Fin[index-1][pGetComp(q)]-1; 1070 pos = j+Hin[index-1][pGetComp(q)]; 1196 1071 } 1197 1072 else … … 1201 1076 } 1202 1077 } 1203 nextPairs[i].p = q;1204 } 1205 if ( nextPairs[i].p != NULL)1078 tso.p = q; 1079 } 1080 if (tso.p != NULL) 1206 1081 { 1207 1082 if (TEST_OPT_PROT) Print("g"); 1208 if (k==IDELEMS( res[index]))1209 { 1210 pEnlargeSet(&( res[index]->m),IDELEMS(res[index]),16);1211 truecomponents[index]=(int*)ReAlloc((ADDRESS)truecomponents[index],1212 (IDELEMS( res[index])+1)*sizeof(int),1213 (IDELEMS( res[index])+17)*sizeof(int));1214 backcomponents[index]=(int*)ReAlloc((ADDRESS)backcomponents[index],1215 (IDELEMS( res[index])+1)*sizeof(int),1216 (IDELEMS( res[index])+17)*sizeof(int));1217 Howmuch[index]=(int*)ReAlloc((ADDRESS)Howmuch[index],1218 (IDELEMS( res[index])+1)*sizeof(int),1219 (IDELEMS( res[index])+17)*sizeof(int));1220 Firstelem[index]=(int*)ReAlloc((ADDRESS)Firstelem[index],1221 (IDELEMS( res[index])+1)*sizeof(int),1222 (IDELEMS( res[index])+17)*sizeof(int));1083 if (k==IDELEMS((syzstr->res)[index])) 1084 { 1085 pEnlargeSet(&(syzstr->res[index]->m),IDELEMS(syzstr->res[index]),16); 1086 syzstr->truecomponents[index]=(int*)ReAlloc((ADDRESS)syzstr->truecomponents[index], 1087 (IDELEMS(syzstr->res[index])+1)*sizeof(int), 1088 (IDELEMS(syzstr->res[index])+17)*sizeof(int)); 1089 syzstr->backcomponents[index]=(int*)ReAlloc((ADDRESS)syzstr->backcomponents[index], 1090 (IDELEMS(syzstr->res[index])+1)*sizeof(int), 1091 (IDELEMS(syzstr->res[index])+17)*sizeof(int)); 1092 syzstr->Howmuch[index]=(int*)ReAlloc((ADDRESS)syzstr->Howmuch[index], 1093 (IDELEMS(syzstr->res[index])+1)*sizeof(int), 1094 (IDELEMS(syzstr->res[index])+17)*sizeof(int)); 1095 syzstr->Firstelem[index]=(int*)ReAlloc((ADDRESS)syzstr->Firstelem[index], 1096 (IDELEMS(syzstr->res[index])+1)*sizeof(int), 1097 (IDELEMS(syzstr->res[index])+17)*sizeof(int)); 1223 1098 int mk; 1224 for (mk=IDELEMS( res[index])+1;mk<IDELEMS(res[index])+17;mk++)1225 { 1226 Howmuch[index][mk] = 0;1227 Firstelem[index][mk] = 0;1099 for (mk=IDELEMS(syzstr->res[index])+1;mk<IDELEMS(syzstr->res[index])+17;mk++) 1100 { 1101 syzstr->Howmuch[index][mk] = 0; 1102 syzstr->Firstelem[index][mk] = 0; 1228 1103 } 1229 1104 //Print("sort %d has now size %d\n",index,IDELEMS(res[index])+17); 1230 IDELEMS( res[index]) += 16;1231 pEnlargeSet(&( orderedRes[index]->m),IDELEMS(orderedRes[index]),16);1232 IDELEMS( orderedRes[index]) += 16;1233 redset= orderedRes[index]->m;1234 } 1235 pNext(p) = pHead( nextPairs[i].p);1105 IDELEMS(syzstr->res[index]) += 16; 1106 pEnlargeSet(&(syzstr->orderedRes[index]->m),IDELEMS(syzstr->orderedRes[index]),16); 1107 IDELEMS(syzstr->orderedRes[index]) += 16; 1108 redset=syzstr->orderedRes[index]->m; 1109 } 1110 pNext(p) = pHead(tso.p); 1236 1111 pIter(p); 1237 1112 if (p!=NULL) … … 1241 1116 pGetCoeff(p) = nNeg(pGetCoeff(p)); 1242 1117 } 1243 if ( nextPairs[i].p!=NULL)1244 { 1245 res[index]->m[k-1] = nextPairs[i].p;1246 pNorm( res[index]->m[k-1]);1247 syOrder( res[index]->m[k-1],res,orderedRes,index,k);1248 } 1249 nextPairs[i].isNotMinimal = 1;1250 nextPairs[i].p =NULL;1118 if (tso.p!=NULL) 1119 { 1120 syzstr->res[index]->m[k-1] = tso.p; 1121 pNorm(syzstr->res[index]->m[k-1]); 1122 syOrder(syzstr->res[index]->m[k-1],syzstr,index,k); 1123 } 1124 tso.isNotMinimal = p; 1125 tso.p = NULL; 1251 1126 } 1252 1127 else … … 1258 1133 euler--; 1259 1134 } 1260 if (ks==IDELEMS( res[index+1]))1261 { 1262 pEnlargeSet(&( res[index+1]->m),IDELEMS(res[index+1]),16);1263 truecomponents[index+1]=(int*)ReAlloc((ADDRESS)truecomponents[index+1],1264 (IDELEMS( res[index+1])+1)*sizeof(int),1265 (IDELEMS( res[index+1])+17)*sizeof(int));1266 backcomponents[index+1]=(int*)ReAlloc((ADDRESS)backcomponents[index+1],1267 (IDELEMS( res[index+1])+1)*sizeof(int),1268 (IDELEMS( res[index+1])+17)*sizeof(int));1269 Howmuch[index+1]=(int*)ReAlloc((ADDRESS)Howmuch[index+1],1270 (IDELEMS( res[index+1])+1)*sizeof(int),1271 (IDELEMS( res[index+1])+17)*sizeof(int));1272 Firstelem[index+1]=(int*)ReAlloc((ADDRESS)Firstelem[index+1],1273 (IDELEMS( res[index+1])+1)*sizeof(int),1274 (IDELEMS( res[index+1])+17)*sizeof(int));1135 if (ks==IDELEMS(syzstr->res[index+1])) 1136 { 1137 pEnlargeSet(&(syzstr->res[index+1]->m),IDELEMS(syzstr->res[index+1]),16); 1138 syzstr->truecomponents[index+1]=(int*)ReAlloc((ADDRESS)syzstr->truecomponents[index+1], 1139 (IDELEMS(syzstr->res[index+1])+1)*sizeof(int), 1140 (IDELEMS(syzstr->res[index+1])+17)*sizeof(int)); 1141 syzstr->backcomponents[index+1]=(int*)ReAlloc((ADDRESS)syzstr->backcomponents[index+1], 1142 (IDELEMS(syzstr->res[index+1])+1)*sizeof(int), 1143 (IDELEMS(syzstr->res[index+1])+17)*sizeof(int)); 1144 syzstr->Howmuch[index+1]=(int*)ReAlloc((ADDRESS)syzstr->Howmuch[index+1], 1145 (IDELEMS(syzstr->res[index+1])+1)*sizeof(int), 1146 (IDELEMS(syzstr->res[index+1])+17)*sizeof(int)); 1147 syzstr->Firstelem[index+1]=(int*)ReAlloc((ADDRESS)syzstr->Firstelem[index+1], 1148 (IDELEMS(syzstr->res[index+1])+1)*sizeof(int), 1149 (IDELEMS(syzstr->res[index+1])+17)*sizeof(int)); 1275 1150 int mk; 1276 for (mk=IDELEMS( res[index+1])+1;mk<IDELEMS(res[index+1])+17;mk++)1277 { 1278 Howmuch[index+1][mk] = 0;1279 Firstelem[index+1][mk] = 0;1151 for (mk=IDELEMS(syzstr->res[index+1])+1;mk<IDELEMS(syzstr->res[index+1])+17;mk++) 1152 { 1153 syzstr->Howmuch[index+1][mk] = 0; 1154 syzstr->Firstelem[index+1][mk] = 0; 1280 1155 } 1281 1156 //Print("sort %d has now size %d\n",index+1,IDELEMS(res[index+1])+17); 1282 IDELEMS(res[index+1]) += 16; 1283 pEnlargeSet(&(orderedRes[index+1]->m),IDELEMS(orderedRes[index+1]),16); 1284 IDELEMS(orderedRes[index+1]) += 16; 1285 } 1286 currcomponents = truecomponents[index]; 1287 res[index+1]->m[ks] = syRedtail(nextPairs[i].syz,orderedRes[index+1],index+1); 1288 currcomponents = truecomponents[index-1]; 1289 //res[index+1]->m[ks] = nextPairs[i].syz; 1290 pNorm(res[index+1]->m[ks]); 1291 nextPairs[i].syz =NULL; 1292 syOrder(res[index+1]->m[ks],res,orderedRes,index+1,ks+1); 1157 IDELEMS(syzstr->res[index+1]) += 16; 1158 pEnlargeSet(&(syzstr->orderedRes[index+1]->m),IDELEMS(syzstr->orderedRes[index+1]),16); 1159 IDELEMS(syzstr->orderedRes[index+1]) += 16; 1160 } 1161 currcomponents = syzstr->truecomponents[index]; 1162 syzstr->res[index+1]->m[ks] = syRedtail(tso.syz,syzstr,index+1); 1163 currcomponents = syzstr->truecomponents[index-1]; 1164 syzstr->res[index+1]->m[ks] = tso.syz; 1165 pNorm(syzstr->res[index+1]->m[ks]); 1166 tso.syz =NULL; 1167 tso.syzind = ks; 1168 syOrder(syzstr->res[index+1]->m[ks],syzstr,index+1,ks+1); 1293 1169 ks++; 1294 1170 p = NULL; 1171 nextPairs[i] = tso; 1295 1172 } 1296 1173 else … … 1308 1185 * wrt. the ideal generated by elements of lower degrees 1309 1186 */ 1310 static void syRedGenerOfCurrDeg(SRes resPairs,resolvente res,resolvente orderedRes, 1311 int deg, int index,intvec * Tl) 1312 { 1313 int i=0,j,k=IDELEMS(res[index]),kk; 1314 1315 while ((k>0) && (res[index]->m[k-1]==NULL)) k--; 1316 while ((i<(*Tl)[index-1]) && (((resPairs[index-1])[i].syz==NULL) || 1317 (pTotaldegree((resPairs[index-1])[i].syz)<deg))) 1187 static void syRedGenerOfCurrDeg(syStrategy syzstr, int deg, int index) 1188 { 1189 ideal res=syzstr->res[index]; 1190 int i=0,j,k=IDELEMS(res),kk; 1191 SSet sPairs=syzstr->resPairs[index-1]; 1192 1193 while ((k>0) && (res->m[k-1]==NULL)) k--; 1194 while ((i<(*syzstr->Tl)[index-1]) && (((sPairs)[i].syz==NULL) || 1195 ((sPairs)[i].order<deg))) 1318 1196 i++; 1319 if ((i>=(* Tl)[index-1]) || (pTotaldegree((resPairs[index-1])[i].syz)>deg)) return;1320 while ((i<(* Tl)[index-1]) && (((resPairs[index-1])[i].syz==NULL) ||1321 ( pTotaldegree((resPairs[index-1])[i].syz)==deg)))1322 { 1323 if (( resPairs[index-1])[i].syz!=NULL)1197 if ((i>=(*syzstr->Tl)[index-1]) || ((sPairs)[i].order>deg)) return; 1198 while ((i<(*syzstr->Tl)[index-1]) && (((sPairs)[i].syz==NULL) || 1199 ((sPairs)[i].order==deg))) 1200 { 1201 if ((sPairs)[i].syz!=NULL) 1324 1202 { 1325 1203 j = k-1; 1326 while ((j>=0) && (res [index]->m[j]!=NULL) &&1327 (( resPairs[index-1])[i].syz!=NULL))1328 { 1329 if (syDivisibleBy(res [index]->m[j],(resPairs[index-1])[i].syz))1204 while ((j>=0) && (res->m[j]!=NULL) && 1205 ((sPairs)[i].syz!=NULL)) 1206 { 1207 if (syDivisibleBy(res->m[j],(sPairs)[i].syz)) 1330 1208 { 1331 1209 //Print("r"); 1332 ( resPairs[index-1])[i].syz =1333 //spSpolyRed(res [index]->m[j],(resPairs[index-1])[i].syz,NULL);1334 sySPolyRed(( resPairs[index-1])[i].syz,res[index]->m[j]);1210 (sPairs)[i].syz = 1211 //spSpolyRed(res->m[j],(sPairs)[i].syz,NULL); 1212 sySPolyRed((sPairs)[i].syz,res->m[j]); 1335 1213 j = k-1; 1336 1214 } … … 1340 1218 } 1341 1219 } 1342 if (( resPairs[index-1])[i].syz != NULL)1343 { 1344 if (k==IDELEMS(res [index]))1345 { 1346 pEnlargeSet(&(res [index]->m),IDELEMS(res[index]),16);1347 truecomponents[index]=(int*)ReAlloc((ADDRESS)truecomponents[index],1348 (IDELEMS(res [index])+1)*sizeof(int),1349 (IDELEMS(res [index])+17)*sizeof(int));1350 backcomponents[index]=(int*)ReAlloc((ADDRESS)backcomponents[index],1351 (IDELEMS(res [index])+1)*sizeof(int),1352 (IDELEMS(res [index])+17)*sizeof(int));1353 Howmuch[index]=(int*)ReAlloc((ADDRESS)Howmuch[index],1354 (IDELEMS(res [index])+1)*sizeof(int),1355 (IDELEMS(res [index])+17)*sizeof(int));1356 Firstelem[index]=(int*)ReAlloc((ADDRESS)Firstelem[index],1357 (IDELEMS(res [index])+1)*sizeof(int),1358 (IDELEMS(res [index])+17)*sizeof(int));1220 if ((sPairs)[i].syz != NULL) 1221 { 1222 if (k==IDELEMS(res)) 1223 { 1224 pEnlargeSet(&(res->m),IDELEMS(res),16); 1225 syzstr->truecomponents[index]=(int*)ReAlloc((ADDRESS)syzstr->truecomponents[index], 1226 (IDELEMS(res)+1)*sizeof(int), 1227 (IDELEMS(res)+17)*sizeof(int)); 1228 syzstr->backcomponents[index]=(int*)ReAlloc((ADDRESS)syzstr->backcomponents[index], 1229 (IDELEMS(res)+1)*sizeof(int), 1230 (IDELEMS(res)+17)*sizeof(int)); 1231 syzstr->Howmuch[index]=(int*)ReAlloc((ADDRESS)syzstr->Howmuch[index], 1232 (IDELEMS(res)+1)*sizeof(int), 1233 (IDELEMS(res)+17)*sizeof(int)); 1234 syzstr->Firstelem[index]=(int*)ReAlloc((ADDRESS)syzstr->Firstelem[index], 1235 (IDELEMS(res)+1)*sizeof(int), 1236 (IDELEMS(res)+17)*sizeof(int)); 1359 1237 int mk; 1360 for (mk=IDELEMS(res [index])+1;mk<IDELEMS(res[index])+17;mk++)1361 { 1362 Howmuch[index][mk] = 0;1363 Firstelem[index][mk] = 0;1238 for (mk=IDELEMS(res)+1;mk<IDELEMS(res)+17;mk++) 1239 { 1240 syzstr->Howmuch[index][mk] = 0; 1241 syzstr->Firstelem[index][mk] = 0; 1364 1242 } 1365 1243 //Print("sort %d has now size %d\n",index,IDELEMS(res[index])+17); 1366 IDELEMS(res [index]) += 16;1367 pEnlargeSet(&( orderedRes[index]->m),IDELEMS(orderedRes[index]),16);1368 IDELEMS( orderedRes[index]) += 16;1244 IDELEMS(res) += 16; 1245 pEnlargeSet(&(syzstr->orderedRes[index]->m),IDELEMS(syzstr->orderedRes[index]),16); 1246 IDELEMS(syzstr->orderedRes[index]) += 16; 1369 1247 } 1370 1248 if (BTEST1(6)) 1371 1249 { 1372 if (( resPairs[index-1])[i].isNotMinimal==0)1250 if ((sPairs)[i].isNotMinimal==NULL) 1373 1251 { 1374 1252 PrintLn(); 1375 Print("minimal generator: ");pWrite(( resPairs[index-1])[i].syz);1376 Print("comes from: ");pWrite(( resPairs[index-1])[i].p1);1377 Print("and: ");pWrite(( resPairs[index-1])[i].p2);1253 Print("minimal generator: ");pWrite((syzstr->resPairs[index-1])[i].syz); 1254 Print("comes from: ");pWrite((syzstr->resPairs[index-1])[i].p1); 1255 Print("and: ");pWrite((syzstr->resPairs[index-1])[i].p2); 1378 1256 } 1379 1257 } 1380 //res[index]->m[k] = (resPairs[index-1])[i].syz; 1381 res[index]->m[k] = syRedtail((resPairs[index-1])[i].syz,orderedRes[index],index); 1382 pNorm(res[index]->m[k]); 1383 // (resPairs[index-1])[i].syz = NULL; 1258 //res->m[k] = (sPairs)[i].syz; 1259 res->m[k] = syRedtail((sPairs)[i].syz,syzstr,index); 1260 (sPairs)[i].syzind = k; 1261 pNorm(res->m[k]); 1262 // (sPairs)[i].syz = NULL; 1384 1263 k++; 1385 syOrder(res [index]->m[k-1],res,orderedRes,index,k);1264 syOrder(res->m[k-1],syzstr,index,k); 1386 1265 euler++; 1387 1266 } 1388 //else 1389 //{ 1390 //zeroRed++; 1391 //} 1267 else 1268 (sPairs)[i].syzind = -1; 1392 1269 } 1393 1270 i++; … … 1451 1328 1452 1329 /*3 1453 * applies GM-criteria to triples (i,j,k) where j is fixed1454 */1455 static void syCrit(SRes resPairs, intvec * Tl, int index, int j)1456 {1457 int i,k,l,ll,ini=max(1,(*Tl)[index]);1458 ideal temp=idInit(ini,1);1459 1460 for (l=(*Tl)[index]-1;l>=0;l--)1461 {1462 if ((resPairs[index][l].lcm!=NULL) &&1463 (pGetComp(resPairs[index][l].lcm)==j))1464 {1465 temp->m[l] = pDivide(resPairs[index][l].p1,resPairs[index][l].lcm);1466 pSetComp(temp->m[l],resPairs[index][l].ind1);1467 }1468 }1469 idSkipZeroes(temp);1470 k = IDELEMS(temp)-1;1471 while ((k>=0) && (temp->m[k]==NULL)) k--;1472 while (k>0)1473 {1474 for (i=0;i<k;i++)1475 {1476 l = pVariables;1477 while ((l>0) && (pGetExp(temp->m[i],l)*pGetExp(temp->m[k],l)==0))1478 l--;1479 if (l==0)1480 {1481 ll = 0;1482 while ((ll<(*Tl)[index]) &&1483 (((pGetComp(temp->m[i])!=resPairs[index][ll].ind1) ||1484 (pGetComp(temp->m[k])!=resPairs[index][ll].ind2)) &&1485 ((pGetComp(temp->m[k])!=resPairs[index][ll].ind1) ||1486 (pGetComp(temp->m[i])!=resPairs[index][ll].ind2))))1487 ll++;1488 if ((ll<(*Tl)[index]) && (resPairs[index][ll].lcm!=NULL))1489 {1490 syDeletePair(&resPairs[index][ll]);1491 //crit++;1492 }1493 }1494 }1495 k--;1496 }1497 syCompactifyPairSet(resPairs[index],(*Tl)[index],0);1498 idDelete(&temp);1499 }1500 1501 /*31502 1330 * computes pairs from the new elements (beginning with the element newEl) 1503 1331 * in the module index 1504 1332 */ 1505 static void syCreateNewPairs(SRes resPairs, intvec * Tl, resolvente res, 1506 int index, int newEl) 1333 static void syCreateNewPairs(syStrategy syzstr, int index, int newEl) 1507 1334 { 1508 1335 SSet temp; 1509 1336 SObject tso; 1510 int i,ii,j,k=IDELEMS( res[index]),l=(*Tl)[index],ll;1337 int i,ii,j,k=IDELEMS(syzstr->res[index]),l=(*syzstr->Tl)[index],ll; 1511 1338 int qc,first,pos,jj,j1; 1339 int * bci=syzstr->backcomponents[index]; 1512 1340 poly p,q; 1513 polyset rs= res[index]->m,nPm;1514 1515 while ((k>0) && (r es[index]->m[k-1]==NULL)) k--;1341 polyset rs=syzstr->res[index]->m,nPm; 1342 1343 while ((k>0) && (rs[k-1]==NULL)) k--; 1516 1344 if (newEl>=k) return; 1517 ideal nP=idInit(k, res[index]->rank);1345 ideal nP=idInit(k,syzstr->res[index]->rank); 1518 1346 nPm=nP->m; 1519 while ((l>0) && (( resPairs[index])[l-1].p1==NULL)) l--;1347 while ((l>0) && ((syzstr->resPairs[index])[l-1].p1==NULL)) l--; 1520 1348 //Print("new pairs in module %d\n",index); 1521 1349 for (j=newEl;j<k;j++) … … 1523 1351 q = rs[j]; 1524 1352 qc = pGetComp(q); 1525 first = Firstelem[index-1][pGetComp(q)]-1;1526 pos = first+ Howmuch[index-1][pGetComp(q)];1353 first = syzstr->Firstelem[index-1][pGetComp(q)]-1; 1354 pos = first+syzstr->Howmuch[index-1][pGetComp(q)]; 1527 1355 for (i=first;i<pos;i++) 1528 1356 { 1529 jj = b ackcomponents[index][i];1357 jj = bci[i]; 1530 1358 if (jj>=j) break; 1531 1359 p = pOne(); … … 1535 1363 loop 1536 1364 { 1537 j1 = b ackcomponents[index][ii];1365 j1 = bci[ii]; 1538 1366 if (nPm[j1]!=NULL) 1539 1367 { … … 1557 1385 } 1558 1386 } 1559 for (i=0;i<j;i++) 1560 { 1561 if (nPm[i]!=NULL) 1562 { 1563 if (l>=(*Tl)[index]) 1564 { 1565 temp = (SSet)Alloc0(((*Tl)[index]+16)*sizeof(SObject)); 1566 for (ll=0;ll<(*Tl)[index];ll++) 1387 //for (i=0;i<j;i++) 1388 for (i=first;i<pos;i++) 1389 { 1390 ii = bci[i]; 1391 if (nPm[ii]!=NULL) 1392 { 1393 if (l>=(*syzstr->Tl)[index]) 1394 { 1395 temp = (SSet)Alloc0(((*syzstr->Tl)[index]+16)*sizeof(SObject)); 1396 for (ll=0;ll<(*syzstr->Tl)[index];ll++) 1567 1397 { 1568 temp[ll].p = (resPairs[index])[ll].p; 1569 temp[ll].p1 = (resPairs[index])[ll].p1; 1570 temp[ll].p2 = (resPairs[index])[ll].p2; 1571 temp[ll].syz = (resPairs[index])[ll].syz; 1572 temp[ll].lcm = (resPairs[index])[ll].lcm; 1573 temp[ll].ind1 = (resPairs[index])[ll].ind1; 1574 temp[ll].ind2 = (resPairs[index])[ll].ind2; 1575 temp[ll].order = (resPairs[index])[ll].order; 1576 temp[ll].isNotMinimal = (resPairs[index])[ll].isNotMinimal; 1398 temp[ll].p = (syzstr->resPairs[index])[ll].p; 1399 temp[ll].p1 = (syzstr->resPairs[index])[ll].p1; 1400 temp[ll].p2 = (syzstr->resPairs[index])[ll].p2; 1401 temp[ll].syz = (syzstr->resPairs[index])[ll].syz; 1402 temp[ll].lcm = (syzstr->resPairs[index])[ll].lcm; 1403 temp[ll].ind1 = (syzstr->resPairs[index])[ll].ind1; 1404 temp[ll].ind2 = (syzstr->resPairs[index])[ll].ind2; 1405 temp[ll].syzind = (syzstr->resPairs[index])[ll].syzind; 1406 temp[ll].order = (syzstr->resPairs[index])[ll].order; 1407 temp[ll].isNotMinimal = (syzstr->resPairs[index])[ll].isNotMinimal; 1577 1408 } 1578 Free((ADDRESS) resPairs[index],(*Tl)[index]*sizeof(SObject));1579 (* Tl)[index] += 16;1580 resPairs[index] = temp;1581 } 1582 tso.lcm = p = nPm[i ];1583 nPm[i ] = NULL;1409 Free((ADDRESS)syzstr->resPairs[index],(*syzstr->Tl)[index]*sizeof(SObject)); 1410 (*syzstr->Tl)[index] += 16; 1411 syzstr->resPairs[index] = temp; 1412 } 1413 tso.lcm = p = nPm[ii]; 1414 nPm[ii] = NULL; 1584 1415 tso.order = pGetOrder(p) = pTotaldegree(p); 1585 tso.p1 = rs[i ];1416 tso.p1 = rs[ii]; 1586 1417 tso.p2 = q; 1587 tso.ind1 = i ;1418 tso.ind1 = ii; 1588 1419 tso.ind2 = j; 1589 tso.isNotMinimal = 0; 1420 tso.syzind = -1; 1421 tso.isNotMinimal = NULL; 1590 1422 tso.p = NULL; 1591 1423 tso.syz = NULL; 1592 syEnterPair( resPairs[index],&tso,&l,index);1424 syEnterPair(syzstr->resPairs[index],&tso,&l,index); 1593 1425 } 1594 1426 } … … 1597 1429 } 1598 1430 1599 static void sySyzTail(SRes resPairs, intvec * Tl, resolvente orderedRes, 1600 resolvente res, int index, int newEl) 1601 { 1602 int j,ll,k=IDELEMS(res[index]); 1603 while ((k>0) && (res[index]->m[k-1]==NULL)) k--; 1431 static void sySyzTail(syStrategy syzstr, int index, int newEl) 1432 { 1433 int j,ll,k=IDELEMS((syzstr->res)[index]); 1434 while ((k>0) && ((syzstr->res)[index]->m[k-1]==NULL)) k--; 1604 1435 for (j=newEl;j<k;j++) 1605 1436 { 1606 1437 ll = 0; 1607 while ((ll<(* Tl)[index]) && (resPairs[index][ll].p1!=NULL) &&1608 ( resPairs[index][ll].ind1!=j) && (resPairs[index][ll].ind2!=j))1438 while ((ll<(*syzstr->Tl)[index]) && (syzstr->resPairs[index][ll].p1!=NULL) && 1439 (syzstr->resPairs[index][ll].ind1!=j) && (syzstr->resPairs[index][ll].ind2!=j)) 1609 1440 ll++; 1610 if ((ll<(*Tl)[index]) && (resPairs[index][ll].p1!=NULL)) 1611 res[index]->m[j] = syRedtail(res[index]->m[j],orderedRes[index],index); 1612 } 1613 } 1614 1615 /*3 1616 * looks through the pair set and the given module for 1617 * remaining pairs or generators to consider 1618 */ 1619 static BOOLEAN syCheckPairs(SRes resPairs,intvec * Tl, 1620 int length,int * actdeg) 1621 { 1622 int newdeg=*actdeg,i,index=0,t; 1623 1624 while ((index<length) && (resPairs[index]!=NULL)) 1625 { 1626 i = 0; 1627 while ((i<(*Tl)[index])) 1628 { 1629 t = *actdeg; 1630 if ((resPairs[index])[i].lcm!=NULL) 1631 { 1632 if (pGetOrder((resPairs[index])[i].lcm) > *actdeg) 1633 t = pGetOrder((resPairs[index])[i].lcm); 1634 } 1635 else if ((resPairs[index])[i].syz!=NULL) 1636 { 1637 if (pGetOrder((resPairs[index])[i].syz) > *actdeg) 1638 t = pGetOrder((resPairs[index])[i].syz); 1639 } 1640 if ((t>*actdeg) && ((newdeg==*actdeg) || (t<newdeg))) 1641 { 1642 newdeg = t; 1643 break; 1644 } 1645 i++; 1646 } 1647 index++; 1648 } 1649 if (newdeg>*actdeg) 1650 { 1651 *actdeg = newdeg; 1652 return TRUE; 1653 } 1654 else return FALSE; 1441 if ((ll<(*syzstr->Tl)[index]) && (syzstr->resPairs[index][ll].p1!=NULL)) 1442 syzstr->res[index]->m[j] = syRedtail(syzstr->res[index]->m[j],syzstr,index); 1443 } 1655 1444 } 1656 1445 … … 1661 1450 * works with slanted degree (i.e. deg=realdeg-index) 1662 1451 */ 1663 static SSet syChosePairs( SRes resPairs,intvec * Tl, int *index, int *howmuch,1664 int length,int * actdeg)1452 static SSet syChosePairs(syStrategy syzstr, int *index, 1453 int *howmuch, int * actdeg) 1665 1454 { 1666 1455 int newdeg=*actdeg,newindex=-1,i,t,sldeg; 1456 poly p; 1667 1457 SSet result; 1458 SRes resPairs=syzstr->resPairs; 1668 1459 1669 while (*index< length)1460 while (*index<syzstr->length) 1670 1461 { 1671 1462 if (resPairs[*index]!=NULL) … … 1675 1466 if (*index!=0) 1676 1467 { 1677 while ((i<(*Tl)[*index])) 1678 { 1679 if ((resPairs[*index])[i].lcm!=NULL) 1468 while ((i<(*syzstr->Tl)[*index])) 1469 { 1470 p = (resPairs[*index])[i].lcm; 1471 if (p!=NULL) 1680 1472 { 1681 if (pGetOrder( (resPairs[*index])[i].lcm) == sldeg)1473 if (pGetOrder(p) == sldeg) 1682 1474 { 1683 1475 result = &(resPairs[*index])[i]; 1684 1476 *howmuch =1; 1685 1477 i++; 1686 while ((i<(* Tl)[*index]) && ((resPairs[*index])[i].lcm!=NULL)1478 while ((i<(*syzstr->Tl)[*index]) && ((resPairs[*index])[i].lcm!=NULL) 1687 1479 && (pGetOrder((resPairs[*index])[i].lcm) == sldeg)) 1688 1480 { … … 1698 1490 else 1699 1491 { 1700 while ((i<(* Tl)[*index]))1492 while ((i<(*syzstr->Tl)[*index])) 1701 1493 { 1702 1494 if ((resPairs[*index])[i].syz!=NULL) … … 1707 1499 (*howmuch) =1; 1708 1500 i++; 1709 while ((i<(* Tl)[*index]) && ((resPairs[*index])[i].syz!=NULL)1501 while ((i<(*syzstr->Tl)[*index]) && ((resPairs[*index])[i].syz!=NULL) 1710 1502 && (pTotaldegree((resPairs[*index])[i].syz) == *actdeg)) 1711 1503 { … … 1724 1516 *index = 0; 1725 1517 //if (TEST_OPT_PROT) Print("(Euler:%d)",euler); 1726 while (*index< length)1518 while (*index<syzstr->length) 1727 1519 { 1728 1520 if (resPairs[*index]!=NULL) 1729 1521 { 1730 1522 i = 0; 1731 while ((i<(* Tl)[*index]))1523 while ((i<(*syzstr->Tl)[*index])) 1732 1524 { 1733 1525 t = *actdeg+*index; 1734 if ((resPairs[*index])[i].lcm!=NULL) 1735 { 1736 if (pGetOrder((resPairs[*index])[i].lcm) > *actdeg+*index) 1737 t = pGetOrder((resPairs[*index])[i].lcm); 1526 p = (resPairs[*index])[i].lcm; 1527 if (p!=NULL) 1528 { 1529 if (pGetOrder(p) > t) 1530 t = pGetOrder(p); 1738 1531 } 1739 1532 else if ((resPairs[*index])[i].syz!=NULL) 1740 1533 { 1741 if (pTotaldegree((resPairs[*index])[i].syz) > *actdeg+*index)1534 if (pTotaldegree((resPairs[*index])[i].syz) > t) 1742 1535 t = pTotaldegree((resPairs[*index])[i].syz); 1743 1536 } … … 1753 1546 (*index)++; 1754 1547 } 1755 if (TEST_OPT_DEGBOUND && (newdeg > Kstd1_deg))1756 return NULL;1757 1548 if (newdeg>*actdeg) 1758 1549 { 1759 1550 *actdeg = newdeg; 1760 1551 *index = newindex; 1761 return syChosePairs( resPairs,Tl,index,howmuch,length,actdeg);1552 return syChosePairs(syzstr,index,howmuch,actdeg); 1762 1553 } 1763 1554 else return NULL; … … 1770 1561 * works deg by deg 1771 1562 */ 1772 static SSet syChosePairs1(SRes resPairs,intvec * Tl, int *index, int *howmuch, 1773 int length,int * actdeg) 1774 { 1775 int newdeg=*actdeg,newindex=-1,i,t; 1776 SSet result; 1777 1778 while (*index>=0) 1779 { 1780 if (resPairs[*index]!=NULL) 1781 { 1782 i = 0; 1783 if (*index!=0) 1784 { 1785 while ((i<(*Tl)[*index])) 1786 { 1787 if ((resPairs[*index])[i].lcm!=NULL) 1788 { 1789 if (pGetOrder((resPairs[*index])[i].lcm) == *actdeg) 1790 { 1791 result = &(resPairs[*index])[i]; 1792 *howmuch =1; 1793 i++; 1794 while ((i<(*Tl)[*index]) && ((resPairs[*index])[i].lcm!=NULL) 1795 && (pGetOrder((resPairs[*index])[i].lcm) == *actdeg)) 1796 { 1797 i++; 1798 (*howmuch)++; 1799 } 1800 return result; 1801 } 1802 } 1803 i++; 1804 } 1805 } 1806 else 1807 { 1808 while ((i<(*Tl)[*index])) 1809 { 1810 if ((resPairs[*index])[i].syz!=NULL) 1811 { 1812 if (pTotaldegree((resPairs[*index])[i].syz) == *actdeg) 1813 { 1814 result = &(resPairs[*index])[i]; 1815 (*howmuch) =1; 1816 i++; 1817 while ((i<(*Tl)[*index]) && ((resPairs[*index])[i].syz!=NULL) 1818 && (pTotaldegree((resPairs[*index])[i].syz) == *actdeg)) 1819 { 1820 i++; 1821 (*howmuch)++; 1822 } 1823 return result; 1824 } 1825 } 1826 i++; 1827 } 1828 } 1829 } 1830 (*index)--; 1831 } 1832 *index = length-1; 1833 while (*index>=0) 1834 { 1835 if (resPairs[*index]!=NULL) 1836 { 1837 i = 0; 1838 while ((i<(*Tl)[*index])) 1839 { 1840 t = *actdeg; 1841 if ((resPairs[*index])[i].lcm!=NULL) 1842 { 1843 if (pGetOrder((resPairs[*index])[i].lcm) > *actdeg) 1844 t = pGetOrder((resPairs[*index])[i].lcm); 1845 } 1846 else if ((resPairs[*index])[i].syz!=NULL) 1847 { 1848 if (pTotaldegree((resPairs[*index])[i].syz) > *actdeg) 1849 t = pTotaldegree((resPairs[*index])[i].syz); 1850 } 1851 if ((t>*actdeg) && ((newdeg==*actdeg) || (t<newdeg))) 1852 { 1853 newdeg = t; 1854 newindex = *index; 1855 break; 1856 } 1857 i++; 1858 } 1859 } 1860 (*index)--; 1861 } 1862 if (newdeg>*actdeg) 1863 { 1864 *actdeg = newdeg; 1865 *index = newindex; 1866 return syChosePairs1(resPairs,Tl,index,howmuch,length,actdeg); 1867 } 1868 else return NULL; 1869 } 1870 1563 /* 1564 *static SSet syChosePairs1(SRes resPairs,intvec * Tl, int *index, int *howmuch, 1565 * int length,int * actdeg) 1566 *{ 1567 * int newdeg=*actdeg,newindex=-1,i,t; 1568 * SSet result; 1569 * 1570 * while (*index>=0) 1571 * { 1572 * if (resPairs[*index]!=NULL) 1573 * { 1574 * i = 0; 1575 * if (*index!=0) 1576 * { 1577 * while ((i<(*Tl)[*index])) 1578 * { 1579 * if ((resPairs[*index])[i].lcm!=NULL) 1580 * { 1581 * if (pGetOrder((resPairs[*index])[i].lcm) == *actdeg) 1582 * { 1583 * result = &(resPairs[*index])[i]; 1584 * *howmuch =1; 1585 * i++; 1586 * while ((i<(*Tl)[*index]) && ((resPairs[*index])[i].lcm!=NULL) 1587 * && (pGetOrder((resPairs[*index])[i].lcm) == *actdeg)) 1588 * { 1589 * i++; 1590 * (*howmuch)++; 1591 * } 1592 * return result; 1593 * } 1594 * } 1595 * i++; 1596 * } 1597 * } 1598 * else 1599 * { 1600 * while ((i<(*Tl)[*index])) 1601 * { 1602 * if ((resPairs[*index])[i].syz!=NULL) 1603 * { 1604 * if (pTotaldegree((resPairs[*index])[i].syz) == *actdeg) 1605 * { 1606 * result = &(resPairs[*index])[i]; 1607 * (*howmuch) =1; 1608 * i++; 1609 * while ((i<(*Tl)[*index]) && ((resPairs[*index])[i].syz!=NULL) 1610 * && (pTotaldegree((resPairs[*index])[i].syz) == *actdeg)) 1611 * { 1612 * i++; 1613 * (*howmuch)++; 1614 * } 1615 * return result; 1616 * } 1617 * } 1618 * i++; 1619 * } 1620 * } 1621 * } 1622 * (*index)--; 1623 * } 1624 * *index = length-1; 1625 * while (*index>=0) 1626 * { 1627 * if (resPairs[*index]!=NULL) 1628 * { 1629 * i = 0; 1630 * while ((i<(*Tl)[*index])) 1631 * { 1632 * t = *actdeg; 1633 * if ((resPairs[*index])[i].lcm!=NULL) 1634 * { 1635 * if (pGetOrder((resPairs[*index])[i].lcm) > *actdeg) 1636 * t = pGetOrder((resPairs[*index])[i].lcm); 1637 * } 1638 * else if ((resPairs[*index])[i].syz!=NULL) 1639 * { 1640 * if (pTotaldegree((resPairs[*index])[i].syz) > *actdeg) 1641 * t = pTotaldegree((resPairs[*index])[i].syz); 1642 * } 1643 * if ((t>*actdeg) && ((newdeg==*actdeg) || (t<newdeg))) 1644 * { 1645 * newdeg = t; 1646 * newindex = *index; 1647 * break; 1648 * } 1649 * i++; 1650 * } 1651 * } 1652 * (*index)--; 1653 * } 1654 * if (newdeg>*actdeg) 1655 * { 1656 * *actdeg = newdeg; 1657 * *index = newindex; 1658 * return syChosePairs1(resPairs,Tl,index,howmuch,length,actdeg); 1659 * } 1660 * else return NULL; 1661 *} 1662 */ 1871 1663 /*3 1872 1664 * statistics of the resolution … … 1899 1691 1900 1692 /*3 1901 * sets regularity computed from the leading terms of arg1902 */1903 static int sySetRegularity(ideal arg)1904 {1905 if (idIs0(arg)) return -1;1906 ideal temp=idInit(IDELEMS(arg),arg->rank);1907 int i,len,reg=-1;1908 // intvec * w=new intvec(2);1909 1910 for (i=IDELEMS(arg)-1;i>=0;i--)1911 {1912 if (arg->m[i]!=NULL)1913 temp->m[i] = pHead(arg->m[i]);1914 }1915 idSkipZeroes(temp);1916 resolvente res = sySchreyerResolvente(temp,-1,&len,TRUE,TRUE);1917 intvec * dummy = syBetti(res,len,®, NULL);1918 delete dummy;1919 for (i=0;i<len;i++)1920 {1921 if (res[i]!=NULL) idDelete(&(res[i]));1922 }1923 Free((ADDRESS)res,len*sizeof(ideal));1924 idDelete(&temp);1925 return reg;1926 }1927 1928 /*31929 1693 * initialize a module 1930 1694 */ 1931 static int syInitSyzMod(resolvente res,resolvente orderedRes, 1932 int index) 1695 static int syInitSyzMod(syStrategy syzstr, int index, int init=17) 1933 1696 { 1934 1697 int result; 1935 1698 1936 if (res[index]==NULL) 1937 { 1938 res[index] = idInit(16,1); 1939 truecomponents[index] = (int*)Alloc0(17*sizeof(int)); 1940 backcomponents[index] = (int*)Alloc0(17*sizeof(int)); 1941 Howmuch[index] = (int*)Alloc0(17*sizeof(int)); 1942 Firstelem[index] = (int*)Alloc0(17*sizeof(int)); 1943 //Print("sort %d has now size %d\n",index,17); 1944 orderedRes[index] = idInit(16,1); 1699 if (syzstr->res[index]==NULL) 1700 { 1701 syzstr->res[index] = idInit(init-1,1); 1702 syzstr->truecomponents[index] = (int*)Alloc0(init*sizeof(int)); 1703 if (index==0) 1704 { 1705 for (int i=0;i<init;i++) 1706 syzstr->truecomponents[0][i] = i; 1707 } 1708 syzstr->backcomponents[index] = (int*)Alloc0(init*sizeof(int)); 1709 syzstr->Howmuch[index] = (int*)Alloc0(init*sizeof(int)); 1710 syzstr->Firstelem[index] = (int*)Alloc0(init*sizeof(int)); 1711 //Print("sort %d has now size %d\n",index,init); 1712 syzstr->orderedRes[index] = idInit(init-1,1); 1945 1713 result = 0; 1946 1714 } 1947 1715 else 1948 1716 { 1949 result = IDELEMS( res[index]);1950 while ((result>0) && ( res[index]->m[result-1]==NULL)) result--;1717 result = IDELEMS(syzstr->res[index]); 1718 while ((result>0) && (syzstr->res[index]->m[result-1]==NULL)) result--; 1951 1719 } 1952 1720 return result; 1953 1721 } 1954 1722 1723 void syKillComputation(syStrategy syzstr) 1724 { 1725 //Print("ref: %d\n",syzstr->references); 1726 if (syzstr->references>0) 1727 { 1728 (syzstr->references)--; 1729 } 1730 else 1731 { 1732 int i,j; 1733 1734 if (syzstr->resPairs!=NULL) 1735 { 1736 for (i=0;i<syzstr->length;i++) 1737 { 1738 for (j=0;j<(*syzstr->Tl)[i];j++) 1739 { 1740 if ((syzstr->resPairs[i])[j].lcm!=NULL) 1741 pDelete(&((syzstr->resPairs[i])[j].lcm)); 1742 } 1743 if (syzstr->orderedRes[i]!=NULL) 1744 { 1745 for (j=0;j<IDELEMS(syzstr->orderedRes[i]);j++) 1746 { 1747 syzstr->orderedRes[i]->m[j] = NULL; 1748 } 1749 } 1750 idDelete(&(syzstr->orderedRes[i])); 1751 if (syzstr->truecomponents[i]!=NULL) 1752 { 1753 Free((ADDRESS)syzstr->truecomponents[i],(IDELEMS(syzstr->res[i])+1)*sizeof(int)); 1754 syzstr->truecomponents[i]=NULL; 1755 } 1756 if (syzstr->backcomponents[i]!=NULL) 1757 { 1758 Free((ADDRESS)syzstr->backcomponents[i],(IDELEMS(syzstr->res[i])+1)*sizeof(int)); 1759 syzstr->backcomponents[i]=NULL; 1760 } 1761 if (syzstr->Howmuch[i]!=NULL) 1762 { 1763 Free((ADDRESS)syzstr->Howmuch[i],(IDELEMS(syzstr->res[i])+1)*sizeof(int)); 1764 syzstr->Howmuch[i]=NULL; 1765 } 1766 if (syzstr->Firstelem[i]!=NULL) 1767 { 1768 Free((ADDRESS)syzstr->Firstelem[i],(IDELEMS(syzstr->res[i])+1)*sizeof(int)); 1769 syzstr->Firstelem[i]=NULL; 1770 } 1771 if (syzstr->res[i]!=NULL) 1772 { 1773 for (j=0;j<IDELEMS(syzstr->res[i]);j++) 1774 { 1775 if (syzstr->res[i]->m[j]!=NULL) 1776 pDelete(&(syzstr->res[i]->m[j])); 1777 } 1778 } 1779 idDelete(&(syzstr->res[i])); 1780 Free((ADDRESS)syzstr->resPairs[i],(*syzstr->Tl)[i]*sizeof(SObject)); 1781 } 1782 Free((ADDRESS)syzstr->resPairs,syzstr->length*sizeof(SObject*)); 1783 Free((ADDRESS)syzstr->res,(syzstr->length+1)*sizeof(ideal)); 1784 Free((ADDRESS)syzstr->orderedRes,(syzstr->length+1)*sizeof(ideal)); 1785 Free((ADDRESS)syzstr->truecomponents,(syzstr->length+1)*sizeof(int*)); 1786 Free((ADDRESS)syzstr->backcomponents,(syzstr->length+1)*sizeof(int*)); 1787 Free((ADDRESS)syzstr->Howmuch,(syzstr->length+1)*sizeof(int*)); 1788 Free((ADDRESS)syzstr->Firstelem,(syzstr->length+1)*sizeof(int*)); 1789 Free((ADDRESS)syzstr->binom,pVariables*(syzstr->highdeg_1)*sizeof(int)); 1790 } 1791 if (syzstr->minres!=NULL) 1792 { 1793 for (i=0;i<syzstr->length;i++) 1794 { 1795 if (syzstr->minres[i]!=NULL) 1796 { 1797 for (j=0;j<IDELEMS(syzstr->minres[i]);j++) 1798 { 1799 if (syzstr->minres[i]->m[j]!=NULL) 1800 pDelete(&(syzstr->minres[i]->m[j])); 1801 } 1802 } 1803 idDelete(&(syzstr->minres[i])); 1804 } 1805 Free((ADDRESS)syzstr->minres,(syzstr->length+1)*sizeof(ideal)); 1806 } 1807 if (syzstr->fullres!=NULL) 1808 { 1809 for (i=0;i<syzstr->length;i++) 1810 { 1811 if (syzstr->fullres[i]!=NULL) 1812 { 1813 for (j=0;j<IDELEMS(syzstr->fullres[i]);j++) 1814 { 1815 if (syzstr->fullres[i]->m[j]!=NULL) 1816 pDelete(&(syzstr->fullres[i]->m[j])); 1817 } 1818 } 1819 idDelete(&(syzstr->fullres[i])); 1820 } 1821 Free((ADDRESS)syzstr->fullres,(syzstr->length+1)*sizeof(ideal)); 1822 } 1823 if (syzstr->resolution!=NULL) 1824 delete syzstr->resolution; 1825 Free((ADDRESS)syzstr,sizeof(ssyStrategy)); 1826 } 1827 } 1828 1829 intvec * syBettiOfComputation(syStrategy syzstr) 1830 { 1831 int dummy; 1832 if (syzstr->resPairs!=NULL) 1833 { 1834 int i,j=-1,jj=-1,l; 1835 SRes rP=syzstr->resPairs; 1836 1837 l = syzstr->length; 1838 while ((l>0) && (rP[l-1]==NULL)) l--; 1839 if (l==0) return NULL; 1840 l--; 1841 while (l>=0) 1842 { 1843 i = 0; 1844 while ((i<(*syzstr->Tl)[l]) && 1845 ((rP[l][i].lcm!=NULL) || (rP[l][i].syz!=NULL))) 1846 { 1847 if (rP[l][i].isNotMinimal==NULL) 1848 { 1849 if (j<rP[l][i].order-l) 1850 j = rP[l][i].order-l; 1851 if (jj<l) 1852 jj = l; 1853 } 1854 i++; 1855 } 1856 l--; 1857 } 1858 jj=jj+2; 1859 intvec *result=new intvec(j,jj,0); 1860 IMATELEM(*result,1,1) = idRankFreeModule(syzstr->res[1]); 1861 for (i=0;i<jj;i++) 1862 { 1863 j = 0; 1864 while ((j<(*syzstr->Tl)[i]) && 1865 ((rP[i][j].lcm!=NULL) || (rP[i][j].syz!=NULL))) 1866 { 1867 if (rP[i][j].isNotMinimal==NULL) 1868 IMATELEM(*result,rP[i][j].order-i,i+2)++; 1869 j++; 1870 } 1871 } 1872 return result; 1873 } 1874 else if (syzstr->fullres!=NULL) 1875 return syBetti(syzstr->fullres,syzstr->length,&dummy); 1876 else 1877 return syBetti(syzstr->minres,syzstr->length,&dummy); 1878 } 1879 1880 int syLength(syStrategy syzstr) 1881 { 1882 return syzstr->length; 1883 } 1884 1885 int sySize(syStrategy syzstr) 1886 { 1887 resolvente r=syzstr->res; 1888 if (r==NULL) 1889 r = syzstr->fullres; 1890 if (r==NULL) 1891 r = syzstr->minres; 1892 if (r==NULL) 1893 { 1894 WerrorS("No resolution found"); 1895 return 0; 1896 } 1897 int i=syzstr->length; 1898 while ((i>0) && (r[i-1]==NULL)) i--; 1899 return i; 1900 } 1901 1902 int syDim(syStrategy syzstr) 1903 { 1904 int i,j=-1,l; 1905 if (syzstr->resPairs!=NULL) 1906 { 1907 SRes rP=syzstr->resPairs; 1908 1909 l = syzstr->length; 1910 while ((l>0) && (rP[l-1]==NULL)) l--; 1911 if (l==0) return -1; 1912 l--; 1913 while (l>=0) 1914 { 1915 i = 0; 1916 while ((i<(*syzstr->Tl)[l]) && 1917 ((rP[l][i].lcm!=NULL) || (rP[l][i].syz!=NULL)) && 1918 (rP[l][i].isNotMinimal!=NULL)) 1919 { 1920 i++; 1921 } 1922 if ((i<(*syzstr->Tl)[l]) && 1923 ((rP[l][i].lcm!=NULL) || (rP[l][i].syz!=NULL)) && 1924 (rP[l][i].isNotMinimal==NULL)) 1925 return l; 1926 l--; 1927 } 1928 return l; 1929 } 1930 else 1931 return sySize(syzstr); 1932 } 1933 1934 syStrategy syCopy(syStrategy syzstr) 1935 { 1936 syStrategy result=syzstr; 1937 (result->references)++; 1938 return result; 1939 } 1940 1941 static void syPrintEmptySpaces(int i) 1942 { 1943 if (i!=0) 1944 { 1945 Print(" "); 1946 syPrintEmptySpaces(i/10); 1947 } 1948 } 1949 1950 static void syPrintEmptySpaces1(int i) 1951 { 1952 if (i!=0) 1953 { 1954 Print(" "); 1955 syPrintEmptySpaces1(i-1); 1956 } 1957 } 1958 1959 static int syLengthInt(int i) 1960 { 1961 int j=0; 1962 1963 if (i==0) return 1; 1964 while (i!=0) 1965 { 1966 j++; 1967 i = i/10; 1968 } 1969 return j; 1970 } 1971 1972 void syPrint(syStrategy syzstr) 1973 { 1974 if ((syzstr->resPairs==NULL) && (syzstr->fullres==NULL) 1975 && (syzstr->minres==NULL)) 1976 { 1977 Print("No resolution defined\n"); 1978 return; 1979 } 1980 int l=0; 1981 if (syzstr->resolution==NULL) 1982 { 1983 int j; 1984 if (syzstr->resPairs!=NULL) 1985 { 1986 syzstr->resolution = new intvec(syzstr->length+1); 1987 SRes rP=syzstr->resPairs; 1988 (*syzstr->resolution)[0] = max(1,idRankFreeModule(syzstr->res[1])); 1989 while ((l<syzstr->length) && (rP[l]!=NULL)) 1990 { 1991 j=0; 1992 while ((j<(*syzstr->Tl)[l]) && 1993 ((rP[l][j].lcm!=NULL) || (rP[l][j].syz!=NULL))) 1994 { 1995 if (rP[l][j].isNotMinimal==NULL) 1996 ((*syzstr->resolution)[l+1])++; 1997 j++; 1998 } 1999 l++; 2000 } 2001 } 2002 else 2003 { 2004 resolvente rr; 2005 syzstr->resolution = new intvec(syzstr->length+2); 2006 if (syzstr->minres!=NULL) 2007 rr = syzstr->minres; 2008 else 2009 rr = syzstr->fullres; 2010 (*syzstr->resolution)[0] = max(1,idRankFreeModule(rr[0])); 2011 while ((l<syzstr->length) && (rr[l]!=NULL)) 2012 { 2013 j = IDELEMS(rr[l]); 2014 while ((l>0) && (rr[l]->m[j-1]==NULL)) j--; 2015 ((*syzstr->resolution)[l+1]) = j; 2016 l++; 2017 } 2018 } 2019 } 2020 char *sn=currRingHdl->id; 2021 int sl=strlen(sn); 2022 syPrintEmptySpaces1(sl); 2023 l = 0; 2024 loop 2025 { 2026 Print("%d",(*syzstr->resolution)[l]); 2027 if ((l>=syzstr->resolution->length()) || ((*syzstr->resolution)[l]==0)) 2028 break; 2029 syPrintEmptySpaces1(sl+5); 2030 l++; 2031 } 2032 PrintLn(); 2033 l = 0; 2034 loop 2035 { 2036 Print(sn); 2037 if ((l>=syzstr->resolution->length()) || ((*syzstr->resolution)[l]==0)) 2038 break; 2039 syPrintEmptySpaces((*syzstr->resolution)[l]); 2040 Print(" <-- "); 2041 l++; 2042 } 2043 PrintLn(); 2044 PrintLn(); 2045 l = 0; 2046 loop 2047 { 2048 Print("%d",l); 2049 if ((l>=syzstr->resolution->length()) || ((*syzstr->resolution)[l]==0)) 2050 break; 2051 syPrintEmptySpaces1(sl+5+syLengthInt((*syzstr->resolution)[l])- 2052 syLengthInt(l)); 2053 l++; 2054 } 2055 PrintLn(); 2056 if (syzstr->minres==NULL) 2057 { 2058 Print("resolution not minimized yet"); 2059 PrintLn(); 2060 } 2061 } 2062 2063 static resolvente syReorder(resolvente res,int length, 2064 syStrategy syzstr,BOOLEAN toCopy=TRUE,resolvente totake=NULL) 2065 { 2066 int i,j,l; 2067 poly p,q,tq; 2068 polyset ri1; 2069 resolvente fullres; 2070 fullres = (resolvente)Alloc0((length+1)*sizeof(ideal)); 2071 if (totake==NULL) 2072 totake = res; 2073 for (i=length-1;i>0;i--) 2074 { 2075 if (res[i]!=NULL) 2076 { 2077 if (i>1) 2078 { 2079 j = IDELEMS(res[i-1]); 2080 while ((j>0) && (res[i-1]->m[j-1]==NULL)) j--; 2081 fullres[i-1] = idInit(IDELEMS(res[i]),j); 2082 ri1 = totake[i-1]->m; 2083 for (j=IDELEMS(res[i])-1;j>=0;j--) 2084 { 2085 p = res[i]->m[j]; 2086 q = NULL; 2087 while (p!=NULL) 2088 { 2089 if (toCopy) 2090 { 2091 tq = pHead(p); 2092 pIter(p); 2093 } 2094 else 2095 { 2096 tq = p; 2097 pIter(p); 2098 pNext(tq) = NULL; 2099 } 2100 for (l=pVariables;l>0;l--) 2101 pGetExp(tq,l) -= pGetExp(ri1[pGetComp(tq)-1],l); 2102 pSetm(tq); 2103 q = pAdd(q,tq); 2104 } 2105 fullres[i-1]->m[j] = q; 2106 } 2107 } 2108 else 2109 { 2110 if (toCopy) 2111 fullres[i-1] = idCopy(res[i]); 2112 else 2113 fullres[i-1] = res[i]; 2114 for (j=IDELEMS(res[i])-1;j>=0;j--) 2115 fullres[i-1]->m[j] = pOrdPoly(fullres[i-1]->m[j]); 2116 } 2117 } 2118 } 2119 if (!toCopy) 2120 Free((ADDRESS)res,(length+1)*sizeof(ideal)); 2121 //syzstr->length = length; 2122 return fullres; 2123 } 2124 2125 lists syConvRes(syStrategy syzstr) 2126 { 2127 if ((syzstr->fullres==NULL) && (syzstr->minres==NULL)) 2128 { 2129 syzstr->fullres = syReorder(syzstr->res,syzstr->length,syzstr); 2130 } 2131 resolvente tr; 2132 int typ0; 2133 if (syzstr->minres!=NULL) 2134 tr = syzstr->minres; 2135 else 2136 tr = syzstr->fullres; 2137 resolvente trueres=(resolvente)Alloc0((syzstr->length)*sizeof(ideal)); 2138 for (int i=(syzstr->length)-1;i>=0;i--) 2139 { 2140 if (tr[i]!=NULL) 2141 { 2142 trueres[i] = idCopy(tr[i]); 2143 } 2144 } 2145 if (idRankFreeModule(trueres[0])==0) 2146 typ0 = IDEAL_CMD; 2147 else 2148 typ0 = MODUL_CMD; 2149 return liMakeResolv(trueres,syzstr->length,-1,typ0,NULL); 2150 } 2151 2152 syStrategy syConvList(lists li) 2153 { 2154 int typ0; 2155 syStrategy result=(syStrategy)Alloc0(sizeof(ssyStrategy)); 2156 2157 resolvente fr = liFindRes(li,&(result->length),&typ0); 2158 result->fullres = (resolvente)Alloc0((result->length+1)*sizeof(ideal)); 2159 for (int i=result->length-1;i>=0;i--) 2160 { 2161 if (fr[i]!=NULL) 2162 result->fullres[i] = idCopy(fr[i]); 2163 } 2164 Free((ADDRESS)fr,(result->length)*sizeof(ideal)); 2165 return result; 2166 } 2167 2168 syStrategy syForceMin(lists li) 2169 { 2170 int typ0; 2171 syStrategy result=(syStrategy)Alloc0(sizeof(ssyStrategy)); 2172 2173 resolvente fr = liFindRes(li,&(result->length),&typ0); 2174 result->minres = (resolvente)Alloc0((result->length+1)*sizeof(ideal)); 2175 for (int i=result->length-1;i>=0;i--) 2176 { 2177 if (fr[i]!=NULL) 2178 result->minres[i] = idCopy(fr[i]); 2179 } 2180 Free((ADDRESS)fr,(result->length)*sizeof(ideal)); 2181 return result; 2182 } 2183 2184 static poly syStripOut(poly p,intvec * toStrip) 2185 { 2186 if (toStrip==NULL) return p; 2187 poly pp=p; 2188 2189 while ((pp!=NULL) && ((*toStrip)[pGetComp(pp)]!=0)) 2190 pDelete1(&pp); 2191 p = pp; 2192 if (pp!=NULL) 2193 { 2194 while (pNext(pp)!=NULL) 2195 { 2196 if ((*toStrip)[pGetComp(pNext(pp))]!=0) 2197 pDelete1(&pNext(pp)); 2198 else 2199 pIter(pp); 2200 } 2201 } 2202 return p; 2203 } 2204 2205 static poly syMinimizeP(poly toMin,syStrategy syzstr,int pNum,int index, 2206 intvec * toStrip) 2207 { 2208 int i,j,tc; 2209 poly p,pp=pCopy(toMin),q=NULL,tq,pisN; 2210 SSet sPairs=syzstr->resPairs[index]; 2211 BOOLEAN nothingToReduce; 2212 2213 pp = syStripOut(pp,toStrip); 2214 loop 2215 { 2216 nothingToReduce = TRUE; 2217 for (i=pNum-1;i>=0;i--) 2218 { 2219 if (sPairs[i].isNotMinimal!=NULL) 2220 { 2221 pisN = sPairs[i].isNotMinimal; 2222 tc = pGetComp(pisN); 2223 p = pp; 2224 while (p!=NULL) 2225 { 2226 if (pGetComp(p)==tc) 2227 { 2228 tq = pNew(); 2229 for(j=pVariables; j>0; j--) 2230 tq->exp[j] = p->exp[j]-pisN->exp[j]; 2231 tq->exp[0] = 0; 2232 pSetCoeff0(tq,nDiv(pGetCoeff(p),pGetCoeff(pisN))); 2233 pGetCoeff(tq) = nNeg(pGetCoeff(tq)); 2234 q = syAdd(q,syStripOut(syMultT1(syzstr->res[index+1]->m[sPairs[i].syzind],tq),toStrip)); 2235 nothingToReduce = FALSE; 2236 } 2237 pIter(p); 2238 } 2239 if (q!=NULL) 2240 { 2241 pp = syAdd(pp,q); 2242 q = NULL; 2243 } 2244 } 2245 } 2246 if (nothingToReduce) break; 2247 } 2248 return pp; 2249 } 2250 2251 static void syKillEmptyEntres(resolvente res,int length) 2252 { 2253 int i,j,jj,k,rj; 2254 intvec * changes; 2255 poly p; 2256 ideal ri; 2257 2258 for (i=0;i<length;i++) 2259 { 2260 ri = res[i]; 2261 if (ri!=NULL) 2262 { 2263 rj = IDELEMS(ri); 2264 changes = new intvec(rj+1,1,-1); 2265 while ((rj>0) && (ri->m[rj-1]==NULL)) rj--; 2266 j = k = 0; 2267 while (j+k<rj) 2268 { 2269 if (ri->m[j+k]!=NULL) 2270 { 2271 ri->m[j] = ri->m[j+k]; 2272 (*changes)[j+k+1] = j+1; 2273 j++; 2274 } 2275 else 2276 { 2277 k++; 2278 } 2279 } 2280 for (jj=j;jj<rj;jj++) 2281 ri->m[jj] = NULL; 2282 if (res[i+1]!=NULL) 2283 { 2284 ri = res[i+1]; 2285 for (j=IDELEMS(ri)-1;j>=0;j--) 2286 { 2287 p = ri->m[j]; 2288 while (p!=NULL) 2289 { 2290 pSetComp(p,(*changes)[pGetComp(p)]); 2291 pIter(p); 2292 } 2293 } 2294 } 2295 } 2296 } 2297 } 2298 2299 static intvec * syToStrip(syStrategy syzstr, int index) 2300 { 2301 intvec * result=NULL; 2302 2303 if ((syzstr->resPairs[index-1]!=NULL) && (!idIs0(syzstr->res[index]))) 2304 { 2305 result=new intvec(IDELEMS(syzstr->res[index])+1); 2306 for (int i=(*syzstr->Tl)[index-1]-1;i>=0;i--) 2307 { 2308 if (syzstr->resPairs[index-1][i].isNotMinimal!=NULL) 2309 { 2310 (*result)[syzstr->resPairs[index-1][i].syzind+1] = 1; 2311 } 2312 } 2313 } 2314 return result; 2315 } 2316 2317 static resolvente syReadOutMinimalRes(syStrategy syzstr, 2318 BOOLEAN computeStd=FALSE) 2319 { 2320 intvec * Strip; 2321 resolvente tres=(resolvente)Alloc0((syzstr->length+1)*sizeof(ideal)); 2322 if (computeStd) 2323 { 2324 tres[0] = syzstr->res[1]; 2325 syzstr->res[1] = idInit(IDELEMS(tres[0]),tres[0]->rank); 2326 return tres; 2327 } 2328 int i,j,l,index,o1,ii,i1; 2329 poly p; 2330 ideal rs; 2331 SSet sPairs; 2332 int * ord,*b0,*b1; 2333 pSetmProc oldSetm=pSetm; 2334 pCompProc oldComp0=pComp0; 2335 2336 if ((currRing->order[0]==ringorder_dp) 2337 && (currRing->order[1]==ringorder_C) 2338 && (currRing->order[2]==0)) 2339 { 2340 ord=NULL; 2341 } 2342 /*--- changes to a dpC-ring with special comp0------*/ 2343 else 2344 { 2345 ord = (int*)Alloc0(3*sizeof(int)); 2346 b0 = (int*)Alloc0(3*sizeof(int)); 2347 b1 = (int*)Alloc0(3*sizeof(int)); 2348 ord[0] = ringorder_dp; 2349 ord[1] = ringorder_C; 2350 b0[1] = 1; 2351 b1[0] = pVariables; 2352 pChangeRing(pVariables,1,ord,b0,b1,currRing->wvhdl); 2353 } 2354 pSetm =syzSetm; 2355 binomials = syzstr->binom; 2356 highdeg_1 = syzstr->highdeg_1; 2357 pComp0 = syzcomp2dpc; 2358 for (index=syzstr->length-1;index>0;index--) 2359 { 2360 if (syzstr->resPairs[index]!=NULL) 2361 { 2362 currcomponents = syzstr->truecomponents[index]; 2363 sPairs = syzstr->resPairs[index]; 2364 Strip = syToStrip(syzstr,index); 2365 tres[index+1] = idInit(IDELEMS(syzstr->res[index+1]),syzstr->res[index+1]->rank); 2366 i1 = (*syzstr->Tl)[index]; 2367 for (i=0;i<i1;i++) 2368 { 2369 if ((sPairs[i].isNotMinimal==NULL) && (sPairs[i].lcm!=NULL)) 2370 { 2371 o1 = sPairs[i].order; 2372 ii = i; 2373 while ((ii<i1) && (sPairs[ii].lcm!=NULL) && (sPairs[ii].order==o1)) 2374 ii++; 2375 l = sPairs[i].syzind; 2376 tres[index+1]->m[l] = 2377 syMinimizeP(syzstr->res[index+1]->m[l],syzstr,ii,index,Strip); 2378 } 2379 } 2380 delete Strip; 2381 Strip = NULL; 2382 } 2383 } 2384 currcomponents = syzstr->truecomponents[0]; 2385 tres[1] = idInit(IDELEMS(syzstr->res[1]),syzstr->res[1]->rank); 2386 sPairs = syzstr->resPairs[0]; 2387 for (i=(*syzstr->Tl)[0]-1;i>=0;i--) 2388 { 2389 if (sPairs[i].syzind>=0) 2390 { 2391 tres[1]->m[sPairs[i].syzind] = pCopy(syzstr->res[1]->m[sPairs[i].syzind]); 2392 } 2393 } 2394 /*--- changes to the original ring------------------*/ 2395 if (ord!=NULL) 2396 { 2397 pChangeRing(pVariables,currRing->OrdSgn,currRing->order, 2398 currRing->block0,currRing->block1,currRing->wvhdl); 2399 } 2400 else 2401 { 2402 pSetm=oldSetm; 2403 pComp0=oldComp0; 2404 } 2405 tres = syReorder(tres,syzstr->length,syzstr,FALSE,syzstr->res); 2406 syKillEmptyEntres(tres,syzstr->length); 2407 idSkipZeroes(tres[0]); 2408 return tres; 2409 } 2410 2411 syStrategy syMinimize(syStrategy syzstr) 2412 { 2413 if (syzstr->minres==NULL) 2414 { 2415 if (syzstr->resPairs!=NULL) 2416 { 2417 syzstr->minres = syReadOutMinimalRes(syzstr); 2418 } 2419 else if (syzstr->fullres!=NULL) 2420 { 2421 syMinimizeResolvente(syzstr->fullres,syzstr->length,1); 2422 syzstr->minres = syzstr->fullres; 2423 syzstr->fullres = NULL; 2424 } 2425 } 2426 (syzstr->references)++; 2427 return syzstr; 2428 } 2429 1955 2430 static void sySetHighdeg() 1956 { 1957 long long t=1, h_d=1; 1958 long long h_n=1+pVariables; 1959 while ((t=((t*h_n)/h_d))<INT_MAX) 1960 { 1961 h_d++; 1962 h_n++; 1963 } 1964 h_d--; 1965 highdeg = h_d; 1966 //Print("max deg=%d\n",highdeg); 1967 } 2431 { 2432 long long t=1, h_d=1; 2433 long long h_n=1+pVariables; 2434 while ((t=((t*h_n)/h_d))<INT_MAX) 2435 { 2436 h_d++; 2437 h_n++; 2438 } 2439 h_d--; 2440 highdeg = h_d; 2441 //Print("max deg=%d\n",highdeg); 2442 } 2443 1968 2444 1969 2445 /*2 … … 1972 2448 * works with slanted degree, uses syChosePairs 1973 2449 */ 2450 //syStrategy syLaScala1(ideal arg,int * length) 1974 2451 resolvente syLaScala1(ideal arg,int * length) 1975 2452 { … … 1977 2454 int i,j,* ord,*b0,*b1,actdeg=32000,index=0,reg=-1; 1978 2455 int startdeg,howmuch; 1979 intvec * Tl;1980 2456 poly p; 1981 2457 ideal temp; 1982 resolvente res,orderedRes;1983 2458 SSet nextPairs; 1984 SRes resPairs;2459 syStrategy syzstr=(syStrategy)Alloc0(sizeof(ssyStrategy)); 1985 2460 pSetmProc oldSetm=pSetm; 1986 pCompProc old pComp=pComp0;2461 pCompProc oldComp0=pComp0; 1987 2462 1988 2463 //crit = 0; … … 1994 2469 //orderingdepth = new intvec(pVariables+1); 1995 2470 if (*length<=0) *length = pVariables+2; 2471 syzstr->length = *length; 1996 2472 if (idIs0(arg)) return NULL; 1997 2473 if ((currRing->order[0]==ringorder_dp) … … 2014 2490 } 2015 2491 /*--- initializes the data structures---------------*/ 2016 Tl = new intvec(*length);2492 syzstr->Tl = new intvec(*length); 2017 2493 temp = idInit(IDELEMS(arg),arg->rank); 2018 2494 for (i=0;i<IDELEMS(arg);i++) … … 2039 2515 } 2040 2516 pComp0 = syzcomp2dpc; 2041 resPairs = syInitRes(temp,length,Tl);2042 res = (resolvente)Alloc0((*length+1)*sizeof(ideal));2043 orderedRes = (resolvente)Alloc0((*length+1)*sizeof(ideal));2044 truecomponents = (int**)Alloc0((*length+1)*sizeof(int*));2045 backcomponents = (int**)Alloc0((*length+1)*sizeof(int*));2046 Howmuch = (int**)Alloc0((*length+1)*sizeof(int*));2047 Firstelem = (int**)Alloc0((*length+1)*sizeof(int*));2517 syzstr->resPairs = syInitRes(temp,length,syzstr->Tl); 2518 syzstr->res = (resolvente)Alloc0((*length+1)*sizeof(ideal)); 2519 syzstr->orderedRes = (resolvente)Alloc0((*length+1)*sizeof(ideal)); 2520 syzstr->truecomponents = (int**)Alloc0((*length+1)*sizeof(int*)); 2521 syzstr->backcomponents = (int**)Alloc0((*length+1)*sizeof(int*)); 2522 syzstr->Howmuch = (int**)Alloc0((*length+1)*sizeof(int*)); 2523 syzstr->Firstelem = (int**)Alloc0((*length+1)*sizeof(int*)); 2048 2524 int len0=idRankFreeModule(arg)+1; 2049 truecomponents[0] = (int*)Alloc(len0*sizeof(int));2050 backcomponents[0] = (int*)Alloc(len0*sizeof(int));2051 Howmuch[0] = (int*)Alloc(len0*sizeof(int));2052 Firstelem[0] = (int*)Alloc(len0*sizeof(int));2525 syzstr->truecomponents[0] = (int*)Alloc(len0*sizeof(int)); 2526 syzstr->backcomponents[0] = (int*)Alloc(len0*sizeof(int)); 2527 syzstr->Howmuch[0] = (int*)Alloc(len0*sizeof(int)); 2528 syzstr->Firstelem[0] = (int*)Alloc(len0*sizeof(int)); 2053 2529 //Print("sort %d has now size %d\n",0,len0); 2054 2530 for (i=0;i<len0;i++) 2055 truecomponents[0][i] = i;2531 syzstr->truecomponents[0][i] = i; 2056 2532 startdeg = actdeg; 2057 nextPairs = syChosePairs( resPairs,Tl,&index,&howmuch,*length,&actdeg);2533 nextPairs = syChosePairs(syzstr,&index,&howmuch,&actdeg); 2058 2534 //if (TEST_OPT_PROT) Print("(%d,%d)",howmuch,index); 2059 2535 /*--- computes the resolution ----------------------*/ … … 2062 2538 if (TEST_OPT_PROT) Print("%d",actdeg); 2063 2539 if (TEST_OPT_PROT) Print("(m%d)",index); 2064 currcomponents = truecomponents[max(index-1,0)];2065 i = syInitSyzMod( res,orderedRes,index);2066 j = syInitSyzMod( res,orderedRes,index+1);2540 currcomponents = syzstr->truecomponents[max(index-1,0)]; 2541 i = syInitSyzMod(syzstr,index); 2542 j = syInitSyzMod(syzstr,index+1); 2067 2543 if (index>0) 2068 2544 { 2069 syRedNextPairs(nextPairs, res,orderedRes,howmuch,index);2070 syCompactifyPairSet( resPairs[index],(*Tl)[index],0);2545 syRedNextPairs(nextPairs,syzstr,howmuch,index); 2546 syCompactifyPairSet(syzstr->resPairs[index],(*syzstr->Tl)[index],0); 2071 2547 } 2072 2548 else 2073 syRedGenerOfCurrDeg( resPairs,res,orderedRes,actdeg,index+1,Tl);2549 syRedGenerOfCurrDeg(syzstr,actdeg,index+1); 2074 2550 /*--- creates new pairs -----------------------------*/ 2075 syCreateNewPairs( resPairs,Tl,res,index,i);2551 syCreateNewPairs(syzstr,index,i); 2076 2552 if (index<(*length)-1) 2077 2553 { 2078 syCreateNewPairs( resPairs,Tl,res,index+1,j);2079 //currcomponents = truecomponents[index];2080 //sySyzTail( resPairs,Tl,orderedRes,res,index+1,j);2081 //currcomponents = truecomponents[index-1];2554 syCreateNewPairs(syzstr,index+1,j); 2555 //currcomponents = syzstr->truecomponents[index]; 2556 //sySyzTail(syzstr,index+1,j); 2557 //currcomponents = syzstr->truecomponents[index-1]; 2082 2558 } 2083 2559 index++; 2084 nextPairs = syChosePairs( resPairs,Tl,&index,&howmuch,*length,&actdeg);2560 nextPairs = syChosePairs(syzstr,&index,&howmuch,&actdeg); 2085 2561 //if (TEST_OPT_PROT) Print("(%d,%d)",howmuch,index); 2086 2562 } 2563 //return syzstr; 2564 //} 2087 2565 /*--- deletes temporary data structures-------------*/ 2088 2566 idDelete(&temp); 2089 2567 for (i=0;i<*length;i++) 2090 2568 { 2091 for (j=0;j<(* Tl)[i];j++)2092 { 2093 if (( resPairs[i])[j].lcm!=NULL)2094 pDelete(&( resPairs[i])[j].lcm);2095 } 2096 if ( orderedRes[i]!=NULL)2097 { 2098 for (j=0;j<IDELEMS( orderedRes[i]);j++)2099 orderedRes[i]->m[j] = NULL;2100 } 2101 idDelete(& orderedRes[i]);2102 if ( truecomponents[i]!=NULL)2103 { 2104 Free((ADDRESS) truecomponents[i],(IDELEMS(res[i])+1)*sizeof(int));2105 truecomponents[i]=NULL;2106 } 2107 if ( backcomponents[i]!=NULL)2108 { 2109 Free((ADDRESS) backcomponents[i],(IDELEMS(res[i])+1)*sizeof(int));2110 backcomponents[i]=NULL;2111 } 2112 if ( Howmuch[i]!=NULL)2113 { 2114 Free((ADDRESS) Howmuch[i],(IDELEMS(res[i])+1)*sizeof(int));2115 Howmuch[i]=NULL;2116 } 2117 if ( Firstelem[i]!=NULL)2118 { 2119 Free((ADDRESS) Firstelem[i],(IDELEMS(res[i])+1)*sizeof(int));2120 Firstelem[i]=NULL;2121 } 2122 Free((ADDRESS) resPairs[i],(*Tl)[i]*sizeof(SObject));2123 } 2124 Free((ADDRESS) resPairs,*length*sizeof(SObject*));2125 Free((ADDRESS) orderedRes,(*length+1)*sizeof(ideal));2126 Free((ADDRESS) truecomponents,(*length+1)*sizeof(int*));2127 Free((ADDRESS) backcomponents,(*length+1)*sizeof(int*));2128 Free((ADDRESS) Howmuch,(*length+1)*sizeof(int*));2129 Free((ADDRESS) Firstelem,(*length+1)*sizeof(int*));2130 truecomponents = NULL;2131 backcomponents = NULL;2132 Howmuch = NULL;2133 Firstelem = NULL;2134 if (BTEST1(6)) syStatistics( res,(*length+1));2569 for (j=0;j<(*syzstr->Tl)[i];j++) 2570 { 2571 if ((syzstr->resPairs[i])[j].lcm!=NULL) 2572 pDelete(&((syzstr->resPairs[i])[j].lcm)); 2573 } 2574 if (syzstr->orderedRes[i]!=NULL) 2575 { 2576 for (j=0;j<IDELEMS(syzstr->orderedRes[i]);j++) 2577 syzstr->orderedRes[i]->m[j] = NULL; 2578 } 2579 idDelete(&(syzstr->orderedRes[i])); 2580 if (syzstr->truecomponents[i]!=NULL) 2581 { 2582 Free((ADDRESS)syzstr->truecomponents[i],(IDELEMS(syzstr->res[i])+1)*sizeof(int)); 2583 syzstr->truecomponents[i]=NULL; 2584 } 2585 if (syzstr->backcomponents[i]!=NULL) 2586 { 2587 Free((ADDRESS)syzstr->backcomponents[i],(IDELEMS(syzstr->res[i])+1)*sizeof(int)); 2588 syzstr->backcomponents[i]=NULL; 2589 } 2590 if (syzstr->Howmuch[i]!=NULL) 2591 { 2592 Free((ADDRESS)syzstr->Howmuch[i],(IDELEMS(syzstr->res[i])+1)*sizeof(int)); 2593 syzstr->Howmuch[i]=NULL; 2594 } 2595 if (syzstr->Firstelem[i]!=NULL) 2596 { 2597 Free((ADDRESS)syzstr->Firstelem[i],(IDELEMS(syzstr->res[i])+1)*sizeof(int)); 2598 syzstr->Firstelem[i]=NULL; 2599 } 2600 Free((ADDRESS)syzstr->resPairs[i],(*syzstr->Tl)[i]*sizeof(SObject)); 2601 } 2602 Free((ADDRESS)syzstr->resPairs,*length*sizeof(SObject*)); 2603 Free((ADDRESS)syzstr->orderedRes,(*length+1)*sizeof(ideal)); 2604 Free((ADDRESS)syzstr->truecomponents,(*length+1)*sizeof(int*)); 2605 Free((ADDRESS)syzstr->backcomponents,(*length+1)*sizeof(int*)); 2606 Free((ADDRESS)syzstr->Howmuch,(*length+1)*sizeof(int*)); 2607 Free((ADDRESS)syzstr->Firstelem,(*length+1)*sizeof(int*)); 2608 syzstr->truecomponents = NULL; 2609 syzstr->backcomponents = NULL; 2610 syzstr->Howmuch = NULL; 2611 syzstr->Firstelem = NULL; 2612 if (BTEST1(6)) syStatistics(syzstr->res,(*length+1)); 2135 2613 (*length)++; 2136 2614 /*--- changes to the original ring------------------*/ … … 2143 2621 { 2144 2622 pSetm=oldSetm; 2145 pComp0=old pComp;2146 } 2147 syReOrderResolventFB( res,*length,2);2623 pComp0=oldComp0; 2624 } 2625 syReOrderResolventFB(syzstr->res,*length,2); 2148 2626 for (i=0;i<*length-1;i++) 2149 2627 { 2150 res[i] = res[i+1]; 2151 if (res[i]!=NULL) 2152 { 2628 syzstr->res[i] = syzstr->res[i+1]; 2629 if (syzstr->res[i]!=NULL) 2630 { 2631 polyset rsi = syzstr->res[i]->m; 2153 2632 if (i>0) 2154 2633 { 2155 for (j=0;j<IDELEMS(res[i]);j++) 2156 { 2157 res[i]->m[j] = syOrdPolySchreyer(res[i]->m[j]); 2158 } 2159 idSkipZeroes(res[i]); 2634 for (j=IDELEMS(syzstr->res[i])-1;j>=0;j--) 2635 { 2636 rsi[j] = syOrdPolySchreyer(rsi[j]); 2637 } 2160 2638 } 2161 2639 else 2162 2640 { 2163 for (j=0;j<IDELEMS(res[i]);j++) 2164 { 2165 res[i]->m[j] = pOrdPoly(res[i]->m[j]); 2166 } 2167 idSkipZeroes(res[i]); 2168 } 2169 } 2170 } 2171 res[*length-1] = NULL; 2641 if (ord!=NULL) 2642 { 2643 for (j=IDELEMS(syzstr->res[i])-1;j>=0;j--) 2644 { 2645 rsi[j] = pOrdPoly(rsi[j]); 2646 } 2647 } 2648 else 2649 { 2650 for (j=IDELEMS(syzstr->res[i])-1;j>=0;j--) 2651 { 2652 p = rsi[j]; 2653 while (p!=NULL) 2654 { 2655 pSetm(p); 2656 pIter(p); 2657 } 2658 } 2659 } 2660 } 2661 idSkipZeroes(syzstr->res[i]); 2662 } 2663 } 2664 syzstr->res[*length-1] = NULL; 2172 2665 if (ord!=NULL) 2173 2666 { … … 2186 2679 } 2187 2680 //delete orderingdepth; 2188 return res; 2189 } 2190 2681 if (TEST_OPT_PROT) PrintLn(); 2682 return syzstr->res; 2683 } 2684 2685 /*2 2686 * implementation of LaScala's algorithm 2687 * assumes that the given module is homogeneous 2688 * works with slanted degree, uses syChosePairs 2689 */ 2690 syStrategy syLaScala3(ideal arg,int * length) 2691 { 2692 BOOLEAN noPair=FALSE; 2693 int i,j,* ord,*b0,*b1,actdeg=32000,index=0,reg=-1; 2694 int startdeg,howmuch; 2695 poly p; 2696 ideal temp; 2697 SSet nextPairs; 2698 syStrategy syzstr=(syStrategy)Alloc0(sizeof(ssyStrategy)); 2699 pSetmProc oldSetm=pSetm; 2700 pCompProc oldComp0=pComp0; 2701 2702 //crit = 0; 2703 //zeroRed = 0; 2704 //simple = 0; 2705 //dsim = 0; 2706 euler = -1; 2707 redpol = pNew(); 2708 //orderingdepth = new intvec(pVariables+1); 2709 syzstr->length = *length = pVariables+2; 2710 if (idIs0(arg)) return NULL; 2711 if ((currRing->order[0]==ringorder_dp) 2712 && (currRing->order[1]==ringorder_C) 2713 && (currRing->order[2]==0)) 2714 { 2715 ord=NULL; 2716 } 2717 /*--- changes to a dpC-ring with special comp0------*/ 2718 else 2719 { 2720 ord = (int*)Alloc0(3*sizeof(int)); 2721 b0 = (int*)Alloc0(3*sizeof(int)); 2722 b1 = (int*)Alloc0(3*sizeof(int)); 2723 ord[0] = ringorder_dp; 2724 ord[1] = ringorder_C; 2725 b0[1] = 1; 2726 b1[0] = pVariables; 2727 pChangeRing(pVariables,1,ord,b0,b1,currRing->wvhdl); 2728 } 2729 /*--- initializes the data structures---------------*/ 2730 syzstr->Tl = new intvec(*length); 2731 temp = idInit(IDELEMS(arg),arg->rank); 2732 for (i=0;i<IDELEMS(arg);i++) 2733 { 2734 temp->m[i] = pOrdPoly(pCopy(arg->m[i])); 2735 if (temp->m[i]!=NULL) 2736 { 2737 j = pTotaldegree(temp->m[i]); 2738 if (j<actdeg) actdeg = j; 2739 } 2740 } 2741 sySetHighdeg(); 2742 binomials = (int*)Alloc(pVariables*(highdeg+1)*sizeof(int)); 2743 syBinomSet(); 2744 pSetm =syzSetm; 2745 for (i=0;i<IDELEMS(arg);i++) 2746 { 2747 p = temp->m[i]; 2748 while (p!=NULL) 2749 { 2750 pSetm(p); 2751 pIter(p); 2752 } 2753 } 2754 pComp0 = syzcomp2dpc; 2755 syzstr->resPairs = syInitRes(temp,length,syzstr->Tl); 2756 syzstr->res = (resolvente)Alloc0((*length+1)*sizeof(ideal)); 2757 syzstr->orderedRes = (resolvente)Alloc0((*length+1)*sizeof(ideal)); 2758 syzstr->truecomponents = (int**)Alloc0((*length+1)*sizeof(int*)); 2759 syzstr->backcomponents = (int**)Alloc0((*length+1)*sizeof(int*)); 2760 syzstr->Howmuch = (int**)Alloc0((*length+1)*sizeof(int*)); 2761 syzstr->Firstelem = (int**)Alloc0((*length+1)*sizeof(int*)); 2762 int len0=idRankFreeModule(arg)+1; 2763 //syzstr->truecomponents[0] = (int*)Alloc(len0*sizeof(int)); 2764 //syzstr->backcomponents[0] = (int*)Alloc(len0*sizeof(int)); 2765 //syzstr->Howmuch[0] = (int*)Alloc(len0*sizeof(int)); 2766 //syzstr->Firstelem[0] = (int*)Alloc(len0*sizeof(int)); 2767 //Print("sort %d has now size %d\n",0,len0); 2768 startdeg = actdeg; 2769 nextPairs = syChosePairs(syzstr,&index,&howmuch,&actdeg); 2770 //if (TEST_OPT_PROT) Print("(%d,%d)",howmuch,index); 2771 /*--- computes the resolution ----------------------*/ 2772 while (nextPairs!=NULL) 2773 { 2774 if (TEST_OPT_PROT) Print("%d",actdeg); 2775 if (TEST_OPT_PROT) Print("(m%d)",index); 2776 currcomponents = syzstr->truecomponents[max(index-1,0)]; 2777 if (index==0) 2778 i = syInitSyzMod(syzstr,index,len0); 2779 else 2780 i = syInitSyzMod(syzstr,index); 2781 j = syInitSyzMod(syzstr,index+1); 2782 if (index>0) 2783 { 2784 syRedNextPairs(nextPairs,syzstr,howmuch,index); 2785 syCompactifyPairSet(syzstr->resPairs[index],(*syzstr->Tl)[index],0); 2786 } 2787 else 2788 syRedGenerOfCurrDeg(syzstr,actdeg,index+1); 2789 /*--- creates new pairs -----------------------------*/ 2790 syCreateNewPairs(syzstr,index,i); 2791 if (index<(*length)-1) 2792 { 2793 syCreateNewPairs(syzstr,index+1,j); 2794 //currcomponents = syzstr->truecomponents[index]; 2795 //sySyzTail(syzstr,index+1,j); 2796 //currcomponents = syzstr->truecomponents[index-1]; 2797 } 2798 index++; 2799 nextPairs = syChosePairs(syzstr,&index,&howmuch,&actdeg); 2800 //if (TEST_OPT_PROT) Print("(%d,%d)",howmuch,index); 2801 } 2802 if (temp!=NULL) idDelete(&temp); 2803 if (ord!=NULL) 2804 { 2805 pChangeRing(pVariables,currRing->OrdSgn,currRing->order, 2806 currRing->block0,currRing->block1,currRing->wvhdl); 2807 } 2808 else 2809 { 2810 pSetm=oldSetm; 2811 pComp0=oldComp0; 2812 } 2813 if (ord!=NULL) 2814 { 2815 Free((ADDRESS)ord,3*sizeof(int)); 2816 Free((ADDRESS)b0,3*sizeof(int)); 2817 Free((ADDRESS)b1,3*sizeof(int)); 2818 } 2819 syzstr->binom = binomials; 2820 syzstr->highdeg_1 = highdeg_1; 2821 pDelete1(&redpol); 2822 if (TEST_OPT_PROT) PrintLn(); 2823 return syzstr; 2824 } 2191 2825 /*2 2192 2826 * second implementation of LaScala's algorithm … … 2194 2828 * works deg by deg, uses syChosePairs1 2195 2829 */ 2196 resolvente syLaScala2(ideal arg,int * length) 2197 { 2198 BOOLEAN noPair=FALSE; 2199 int i,j,* ord,*b0,*b1,actdeg=32000,index=1,reg=-1; 2200 int startdeg,howmuch; 2201 intvec * Tl; 2202 poly p; 2203 ideal temp; 2204 resolvente res,orderedRes; 2205 SSet nextPairs; 2206 SRes resPairs; 2207 2208 //crit = 0; 2209 //zeroRed = 0; 2210 //simple = 0; 2211 //dsim = 0; 2212 redpol = pNew(); 2213 //orderingdepth = new intvec(pVariables+1); 2214 if (*length<=0) *length = pVariables+2; 2215 if (idIs0(arg)) return NULL; 2216 /*--- changes to a dpc-ring with special comp0------*/ 2217 ord = (int*)Alloc0(3*sizeof(int)); 2218 b0 = (int*)Alloc0(3*sizeof(int)); 2219 b1 = (int*)Alloc0(3*sizeof(int)); 2220 ord[0] = ringorder_dp; 2221 ord[1] = ringorder_C; 2222 b0[1] = 1; 2223 b1[0] = pVariables; 2224 pChangeRing(pVariables,1,ord,b0,b1,currRing->wvhdl); 2225 /*--- initializes the data structures---------------*/ 2226 Tl = new intvec(*length); 2227 temp = idInit(IDELEMS(arg),arg->rank); 2228 for (i=0;i<IDELEMS(arg);i++) 2229 { 2230 temp->m[i] = pOrdPoly(pCopy(arg->m[i])); 2231 if (temp->m[i]!=NULL) 2232 { 2233 j = pTotaldegree(temp->m[i]); 2234 if (j<actdeg) actdeg = j; 2235 } 2236 } 2237 sySetHighdeg(); 2238 binomials = (int*)Alloc(pVariables*(highdeg+1)*sizeof(int)); 2239 syBinomSet(); 2240 pSetm =syzSetm; 2241 for (i=0;i<IDELEMS(arg);i++) 2242 { 2243 p = temp->m[i]; 2244 while (p!=NULL) 2245 { 2246 pSetm(p); 2247 pIter(p); 2248 } 2249 } 2250 pComp0 = syzcomp2dpc; 2251 resPairs = syInitRes(temp,length,Tl); 2252 res = (resolvente)Alloc0((*length+1)*sizeof(ideal)); 2253 orderedRes = (resolvente)Alloc0((*length+1)*sizeof(ideal)); 2254 truecomponents = (int**)Alloc0((*length+1)*sizeof(int*)); 2255 backcomponents = (int**)Alloc0((*length+1)*sizeof(int*)); 2256 Howmuch = (int**)Alloc0((*length+1)*sizeof(int*)); 2257 Firstelem = (int**)Alloc0((*length+1)*sizeof(int*)); 2258 int len0=idRankFreeModule(arg)+1; 2259 truecomponents[0] = (int*)Alloc(len0*sizeof(int)); 2260 backcomponents[0] = (int*)Alloc(len0*sizeof(int)); 2261 Howmuch[0] = (int*)Alloc(len0*sizeof(int)); 2262 Firstelem[0] = (int*)Alloc(len0*sizeof(int)); 2830 /* 2831 *resolvente syLaScala2(ideal arg,int * length) 2832 *{ 2833 * BOOLEAN noPair=FALSE; 2834 * int i,j,* ord,*b0,*b1,actdeg=32000,index=1,reg=-1; 2835 * int startdeg,howmuch; 2836 * intvec * Tl; 2837 * poly p; 2838 * ideal temp; 2839 * resolvente res,orderedRes; 2840 * SSet nextPairs; 2841 * SRes resPairs; 2842 * 2843 * //crit = 0; 2844 * //zeroRed = 0; 2845 * //simple = 0; 2846 * //dsim = 0; 2847 * redpol = pNew(); 2848 * //orderingdepth = new intvec(pVariables+1); 2849 * if (*length<=0) *length = pVariables+2; 2850 * if (idIs0(arg)) return NULL; 2851 //--- changes to a dpC-ring with special comp0------ 2852 * ord = (int*)Alloc0(3*sizeof(int)); 2853 * b0 = (int*)Alloc0(3*sizeof(int)); 2854 * b1 = (int*)Alloc0(3*sizeof(int)); 2855 * ord[0] = ringorder_dp; 2856 * ord[1] = ringorder_C; 2857 * b0[1] = 1; 2858 * b1[0] = pVariables; 2859 * pChangeRing(pVariables,1,ord,b0,b1,currRing->wvhdl); 2860 //--- initializes the data structures--------------- 2861 * Tl = new intvec(*length); 2862 * temp = idInit(IDELEMS(arg),arg->rank); 2863 * for (i=0;i<IDELEMS(arg);i++) 2864 * { 2865 * temp->m[i] = pOrdPoly(pCopy(arg->m[i])); 2866 * if (temp->m[i]!=NULL) 2867 * { 2868 * j = pTotaldegree(temp->m[i]); 2869 * if (j<actdeg) actdeg = j; 2870 * } 2871 * } 2872 * { 2873 * highdeg=1; 2874 * long long t=1; 2875 * long long h_n=1+pVariables; 2876 * while ((t=(((long long)t*(long long)h_n)/(long long)highdeg))<INT_MAX) 2877 * { 2878 * highdeg++; 2879 * h_n++; 2880 * } 2881 * highdeg--; 2882 * Print("max deg=%d\n",highdeg); 2883 * } 2884 * binomials = (int*)Alloc(pVariables*(highdeg+1)*sizeof(int)); 2885 * syBinomSet(); 2886 * pSetm =syzSetm; 2887 * for (i=0;i<IDELEMS(arg);i++) 2888 * { 2889 * p = temp->m[i]; 2890 * while (p!=NULL) 2891 * { 2892 * pSetm(p); 2893 * pIter(p); 2894 * } 2895 * } 2896 * pComp0 = syzcomp2dpc; 2897 * resPairs = syInitRes(temp,length,Tl); 2898 * res = (resolvente)Alloc0((*length+1)*sizeof(ideal)); 2899 * orderedRes = (resolvente)Alloc0((*length+1)*sizeof(ideal)); 2900 * truecomponents = (int**)Alloc0((*length+1)*sizeof(int*)); 2901 * backcomponents = (int**)Alloc0((*length+1)*sizeof(int*)); 2902 * Howmuch = (int**)Alloc0((*length+1)*sizeof(int*)); 2903 * Firstelem = (int**)Alloc0((*length+1)*sizeof(int*)); 2904 * int len0=idRankFreeModule(arg)+1; 2905 * truecomponents[0] = (int*)Alloc(len0*sizeof(int)); 2906 * backcomponents[0] = (int*)Alloc(len0*sizeof(int)); 2907 * Howmuch[0] = (int*)Alloc(len0*sizeof(int)); 2908 * Firstelem[0] = (int*)Alloc(len0*sizeof(int)); 2263 2909 //Print("sort %d has now size %d\n",0,len0); 2264 for (i=0;i<len0;i++)2265 truecomponents[0][i] = i;2266 startdeg = actdeg;2267 nextPairs = syChosePairs1(resPairs,Tl,&index,&howmuch,*length,&actdeg);2268 if (TEST_OPT_PROT) Print("(%d,%d)",howmuch,index);2269 / *--- computes the resolution ----------------------*/2270 while (nextPairs!=NULL)2271 {2272 if (TEST_OPT_PROT) Print("%d",actdeg);2273 if (TEST_OPT_PROT) Print("(m%d)",index);2274 currcomponents = truecomponents[max(index-1,0)];2275 i = syInitSyzMod(res,orderedRes,index);2276 j = syInitSyzMod(res,orderedRes,index+1);2277 if (index>0)2278 {2279 syRedNextPairs(nextPairs,res,orderedRes,howmuch,index);2280 syCompactifyPairSet(resPairs[index],(*Tl)[index],0);2281 }2282 else2283 syRedGenerOfCurrDeg(resPairs,res,orderedRes,actdeg,index+1,Tl);2284 / *--- creates new pairs -----------------------------*/2285 syCreateNewPairs(resPairs,Tl,res,index,i);2286 if (index<(*length)-1)2287 {2288 syCreateNewPairs(resPairs,Tl,res,index+1,j);2289 currcomponents = truecomponents[index];2290 sySyzTail(resPairs,Tl,orderedRes,res,index+1,j);2291 currcomponents = truecomponents[index-1];2292 }2293 index--;2294 nextPairs = syChosePairs1(resPairs,Tl,&index,&howmuch,*length,&actdeg);2295 if (TEST_OPT_PROT) Print("(%d,%d)",howmuch,index);2296 }2297 / *--- deletes temporary data structures-------------*/2298 idDelete(&temp);2299 for (i=0;i<*length;i++)2300 {2301 for (j=0;j<(*Tl)[i];j++)2302 {2303 if ((resPairs[i])[j].lcm!=NULL)2304 pDelete(&(resPairs[i])[j].lcm);2305 }2306 if (orderedRes[i]!=NULL)2307 {2308 for (j=0;j<IDELEMS(orderedRes[i]);j++)2309 orderedRes[i]->m[j] = NULL;2310 }2311 idDelete(&orderedRes[i]);2312 if (truecomponents[i]!=NULL)2313 {2314 Free((ADDRESS)truecomponents[i],(IDELEMS(res[i])+1)*sizeof(int));2315 truecomponents[i]=NULL;2316 }2317 if (backcomponents[i]!=NULL)2318 {2319 Free((ADDRESS)backcomponents[i],(IDELEMS(res[i])+1)*sizeof(int));2320 backcomponents[i]=NULL;2321 }2322 if (Howmuch[i]!=NULL)2323 {2324 Free((ADDRESS)Howmuch[i],(IDELEMS(res[i])+1)*sizeof(int));2325 Howmuch[i]=NULL;2326 }2327 if (Firstelem[i]!=NULL)2328 {2329 Free((ADDRESS)Firstelem[i],(IDELEMS(res[i])+1)*sizeof(int));2330 Firstelem[i]=NULL;2331 }2332 Free((ADDRESS)resPairs[i],(*Tl)[i]*sizeof(SObject));2333 }2334 Free((ADDRESS)resPairs,*length*sizeof(SObject*));2335 Free((ADDRESS)orderedRes,(*length+1)*sizeof(ideal));2336 Free((ADDRESS)truecomponents,(*length+1)*sizeof(int*));2337 Free((ADDRESS)backcomponents,(*length+1)*sizeof(int*));2338 Free((ADDRESS)Howmuch,(*length+1)*sizeof(int*));2339 Free((ADDRESS)Firstelem,(*length+1)*sizeof(int*));2340 truecomponents = NULL;2341 backcomponents = NULL;2342 Howmuch = NULL;2343 Firstelem = NULL;2344 if (BTEST1(6)) syStatistics(res,(*length+1));2345 (*length)++;2346 / *--- changes to the original ring------------------*/2347 pChangeRing(pVariables,currRing->OrdSgn,currRing->order,2348 currRing->block0,currRing->block1,currRing->wvhdl);2349 syReOrderResolventFB(res,*length,2);2350 for (i=0;i<*length-1;i++)2351 {2352 res[i] = res[i+1];2353 if (res[i]!=NULL)2354 {2355 if (i>0)2356 {2357 for (j=0;j<IDELEMS(res[i]);j++)2358 {2359 res[i]->m[j] = syOrdPolySchreyer(res[i]->m[j]);2360 }2361 idSkipZeroes(res[i]);2362 }2363 else2364 {2365 for (j=0;j<IDELEMS(res[i]);j++)2366 {2367 p = res[i]->m[j];2368 while (p!=NULL)2369 {2370 pSetm(p);2371 pIter(p);2372 }2373 }2374 idSkipZeroes(res[i]); 2375 2376 2377 } 2378 res[*length-1] = NULL;2379 Free((ADDRESS)ord,3*sizeof(int));2380 Free((ADDRESS)b0,3*sizeof(int));2381 Free((ADDRESS)b1,3*sizeof(int));2382 Free((ADDRESS)binomials,pVariables*(highdeg_1)*sizeof(int));2383 pDelete1(&redpol); 2384 if (TEST_OPT_PROT) 2385 { 2386 //Print("simple: %d\n",simple);2387 //Print("dsim: %d\n",dsim); 2388 //Print("crit %d-times used \n",crit); 2389 //Print("%d reductions to zero \n",zeroRed); 2390 } 2391 //delete orderingdepth;2392 return res; 2393 } 2910 * for (i=0;i<len0;i++) 2911 * truecomponents[0][i] = i; 2912 * startdeg = actdeg; 2913 * nextPairs = syChosePairs1(resPairs,Tl,&index,&howmuch,*length,&actdeg); 2914 * if (TEST_OPT_PROT) Print("(%d,%d)",howmuch,index); 2915 //--- computes the resolution ---------------------- 2916 * while (nextPairs!=NULL) 2917 * { 2918 * if (TEST_OPT_PROT) Print("%d",actdeg); 2919 * if (TEST_OPT_PROT) Print("(m%d)",index); 2920 * currcomponents = truecomponents[max(index-1,0)]; 2921 * i = syInitSyzMod(res,orderedRes,index); 2922 * j = syInitSyzMod(res,orderedRes,index+1); 2923 * if (index>0) 2924 * { 2925 * syRedNextPairs(nextPairs,res,orderedRes,howmuch,index); 2926 * syCompactifyPairSet(resPairs[index],(*Tl)[index],0); 2927 * } 2928 * else 2929 * syRedGenerOfCurrDeg(resPairs,res,orderedRes,actdeg,index+1,Tl); 2930 //--- creates new pairs ----------------------------- 2931 * syCreateNewPairs(resPairs,Tl,res,index,i); 2932 * if (index<(*length)-1) 2933 * { 2934 * syCreateNewPairs(resPairs,Tl,res,index+1,j); 2935 * currcomponents = truecomponents[index]; 2936 * sySyzTail(resPairs,Tl,orderedRes,res,index+1,j); 2937 * currcomponents = truecomponents[index-1]; 2938 * } 2939 * index--; 2940 * nextPairs = syChosePairs1(resPairs,Tl,&index,&howmuch,*length,&actdeg); 2941 * if (TEST_OPT_PROT) Print("(%d,%d)",howmuch,index); 2942 * } 2943 //--- deletes temporary data structures------------- 2944 * idDelete(&temp); 2945 * for (i=0;i<*length;i++) 2946 * { 2947 * for (j=0;j<(*Tl)[i];j++) 2948 * { 2949 * if ((resPairs[i])[j].lcm!=NULL) 2950 * pDelete(&(resPairs[i])[j].lcm); 2951 * } 2952 * if (orderedRes[i]!=NULL) 2953 * { 2954 * for (j=0;j<IDELEMS(orderedRes[i]);j++) 2955 * orderedRes[i]->m[j] = NULL; 2956 * } 2957 * idDelete(&orderedRes[i]); 2958 * if (truecomponents[i]!=NULL) 2959 * { 2960 * Free((ADDRESS)truecomponents[i],(IDELEMS(res[i])+1)*sizeof(int)); 2961 * truecomponents[i]=NULL; 2962 * } 2963 * if (backcomponents[i]!=NULL) 2964 * { 2965 * Free((ADDRESS)backcomponents[i],(IDELEMS(res[i])+1)*sizeof(int)); 2966 * backcomponents[i]=NULL; 2967 * } 2968 * if (Howmuch[i]!=NULL) 2969 * { 2970 * Free((ADDRESS)Howmuch[i],(IDELEMS(res[i])+1)*sizeof(int)); 2971 * Howmuch[i]=NULL; 2972 * } 2973 * if (Firstelem[i]!=NULL) 2974 * { 2975 * Free((ADDRESS)Firstelem[i],(IDELEMS(res[i])+1)*sizeof(int)); 2976 * Firstelem[i]=NULL; 2977 * } 2978 * Free((ADDRESS)resPairs[i],(*Tl)[i]*sizeof(SObject)); 2979 * } 2980 * Free((ADDRESS)resPairs,*length*sizeof(SObject*)); 2981 * Free((ADDRESS)orderedRes,(*length+1)*sizeof(ideal)); 2982 * Free((ADDRESS)truecomponents,(*length+1)*sizeof(int*)); 2983 * Free((ADDRESS)backcomponents,(*length+1)*sizeof(int*)); 2984 * Free((ADDRESS)Howmuch,(*length+1)*sizeof(int*)); 2985 * Free((ADDRESS)Firstelem,(*length+1)*sizeof(int*)); 2986 * truecomponents = NULL; 2987 * backcomponents = NULL; 2988 * Howmuch = NULL; 2989 * Firstelem = NULL; 2990 * if (BTEST1(6)) syStatistics(res,(*length+1)); 2991 * (*length)++; 2992 //--- changes to the original ring------------------ 2993 * pChangeRing(pVariables,currRing->OrdSgn,currRing->order, 2994 * currRing->block0,currRing->block1,currRing->wvhdl); 2995 * syReOrderResolventFB(res,*length,2); 2996 * for (i=0;i<*length-1;i++) 2997 * { 2998 * res[i] = res[i+1]; 2999 * if (res[i]!=NULL) 3000 * { 3001 * if (i>0) 3002 * { 3003 * for (j=0;j<IDELEMS(res[i]);j++) 3004 * { 3005 * res[i]->m[j] = syOrdPolySchreyer(res[i]->m[j]); 3006 * } 3007 * idSkipZeroes(res[i]); 3008 * } 3009 * else 3010 * { 3011 * for (j=0;j<IDELEMS(res[i]);j++) 3012 * { 3013 * p = res[i]->m[j]; 3014 * while (p!=NULL) 3015 * { 3016 * pSetm(p); 3017 * pIter(p); 3018 * } 3019 * } 3020 * } 3021 * } 3022 * } 3023 * res[*length-1] = NULL; 3024 * Free((ADDRESS)ord,3*sizeof(int)); 3025 * Free((ADDRESS)b0,3*sizeof(int)); 3026 * Free((ADDRESS)b1,3*sizeof(int)); 3027 * Free((ADDRESS)binomials,pVariables*(highdeg_1)*sizeof(int)); 3028 * pDelete1(&redpol); 3029 * if (TEST_OPT_PROT) 3030 * { 3031 * //Print("simple: %d\n",simple); 3032 * //Print("dsim: %d\n",dsim); 3033 * //Print("crit %d-times used \n",crit); 3034 * //Print("%d reductions to zero \n",zeroRed); 3035 * } 3036 * //delete orderingdepth; 3037 * return res; 3038 *} 3039 */ -
Singular/tesths.cc
r402a67 rdfc6b54 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: tesths.cc,v 1.2 2 1997-07-04 13:46:45Singular Exp $ */4 /* $Id: tesths.cc,v 1.23 1997-07-09 15:54:08 Singular Exp $ */ 5 5 6 6 /* … … 98 98 fprintf(stderr, "Need a float to set mintime"); 99 99 } 100 }101 }102 else if (strcmp(argv[1], "-d") == 0)103 {104 if (argc > 2)105 {106 char* ptr = NULL;107 #ifdef HAVE_STRTOL108 long res = strtol(argv[2], &ptr, 10);109 if (errno != ERANGE && ptr != argv[2] && res > 0)110 #else111 long res = 0;112 sscanf(argv[2],"%d", &res);113 if (res > 0)114 #endif115 {116 argc--;117 argv++;118 SetTimerResolution(res);119 }120 else121 fprintf(stderr,"Can not convert %s to an integer > 0\n", argv[2]);122 }123 else124 {125 fprintf(stderr,"Need an integer to set timer resolution");126 100 } 127 101 } … … 202 176 printf("search path:%s\n\n", SINGULAR_DATADIR); 203 177 break; 178 } 179 case 'd': 180 { 181 if (argc > 2) 182 { 183 char* ptr = NULL; 184 #ifdef HAVE_STRTOL 185 long res = strtol(argv[2], &ptr, 10); 186 if (errno != ERANGE && ptr != argv[2] && res > 0) 187 #else 188 long res = 0; 189 sscanf(argv[2],"%d", &res); 190 if (res > 0) 191 #endif 192 { 193 argc--; 194 argv++; 195 i=0; 196 SetTimerResolution(res); 197 } 198 else 199 fprintf(stderr,"Can not convert %s to an integer > 0\n", argv[2]); 200 } 201 else 202 { 203 fprintf(stderr,"Need an integer to set timer resolution"); 204 } 204 205 } 205 206 case 'e': if ((argv[1][i+1]>'0') && (argv[1][i+1]<='9')) … … 233 234 break; 234 235 case 't': 235 #if def HAVE_FEREAD236 #if defined(HAVE_FEREAD) || defined(HAVE_READLINE) 236 237 fe_use_fgets=TRUE; 237 238 #endif … … 274 275 dlInit(thisfile); 275 276 myynest=0; 277 iiLibCmd(mstrdup("standard.lib"),FALSE); 278 #ifndef macintosh 279 #if defined(HAVE_FEREAD) || defined(HAVE_READLINE) 280 fe_set_input_mode(); 281 #endif 282 #endif 283 setjmp(si_start_jmpbuf); 276 284 /* if script is given */ 277 285 if ((argc > 1)&&(argv[1][0]!='-')) 278 286 { 279 287 /* read and run the Script */ 288 argc=1; 280 289 iiPStart(NULL,argv[1],NULL); 281 290 } … … 291 300 #endif // HAVE_MPSR 292 301 } 293 #ifndef macintosh294 #if defined(HAVE_FEREAD) || defined(HAVE_READLINE)295 fe_set_input_mode();296 #endif297 #endif298 302 setjmp(si_start_jmpbuf); 299 303 yyparse();
Note: See TracChangeset
for help on using the changeset viewer.