Changeset 86016d in git
- Timestamp:
- Feb 1, 2007, 12:51:25 AM (16 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- c591ad0eb4ed9f5be86c0c85d2412be2ad6be556
- Parents:
- 1cc61e18c0d6c70b177099c23a52159afb280bb4
- Location:
- kernel
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/gr_kstd2.cc
r1cc61e r86016d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: gr_kstd2.cc,v 1.1 0 2007-01-11 10:10:37 SingularExp $ */4 /* $Id: gr_kstd2.cc,v 1.11 2007-01-31 23:51:23 motsak Exp $ */ 5 5 /* 6 6 * ABSTRACT - Kernel: noncomm. alg. of Buchberger … … 11 11 #ifdef HAVE_PLURAL 12 12 13 #define PLURAL_INTERNAL_DECLARATIONS 13 14 14 15 #include "omalloc.h" … … 750 751 #endif 751 752 752 void gr_initBba(ideal F, kStrategy strat)753 void nc_gr_initBba(ideal F, kStrategy strat) 753 754 { 754 755 assume(rIsPluralRing(currRing)); … … 826 827 // initHilbCrit(F,Q,&hilb,strat); 827 828 /* in plural we don't need Hilb yet */ 828 gr_initBba(F,strat);829 nc_gr_initBba(F,strat); 829 830 initBuchMoraPos(strat); 830 831 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/ … … 861 862 pLmFree(strat->P.p); 862 863 /* the real one */ 863 if (( currRing->nc->type==nc_lie) && pHasNotCF(strat->P.p1,strat->P.p2)) /* prod crit */864 if ((ncRingType(currRing)==nc_lie) && pHasNotCF(strat->P.p1,strat->P.p2)) /* prod crit */ 864 865 { 865 866 strat->cp++; … … 922 923 strat->enterS(strat->P,pos,strat,-1); 923 924 } 924 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);925 // if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat); 925 926 } 926 927 if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm); … … 933 934 } 934 935 if (TEST_OPT_DEBUG) messageSets(strat); 936 935 937 /* complete reduction of the standard basis--------- */ 936 if (TEST_OPT_REDSB) completeReduce(strat); 938 if (TEST_OPT_REDSB){ 939 completeReduce(strat); // ??? 940 941 // ideal I = strat->Shdl; 942 // ideal erg = kInterRed(I,Q); 943 // assume(I!=erg); 944 // id_Delete(&I, currRing); 945 // strat->Shdl = erg; 946 } 947 937 948 /* release temp data-------------------------------- */ 938 949 exitBuchMora(strat); … … 949 960 if (TEST_OPT_PROT) messageStat(srmax,lrmax,hilbcount,strat); 950 961 if (Q!=NULL) updateResult(strat->Shdl,Q,strat); 962 963 951 964 #ifdef PDEBUG 952 965 /* for counting number of pairs [enterL] in Plural */ -
kernel/gring.cc
r1cc61e r86016d 7 7 * Author: levandov (Viktor Levandovsky) 8 8 * Created: 8/00 - 11/00 9 * Version: $Id: gring.cc,v 1.3 8 2007-01-25 19:42:26motsak Exp $9 * Version: $Id: gring.cc,v 1.39 2007-01-31 23:51:23 motsak Exp $ 10 10 *******************************************************************/ 11 11 #include "mod2.h" 12 12 13 #ifdef HAVE_PLURAL 13 14 #define PLURAL_INTERNAL_DECLARATIONS … … 26 27 27 28 #include "gring.h" 29 #include "sca.h" 28 30 29 31 // dirty tricks: … … 36 38 37 39 38 40 // some forward declarations: 41 42 43 // polynomial multiplication functions for p_Procs : 44 poly gnc_pp_Mult_mm(const poly p, const poly m, const ring r, poly &last); 45 poly gnc_p_Mult_mm(poly p, const poly m, const ring r); 46 poly gnc_mm_Mult_p(const poly m, poly p, const ring r); 47 poly gnc_mm_Mult_pp(const poly m, const poly p, const ring r); 48 49 50 // set pProcs for r and global variable p_Procs as for general non-commutative algebras. 51 void gnc_p_ProcsSet(ring rGR, p_Procs_s* p_Procs); 52 53 /* syzygies : */ 54 poly gnc_CreateSpolyOld(const poly p1, const poly p2/*, poly spNoether*/, const ring r); 55 poly gnc_ReduceSpolyOld(const poly p1, poly p2/*, poly spNoether*/, const ring r); 56 57 poly gnc_CreateSpolyNew(const poly p1, const poly p2/*, poly spNoether*/, const ring r); 58 poly gnc_ReduceSpolyNew(const poly p1, poly p2/*, poly spNoether*/, const ring r); 59 60 61 62 void gnc_kBucketPolyRedNew(kBucket_pt b, poly p, number *c); 63 void gnc_kBucketPolyRed_ZNew(kBucket_pt b, poly p, number *c); 64 65 void gnc_kBucketPolyRedOld(kBucket_pt b, poly p, number *c); 66 void gnc_kBucketPolyRed_ZOld(kBucket_pt b, poly p, number *c); 67 68 69 // poly gnc_ReduceSpolyNew(poly p1, poly p2, poly spNoether, const ring r); 70 // void gnc_ReduceSpolyTail(poly p1, poly q, poly q2, poly spNoether, const ring r); 71 72 // void nc_kBucketPolyRed(kBucket_pt b, poly p); 73 74 ideal gnc_gr_mora(const ideal, const ideal, const intvec *, const intvec *, kStrategy); // Not yet! 75 ideal gnc_gr_bba (const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat); 76 77 78 #if 0 79 // deprecated functions: 80 // poly gnc_p_Minus_mm_Mult_qq_ign(poly p, const poly m, poly q, int & d1, poly d2, const ring ri, poly &d3); 81 // poly gnc_p_Minus_mm_Mult_qq(poly p, const poly m, poly q, const ring r); 82 // poly nc_p_Minus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp, int lq, const ring r); 83 // poly nc_p_Plus_mm_Mult_qq (poly p, const poly m, const poly q, int &lp, int lq, const ring r); 84 #endif 85 86 87 88 /////////////////////////////////////////////////////////////////////////////// 39 89 poly nc_p_Minus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp, 40 90 const int, const poly, const ring r) … … 325 375 int cpower=0; 326 376 327 if ( r->nc->type==nc_skew)377 if (ncRingType(r)==nc_skew) 328 378 { 329 379 if (r->nc->IsSkewConstant==1) … … 1130 1180 #endif 1131 1181 /* pSetComp(m,r)=0? */ 1132 poly N = mm_Mult_p(m, p_Head(p1,r), r);1182 poly N = nc_mm_Mult_p(m, p_Head(p1,r), r); 1133 1183 number C = n_Copy( p_GetCoeff(N, r), r); 1134 1184 number cF = n_Copy( p_GetCoeff(p2, r),r); … … 1184 1234 1185 1235 /* pSetComp(m,r)=0? */ 1186 poly N = mm_Mult_p(m, p_Head(p1,r), r);1236 poly N = nc_mm_Mult_p(m, p_Head(p1,r), r); 1187 1237 1188 1238 number C = n_Copy( p_GetCoeff(N, r), r); … … 1238 1288 return(NULL); 1239 1289 } 1240 if (( r->nc->type==nc_lie) && pHasNotCF(p1,p2)) /* prod crit */1290 if ((ncRingType(r)==nc_lie) && pHasNotCF(p1,p2)) /* prod crit */ 1241 1291 { 1242 1292 return(nc_p_Bracket_qq(pCopy(p2),p1)); … … 1264 1314 p_Delete(&pL,r); 1265 1315 /* zero exponents ! */ 1266 poly M1 = mm_Mult_p(m1,p_Head(p1,r),r);1316 poly M1 = nc_mm_Mult_p(m1,p_Head(p1,r),r); 1267 1317 number C1 = n_Copy(p_GetCoeff(M1,r),r); 1268 poly M2 = mm_Mult_p(m2,p_Head(p2,r),r);1318 poly M2 = nc_mm_Mult_p(m2,p_Head(p2,r),r); 1269 1319 number C2 = n_Copy(p_GetCoeff(M2,r),r); 1270 1320 /* GCD stuff */ … … 1292 1342 poly tmp=p_Copy(p1,r); 1293 1343 tmp=p_LmDeleteAndNext(tmp,r); 1294 M1= mm_Mult_p(m1,tmp,r);1344 M1=nc_mm_Mult_p(m1,tmp,r); 1295 1345 tmp=p_Copy(p2,r); 1296 1346 tmp=p_LmDeleteAndNext(tmp,r); 1297 1347 M2=p_Add_q(M2,M1,r); 1298 M1= mm_Mult_p(m2,tmp,r);1348 M1=nc_mm_Mult_p(m2,tmp,r); 1299 1349 M2=p_Add_q(M2,M1,r); 1300 1350 p_Delete(&m1,r); … … 1360 1410 1361 1411 /* zero exponents !? */ 1362 poly M1 = mm_Mult_p(m1,p_Head(p1,r),r); // M1 = m1 * lt(p1)1363 poly M2 = mm_Mult_p(m2,p_Head(p2,r),r); // M2 = m2 * lt(p2)1412 poly M1 = nc_mm_Mult_p(m1,p_Head(p1,r),r); // M1 = m1 * lt(p1) 1413 poly M2 = nc_mm_Mult_p(m2,p_Head(p2,r),r); // M2 = m2 * lt(p2) 1364 1414 1365 1415 if(M1 == NULL || M2 == NULL) … … 1419 1469 poly tmp=p_Copy(p1,r); // tmp = p1 1420 1470 tmp=p_LmDeleteAndNext(tmp,r); // tmp = tail(p1) 1421 M1 = mm_Mult_p(m1,tmp,r); // M1 = m1 * tail(p1), delete tmp1471 M1 = nc_mm_Mult_p(m1,tmp,r); // M1 = m1 * tail(p1), delete tmp 1422 1472 tmp=p_Copy(p2,r); // tmp = p2 1423 1473 tmp=p_LmDeleteAndNext(tmp,r); // tmp = tail(p2) 1424 1474 M2=p_Add_q(M2,M1,r); // M2 = spoly(lt(p1), lt(p2)) + m1 * tail(p1), delete M1 1425 M1 = mm_Mult_p(m2,tmp,r); // M1 = m2 * tail(p2), detele tmp1475 M1 = nc_mm_Mult_p(m2,tmp,r); // M1 = m2 * tail(p2), detele tmp 1426 1476 M2=p_Add_q(M2,M1,r); // M2 = spoly(lt(p1), lt(p2)) + m1 * tail(p1) + m2*tail(p2) 1427 1477 // delete M1 … … 1464 1514 poly M = nc_mm_Mult_pp(m, p1,r); 1465 1515 number C=p_GetCoeff(M,r); 1466 M=p_Add_q(M, mm_Mult_p(m,p_LmDeleteAndNext(p_Copy(p1,r),r),r),r); // _pp?1516 M=p_Add_q(M,nc_mm_Mult_p(m,p_LmDeleteAndNext(p_Copy(p1,r),r),r),r); // _pp? 1467 1517 q=p_Mult_nn(q,C,r); 1468 1518 number MinusOne=n_Init(-1,r); … … 2043 2093 for(j=i+1;j<=rN;j++) 2044 2094 { 2045 id_Delete((ideal *)&(r->nc->MT[UPMATELEM(i,j,rN)]),r->nc->basering);2095 id_Delete((ideal *)&(r->nc->MT[UPMATELEM(i,j,rN)]),r->nc->basering); 2046 2096 } 2047 2097 } … … 2052 2102 id_Delete((ideal *)&(r->nc->C),r->nc->basering); 2053 2103 id_Delete((ideal *)&(r->nc->D),r->nc->basering); 2104 2105 if( rIsSCA(r) && (r->nc->SCAQuotient() != NULL) ) 2106 { 2107 id_Delete(&r->nc->SCAQuotient(), r->nc->basering); 2108 } 2109 2054 2110 r->nc->basering->ref--; 2055 if (r->nc->basering<=0) 2111 2112 if (r->nc->basering->ref<=0) 2056 2113 { 2057 2114 rKill(r->nc->basering); 2058 2115 } 2059 omFreeSize((ADDRESS)r->nc,sizeof(nc_struct));2060 r->nc=NULL;2116 2117 ncCleanUp(r); 2061 2118 } 2062 2119 … … 2254 2311 r->nc->basering = r; 2255 2312 r->ref++; 2256 r->nc->type = nc_undef;2313 ncRingType(r, nc_undef); 2257 2314 2258 2315 /* initialition of the matrix C */ … … 2313 2370 if (nIsOne(nN)) 2314 2371 { 2315 r->nc->type = nc_lie;2372 ncRingType(r, nc_lie); 2316 2373 } 2317 2374 else 2318 2375 { 2319 r->nc->type = nc_general;2376 ncRingType(r, nc_general); 2320 2377 } 2321 2378 r->nc->IsSkewConstant = 1; … … 2361 2418 if ( (tmpIsSkewConstant) && (nIsOne(pN)) ) 2362 2419 { 2363 r->nc->type = nc_lie;2420 ncRingType(r, nc_lie); 2364 2421 } 2365 2422 else 2366 2423 { 2367 r->nc->type = nc_general;2424 ncRingType(r, nc_general); 2368 2425 } 2369 2426 } … … 2376 2433 if (DN == NULL) 2377 2434 { 2378 if ( ( r->nc->type == nc_lie) || (r->nc->type== nc_undef) )2379 { 2380 r->nc->type = nc_comm; /* it was nc_skew earlier */2435 if ( (ncRingType(r) == nc_lie) || (ncRingType(r) == nc_undef) ) 2436 { 2437 ncRingType(r, nc_comm); /* it was nc_skew earlier */ 2381 2438 } 2382 2439 else /* nc_general, nc_skew */ 2383 2440 { 2384 r->nc->type = nc_skew;2441 ncRingType(r, nc_skew); 2385 2442 } 2386 2443 } … … 2418 2475 } 2419 2476 2477 ////////////////////////////////////////////////////////////////////////////// 2420 2478 BOOLEAN nc_InitMultiplication(ring r) 2421 2479 { … … 2426 2484 if (rVar(r)==1) 2427 2485 { 2428 r->nc->type=nc_comm;2486 ncRingType(r, nc_comm); 2429 2487 r->nc->IsSkewConstant=1; 2430 2488 return FALSE; … … 2483 2541 } 2484 2542 } 2485 if ( r->nc->type==nc_undef)2543 if (ncRingType(r)==nc_undef) 2486 2544 { 2487 2545 if (IsNonComm==1) … … 2493 2551 if (IsNonComm==0) 2494 2552 { 2495 r->nc->type=nc_skew; /* TODO: check whether it is commutative */2553 ncRingType(r, nc_skew); /* TODO: check whether it is commutative */ 2496 2554 r->nc->IsSkewConstant=tmpIsSkewConstant; 2497 2555 } … … 2499 2557 r->nc->COM=COM; 2500 2558 2501 SetProcsGNC(r, r->p_Procs); 2502 2559 gnc_p_ProcsSet(r, r->p_Procs); 2503 2560 2504 2561 if (WeChangeRing) … … 2509 2566 } 2510 2567 2511 void SetProcsGNC(ring& rGR, p_Procs_s* p_Procs) 2512 { 2513 2568 void gnc_p_ProcsSet(ring rGR, p_Procs_s* p_Procs) 2569 { 2514 2570 // "commutative" 2515 2571 rGR->p_Procs->p_Mult_mm = gnc_p_Mult_mm; … … 2522 2578 2523 2579 2524 // non-commutaitve 2580 // non-commutaitve multiplication by monomial from the left 2525 2581 rGR->nc->p_Procs.mm_Mult_p = gnc_mm_Mult_p; 2526 2582 rGR->nc->p_Procs.mm_Mult_pp = gnc_mm_Mult_pp; … … 2540 2596 rGR->nc->p_Procs.BucketPolyRed_Z= gnc_kBucketPolyRed_ZOld; 2541 2597 #else 2598 // A bit cleaned up and somewhat rewritten functions... 2542 2599 rGR->nc->p_Procs.SPoly = gnc_CreateSpolyNew; 2543 2600 rGR->nc->p_Procs.ReduceSPoly = gnc_ReduceSpolyNew; … … 2551 2608 2552 2609 #if 0 2610 // Old Stuff 2553 2611 p_Procs->p_Mult_mm = gnc_p_Mult_mm; 2554 2612 _p_procs->p_Mult_mm = gnc_p_Mult_mm; … … 2570 2628 #endif 2571 2629 } 2630 2631 2632 // set pProcs table for rGR and global variable p_Procs 2633 void nc_p_ProcsSet(ring rGR, p_Procs_s* p_Procs) 2634 { 2635 assume(rIsPluralRing(rGR)); 2636 assume(p_Procs!=NULL); 2637 2638 gnc_p_ProcsSet(rGR, p_Procs); 2639 2640 if(rIsSCA(rGR)) 2641 { 2642 sca_p_ProcsSet(rGR, p_Procs); 2643 } 2644 } 2645 2572 2646 2573 2647 … … 2604 2678 pSetExpV(pre,PRE); 2605 2679 pSetm(pre); 2606 res = mm_Mult_p(pre,res,currRing);2680 res = nc_mm_Mult_p(pre,res,currRing); 2607 2681 /* multiply with suffix */ 2608 2682 suf = pOne(); … … 2855 2929 r->nc->ref = 1; 2856 2930 r->nc->basering = r; 2857 r->nc->type = nc_comm;2931 ncRingType(r, nc_comm); 2858 2932 r->nc->IsSkewConstant = 1; 2933 2934 // no reference increment to the base commutative ring??? 2935 2859 2936 matrix C = mpNew(r->N,r->N); 2860 2937 matrix D = mpNew(r->N,r->N); … … 2996 3073 } 2997 3074 3075 3076 3077 bool nc_SetupQuotient(ring rGR, const ring rG) 3078 { 3079 // currently only super-commutative extension deals with factors. 3080 return sca_SetupQuotient(rGR, rG); 3081 } 3082 3083 2998 3084 #endif 2999 3085 -
kernel/gring.h
r1cc61e r86016d 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: gring.h,v 1.1 7 2007-01-11 11:27:25 SingularExp $ */6 /* $Id: gring.h,v 1.18 2007-01-31 23:51:24 motsak Exp $ */ 7 7 /* 8 8 * ABSTRACT additional defines etc for --with-plural … … 10 10 11 11 #ifdef HAVE_PLURAL 12 #include "structs.h" 13 #include "ring.h" 12 13 #include <structs.h> 14 #include <ring.h> 14 15 15 16 /* the part, related to the interface */ 16 17 BOOLEAN nc_CallPlural(matrix CC, matrix DD, poly CN, poly DN, ring r); 18 17 19 BOOLEAN nc_CheckOrdCondition(matrix D, ring r); 18 20 BOOLEAN nc_CheckSubalgebra(poly PolyVar, ring r); 19 BOOLEAN nc_InitMultiplication(ring r); 21 BOOLEAN nc_InitMultiplication(ring r); // should call nc_p_ProcsSet! 20 22 BOOLEAN rIsLikeOpposite(ring rBase, ring rCandidate); 21 23 22 // set pProcs for r and global variable p_Procs23 void SetProcsGNC(ring& rGR, p_Procs_s* p_Procs);24 24 25 ring nc_rCreateNCcomm(ring r); 26 void ncKill(ring r); 27 void nc CleanUp(ring r); /* smaller than kill */25 // set pProcs table for rGR and global variable p_Procs 26 // this should be used by p_ProcsSet in p_Procs_Set.h 27 void nc_p_ProcsSet(ring rGR, p_Procs_s* p_Procs); 28 28 29 /* poly functions defined in p_Procs : */ 30 31 /* other routines we need in addition : */ 32 // poly gnc_p_Minus_mm_Mult_qq(poly p, const poly m, poly q, const ring r); 33 34 // #define PLURAL_INTERNAL_DECLARATIONS 35 36 #ifdef PLURAL_INTERNAL_DECLARATIONS 37 // // poly gnc_p_Minus_mm_Mult_qq_ign(poly p, const poly m, poly q, int & d1, poly d2, const ring ri, poly &d3); 29 // this function should be used inside QRing definition! 30 // we go from rG into factor ring rGR with factor ideal rGR->qideal. 31 bool nc_SetupQuotient(ring rGR, const ring rG); 38 32 39 33 40 poly gnc_pp_Mult_mm(const poly p, const poly m, const ring r, poly &last); 41 poly gnc_p_Mult_mm(poly p, const poly m, const ring r); 42 poly gnc_mm_Mult_p(const poly m, poly p, const ring r); 43 poly gnc_mm_Mult_pp(const poly m, const poly p, const ring r); 44 #endif 34 // used by "rSum" from ring.cc only! 35 // purpose init nc structure for initially commutative ring: 36 // "creates a commutative nc extension; "converts" comm.ring to a Plural ring" 37 ring nc_rCreateNCcomm(ring r); 38 39 void ncCleanUp(ring r); /* smaller than kill */ 40 void ncKill(ring r); 45 41 46 42 47 48 // // for p_Minus_mm_Mult_qq in pInline2.h 49 // poly nc_p_Minus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp, int lq, const ring r); 50 // // for p_Plus_mm_Mult_qq in pInline2.h 51 // poly nc_p_Plus_mm_Mult_qq (poly p, const poly m, const poly q, int &lp, int lq, const ring r); 52 53 54 // 43 // for p_Minus_mm_Mult_qq in pInline2.h 55 44 poly nc_p_Minus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp, 56 45 const int, const poly, const ring r); 46 47 // // for p_Plus_mm_Mult_qq in pInline2.h 57 48 // returns p + m*q destroys p, const: q, m 58 49 poly nc_p_Plus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp, … … 76 67 void nc_PolyPolyRed(poly &b, poly p, number *c); 77 68 poly nc_CreateShortSpoly(poly p1, poly p2, const ring r=currRing); 78 79 80 #define PLURAL_INTERNAL_DECLARATIONS81 #ifdef PLURAL_INTERNAL_DECLARATIONS82 /* syzygies : */83 poly gnc_CreateSpolyOld(const poly p1, const poly p2/*, poly spNoether*/, const ring r);84 poly gnc_ReduceSpolyOld(const poly p1, poly p2/*, poly spNoether*/, const ring r);85 86 poly gnc_CreateSpolyNew(const poly p1, const poly p2/*, poly spNoether*/, const ring r);87 poly gnc_ReduceSpolyNew(const poly p1, poly p2/*, poly spNoether*/, const ring r);88 89 90 91 void gnc_kBucketPolyRedNew(kBucket_pt b, poly p, number *c);92 void gnc_kBucketPolyRed_ZNew(kBucket_pt b, poly p, number *c);93 94 void gnc_kBucketPolyRedOld(kBucket_pt b, poly p, number *c);95 void gnc_kBucketPolyRed_ZOld(kBucket_pt b, poly p, number *c);96 97 98 // poly gnc_ReduceSpolyNew(poly p1, poly p2, poly spNoether, const ring r);99 // void gnc_ReduceSpolyTail(poly p1, poly q, poly q2, poly spNoether, const ring r);100 101 /* void nc_kBucketPolyRed(kBucket_pt b, poly p); */102 void gr_initBba(ideal F,kStrategy strat);103 104 ideal gnc_gr_bba (const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat);105 ideal gnc_gr_mora(const ideal, const ideal, const intvec *, const intvec *, kStrategy); // Not yet!106 #endif107 69 108 70 … … 159 121 160 122 // returns m*p, does destroy p, preserves m 161 inline poly mm_Mult_p(const poly m, poly p, const ring r)123 inline poly nc_mm_Mult_p(const poly m, poly p, const ring r) 162 124 { 163 125 assume(rIsPluralRing(r)); … … 226 188 #define UPMATELEM(i,j,nVar) ( (nVar * ((i)-1) - ((i) * ((i)-1))/2 + (j)-1)-(i) ) 227 189 228 #endif 229 #endif 190 191 #ifdef PLURAL_INTERNAL_DECLARATIONS 192 193 // we need nc_gr_initBba for sca_gr_bba and gr_bba. 194 void nc_gr_initBba(ideal F,kStrategy strat); 195 196 #endif // PLURAL_INTERNAL_DECLARATIONS 197 198 #endif // HAVE_PLURAL :( 199 #endif // -
kernel/ideals.cc
r1cc61e r86016d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ideals.cc,v 1.3 7 2007-01-24 10:00:55 SingularExp $ */4 /* $Id: ideals.cc,v 1.38 2007-01-31 23:51:24 motsak Exp $ */ 5 5 /* 6 6 * ABSTRACT - all basic methods to manipulate ideals … … 2314 2314 /* the subalgebra to be intersected with */ 2315 2315 { 2316 if ( currRing->nc->type!=nc_skew) /* in (quasi)-commutative algebras every subalgebra is admissible */2316 if (ncRingType(currRing)!=nc_skew) /* in (quasi)-commutative algebras every subalgebra is admissible */ 2317 2317 { 2318 2318 if (nc_CheckSubalgebra(delVar,currRing)) -
kernel/maps.cc
r1cc61e r86016d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: maps.cc,v 1. 5 2005-09-05 12:30:29 SingularExp $ */4 /* $Id: maps.cc,v 1.6 2007-01-31 23:51:24 motsak Exp $ */ 5 5 /* 6 6 * ABSTRACT - the mapping of polynomials to other rings … … 258 258 omFreeSize(names, (currRing->N)*sizeof(char*)); names=NULL; 259 259 memset(&tmpR,0,sizeof(tmpR)); 260 if ((rIsPluralRing(sourcering)) && ( sourcering->nc->type!=nc_comm))260 if ((rIsPluralRing(sourcering)) && (ncRingType(sourcering)!=nc_comm)) 261 261 { 262 262 Werror("Sorry, not yet implemented for noncomm. rings"); -
kernel/pInline2.h
r1cc61e r86016d 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: pInline2.h,v 1. 9 2007-01-11 11:27:25 SingularExp $9 * Version: $Id: pInline2.h,v 1.10 2007-01-31 23:51:24 motsak Exp $ 10 10 *******************************************************************/ 11 11 #ifndef PINLINE2_H … … 596 596 #ifdef HAVE_PLURAL 597 597 if (rIsPluralRing(r)) 598 q = mm_Mult_p(p, q, r);598 q = nc_mm_Mult_p(p, q, r); 599 599 else 600 600 #endif /* HAVE_PLURAL */ -
kernel/p_Procs_Set.h
r1cc61e r86016d 12 12 * Author: obachman (Olaf Bachmann) 13 13 * Created: 12/00 14 * Version: $Id: p_Procs_Set.h,v 1.1 1 2007-01-15 17:13:59 SingularExp $14 * Version: $Id: p_Procs_Set.h,v 1.12 2007-01-31 23:51:24 motsak Exp $ 15 15 *******************************************************************/ 16 16 #include "modulop.h" 17 17 18 #include "sca.h" 18 #ifdef HAVE_PLURAL 19 // for nc_p_ProcsSet: 20 #include "gring.h" 21 #endif 19 22 20 23 … … 176 179 r->OrdSgn == 1 || r->LexOrder); 177 180 */ 178 181 #ifdef HAVE_PLURAL 179 182 if (rIsPluralRing(r)) 180 { 181 SetProcsGNC(r, _p_procs); 182 183 if(rIsSCA(r)) 184 { 185 SetProcsSCA(r, _p_procs); 186 } 187 } 188 #endif 183 nc_p_ProcsSet(r, _p_procs); // Setup non-commutative p_Procs table! 184 #endif 189 185 } 190 186 -
kernel/ring.cc
r1cc61e r86016d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ring.cc,v 1.5 5 2007-01-29 18:08:21 SingularExp $ */4 /* $Id: ring.cc,v 1.56 2007-01-31 23:51:24 motsak Exp $ */ 5 5 6 6 /* … … 26 26 #ifdef HAVE_PLURAL 27 27 #include "gring.h" 28 #include "sca.h" 28 29 #endif 29 30 #include "maps.h" … … 390 391 else PrintS(" ..."); 391 392 #ifdef PDEBUG 392 Print("\n// noncommutative type:%d", r->nc->type);393 Print("\n// noncommutative type:%d", (int)ncRingType(r)); 393 394 Print("\n// is skew constant:%d",r->nc->IsSkewConstant); 395 if( rIsSCA(r) ) 396 { 397 Print("\n// alternating variables: [%d, %d]", scaFirstAltVar(r), scaLastAltVar(r)); 398 const ideal Q = r->nc->SCAQuotient(); // resides within r! 399 if (Q!=NULL) 400 { 401 PrintS("\n// quotient of sca by ideal"); 402 if (r==currRing) 403 { 404 PrintLn(); 405 iiWriteMatrix((matrix)Q,"__",1); 406 } 407 else PrintS(" ..."); 408 } 409 } 394 410 Print("\n// ref:%d",r->nc->ref); 395 411 #endif … … 1157 1173 if ( !R2_is_nc ) nc_rCreateNCcomm(R2); 1158 1174 /* nc->type's */ 1159 sum->nc->type = nc_undef;1160 nc_type t1 = R1->nc->type, t2 = R2->nc->type;1161 if ( t1==t2) sum->nc->type = t1;1175 ncRingType(sum, nc_undef); 1176 nc_type t1 = ncRingType(R1), t2 = ncRingType(R2); 1177 if ( t1==t2) ncRingType(sum, t1); 1162 1178 else 1163 1179 { 1164 if ( (t1==nc_general) || (t2==nc_general) ) sum->nc->type = nc_general;1165 } 1166 if ( sum->nc->type== nc_undef) /* not yet done */1180 if ( (t1==nc_general) || (t2==nc_general) ) ncRingType(sum, nc_general); 1181 } 1182 if (ncRingType(sum) == nc_undef) /* not yet done */ 1167 1183 { 1168 1184 switch (t1) 1169 1185 { 1170 1186 case nc_comm: 1171 sum->nc->type = t2;1187 ncRingType(sum, t2); 1172 1188 break; 1173 1189 case nc_lie: … … 1175 1191 { 1176 1192 case nc_skew: 1177 sum->nc->type = nc_general; break;1193 ncRingType(sum, nc_general); break; 1178 1194 case nc_comm: 1179 sum->nc->type = nc_lie; break;1195 ncRingType(sum, nc_lie); break; 1180 1196 default: 1181 1197 /*sum->nc->type = nc_undef;*/ break; … … 1186 1202 { 1187 1203 case nc_lie: 1188 sum->nc->type = nc_lie; break;1204 ncRingType(sum, nc_lie); break; 1189 1205 case nc_comm: 1190 sum->nc->type = nc_skew; break;1206 ncRingType(sum, nc_skew); break; 1191 1207 default: 1192 1208 /*sum->nc->type = nc_undef;*/ break; … … 1197 1213 } 1198 1214 } 1199 if ( sum->nc->type== nc_undef)1215 if (ncRingType(sum) == nc_undef) 1200 1216 WarnS("Error on recognizing nc types"); 1201 1217 /* multiplication matrices business: */ … … 3950 3966 r->nc->ref = 1; /* in spite of rCopy(src)? */ 3951 3967 r->nc->basering = r; 3952 r->nc->type = src->nc->type;3968 ncRingType(r, ncRingType(src)); 3953 3969 int *perm = (int *)omAlloc0((rVar(r)+1)*sizeof(int)); 3954 3970 int *par_perm = NULL; -
kernel/ring.h
r1cc61e r86016d 7 7 * ABSTRACT - the interpreter related ring operations 8 8 */ 9 /* $Id: ring.h,v 1.1 6 2007-01-11 10:27:04 SingularExp $ */9 /* $Id: ring.h,v 1.17 2007-01-31 23:51:25 motsak Exp $ */ 10 10 11 11 /* includes */ … … 33 33 ring rEnvelope(ring r); 34 34 35 // we must always have this test! 36 inline bool rIsPluralRing(const ring r) 37 { 35 38 #ifdef HAVE_PLURAL 36 inline BOOLEAN rIsPluralRing(ring r) 37 { 38 return ((r != NULL) && (r->nc != NULL) && (r->nc->type != nc_error)); 39 } 40 #else 41 #define rIsPluralRing(R) 0 42 #endif 39 return (r != NULL) && (r->nc != NULL) && (r->nc->type != nc_error); 40 #else 41 return false; 42 #endif 43 } 43 44 44 45 -
kernel/sca.cc
r1cc61e r86016d 7 7 * Author: motsak (Oleksandr Motsak) 8 8 * Created: 2006/12/18 9 * Version: $Id: sca.cc,v 1. 7 2007-01-25 16:36:50 SingularExp $9 * Version: $Id: sca.cc,v 1.8 2007-01-31 23:51:25 motsak Exp $ 10 10 *******************************************************************/ 11 11 … … 43 43 44 44 45 // scaFirstAltVar( r, 0 ); 46 // scaLastAltVar( r, 0 ); 45 // poly functions defined in p_Procs : 46 47 // return pPoly * pMonom; preserve pPoly and pMonom. 48 poly sca_pp_Mult_mm(const poly pPoly, const poly pMonom, const ring rRing, poly &); 49 50 // return pMonom * pPoly; preserve pPoly and pMonom. 51 poly sca_mm_Mult_pp(const poly pMonom, const poly pPoly, const ring rRing); 52 53 // return pPoly * pMonom; preserve pMonom, destroy or reuse pPoly. 54 poly sca_p_Mult_mm(poly pPoly, const poly pMonom, const ring rRing); 55 56 // return pMonom * pPoly; preserve pMonom, destroy or reuse pPoly. 57 poly sca_mm_Mult_p(const poly pMonom, poly pPoly, const ring rRing); 58 59 60 // compute the spolynomial of p1 and p2 61 poly sca_SPoly(const poly p1, const poly p2, const ring r); 62 poly sca_ReduceSpoly(const poly p1, poly p2, const ring r); 63 64 // Modified Plural's Buchberger's algorithmus. 65 ideal sca_gr_bba(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat); 66 67 // Modified modern Sinuglar Buchberger's algorithm. 68 ideal sca_bba(const ideal F, const ideal Q, const intvec *w, const intvec *, kStrategy strat); 69 70 // Modified modern Sinuglar Mora's algorithm. 71 ideal sca_mora(const ideal F, const ideal Q, const intvec *w, const intvec *, kStrategy strat); 47 72 48 73 … … 280 305 assume( scaFirstAltVar(rRing) <= i ); 281 306 282 if( p_GetExp(pMonom, i, rRing) ) //result is zero!307 if( p_GetExp(pMonom, i, rRing) != 0 ) // => result is zero! 283 308 return NULL; 284 309 … … 939 964 assume(rIsSCA(currRing)); 940 965 941 BOOLEAN bIdHomog = id_IsYHomogeneous(F, currRing); 966 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing); 967 const unsigned int m_iLastAltVar = scaLastAltVar(currRing); 968 969 ideal tempF = id_KillSquares(F, m_iFirstAltVar, m_iLastAltVar, currRing); 970 const ideal tempQ = currRing->nc->SCAQuotient(); 971 972 BOOLEAN bIdHomog = id_IsBiHomogeneous(tempF, m_iFirstAltVar, m_iLastAltVar, currRing); 973 974 assume( !bIdHomog || strat->homog ); // bIdHomog =====[implies]>>>>> strat->homog 942 975 943 976 strat->homog = strat->homog && bIdHomog; … … 952 985 { 953 986 Print("ideal F: \n"); 954 for (int i = 0; i < F->idelems(); i++)987 for (int i = 0; i < tempF->idelems(); i++) 955 988 { 956 989 Print("; F[%d] = ", i+1); 957 p_Write( F->m[i], currRing);990 p_Write(tempF->m[i], currRing); 958 991 } 959 992 Print(";\n"); … … 976 1009 initBuchMoraCrit(strat); // set Gebauer, honey, sugarCrit 977 1010 978 gr_initBba(F,strat); // set enterS, red, initEcart, initEcartPair1011 nc_gr_initBba(tempF,strat); // set enterS, red, initEcart, initEcartPair 979 1012 980 1013 initBuchMoraPos(strat); … … 983 1016 // ?? set spSpolyShort, reduce ??? 984 1017 985 initBuchMora( F, NULL, strat); // Q= squares!!!!!!!1018 initBuchMora(tempF, tempQ, strat); // currRing->nc->SCAQuotient() instead of Q == squares!!!!!!! 986 1019 987 1020 strat->posInT=posInT110; // !!! … … 989 1022 srmax = strat->sl; 990 1023 reduc = olddeg = lrmax = 0; 991 992 993 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);994 const unsigned int m_iLastAltVar = scaLastAltVar(currRing);995 996 997 1024 998 1025 … … 1061 1088 if (strat->sl > srmax) srmax = strat->sl; 1062 1089 1063 ////////////// children !!!!!!!!!!!!!1064 1065 1090 const poly save = strat->P.p; 1066 1091 1067 // if( save != NULL )1068 {1069 1070 1092 #ifdef PDEBUG 1071 1093 p_Test(save, currRing); 1072 1094 #endif 1073 1095 assume( save != NULL ); 1096 1097 // SCA Specials: 1098 1099 { 1074 1100 const poly pNext = pNext(save); 1075 1101 1102 if( pNext != NULL ) 1076 1103 for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ ) 1077 if( p GetExp(save, i)!=0 )1104 if( p_GetExp(save, i, currRing) != 0 ) 1078 1105 { 1106 assume(p_GetExp(save, i, currRing) == 1); 1107 1079 1108 const poly tt = sca_pp_Mult_xi_pp(i, pNext, currRing); 1080 1109 … … 1114 1143 // if(h.IsNull()) continue; 1115 1144 1116 1117 // poly save = p_Copy(h.p, currRing); 1145 // poly save = p_Copy(h.p, currRing); 1118 1146 1119 1147 int pos; … … 1158 1186 if (TEST_OPT_PROT) messageStat(srmax,lrmax,hilbcount,strat); 1159 1187 1160 // if (Q!=NULL) updateResult(strat->Shdl,Q,strat); 1188 if (tempQ!=NULL) updateResult(strat->Shdl,tempQ,strat); 1189 1190 id_Delete(&tempF, currRing); 1161 1191 1162 1192 … … 1166 1196 1167 1197 ideal I = strat->Shdl; 1168 ideal erg = kInterRed(I, NULL);1198 ideal erg = kInterRed(I,tempQ); 1169 1199 assume(I!=erg); 1170 1200 id_Delete(&I, currRing); … … 1174 1204 1175 1205 #if 0 1176 {1177 Print("ideal S: \n");1178 for (int i = 0; i < F->idelems(); i++)1179 {1180 Print("; S[%d] = ", 1+i);1181 p_Write(F->m[i], currRing);1182 }1183 Print(";\n");1184 PrintLn();1185 }1186 1187 1206 PrintS("</sca::bba>\n"); 1188 1207 #endif … … 1192 1211 1193 1212 1194 // is this an exterior algebra or a commuunative polynomial ring \otimes exterior algebra? 1195 // we should check whether qr->qideal is of the form: y_i^2, y_{i+1}^2, \ldots, y_j^2 (j > i) 1196 //.if yes, setup qr->nc->type, etc. 1197 bool sca_SetupSCA(ring& rGR, const ring rG) 1213 // should be used only inside nc_SetupQuotient! 1214 // Check whether this our case: 1215 // 1. rG is a commutative polynomial ring \otimes anticommutative algebra 1216 // 2. factor ideal rGR->qideal contains squares of all alternating variables. 1217 // 1218 // if yes, make rGR a super-commutative algebra! 1219 // NOTE: Factors of SuperCommutative Algebras are supported this way! 1220 bool sca_SetupQuotient(ring rGR, const ring rG) 1198 1221 { 1199 1222 // return false; // test Plural … … 1208 1231 1209 1232 const int N = rG->N; 1233 1210 1234 if(N < 2) 1211 1235 return false; 1212 1236 1213 // skew-commutative + constant skew? => no tensor products at the moment!!! Only exterior algebras are supported!1214 1215 // if( rG->nc->D != NULL )1216 // return false;1217 1218 1237 if(ncRingType(rG) != nc_skew) 1219 1238 return false; 1220 1239 1221 // if(rG->nc->IsSkewConstant != 1) 1222 // return false; 1223 // 1224 // if(!n_IsMOne(p_GetCoeff(MATELEM(rG->nc->COM,1,2),rG->nc->basering), rG->nc->basering)) // COM live in basering! 1225 // return false; 1226 1227 1228 assume(rGR->qideal != NULL); 1229 1230 // sort qr->qideal: 1231 1232 // for sanity 1233 ring rSaveRing = currRing; 1234 1235 bool bWeChangeRing = false; 1236 if(currRing != rG) 1237 { 1238 rChangeCurrRing(rG); 1239 bWeChangeRing = true; 1240 } 1241 1242 const ideal idQuotient = rGR->qideal; 1243 const int iQSize = idQuotient->idelems(); 1244 1245 intvec *iv = idSort(idQuotient, FALSE); // by lex, currRing dependent!!! :( 1246 assume(iv != NULL); 1247 1248 // check for y_{iAltVarStart}^2, y_{iAltVarStart+1}^2, \ldots, y_{iAltVarEnd}^2 (iAltVarEnd > iAltVarStart) 1249 bool bSCA = true; 1250 1251 int iAltVarStart = -1; 1252 int iAltVarEnd = -1; 1253 1254 for(int i = 0; i < iQSize; i++) 1255 { 1256 const poly t = idQuotient->m[(*iv)[i]-1]; 1257 1258 if( pNext(t) != NULL ) 1259 { 1260 bSCA = false; 1261 break; 1262 } 1263 1264 const int iComp = p_GetComp(t, rG); 1265 1266 if( iComp > 0 ) 1267 { 1268 bSCA = false; 1269 break; 1270 } 1271 1272 int iV = -1; 1273 1274 for (int j = N; j; j--) 1275 { 1276 const int e = p_GetExp (t, j, rGR); 1277 1278 if( e > 0 ) 1279 { 1280 if( (e != 2) || (iV != -1) ) 1281 { 1282 bSCA = false; 1283 break; 1284 } 1285 1286 iV = j; 1287 } 1288 } 1289 1290 if(!bSCA) break; 1291 1292 if(iV == -1) 1293 { 1294 bSCA = false; 1295 break; 1296 } 1297 1298 if(iAltVarStart == -1) 1299 { 1300 iAltVarStart = iV; 1301 iAltVarEnd = iV; 1302 } else 1303 { 1304 if((iAltVarStart-1) == iV) 1305 { 1306 iAltVarStart = iV; 1307 } else 1308 if((iAltVarEnd+1) == iV) 1309 { 1310 iAltVarEnd = iV; 1240 if(rGR->qideal == NULL) // there will be a factor! 1241 return false; 1242 1243 if(rG->qideal != NULL) // we cannot change from factor to factor! 1244 return false; 1245 1246 1247 int iAltVarEnd = -1; 1248 int iAltVarStart = N+1; 1249 1250 const ring rBase = rG->nc->basering; 1251 const matrix C = rG->nc->C; // live in rBase! 1252 1253 for(int i = 1; i < N; i++) 1254 { 1255 for(int j = i + 1; j <= N; j++) 1256 { 1257 assume(MATELEM(C,i,j) != NULL); // after CallPlural! 1258 number c = p_GetCoeff(MATELEM(C,i,j), rBase); 1259 1260 if( n_IsMOne(c, rBase) ) 1261 { 1262 if( i < iAltVarStart) 1263 iAltVarStart = i; 1264 1265 if( j > iAltVarEnd) 1266 iAltVarEnd = j; 1311 1267 } else 1312 1268 { 1313 bSCA = false; 1314 break; 1269 if( !n_IsOne(c, rBase) ) 1270 { 1271 #ifdef PDEBUG 1272 // Print("Wrong Coeff at: [%d, %d]\n", i, j); 1273 #endif 1274 return false; 1275 } 1315 1276 } 1316 1277 } 1317 1278 } 1318 1279 1319 // cleanup: 1320 delete iv; 1321 1322 if (bWeChangeRing) 1323 { 1324 rChangeCurrRing(rSaveRing); 1325 } 1326 1327 1328 if(!bSCA) return false; 1329 1330 assume( 1 <= iAltVarStart ); 1331 assume( iAltVarStart <= iAltVarEnd ); 1332 assume( iAltVarEnd <= N ); 1333 1334 #ifdef PDEBUG 1335 // Print("AltVars: [%d, %d]\n", iAltVarStart, iAltVarEnd); 1336 #endif 1337 1338 const ring rBase = rG->nc->basering; 1339 const matrix C = rG->nc->C; // live in rBase! 1340 1280 if( (iAltVarEnd == -1) || (iAltVarStart == (N+1)) ) 1281 return false; // either no alternating varables, or a single one => we are in commutative case! 1282 1341 1283 for(int i = 1; i < N; i++) 1342 1284 { … … 1344 1286 { 1345 1287 assume(MATELEM(C,i,j) != NULL); // after CallPlural! 1346 number c = p_GetCoeff(MATELEM(C,i,j), rBase); 1288 number c = p_GetCoeff(MATELEM(C,i,j), rBase); 1347 1289 1348 1290 if( (iAltVarStart <= i) && (j <= iAltVarEnd) ) // S <= i < j <= E … … 1368 1310 } 1369 1311 1312 assume( 1 <= iAltVarStart ); 1313 assume( iAltVarStart < iAltVarEnd ); 1314 assume( iAltVarEnd <= N ); 1315 1316 bool bWeChangeRing = false; 1317 // for sanity 1318 ring rSaveRing = currRing; 1319 1320 if(rSaveRing != rG) 1321 { 1322 rChangeCurrRing(rG); 1323 bWeChangeRing = true; 1324 } 1325 1326 assume(rGR->qideal != NULL); 1327 assume(rG->qideal == NULL); 1328 1329 const ideal idQuotient = rGR->qideal; 1330 1331 // check for 1332 // y_{iAltVarStart}^2, y_{iAltVarStart+1}^2, \ldots, y_{iAltVarEnd}^2 (iAltVarEnd > iAltVarStart) 1333 // to be within quotient ideal. 1334 1335 bool bSCA = true; 1336 1337 for ( int i = iAltVarStart; (i <= iAltVarEnd) && bSCA; i++ ) 1338 { 1339 poly square = p_ISet(1, rSaveRing); 1340 p_SetExp(square, i, 2, rSaveRing); // square = var(i)^2. 1341 p_Setm(square, rSaveRing); 1342 1343 // square = NF( var(i)^2 | Q ) 1344 // NOTE: rSaveRing == currRing now! 1345 // NOTE: there is no better way to check this in general! 1346 square = kNF(idQuotient, NULL, square, 0, 0); 1347 1348 if( square != NULL ) // var(i)^2 is not in Q? 1349 { 1350 p_Delete(&square, rSaveRing); 1351 bSCA = false; 1352 } 1353 } 1354 1355 1356 if (bWeChangeRing) 1357 { 1358 rChangeCurrRing(rSaveRing); 1359 } 1360 1361 if(!bSCA) return false; 1362 1363 1364 1365 #ifdef PDEBUG 1366 // Print("AltVars: [%d, %d]\n", iAltVarStart, iAltVarEnd); 1367 #endif 1368 1369 1370 1370 ////////////////////////////////////////////////////////////////////////// 1371 // ok... let's setup it!!!1371 // ok... here we go. let's setup it!!! 1372 1372 ////////////////////////////////////////////////////////////////////////// 1373 ideal tempQ = id_KillSquares(idQuotient, iAltVarStart, iAltVarEnd, rG); // in rG!!! 1374 1375 rGR->nc->SCAQuotient() = idrMoveR(tempQ, rG, rGR); // deletes tempQ! 1373 1376 1374 1377 ncRingType( rGR, nc_exterior ); … … 1377 1380 scaLastAltVar( rGR, iAltVarEnd ); 1378 1381 1379 // ???????????????????????????????????????????????????????????????????????????????? 1380 // check ordering!!! alternating variables must be bigger than all other variables? 1381 1382 SetProcsSCA(rGR, rGR->p_Procs); 1383 1382 1383 1384 sca_p_ProcsSet(rGR, rGR->p_Procs); 1385 1386 1384 1387 return true; 1385 1388 } … … 1418 1421 assume(rIsSCA(currRing)); 1419 1422 1420 BOOLEAN bIdHomog = id_IsYHomogeneous(F, currRing); 1423 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing); 1424 const unsigned int m_iLastAltVar = scaLastAltVar(currRing); 1425 1426 BOOLEAN bIdHomog = id_IsBiHomogeneous(F, m_iFirstAltVar, m_iLastAltVar, currRing); 1427 1428 assume( !bIdHomog || strat->homog ); // bIdHomog =====[implies]>>>>> strat->homog 1421 1429 1422 1430 strat->homog = strat->homog && bIdHomog; … … 1442 1450 // initHilbCrit(F, Q, &hilb, strat); 1443 1451 1444 // gr_initBba(F,strat);1452 // nc_gr_initBba(F,strat); 1445 1453 initBba(F, strat); // set enterS, red, initEcart, initEcartPair 1446 1454 … … 1476 1484 /////////////////////////////////////////////////////////////// 1477 1485 // SCA: 1478 const unsigned short m_iFirstAltVar = scaFirstAltVar(currRing);1479 const unsigned short m_iLastAltVar = scaLastAltVar(currRing);1480 1481 1482 1486 1483 1487 /* compute------------------------------------------------------- */ … … 1643 1647 1644 1648 // if(0) 1645 for( unsigned short i = m_iFirstAltVar; i <= m_iLastAltVar; i++ )1646 if( p_GetExp(pSave, i, currRing) )1649 for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ ) 1650 if( p_GetExp(pSave, i, currRing) != 0 ) 1647 1651 { 1652 assume(p_GetExp(pSave, i, currRing) == 1); 1653 1648 1654 const poly pNew = sca_pp_Mult_xi_pp(i, pNext, currRing); 1649 1655 … … 1783 1789 1784 1790 1785 1786 // y-Degree1787 inline long p_yDegree(const poly p, const ring r)1788 {1789 assume(rIsSCA(r));1790 1791 const unsigned short m_iFirstAltVar = scaFirstAltVar(r);1792 const unsigned short m_iLastAltVar = scaLastAltVar(r);1793 1794 long sum = 0;1795 1796 for(int i = m_iFirstAltVar; i <= m_iLastAltVar; i++)1797 sum += p_GetExp(p, i, r);1798 1799 return sum;1800 }1801 1802 1803 1804 1805 /**21806 * tests whether p is sca-homogeneous without respect to the actual weigths(=>all ones)1807 */1808 BOOLEAN p_IsYHomogeneous(const poly p, const ring r)1809 {1810 assume(rIsSCA(r));1811 1812 if( p == NULL ) return TRUE;1813 1814 poly q = p;1815 1816 const long o = p_yDegree(q, r);1817 pIter(q);1818 1819 while( q != NULL )1820 {1821 if (p_yDegree(q,r) != o) return FALSE;1822 pIter(q);1823 }1824 1825 return TRUE;1826 }1827 1828 1829 /*21830 *returns true if id is y-homogenous without respect to the aktual weights(=> all ones)1831 */1832 BOOLEAN id_IsYHomogeneous(const ideal id, const ring r)1833 {1834 if (id == NULL) return TRUE;1835 1836 const int iSize = IDELEMS(id);1837 1838 if (iSize == 0) return TRUE;1839 1840 BOOLEAN b = TRUE;1841 1842 for(int i = iSize - 1; (i >= 0 ) && b; i--)1843 b = p_IsYHomogeneous(id->m[i], r);1844 1845 return b;1846 }1847 1848 1791 // ////////////////////////////////////////////////////////////////////////////// 1849 1792 // sca mora... … … 1884 1827 ideal sca_mora(const ideal F, const ideal Q, const intvec *w, const intvec *, kStrategy strat) 1885 1828 { 1886 BOOLEAN bIdHomog = id_IsYHomogeneous(F, currRing); 1829 assume(rIsSCA(currRing)); 1830 1831 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing); 1832 const unsigned int m_iLastAltVar = scaLastAltVar(currRing); 1833 1834 ideal tempF = id_KillSquares(F, m_iFirstAltVar, m_iLastAltVar, currRing); 1835 1836 const ideal tempQ = currRing->nc->SCAQuotient(); 1837 1838 BOOLEAN bIdHomog = id_IsBiHomogeneous(tempF, m_iFirstAltVar, m_iLastAltVar, currRing); 1839 1840 assume( !bIdHomog || strat->homog ); // bIdHomog =====[implies]>>>>> strat->homog 1887 1841 1888 1842 strat->homog = strat->homog && bIdHomog; … … 1891 1845 assume( strat->homog == bIdHomog ); 1892 1846 #endif /*PDEBUG*/ 1893 1894 1847 1895 1848 #ifdef HAVE_ASSUME … … 1897 1850 sca_mora_loop_count = 0; 1898 1851 #endif 1852 1899 1853 #ifdef KDEBUG 1900 1854 om_Opts.MinTrack = 5; … … 1911 1865 initBuchMoraCrit(strat); 1912 1866 // initHilbCrit(F,NULL,&hilb,strat); // no Q! 1913 initMora( F,strat);1867 initMora(tempF, strat); 1914 1868 initBuchMoraPos(strat); 1915 /*Shdl=*/initBuchMora( F,NULL,strat); // no Q!1869 /*Shdl=*/initBuchMora(tempF, tempQ, strat); // temp Q, F! 1916 1870 // if (TEST_OPT_FASTHC) missingAxis(&strat->lastAxis,strat); 1917 1871 /*updateS in initBuchMora has Hecketest … … 1951 1905 #endif 1952 1906 1953 1954 // 4SCA:1955 const unsigned short m_iFirstAltVar = scaFirstAltVar(currRing);1956 const unsigned short m_iLastAltVar = scaLastAltVar(currRing);1957 1907 1958 1908 while (strat->Ll >= 0) … … 2052 2002 const poly pNext = pNext(pSave); 2053 2003 2054 // if(0)2055 for( unsigned short i = m_iFirstAltVar; i <= m_iLastAltVar; i++ )2056 if( p_GetExp(pSave, i, currRing) )2004 if(pNext != NULL) 2005 for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ ) 2006 if( p_GetExp(pSave, i, currRing) != 0 ) 2057 2007 { 2058 2008 … … 2142 2092 } 2143 2093 } 2144 // if (Q!=NULL) updateResult(strat->Shdl,Q,strat);2094 if (tempQ!=NULL) updateResult(strat->Shdl,tempQ,strat); 2145 2095 idTest(strat->Shdl); 2096 2097 id_Delete( &tempF, currRing); 2098 2146 2099 return (strat->Shdl); 2147 2100 } … … 2152 2105 2153 2106 2154 void SetProcsSCA(ring&rGR, p_Procs_s* p_Procs)2107 void sca_p_ProcsSet(ring rGR, p_Procs_s* p_Procs) 2155 2108 { 2156 2109 … … 2214 2167 #endif 2215 2168 } 2216 #endif 2169 2170 2171 // bi-Degree (x, y) of lm(p) 2172 // Y are ones from iFirstAltVar up to iLastAltVar 2173 inline void p_GetSCADegree(const poly p, 2174 const unsigned int iFirstAltVar, const unsigned int iLastAltVar, 2175 long& dx, long& dy, const ring r) 2176 { 2177 const unsigned int N = r->N; 2178 2179 int i = 1; 2180 2181 dx = 0; 2182 dy = 0; 2183 2184 for(; i < iFirstAltVar; i++) 2185 dx += p_GetExp(p, i, r); 2186 2187 for(; i <= iLastAltVar; i++) 2188 dy += p_GetExp(p, i, r); 2189 2190 for(; i <= N; i++) 2191 dx += p_GetExp(p, i, r); 2192 } 2193 2194 // tests whether p is bi-homogeneous without respect to the actual weigths(=>all ones) 2195 // Polynomial is bi-homogeneous iff all monomials have the same bi-degree (x,y). 2196 // Y are ones from iFirstAltVar up to iLastAltVar 2197 bool p_IsBiHomogeneous(const poly p, 2198 const unsigned int iFirstAltVar, const unsigned int iLastAltVar, 2199 const ring r) 2200 { 2201 if( p == NULL ) return true; 2202 2203 poly q = p; 2204 2205 2206 long dx, dy; 2207 2208 p_GetSCADegree( q, iFirstAltVar, iLastAltVar, dx, dy, r); // get bi degree of lm(p) 2209 2210 pIter(q); 2211 2212 for(; q != NULL; pIter(q) ) 2213 { 2214 long x, y; 2215 2216 p_GetSCADegree( q, iFirstAltVar, iLastAltVar, x, y, r); // get bi degree of q 2217 2218 if ( (x != dx) || (y != dy) ) return false; 2219 } 2220 2221 return true; 2222 } 2223 2224 2225 // returns true if id is bi-homogenous without respect to the aktual weights(=> all ones) 2226 bool id_IsBiHomogeneous(const ideal id, 2227 const unsigned int iFirstAltVar, const unsigned int iLastAltVar, 2228 const ring r) 2229 { 2230 if (id == NULL) return true; // zero ideal 2231 2232 const int iSize = IDELEMS(id); 2233 2234 if (iSize == 0) return true; 2235 2236 bool b = true; 2237 2238 for(int i = iSize - 1; (i >= 0 ) && b; i--) 2239 b = p_IsBiHomogeneous(id->m[i], iFirstAltVar, iLastAltVar, r); 2240 2241 return b; 2242 } 2243 2244 2245 2246 2247 // reduce term lt(m) modulo <y_i^2> , i = iFirstAltVar .. iLastAltVar: 2248 // either create a copy of m or return NULL 2249 inline poly m_KillSquares(const poly m, 2250 const unsigned int iFirstAltVar, const unsigned int iLastAltVar, 2251 const ring r) 2252 { 2253 #ifdef PDEBUG 2254 p_Test(m, r); 2255 2256 #if 0 2257 Print("m_KillSquares, m = "); // ! 2258 p_Write(m, r); 2259 #endif 2260 #endif 2261 2262 assume( m != NULL ); 2263 2264 for(int k = iFirstAltVar; k <= iLastAltVar; k++) 2265 if( p_GetExp(m, k, r) > 1 ) 2266 return NULL; 2267 2268 return p_Head(m, r); 2269 } 2270 2271 2272 // reduce polynomial p modulo <y_i^2> , i = iFirstAltVar .. iLastAltVar 2273 poly p_KillSquares(const poly p, 2274 const unsigned int iFirstAltVar, const unsigned int iLastAltVar, 2275 const ring r) 2276 { 2277 #ifdef PDEBUG 2278 p_Test(p, r); 2279 2280 #if 0 2281 Print("p_KillSquares, p = "); // ! 2282 p_Write(p, r); 2283 #endif 2284 #endif 2285 2286 2287 if( p == NULL ) 2288 return NULL; 2289 2290 poly pResult = NULL; 2291 poly* ppPrev = &pResult; 2292 2293 for( poly q = p; q!= NULL; pIter(q) ) 2294 { 2295 #ifdef PDEBUG 2296 p_Test(q, r); 2297 #endif 2298 2299 // terms will be in the same order because of quasi-ordering! 2300 poly v = m_KillSquares(q, iFirstAltVar, iLastAltVar, r); 2301 2302 if( v != NULL ) 2303 { 2304 *ppPrev = v; 2305 ppPrev = &pNext(v); 2306 } 2307 2308 } 2309 2310 #ifdef PDEBUG 2311 p_Test(pResult, r); 2312 #if 0 2313 Print("p_KillSquares => "); // ! 2314 p_Write(pResult, r); 2315 #endif 2316 #endif 2317 2318 return(pResult); 2319 } 2320 2321 2322 2323 2324 // reduces ideal id modulo <y_i^2> , i = iFirstAltVar .. iLastAltVar 2325 // returns the reduced ideal or zero ideal. 2326 ideal id_KillSquares(const ideal id, 2327 const unsigned int iFirstAltVar, const unsigned int iLastAltVar, 2328 const ring r) 2329 { 2330 if (id == NULL) return id; // zero ideal 2331 2332 const int iSize = id->idelems(); 2333 2334 if (iSize == 0) return id; 2335 2336 ideal temp = idInit(iSize, 1); 2337 2338 #if 0 2339 PrintS("<id_KillSquares>\n"); 2340 { 2341 Print("ideal id: \n"); 2342 for (int i = 0; i < id->idelems(); i++) 2343 { 2344 Print("; id[%d] = ", i+1); 2345 p_Write(id->m[i], r); 2346 } 2347 Print(";\n"); 2348 PrintLn(); 2349 } 2350 #endif 2351 2352 2353 for (int j = 0; j < iSize; j++) 2354 temp->m[j] = p_KillSquares(id->m[j], iFirstAltVar, iLastAltVar, r); 2355 2356 idSkipZeroes(temp); 2357 2358 #if 0 2359 PrintS("<id_KillSquares>\n"); 2360 { 2361 Print("ideal temp: \n"); 2362 for (int i = 0; i < temp->idelems(); i++) 2363 { 2364 Print("; temp[%d] = ", i+1); 2365 p_Write(temp->m[i], r); 2366 } 2367 Print(";\n"); 2368 PrintLn(); 2369 } 2370 PrintS("</id_KillSquares>\n"); 2371 #endif 2372 2373 return temp; 2374 } 2375 2376 2377 2378 2379 #endif -
kernel/sca.h
r1cc61e r86016d 5 5 * Computer Algebra System SINGULAR * 6 6 ****************************************/ 7 /* $Id: sca.h,v 1. 6 2007-01-12 11:08:42 SingularExp $ */7 /* $Id: sca.h,v 1.7 2007-01-31 23:51:25 motsak Exp $ */ 8 8 9 #include <ring.h> 9 10 #include <gring.h> 11 #include <structs.h> 12 13 14 // we must always have this test! 15 inline bool rIsSCA(const ring r) 16 { 10 17 #ifdef HAVE_PLURAL 11 #include <structs.h> 12 // #include <polys-impl.h> 13 // #include <ring.h> 18 return rIsPluralRing(r) && (ncRingType(r) == nc_exterior); 19 #else 20 return false; 21 #endif 22 } 14 23 15 inline bool rIsSCA(ring r) 16 { 17 if(!rIsPluralRing(r)) 18 return false; 19 20 const bool result = (ncRingType(r) == nc_exterior); 21 22 // if( result ) 23 // assume( ((scaFirstAltVar(r) != 0) && (scaLastAltVar(r) != 0)) ); 24 25 return(result); 26 } 24 #ifdef HAVE_PLURAL 25 #include <gring.h> 27 26 28 27 … … 41 40 }; 42 41 42 43 // The following inlines are just helpers for setup functions. 43 44 inline void scaFirstAltVar(ring r, int n) 44 45 { … … 66 67 67 68 // set pProcs for r and the variable p_Procs 68 // should be used by p_ProcsSet in "p_Procs_Set.h" 69 void SetProcsSCA(ring& rGR, p_Procs_s* p_Procs); 69 // should be used by nc_p_ProcsSet in "gring.h" 70 void sca_p_ProcsSet(ring rGR, p_Procs_s* p_Procs); 71 72 ////////////////////////////////////////////////////////////////////////////////////// 73 74 // tests whether p is bi-homogeneous without respect to the actual weigths(=>all ones) 75 // Polynomial is bi-homogeneous iff all monomials have the same bi-degree (x,y). 76 // Y are ones from iFirstAltVar up to iLastAltVar 77 bool p_IsBiHomogeneous(const poly p, 78 const unsigned int iFirstAltVar, const unsigned int iLastAltVar, 79 const ring r); 80 81 ////////////////////////////////////////////////////////////////////////////////////// 82 83 // returns true if id is bi-homogenous without respect to the aktual weights(=> all ones) 84 // Ideal is bi-homogeneous iff all its generators are bi-homogeneous. 85 bool id_IsBiHomogeneous(const ideal id, 86 const unsigned int iFirstAltVar, const unsigned int iLastAltVar, 87 const ring r); 88 89 ////////////////////////////////////////////////////////////////////////////////////// 90 91 // reduce polynomial p modulo <y_i^2> , i = iFirstAltVar .. iLastAltVar 92 poly p_KillSquares(const poly p, 93 const unsigned int iFirstAltVar, const unsigned int iLastAltVar, 94 const ring r); 95 96 ////////////////////////////////////////////////////////////////////////////////////// 97 98 // reduce ideal id modulo <y_i^2> , i = iFirstAltVar .. iLastAltVar 99 ideal id_KillSquares(const ideal id, 100 const unsigned int iFirstAltVar, const unsigned int iLastAltVar, 101 const ring r); 70 102 71 103 72 // is this an exterior algebra or a commutative polynomial ring \otimes exterior algebra? 73 // we should check whether qr->qideal is of the form: y_i^2, y_{i+1}^2, \ldots, y_j^2 (j > i) 74 // if yes, setup qr->nc->type, etc. 75 // should be used inside QRing definition! 76 // NOTE: (&TODO): Factors of SuperCommutative Algebras are not supported this way! 77 bool sca_SetupSCA(ring& rGR, const ring rG); 104 #ifdef PLURAL_INTERNAL_DECLARATIONS 78 105 106 // should be used only inside nc_SetupQuotient! 107 // Check whether this our case: 108 // 1. rG is a commutative polynomial ring \otimes anticommutative algebra 109 // 2. factor ideal rGR->qideal contains squares of all alternating variables. 110 // 111 // if yes, make rGR a super-commutative algebra! 112 // NOTE: Factors of SuperCommutative Algebras are supported this way! 113 bool sca_SetupQuotient(ring rGR, const ring rG); 79 114 80 81 82 // tests whether p is sca(y)-homogeneous without respect to the actual weigths(=>all ones) 83 BOOLEAN p_IsYHomogeneous(const poly p, const ring r); 84 85 // returns true if id is sca(y)-homogenous without respect to the aktual weights(=> all ones) 86 BOOLEAN id_IsYHomogeneous(const ideal id, const ring r); 87 88 89 90 // #define PLURAL_INTERNAL_DECLARATIONS 91 92 #ifdef PLURAL_INTERNAL_DECLARATIONS 93 // poly functions defined in p_Procs : 94 95 // return pPoly * pMonom; preserve pPoly and pMonom. 96 poly sca_pp_Mult_mm(const poly pPoly, const poly pMonom, const ring rRing, poly &); 97 98 // return pMonom * pPoly; preserve pPoly and pMonom. 99 poly sca_mm_Mult_pp(const poly pMonom, const poly pPoly, const ring rRing); 100 101 // return pPoly * pMonom; preserve pMonom, destroy or reuse pPoly. 102 poly sca_p_Mult_mm(poly pPoly, const poly pMonom, const ring rRing); 103 104 // return pMonom * pPoly; preserve pMonom, destroy or reuse pPoly. 105 poly sca_mm_Mult_p(const poly pMonom, poly pPoly, const ring rRing); 106 107 108 // compute the spolynomial of p1 and p2 109 poly sca_SPoly(const poly p1, const poly p2, const ring r); 110 poly sca_ReduceSpoly(const poly p1, poly p2, const ring r); 111 112 // Modified Plural's Buchberger's algorithmus. 113 ideal sca_gr_bba(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat); 114 115 // Modified modern Sinuglar Buchberger's algorithm. 116 ideal sca_bba(const ideal F, const ideal Q, const intvec *w, const intvec *, kStrategy strat); 117 118 // Modified modern Sinuglar Mora's algorithm. 119 ideal sca_mora(const ideal F, const ideal Q, const intvec *w, const intvec *, kStrategy strat); 120 #endif 115 #endif // PLURAL_INTERNAL_DECLARATIONS 121 116 122 117 123 118 #else 124 #define rIsSCA(R) 0 125 #define scaFirstAltVar(R) 0126 #define scaLastAltVar(R) 0119 // these must not be used at all. 120 // #define scaFirstAltVar(R) 0 121 // #define scaLastAltVar(R) 0 127 122 #endif 128 123 #endif // #ifndef GRING_SUPER_COMMUTATIVE_ALGEBRA_H -
kernel/structs.h
r1cc61e r86016d 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: structs.h,v 1. 29 2007-01-11 11:27:26 SingularExp $ */6 /* $Id: structs.h,v 1.30 2007-01-31 23:51:25 motsak Exp $ */ 7 7 /* 8 8 * ABSTRACT … … 462 462 // iAltVarsStart, iAltVarsEnd are only used together with nc_type=nc_exterior 463 463 // 1 <= iAltVarsStart <= iAltVarsEnd <= r->N 464 unsigned int iFirstAltVar, iLastAltVar; 464 unsigned int iFirstAltVar, iLastAltVar; // = 0 by default 465 466 // for factors of super-commutative algebras we need 467 // the part of general quotient ideal modulo squares! 468 ideal idSCAQuotient; // = NULL by default. 465 469 466 470 public: … … 470 474 inline unsigned int FirstAltVar() const { return (iFirstAltVar); }; 471 475 inline unsigned int LastAltVar () const { return (iLastAltVar ); }; 476 477 inline ideal& SCAQuotient() { return (idSCAQuotient); }; 472 478 473 479 public:
Note: See TracChangeset
for help on using the changeset viewer.