Changeset 52e2f6 in git
- Timestamp:
- Jun 10, 2008, 12:17:33 PM (16 years ago)
- Branches:
- (u'spielwiese', 'd1b01e9d51ade4b46b745d3bada5c5f3696be3a8')
- Children:
- 28325ab307b0d45f178c4ce869547de7d3f3faa7
- Parents:
- f2b58394b7c0b28984794adfcef85f56f72e35bf
- Location:
- kernel
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/RULES
rf2b5839 r52e2f6 1 1 * never use fopen, but myfopen, in order to open text files 2 2 3 * call rComplete after constructing a ring 3 * call rComplete after constructing a ring (returns purely commutative ring!) 4 5 ** call nc_CallPlural to make a newly constucted commutative ring (see above) noncommutative 4 6 5 7 * never allocate memory with 0 as size request -
kernel/gr_kstd2.cc
rf2b5839 r52e2f6 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: gr_kstd2.cc,v 1.1 3 2007-02-07 10:49:39 SingularExp $ */4 /* $Id: gr_kstd2.cc,v 1.14 2008-06-10 10:17:31 motsak Exp $ */ 5 5 /* 6 6 * ABSTRACT - Kernel: noncomm. alg. of Buchberger … … 500 500 { 501 501 strat->fromT=FALSE; 502 (*h).p = gnc_ReduceSpolyNew(pi,(*h).p,strat->kNoether,currRing);502 (*h).p = nc_ReduceSpoly(pi,(*h).p,strat->kNoether,currRing); 503 503 } 504 504 else … … 814 814 } 815 815 816 #define MYTEST 0 817 816 818 ideal gnc_gr_bba(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat) 817 819 { 820 #if MYTEST 821 PrintS("<gnc_gr_bba>\n"); 822 #endif 823 824 #ifdef HAVE_PLURAL 825 #if MYTEST 826 PrintS("currRing: \n"); 827 rWrite(currRing); 828 #ifdef RDEBUG 829 rDebugPrint(currRing); 830 #endif 831 832 PrintS("F: \n"); 833 idPrint(F); 834 PrintS("Q: \n"); 835 idPrint(Q); 836 #endif 837 #endif 838 839 840 818 841 assume(pOrdSgn != -1); // no mora!!! it terminates only for global ordering!!! (?) 819 842 … … 835 858 srmax = strat->sl; 836 859 reduc = olddeg = lrmax = 0; 860 837 861 /* compute------------------------------------------------------- */ 838 862 while (strat->Ll >= 0) 839 863 { 840 864 if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/ 865 841 866 if (TEST_OPT_DEBUG) messageSets(strat); 867 842 868 if (strat->Ll== 0) strat->interpt=TRUE; 843 869 if (TEST_OPT_DEGBOUND … … 858 884 strat->Ll--; 859 885 //kTest(strat); 886 887 if (strat->P.p != NULL) 860 888 if (pNext(strat->P.p) == strat->tail) 861 889 { … … 863 891 pLmFree(strat->P.p); 864 892 /* the real one */ 865 if ((ncRingType(currRing)==nc_lie) && pHasNotCF(strat->P.p1,strat->P.p2)) /* prod crit */ 866 { 867 strat->cp++; 868 /* prod.crit itself in nc_CreateSpoly */ 869 } 893 if (ncRingType(currRing)==nc_lie) /* prod crit */ 894 if(pHasNotCF(strat->P.p1,strat->P.p2)) 895 { 896 // strat->cp++; 897 /* prod.crit itself in nc_CreateSpoly */ 898 } 899 870 900 strat->P.p = nc_CreateSpoly(strat->P.p1,strat->P.p2,currRing); 871 } 901 902 #ifdef PDEBUG 903 p_Test(strat->P.p, currRing); 904 #endif 905 906 #if MYTEST 907 if (TEST_OPT_DEBUG) 908 { 909 PrintS("p1: "); pWrite(strat->P.p1); 910 PrintS("p2: "); pWrite(strat->P.p2); 911 PrintS("SPoly: "); pWrite(strat->P.p); 912 } 913 #endif 914 } 915 916 872 917 if (strat->P.p != NULL) 873 918 { 874 919 if (TEST_OPT_PROT) 875 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),920 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(), 876 921 &olddeg,&reduc,strat, red_result); 922 923 #if MYTEST 924 if (TEST_OPT_DEBUG) 925 { 926 PrintS("p1: "); pWrite(strat->P.p1); 927 PrintS("p2: "); pWrite(strat->P.p2); 928 PrintS("SPoly before: "); pWrite(strat->P.p); 929 } 930 #endif 931 877 932 /* reduction of the element chosen from L */ 878 933 strat->red(&strat->P,strat); 934 935 #if MYTEST 936 if (TEST_OPT_DEBUG) 937 { 938 PrintS("red SPoly: "); pWrite(strat->P.p); 939 } 940 #endif 941 879 942 } 880 943 if (strat->P.p != NULL) … … 913 976 if (TEST_OPT_DEBUG) 914 977 { 915 PrintS("new s:"); 916 wrp(strat->P.p); 978 PrintS("new s:"); wrp(strat->P.p); 917 979 PrintLn(); 980 #if MYTEST 981 Print("s: "); pWrite(strat->P.p); 982 #endif 983 918 984 } 919 985 // kTest(strat); 920 986 // 921 987 enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat); 988 922 989 if (strat->sl==-1) pos=0; 923 990 else pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart); 991 924 992 strat->enterS(strat->P,pos,strat,-1); 925 993 } … … 977 1045 /* Print("Total pairs considered:%d\n",zaehler); zaehler=0; */ 978 1046 #endif /*PDEBUG*/ 1047 1048 #if MYTEST 1049 PrintS("</gnc_gr_bba>\n"); 1050 #endif 1051 979 1052 return (strat->Shdl); 980 1053 } -
kernel/gring.cc
rf2b5839 r52e2f6 7 7 * Author: levandov (Viktor Levandovsky) 8 8 * Created: 8/00 - 11/00 9 * Version: $Id: gring.cc,v 1.5 3 2008-05-15 17:24:36motsak Exp $9 * Version: $Id: gring.cc,v 1.54 2008-06-10 10:17:31 motsak Exp $ 10 10 *******************************************************************/ 11 12 #define OM_CHECK 4 13 #define OM_TRACK 5 14 11 15 #include "mod2.h" 12 16 … … 26 30 #include "p_Mult_q.h" 27 31 32 #include "pInline1.h" 33 28 34 #include "gring.h" 29 35 #include "sca.h" 36 37 38 #define MYTEST 0 39 #define OUTPUT 0 40 30 41 31 42 // dirty tricks: … … 85 96 // poly nc_p_Plus_mm_Mult_qq (poly p, const poly m, const poly q, int &lp, int lq, const ring r); 86 97 #endif 98 99 100 101 /*2 102 * returns the LCM of the head terms of a and b 103 */ 104 poly p_Lcm(const poly a, const poly b, const long lCompM, const ring r) 105 { 106 poly m = p_ISet(1, r); 107 108 const int pVariables = r->N; 109 110 for (int i = pVariables; i; i--) 111 { 112 const int lExpA = p_GetExp (a, i, r); 113 const int lExpB = p_GetExp (b, i, r); 114 115 p_SetExp (m, i, si_max(lExpA, lExpB), r); 116 } 117 118 p_SetComp (m, lCompM, r); 119 120 p_Setm(m,r); 121 122 #ifdef PDEBUG 123 p_Test(m,r); 124 #endif 125 126 return(m); 127 }; 128 129 poly p_Lcm(const poly a, const poly b, const ring r) 130 { 131 #ifdef PDEBUG 132 p_Test(a, r); 133 p_Test(b, r); 134 #endif 135 136 const long lCompP1 = p_GetComp(a, r); 137 const long lCompP2 = p_GetComp(b, r); 138 139 const poly m = p_Lcm(a, b, si_max(lCompP1, lCompP2), r); 140 141 #ifdef PDEBUG 142 p_Test(m,r); 143 #endif 144 return(m); 145 }; 87 146 88 147 … … 254 313 if (side) 255 314 { 256 Print(" Multiplication in the left module from the right");315 Print("gnc_p_Mult_mm: Multiplication in the left module from the right"); 257 316 } 258 317 #endif … … 379 438 if (ncRingType(r)==nc_skew) 380 439 { 381 if (r-> nc->IsSkewConstant==1)440 if (r->GetNC()->IsSkewConstant==1) 382 441 { 383 442 int tpower=0; … … 395 454 } 396 455 } 397 cff = n_Copy(p_GetCoeff(MATELEM(r-> nc->COM,1,2),r),r);456 cff = n_Copy(p_GetCoeff(MATELEM(r->GetNC()->COM,1,2),r),r); 398 457 nPower(cff,tpower,&tmp_num); 399 458 n_Delete(&cff,r); … … 413 472 { 414 473 cpower = F[i]*G[j]; 415 cff = n_Copy(p_GetCoeff(MATELEM(r-> nc->COM,j,i),r),r);474 cff = n_Copy(p_GetCoeff(MATELEM(r->GetNC()->COM,j,i),r),r); 416 475 nPower(cff,cpower,&tmp_num); 417 476 cff = nMult(totcff,tmp_num); … … 443 502 /* g is univariate monomial */ 444 503 { 445 /* if (ri-> nc->type==nc_skew) -- postpone to TU */504 /* if (ri->GetNC()->type==nc_skew) -- postpone to TU */ 446 505 out = gnc_mm_Mult_uu(F,jG,G[jG],r); 447 506 freeT(F,rN); … … 627 686 /* Now: F is mono with >=2 exponents, jG<iF */ 628 687 /* check the quasi-commutative case */ 629 // matrix LCOM=r-> nc->COM;688 // matrix LCOM=r->GetNC()->COM; 630 689 // number rescoef=n_Init(1,r); 631 690 // number tmpcoef=n_Init(1,r); … … 826 885 int k,m; 827 886 int rN=r->N; 828 matrix cMT=r-> nc->MT[UPMATELEM(j,i,rN)]; /* cMT=current MT */887 matrix cMT=r->GetNC()->MT[UPMATELEM(j,i,rN)]; /* cMT=current MT */ 829 888 830 889 poly x=pOne();p_SetExp(x,j,1,r);p_Setm(x,r); … … 897 956 /* if ((a==0)||(b==0)||(i<=j)) return(out); */ 898 957 899 if (MATELEM(r-> nc->COM,j,i)!=NULL)958 if (MATELEM(r->GetNC()->COM,j,i)!=NULL) 900 959 /* commutative or quasicommutative case */ 901 960 { … … 903 962 p_AddExp(out,j,b,r); 904 963 p_Setm(out,r); 905 if (r->cf->nIsOne(p_GetCoeff(MATELEM(r-> nc->COM,j,i),r))) /* commutative case */964 if (r->cf->nIsOne(p_GetCoeff(MATELEM(r->GetNC()->COM,j,i),r))) /* commutative case */ 906 965 { 907 966 return(out); … … 909 968 else 910 969 { 911 number tmp_number=p_GetCoeff(MATELEM(r-> nc->COM,j,i),r); /* quasicommutative case */970 number tmp_number=p_GetCoeff(MATELEM(r->GetNC()->COM,j,i),r); /* quasicommutative case */ 912 971 nPower(tmp_number,a*b,&tmp_number); 913 972 p_SetCoeff(out,tmp_number,r); … … 922 981 int rN=r->N; 923 982 int vik = UPMATELEM(j,i,rN); 924 int cMTsize=r-> nc->MTsize[vik];983 int cMTsize=r->GetNC()->MTsize[vik]; 925 984 int newcMTsize=0; 926 985 newcMTsize=si_max(a,b); … … 928 987 if (newcMTsize<=cMTsize) 929 988 { 930 out = nc_p_CopyGet(MATELEM(r-> nc->MT[vik],a,b),r);989 out = nc_p_CopyGet(MATELEM(r->GetNC()->MT[vik],a,b),r); 931 990 if (out !=NULL) return (out); 932 991 } … … 944 1003 for (m=1;m<=cMTsize;m++) 945 1004 { 946 out = MATELEM(r-> nc->MT[UPMATELEM(j,i,rN)],k,m);1005 out = MATELEM(r->GetNC()->MT[UPMATELEM(j,i,rN)],k,m); 947 1006 if ( out != NULL ) 948 1007 { 949 MATELEM(tmp,k,m) = out;/*MATELEM(r-> nc->MT[UPMATELEM(j,i,rN)],k,m)*/1008 MATELEM(tmp,k,m) = out;/*MATELEM(r->GetNC()->MT[UPMATELEM(j,i,rN)],k,m)*/ 950 1009 // omCheckAddr(tmp->m); 951 MATELEM(r-> nc->MT[UPMATELEM(j,i,rN)],k,m)=NULL;952 // omCheckAddr(r-> nc->MT[UPMATELEM(j,i,rN)]->m);1010 MATELEM(r->GetNC()->MT[UPMATELEM(j,i,rN)],k,m)=NULL; 1011 // omCheckAddr(r->GetNC()->MT[UPMATELEM(j,i,rN)]->m); 953 1012 } 954 1013 } 955 1014 } 956 id_Delete((ideal *)&(r-> nc->MT[UPMATELEM(j,i,rN)]),r);957 r-> nc->MT[UPMATELEM(j,i,rN)] = tmp;1015 id_Delete((ideal *)&(r->GetNC()->MT[UPMATELEM(j,i,rN)]),r); 1016 r->GetNC()->MT[UPMATELEM(j,i,rN)] = tmp; 958 1017 tmp=NULL; 959 r-> nc->MTsize[UPMATELEM(j,i,rN)] = newcMTsize;1018 r->GetNC()->MTsize[UPMATELEM(j,i,rN)] = newcMTsize; 960 1019 } 961 1020 /* The update of multiplication matrix is finished */ … … 971 1030 int k,m; 972 1031 int rN=r->N; 973 matrix cMT=r-> nc->MT[UPMATELEM(j,i,rN)]; /* cMT=current MT */1032 matrix cMT=r->GetNC()->MT[UPMATELEM(j,i,rN)]; /* cMT=current MT */ 974 1033 975 1034 poly x=pOne();p_SetExp(x,j,1,r);p_Setm(x,r);/* var(j); */ … … 1166 1225 poly gnc_ReduceSpolyOld(const poly p1, poly p2/*,poly spNoether*/, const ring r) 1167 1226 { 1227 assume(p_LmDivisibleBy(p1, p2, r)); 1228 1168 1229 if (p_GetComp(p1,r)!=p_GetComp(p2,r) 1169 1230 && (p_GetComp(p1,r)!=0) … … 1217 1278 poly gnc_ReduceSpolyNew(const poly p1, poly p2, const ring r) 1218 1279 { 1280 assume(p_LmDivisibleBy(p1, p2, r)); 1281 1219 1282 const long lCompP1 = p_GetComp(p1,r); 1220 1283 const long lCompP2 = p_GetComp(p2,r); … … 1365 1428 poly gnc_CreateSpolyNew(poly p1, poly p2/*,poly spNoether*/, const ring r) 1366 1429 { 1430 assume(r == currRing); 1431 1432 #ifdef PDEBUG 1433 pTest(p1); 1434 pTest(p2); 1435 #if MYTEST 1436 Print("p1: "); pWrite(p1); 1437 Print("p2: "); pWrite(p2); 1438 #endif 1439 #endif 1440 1367 1441 const long lCompP1 = p_GetComp(p1,r); 1368 1442 const long lCompP2 = p_GetComp(p2,r); … … 1376 1450 } 1377 1451 1378 // if ((r->nc->type==nc_lie) && pHasNotCF(p1,p2)) /* prod crit */ 1452 #ifdef PDEBUG 1453 if (lCompP1!=lCompP2) 1454 { 1455 WarnS("gnc_CreateSpolyNew: vector & poly in SPoly!"); 1456 } 1457 #endif 1458 1459 1460 // if ((r->GetNC()->type==nc_lie) && pHasNotCF(p1,p2)) /* prod crit */ 1379 1461 // { 1380 1462 // return(nc_p_Bracket_qq(pCopy(p2),p1)); 1381 1463 // } 1382 1464 1383 poly pL=pOne();1384 1385 poly m1=p One();1386 poly m2=p One();1387 1388 p Lcm(p1,p2,pL); // pL = lcm( lm(p1), lm(p2) )1389 1390 p_Setm(pL,r);1465 // poly pL=p_ISet(1, r); 1466 1467 poly m1=p_ISet(1, r); 1468 poly m2=p_ISet(1, r); 1469 1470 poly pL = p_Lcm(p1,p2,r); // pL = lcm( lm(p1), lm(p2) ) 1471 1472 // p_Setm(pL,r); 1391 1473 1392 1474 #ifdef PDEBUG … … 1394 1476 #endif 1395 1477 1396 p_ExpVectorDiff(m1, pL,p1,r); // m1 = pL / lm(p1)1478 p_ExpVectorDiff(m1, pL, p1, r); // m1 = pL / lm(p1) 1397 1479 //p_SetComp(m1,0,r); 1398 1480 //p_Setm(m1,r); 1481 1399 1482 #ifdef PDEBUG 1400 1483 p_Test(m1,r); 1401 1484 #endif 1402 1403 p_ExpVectorDiff(m2,pL,p2,r); // m2 = pL / lm(p2) 1485 // assume(p_GetComp(m1,r) == 0); 1486 1487 p_ExpVectorDiff(m2, pL, p2, r); // m2 = pL / lm(p2) 1404 1488 1405 1489 //p_SetComp(m2,0,r); … … 1408 1492 p_Test(m2,r); 1409 1493 #endif 1494 1495 #ifdef PDEBUG 1496 #if MYTEST 1497 Print("m1: "); pWrite(m1); 1498 Print("m2: "); pWrite(m2); 1499 #endif 1500 #endif 1501 1502 1503 // assume(p_GetComp(m2,r) == 0); 1504 1505 #ifdef PDEBUG 1506 #if 0 1507 if( (p_GetComp(m2,r) != 0) || (p_GetComp(m1,r) != 0) ) 1508 { 1509 WarnS("gnc_CreateSpolyNew: wrong monomials!"); 1510 1511 1512 #ifdef RDEBUG 1513 PrintS("m1 = "); p_Write(m1, r); 1514 pDebugPrintR(m1, r); 1515 1516 PrintS("m2 = "); p_Write(m2, r); 1517 pDebugPrintR(m2, r); 1518 1519 PrintS("p1 = "); p_Write(p1, r); 1520 pDebugPrintR(p1, r); 1521 1522 PrintS("p2 = "); p_Write(p2, r); 1523 pDebugPrintR(p2, r); 1524 1525 PrintS("pL = "); p_Write(pL, r); 1526 pDebugPrintR(pL, r); 1527 #endif 1528 1529 } 1530 1531 #endif 1532 #endif 1533 1534 1410 1535 1411 1536 p_Delete(&pL,r); … … 1415 1540 poly M2 = nc_mm_Mult_p(m2,p_Head(p2,r),r); // M2 = m2 * lt(p2) 1416 1541 1542 #ifdef PDEBUG 1543 p_Test(M1,r); 1544 p_Test(M2,r); 1545 1546 #if MYTEST 1547 Print("M1: "); pWrite(M1); 1548 Print("M2: "); pWrite(M2); 1549 #endif 1550 #endif 1551 1417 1552 if(M1 == NULL || M2 == NULL) 1418 1553 { … … 1459 1594 // { 1460 1595 M1=p_Mult_nn(M1,C2,r); // M1 = (C2*lc(p1)) * (lcm(lm(p1),lm(p2)) / lm(p1)) * lm(p1) 1596 1597 #ifdef PDEBUG 1598 p_Test(M1,r); 1599 #endif 1600 1461 1601 M2=p_Mult_nn(M2,C1,r); // M2 =(-C1*lc(p2)) * (lcm(lm(p1),lm(p2)) / lm(p2)) * lm(p2) 1602 1603 1604 1605 #ifdef PDEBUG 1606 p_Test(M2,r); 1607 1608 #if MYTEST 1609 Print("M1: "); pWrite(M1); 1610 Print("M2: "); pWrite(M2); 1611 #endif 1612 #endif 1613 1614 #endif 1615 1462 1616 M2=p_Add_q(M1,M2,r); // M1 is killed, M2 = spoly(lt(p1), lt(p2)) = C2*M1 - C1*M2 1463 // M2 == 0 for supercommutative algebras! 1617 1618 #ifdef PDEBUG 1619 p_Test(M2,r); 1620 1621 #if MYTEST 1622 Print("M2: "); pWrite(M2); 1623 #endif 1624 1625 #endif 1626 1627 // M2 == 0 for supercommutative algebras! 1464 1628 // } 1465 1629 // n_Delete(&MinusOne,r); … … 1468 1632 p_SetCoeff(m2,C1,r); // lc(m2) = C1!!! 1469 1633 1470 1471 poly tmp=p_Copy(p1,r); // tmp = p1 1472 tmp=p_LmDeleteAndNext(tmp,r); // tmp = tail(p1) 1473 M1 = nc_mm_Mult_p(m1,tmp,r); // M1 = m1 * tail(p1), delete tmp 1474 tmp=p_Copy(p2,r); // tmp = p2 1475 tmp=p_LmDeleteAndNext(tmp,r); // tmp = tail(p2) 1634 #ifdef PDEBUG 1635 p_Test(m1,r); 1636 p_Test(m2,r); 1637 #endif 1638 1639 // poly tmp = p_Copy(p1,r); // tmp = p1 1640 // tmp=p_LmDeleteAndNext(tmp,r); // tmp = tail(p1) 1641 //#ifdef PDEBUG 1642 // p_Test(tmp,r); 1643 //#endif 1644 1645 M1 = nc_mm_Mult_pp(m1, pNext(p1), r); // M1 = m1 * tail(p1), delete tmp // ??? 1646 1647 #ifdef PDEBUG 1648 p_Test(M1,r); 1649 1650 #if MYTEST 1651 Print("M1: "); pWrite(M1); 1652 #endif 1653 1654 #endif 1655 1476 1656 M2=p_Add_q(M2,M1,r); // M2 = spoly(lt(p1), lt(p2)) + m1 * tail(p1), delete M1 1477 M1 = nc_mm_Mult_p(m2,tmp,r); // M1 = m2 * tail(p2), detele tmp 1478 M2=p_Add_q(M2,M1,r); // M2 = spoly(lt(p1), lt(p2)) + m1 * tail(p1) + m2*tail(p2) 1657 #ifdef PDEBUG 1658 p_Test(M2,r); 1659 1660 #if MYTEST 1661 Print("M2: "); pWrite(M2); 1662 #endif 1663 1664 #endif 1665 1666 // tmp=p_Copy(p2,r); // tmp = p2 1667 // tmp=p_LmDeleteAndNext(tmp,r); // tmp = tail(p2) 1668 1669 //#ifdef PDEBUG 1670 // p_Test(tmp,r); 1671 //#endif 1672 1673 M1 = nc_mm_Mult_pp(m2, pNext(p2), r); // M1 = m2 * tail(p2), detele tmp 1674 1675 #ifdef PDEBUG 1676 p_Test(M1,r); 1677 1678 #if MYTEST 1679 Print("M1: "); pWrite(M1); 1680 #endif 1681 1682 #endif 1683 1684 M2 = p_Add_q(M2,M1,r); // M2 = spoly(lt(p1), lt(p2)) + m1 * tail(p1) + m2*tail(p2) 1685 1686 #ifdef PDEBUG 1687 p_Test(M2,r); 1688 1689 #if MYTEST 1690 Print("M2: "); pWrite(M2); 1691 #endif 1692 1693 #endif 1479 1694 // delete M1 1480 1695 … … 1486 1701 #endif 1487 1702 1488 if (M2!=NULL) pCleardenom(M2); 1703 if (M2!=NULL) pCleardenom(M2); //? 1489 1704 // if (M2!=NULL) pContent(M2); 1490 1705 … … 1542 1757 poly nc_CreateShortSpoly(poly p1, poly p2, const ring r) 1543 1758 { 1544 if (p_GetComp(p1,r)!=p_GetComp(p2,r)) 1545 { 1546 #ifdef PDEBUG 1547 Werror("nc_CreateShortSpoly: exponent mismatch!"); 1759 #ifdef PDEBUG 1760 p_Test(p1, r); 1761 p_Test(p2, r); 1762 #endif 1763 1764 const long lCompP1 = p_GetComp(p1,r); 1765 const long lCompP2 = p_GetComp(p2,r); 1766 1767 if ((lCompP1!=lCompP2) && (lCompP1!=0) && (lCompP2!=0)) 1768 { 1769 #ifdef PDEBUG 1770 Werror("nc_CreateShortSpoly: exponent mismatch!"); // !!!! 1548 1771 #endif 1549 1772 return(NULL); 1550 1773 } 1551 poly m=pOne(); 1552 pLcm(p1,p2,m); 1553 p_Setm(m,r); 1774 1775 const poly m = p_Lcm(p1, p2, si_max(lCompP1, lCompP2), r); 1776 1777 n_Delete(&p_GetCoeff(m, r), r); 1778 pSetCoeff0(m, NULL); 1779 1554 1780 #ifdef PDEBUG 1555 1781 p_Test(m,r); 1556 1782 #endif 1783 1557 1784 return(m); 1558 1785 } … … 1602 1829 #ifdef PDEBUG 1603 1830 pTest(p); 1604 // Print("p: "); pWrite(p); 1831 #if MYTEST 1832 Print("p: "); pWrite(p); 1833 #endif 1605 1834 #endif 1606 1835 … … 1611 1840 const poly pLmB = kBucketGetLm(b); // no new copy! 1612 1841 1613 1842 assume( pLmB != NULL ); 1843 1614 1844 #ifdef PDEBUG 1615 1845 pTest(pLmB); 1616 // Print("pLmB: "); pWrite(pLmB); 1846 1847 #if MYTEST 1848 Print("pLmB: "); pWrite(pLmB); 1849 #endif 1617 1850 #endif 1618 1851 … … 1622 1855 #ifdef PDEBUG 1623 1856 pTest(m); 1624 #endif 1625 1626 poly pp = nc_mm_Mult_pp(m,p,currRing); 1857 #if MYTEST 1858 Print("m: "); pWrite(m); 1859 #endif 1860 #endif 1861 1862 poly pp = nc_mm_Mult_pp(m, p, currRing); 1627 1863 pDelete(&m); 1628 1864 1629 const number n = pGetCoeff(pp); 1865 assume( pp != NULL ); 1866 const number n = pGetCoeff(pp); // bug! 1630 1867 number nn; 1631 1868 … … 1749 1986 1750 1987 1751 #define MYTEST 01752 1753 1988 inline void nc_PolyPolyRedNew(poly &b, poly p, number *c) 1754 1989 // reduces b with p, do not delete both … … 1864 2099 /* returns [p,q], destroys p */ 1865 2100 { 2101 1866 2102 if (!rIsPluralRing(currRing)) return(NULL); 1867 2103 if (pComparePolys(p,q)) return(NULL); … … 1935 2171 /* compute [ x_j^M1[j],x_i^M2[i] ] */ 1936 2172 if (i<j) {nMax=j; nMin=i;} else {nMax=i; nMin=j;} 1937 if ( (i==j) || ((MATELEM(currRing-> nc->COM,nMin,nMax)!=NULL) && nIsOne(pGetCoeff(MATELEM(currRing->nc->C,nMin,nMax))) )) /* not (the same exp. or commuting exps)*/2173 if ( (i==j) || ((MATELEM(currRing->GetNC()->COM,nMin,nMax)!=NULL) && nIsOne(pGetCoeff(MATELEM(currRing->GetNC()->C,nMin,nMax))) )) /* not (the same exp. or commuting exps)*/ 1938 2174 { bres=NULL; } 1939 2175 else … … 2051 2287 Print("Reducing p: "); // ! 2052 2288 p_Write(p, currRing); 2053 2054 2289 Print("With q: "); // ! 2055 2290 p_Write(q, currRing); … … 2203 2438 /* i<j */ 2204 2439 int rN=r->N; 2205 int size=r-> nc->MTsize[UPMATELEM(i,j,rN)];2206 matrix M = r-> nc->MT[UPMATELEM(i,j,rN)];2440 int size=r->GetNC()->MTsize[UPMATELEM(i,j,rN)]; 2441 matrix M = r->GetNC()->MT[UPMATELEM(i,j,rN)]; 2207 2442 /* return(M); */ 2208 2443 int sizeofres; … … 2258 2493 } 2259 2494 2260 void ncKill(ring r) 2261 /* kills the nc extension of ring r */ 2262 { 2495 void ncKill(ring r) 2496 // kills the nc extension of ring r 2497 { 2498 if (r->GetNC()->ref >= 1) /* in use by somebody else */ 2499 { 2500 r->GetNC()->ref--; 2501 r->GetNC() = NULL; // don't cleanup, just dereference 2502 return; 2503 } 2504 /* otherwise kill the previous nc data */ 2505 2506 assume( r->GetNC()->ref == 0 ); 2507 2263 2508 int i,j; 2264 2509 int rN=r->N; … … 2269 2514 for(j=i+1;j<=rN;j++) 2270 2515 { 2271 id_Delete((ideal *)&(r-> nc->MT[UPMATELEM(i,j,rN)]),r->nc->basering);2516 id_Delete((ideal *)&(r->GetNC()->MT[UPMATELEM(i,j,rN)]),r->GetNC()->basering); 2272 2517 } 2273 2518 } 2274 omFreeSize((ADDRESS)r-> nc->MT,rN*(rN-1)/2*sizeof(matrix));2275 omFreeSize((ADDRESS)r-> nc->MTsize,rN*(rN-1)/2*sizeof(int));2276 id_Delete((ideal *)&(r-> nc->COM),r->nc->basering);2277 } 2278 id_Delete((ideal *)&(r-> nc->C),r->nc->basering);2279 id_Delete((ideal *)&(r-> nc->D),r->nc->basering);2280 2281 if( rIsSCA(r) && (r-> nc->SCAQuotient() != NULL) )2282 { 2283 id_Delete(&r-> nc->SCAQuotient(), r->nc->basering);2284 } 2285 2286 r-> nc->basering->ref--;2287 2288 if ((r-> nc->basering->ref<=0)&&(r->nc->basering->nc==NULL))2289 { 2290 rKill(r-> nc->basering);2519 omFreeSize((ADDRESS)r->GetNC()->MT,rN*(rN-1)/2*sizeof(matrix)); 2520 omFreeSize((ADDRESS)r->GetNC()->MTsize,rN*(rN-1)/2*sizeof(int)); 2521 id_Delete((ideal *)&(r->GetNC()->COM),r->GetNC()->basering); 2522 } 2523 id_Delete((ideal *)&(r->GetNC()->C),r->GetNC()->basering); 2524 id_Delete((ideal *)&(r->GetNC()->D),r->GetNC()->basering); 2525 2526 if( rIsSCA(r) && (r->GetNC()->SCAQuotient() != NULL) ) 2527 { 2528 id_Delete(&r->GetNC()->SCAQuotient(), r->GetNC()->basering); 2529 } 2530 2531 r->GetNC()->basering->ref--; 2532 2533 if ((r->GetNC()->basering->ref<=0)&&(r->GetNC()->basering->GetNC()==NULL)) 2534 { 2535 rKill(r->GetNC()->basering); 2291 2536 } 2292 2537 … … 2294 2539 } 2295 2540 2296 void ncCleanUp(ring r) 2297 { 2298 /* small CleanUp of r->nc */ 2299 omFreeSize((ADDRESS)r->nc,sizeof(nc_struct)); 2300 r->nc = NULL; 2301 } 2541 inline void ncCleanUp(nc_struct* p) 2542 { 2543 assume(p != NULL); 2544 omFreeSize((ADDRESS)p,sizeof(nc_struct)); 2545 } 2546 2547 inline void ncCleanUp(ring r) 2548 { 2549 /* small CleanUp of r->GetNC() */ 2550 assume(r != NULL); 2551 ncCleanUp(r->GetNC()); 2552 r->GetNC() = NULL; 2553 } 2554 2555 // inline 2556 void nc_rCopy0(ring res, const ring r) 2557 { 2558 assume(rIsPluralRing(r)); 2559 assume( res != r ); 2560 2561 res->GetNC() = r->GetNC(); 2562 res->GetNC()->ref++; 2563 nc_p_ProcsSet(res, res->p_Procs); 2564 } 2565 2566 2302 2567 2303 2568 poly nc_p_CopyGet(poly a, const ring r) 2304 2569 /* for use in getting the mult. matrix elements*/ 2305 2570 /* ring r must be a currRing! */ 2306 /* for consistency, copies a poly from the comm. r-> nc->basering */2571 /* for consistency, copies a poly from the comm. r->GetNC()->basering */ 2307 2572 /* to its image in NC ring */ 2308 2573 { … … 2315 2580 } 2316 2581 if (!rIsPluralRing(r)) return(p_Copy(a,r)); 2317 if (r==r-> nc->basering) return(p_Copy(a,r));2582 if (r==r->GetNC()->basering) return(p_Copy(a,r)); 2318 2583 else 2319 2584 { 2320 return(prCopyR_NoSort(a,r-> nc->basering,r));2585 return(prCopyR_NoSort(a,r->GetNC()->basering,r)); 2321 2586 } 2322 2587 } … … 2326 2591 /* ring r must be a currRing! */ 2327 2592 /* for consistency, puts a polynomial from the NC ring */ 2328 /* to its presentation in the comm. r-> nc->basering */2593 /* to its presentation in the comm. r->GetNC()->basering */ 2329 2594 { 2330 2595 if (r != currRing) … … 2337 2602 2338 2603 if (!rIsPluralRing(r)) return(p_Copy(a,r)); 2339 if (r==r-> nc->basering) return(p_Copy(a,r));2604 if (r==r->GetNC()->basering) return(p_Copy(a,r)); 2340 2605 else 2341 2606 { 2342 return(prCopyR_NoSort(a,r,r-> nc->basering));2607 return(prCopyR_NoSort(a,r,r->GetNC()->basering)); 2343 2608 } 2344 2609 } … … 2372 2637 if (ExpVar[j]==0) 2373 2638 { 2374 test = nc_p_CopyGet(MATELEM(r-> nc->D,i,j),r);2639 test = nc_p_CopyGet(MATELEM(r->GetNC()->D,i,j),r); 2375 2640 while (test!=NULL) 2376 2641 { … … 2399 2664 } 2400 2665 2401 BOOLEAN nc_CheckOrdCondition(matrix D, ring r) 2666 2667 BOOLEAN gnc_CheckOrdCondition(matrix D, ring r) 2402 2668 /* returns TRUE if there were errors */ 2403 2669 /* checks whether the current ordering */ 2404 /* is admissible for r and D == r-> nc->D */2670 /* is admissible for r and D == r->GetNC()->D */ 2405 2671 /* to be executed in a currRing */ 2406 2672 { … … 2450 2716 2451 2717 2452 BOOLEAN nc_CallPlural(matrix CCC, matrix DDD, poly CCN, poly DDN, ring r) 2718 BOOLEAN nc_CallPlural( 2719 matrix CCC, matrix DDD, 2720 poly CCN, poly DDN, 2721 ring r, 2722 bool bSetupQuotient, bool bCopyInput, bool bBeQuiet, 2723 ring curr) 2453 2724 /* returns TRUE if there were errors */ 2454 2725 /* analyze inputs, check them for consistency */ 2455 2726 /* detects nc_type, DO NOT initialize multiplication but call for it at the end*/ 2456 2727 /* checks the ordering condition and evtl. NDC */ 2457 // NOTE: all the data are READ_ONLY from the currRing, we change r, 2458 // which is a DIFFERENT ring, but has the same representation! 2459 { 2460 2728 // NOTE: all the data belong to the curr, 2729 // we change r which may be the same ring, and must have the same representation! 2730 { 2731 // assume( curr != r ); 2732 assume( rSamePolyRep(r, curr) ); 2733 2734 2735 if( r->N == 1 ) // clearly commutative!!! 2736 { 2737 assume( 2738 ( (CCC != NULL) && (MATCOLS(CCC) == 1) && (MATROWS(CCC) == 1) && (MATELEM(CCC,1,1) == NULL) ) || 2739 ( (CCN == NULL) ) 2740 ); 2741 2742 assume( 2743 ( (DDD != NULL) && (MATCOLS(DDD) == 1) && (MATROWS(DDD) == 1) && (MATELEM(DDD,1,1) == NULL) ) || 2744 ( (DDN == NULL) ) 2745 ); 2746 2747 2748 } 2749 2750 2751 // there must be: 2752 assume( (CCC != NULL) != (CCN != NULL) ); // exactly one data about coeffs (C). 2753 assume( !((DDD != NULL) && (DDN != NULL)) ); // at most one data about tails (D). 2754 2755 ring save = currRing; 2756 2757 if( save != curr ) 2758 rChangeCurrRing(curr); 2759 2760 #if OUTPUT 2761 if( CCC != NULL ) 2762 { 2763 PrintS("nc_CallPlural(), Input data, CCC: \n"); 2764 iiWriteMatrix(CCC, "C", 2, 4); 2765 } 2766 if( DDD != NULL ) 2767 { 2768 PrintS("nc_CallPlural(), Input data, DDD: \n"); 2769 iiWriteMatrix(DDD, "D", 2, 4); 2770 } 2771 #endif 2772 2773 2461 2774 #ifndef NDEBUG 2462 2775 idTest((ideal)CCC); … … 2466 2779 #endif 2467 2780 2468 matrix CC = NULL; 2469 matrix DD = NULL; 2470 poly CN = NULL; 2471 poly DN = NULL; 2472 matrix C; 2473 matrix D; 2474 number nN,pN,qN; 2475 int tmpIsSkewConstant; 2476 int i,j; 2477 2478 2479 if (r->nc != NULL) 2480 { 2481 WarnS("redefining algebra structure"); 2482 if (r->nc->ref>1) /* in use by somebody else */ 2483 { 2484 r->nc->ref--; 2485 } 2486 else /* kill the previous nc data */ 2487 { 2488 ncKill(r); 2489 } 2490 } 2491 ring save = currRing; 2492 2493 assume(currRing!=r); 2494 assume( rSamePolyRep(r, currRing) ); 2495 rChangeCurrRing(r); 2496 2497 r->nc = (nc_struct *)omAlloc0(sizeof(nc_struct)); 2498 r->nc->ref = 1; 2499 r->nc->basering = r; // !? 2500 r->ref++; 2501 ncRingType(r, nc_undef); 2781 if( (!bBeQuiet) && (r->GetNC() != NULL) ) 2782 WarnS("going to redefine the algebra structure"); 2783 2784 if( currRing != r ) 2785 rChangeCurrRing(r); 2502 2786 2503 2787 #ifndef NDEBUG … … 2508 2792 #endif 2509 2793 2510 // there must be: 2511 assume( (CCC != NULL) != (CCN != NULL) ); // exactly one data about coeffs (C). 2512 assume( !((DDD != NULL) && (DDN != NULL)) ); // at most one data about tails (D). 2513 2514 /* initialition of the matrix C */ 2515 /* check the correctness of arguments */ 2516 2794 matrix CC = NULL; 2795 poly CN = NULL; 2796 matrix C; bool bCnew = false; 2797 2798 matrix DD = NULL; 2799 poly DN = NULL; 2800 matrix D; bool bDnew = false; 2801 2802 number nN, pN, qN; 2803 2804 bool IsSkewConstant = false, tmpIsSkewConstant; 2805 int i, j; 2806 2807 nc_type nctype = nc_undef; 2808 2809 ////////////////////////////////////////////////////////////////// 2810 // check the correctness of arguments, without any real chagnes!!! 2811 2812 2813 2814 // check C 2517 2815 if ((CCC != NULL) && ( (MATCOLS(CCC)==1) || MATROWS(CCC)==1 ) ) 2518 2816 { … … 2523 2821 if ((CCC != NULL) && ( (MATCOLS(CCC)!=r->N) || (MATROWS(CCC)!=r->N) )) 2524 2822 { 2525 Werror("Square %d x %d matrix expected",r->N,r->N); 2526 ncCleanUp(r); 2527 rChangeCurrRing(save); 2823 Werror("Square %d x %d matrix expected", r->N, r->N); 2824 2825 if( currRing != save ) 2826 rChangeCurrRing(save); 2528 2827 return TRUE; 2529 2828 } … … 2532 2831 if (( CCN != NULL) && (CN == NULL)) CN = CCN; 2533 2832 2534 /* initialition of the matrix D */ 2535 /* check the correctness of arguments */ 2536 2833 // check D 2537 2834 if ((DDD != NULL) && ( (MATCOLS(DDD)==1) || MATROWS(DDD)==1 ) ) 2538 2835 { … … 2544 2841 { 2545 2842 Werror("Square %d x %d matrix expected",r->N,r->N); 2546 ncCleanUp(r); 2547 rChangeCurrRing(save); 2843 2844 if( currRing != save ) 2845 rChangeCurrRing(save); 2548 2846 return TRUE; 2549 2847 } 2550 2848 } 2849 2551 2850 if (( DDD != NULL) && (DD == NULL)) DD = DDD; // mpCopy(DDD); // ??? 2552 2851 if (( DDN != NULL) && (DN == NULL)) DN = DDN; 2553 2852 2554 /* further checks */ 2555 2556 // all data in 'save'! 2557 2853 // further checks and some analysis: 2854 // all data in 'curr'! 2558 2855 if (CN != NULL) /* create matrix C = CN * Id */ 2559 2856 { 2560 nN = p_GetCoeff(CN, save);2561 if (n_IsZero(nN, save))2857 nN = p_GetCoeff(CN, curr); 2858 if (n_IsZero(nN, curr)) 2562 2859 { 2563 2860 Werror("Incorrect input : zero coefficients are not allowed"); 2564 ncCleanUp(r); 2565 rChangeCurrRing(save); 2861 2862 if( currRing != save ) 2863 rChangeCurrRing(save); 2566 2864 return TRUE; 2567 2865 } 2568 if (n_IsOne(nN, save)) 2569 { 2570 ncRingType(r, nc_lie); 2571 } 2866 2867 if (n_IsOne(nN, curr)) 2868 nctype = nc_lie; 2572 2869 else 2573 {2574 ncRingType(r, nc_general); 2575 }2576 r->nc->IsSkewConstant = 1; 2870 nctype = nc_general; 2871 2872 IsSkewConstant = true; 2873 2577 2874 C = mpNew(r->N,r->N); // ring independent! 2875 bCnew = true; 2876 2578 2877 for(i=1; i<r->N; i++) 2579 { 2878 for(j=i+1; j<=r->N; j++) 2879 MATELEM(C,i,j) = prCopyR_NoSort(CN, curr, r); // nc_p_CopyPut(CN, r); // copy CN from curr into r 2880 } else 2881 if ( (CN == NULL) && (CC != NULL) ) /* copy matrix C */ 2882 { 2883 /* analyze C */ 2884 2885 pN = NULL; /* check the consistency later */ 2886 2887 if( r->N > 1 ) 2888 if ( MATELEM(CC,1,2) != NULL ) 2889 pN = p_GetCoeff(MATELEM(CC,1,2), curr); 2890 2891 tmpIsSkewConstant = true; 2892 2893 for(i=1; i<r->N; i++) 2580 2894 for(j=i+1; j<=r->N; j++) 2581 2895 { 2582 MATELEM(C,i,j) = nc_p_CopyPut(CN, r); // copy CN from r into r->nc->basering 2583 } 2584 } 2585 } 2586 if ( (CN == NULL) && (CC != NULL) ) /* copy matrix C */ 2587 { 2588 C = mpCopy(CC); 2589 /* analyze C */ 2590 if ( MATELEM(C,1,2) == NULL ) 2591 pN = NULL; /* check the consistency later */ 2592 else 2593 pN = p_GetCoeff(MATELEM(C,1,2),r); 2594 tmpIsSkewConstant = 1; 2595 for(i=1; i<r->N; i++) 2596 { 2597 for(j=i+1; j<=r->N; j++) 2598 { 2599 if (MATELEM(C,i,j) == NULL) 2896 if (MATELEM(CC,i,j) == NULL) 2600 2897 qN = NULL; 2601 2898 else 2602 qN = p_GetCoeff(MATELEM(C ,i,j),r);2899 qN = p_GetCoeff(MATELEM(CC,i,j),curr); 2603 2900 2604 2901 if ( qN == NULL ) /* check the consistency: Cij!=0 */ 2605 2902 // find also illegal pN 2606 2903 { 2607 2904 Werror("Incorrect input : matrix of coefficients contains zeros in the upper triangle"); 2608 ncCleanUp(r); 2609 rChangeCurrRing(save); 2905 2906 if( currRing != save ) 2907 rChangeCurrRing(save); 2610 2908 return TRUE; 2611 2909 } 2612 if (!n_Equal(pN,qN, r)) tmpIsSkewConstant = 0; 2910 2911 if (!n_Equal(pN, qN, curr)) tmpIsSkewConstant = false; 2613 2912 } 2614 } 2615 r->nc->IsSkewConstant=tmpIsSkewConstant;2616 if ( (tmpIsSkewConstant) && (nIsOne(pN)) )2617 {2618 ncRingType(r, nc_lie);2913 2914 if( bCopyInput ) 2915 { 2916 C = mpCopy(CC, curr, r); // Copy C into r!!!??? 2917 bCnew = true; 2619 2918 } 2620 2919 else 2621 { 2622 ncRingType(r, nc_general); 2623 } 2920 C = CC; 2921 2922 IsSkewConstant = tmpIsSkewConstant; 2923 2924 if ( tmpIsSkewConstant && n_IsOne(pN, curr) ) 2925 nctype = nc_lie; 2926 else 2927 nctype = nc_general; 2624 2928 } 2625 2929 2626 2930 /* initialition of the matrix D */ 2627 if ( DD == NULL ) 2628 /* we treat DN only (it could also be NULL) */2629 {2630 D = mpNew(r->N,r->N); 2931 if ( DD == NULL ) /* we treat DN only (it could also be NULL) */ 2932 { 2933 D = mpNew(r->N,r->N); bDnew = true; 2934 2631 2935 if (DN == NULL) 2632 2936 { 2633 if ( (ncRingType(r) == nc_lie) || (ncRingType(r) == nc_undef) ) 2937 if ( (nctype == nc_lie) || (nctype == nc_undef) ) 2938 nctype = nc_comm; /* it was nc_skew earlier */ 2939 else /* nc_general, nc_skew */ 2940 nctype = nc_skew; 2941 } 2942 else /* DN != NULL */ 2943 for(i=1; i<r->N; i++) 2944 for(j=i+1; j<=r->N; j++) 2945 MATELEM(D,i,j) = prCopyR_NoSort(DN, curr, r); // project DN into r->GetNC()->basering! 2946 } 2947 else /* DD != NULL */ 2948 { 2949 bool b = true; // DD == null ? 2950 2951 for(int i = 1; (i < r->N) && b; i++) 2952 for(int j = i+1; (j <= r->N) && b; j++) 2953 if (MATELEM(DD, i, j) != NULL) 2634 2954 { 2635 ncRingType(r, nc_comm); /* it was nc_skew earlier */ 2955 b = false; 2956 break; 2636 2957 } 2958 2959 if (b) // D == NULL!!! 2960 { 2961 if ( (nctype == nc_lie) || (nctype == nc_undef) ) 2962 nctype = nc_comm; /* it was nc_skew earlier */ 2637 2963 else /* nc_general, nc_skew */ 2638 { 2639 ncRingType(r, nc_skew); 2640 } 2641 } 2642 else /* DN != NULL */ 2643 { 2644 for(i=1; i<r->N; i++) 2645 { 2646 for(j=i+1; j<=r->N; j++) 2647 { 2648 MATELEM(D,i,j) = nc_p_CopyPut(DN,r); // project DN into r->nc->basering! 2649 } 2650 } 2651 } 2652 } 2653 else /* DD != NULL */ 2654 { 2655 D = mpCopy(DD); // Copy DD into r!!! 2656 } 2657 /* analyze D */ 2658 /* check the ordering condition for D (both matrix and poly cases) */ 2659 2660 if ( nc_CheckOrdCondition(D, r) ) 2661 { 2662 ncCleanUp(r); 2964 nctype = nc_skew; 2965 } 2966 2967 if( bCopyInput ) 2968 { 2969 D = mpCopy(DD, curr, r); // Copy DD into r!!! 2970 bDnew = true; 2971 } 2972 else 2973 D = DD; 2974 2975 } 2976 2977 assume( C != NULL ); 2978 assume( D != NULL ); 2979 2980 #if OUTPUT 2981 PrintS("nc_CallPlural(), Computed data, C: \n"); 2982 iiWriteMatrix(C, "C", 2, 4); 2983 2984 PrintS("nc_CallPlural(), Computed data, D: \n"); 2985 iiWriteMatrix(D, "D", 2, 4); 2986 2987 Print("\nTemporary: type = %d, IsSkewConstant = %d\n", nctype, IsSkewConstant); 2988 #endif 2989 2990 2991 2992 2993 // check the ordering condition for D (both matrix and poly cases): 2994 if ( gnc_CheckOrdCondition(D, r) ) 2995 { 2996 if( bCnew ) mpDelete( &C, r ); 2997 if( bDnew ) mpDelete( &D, r ); 2998 2999 Werror("Matrix of polynomials violates the ordering condition"); 3000 3001 if( currRing != save ) 3002 rChangeCurrRing(save); 3003 return TRUE; 3004 } 3005 3006 // okay now we are ready for this!!! 3007 3008 // create new non-commutative structure 3009 nc_struct *nc_new = (nc_struct *)omAlloc0(sizeof(nc_struct)); 3010 3011 ncRingType(nc_new) = nctype; 3012 3013 nc_new->C = C; // if C and D were given by matrices at the beginning they are in r 3014 nc_new->D = D; // otherwise they should be in r->GetNC()->basering(polynomial * Id_{N}) 3015 3016 nc_new->IsSkewConstant = (IsSkewConstant?1:0); 3017 3018 nc_new->ref = 1; 3019 nc_new->basering = r; // !? 3020 3021 // Setup new NC structure!!! 3022 if (r->GetNC() != NULL) 3023 ncKill(r); 3024 3025 r->ref++; // ? 3026 r->GetNC() = nc_new; 3027 3028 if( currRing != save ) 2663 3029 rChangeCurrRing(save); 2664 Werror("Matrix of polynomials violates the ordering condition"); 2665 return TRUE; 2666 } 2667 r->nc->C = C; // if C and D were given by matrices at the beginning they are in r 2668 r->nc->D = D; // otherwise they should be in r->nc->basering(polynomial * Id_{N}) 2669 2670 rChangeCurrRing(save); 2671 2672 return nc_InitMultiplication(r); 3030 3031 return gnc_InitMultiplication(r, bSetupQuotient); 2673 3032 } 2674 3033 2675 3034 ////////////////////////////////////////////////////////////////////////////// 2676 BOOLEAN nc_InitMultiplication(ring r)3035 BOOLEAN gnc_InitMultiplication(ring r, bool bSetupQuotient) 2677 3036 { 2678 3037 /* returns TRUE if there were errors */ 2679 3038 /* initialize the multiplication: */ 2680 /* r-> nc->MTsize, r->nc->MT, r->nc->COM, */2681 /* and r-> nc->IsSkewConstant for the skew case */3039 /* r->GetNC()->MTsize, r->GetNC()->MT, r->GetNC()->COM, */ 3040 /* and r->GetNC()->IsSkewConstant for the skew case */ 2682 3041 if (rVar(r)==1) 2683 3042 { 2684 3043 ncRingType(r, nc_comm); 2685 r-> nc->IsSkewConstant=1;3044 r->GetNC()->IsSkewConstant=1; 2686 3045 return FALSE; 2687 3046 } 3047 2688 3048 ring save = currRing; 3049 2689 3050 int WeChangeRing = 0; 2690 3051 if (currRing!=r) … … 2693 3054 WeChangeRing = 1; 2694 3055 } 2695 assume( (currRing == r-> nc->basering)2696 || ((currRing-> nc!=NULL) && (currRing->nc->basering==r->nc->basering)) ); // otherwise we cannot work with all these matrices!3056 assume( (currRing == r->GetNC()->basering) 3057 || ((currRing->GetNC()!=NULL) && (currRing->GetNC()->basering==r->GetNC()->basering)) ); // otherwise we cannot work with all these matrices! 2697 3058 2698 3059 int i,j; 2699 r-> nc->MT = (matrix *)omAlloc0((r->N*(r->N-1))/2*sizeof(matrix));2700 r-> nc->MTsize = (int *)omAlloc0((r->N*(r->N-1))/2*sizeof(int));2701 idTest(((ideal)r-> nc->C));2702 matrix COM = mpCopy(r-> nc->C);3060 r->GetNC()->MT = (matrix *)omAlloc0((r->N*(r->N-1))/2*sizeof(matrix)); 3061 r->GetNC()->MTsize = (int *)omAlloc0((r->N*(r->N-1))/2*sizeof(int)); 3062 idTest(((ideal)r->GetNC()->C)); 3063 matrix COM = mpCopy(r->GetNC()->C); 2703 3064 poly p,q; 2704 3065 short DefMTsize=7; … … 2710 3071 for(j=i+1; j<=r->N; j++) 2711 3072 { 2712 if ( MATELEM(r-> nc->D,i,j) == NULL ) /* quasicommutative case */3073 if ( MATELEM(r->GetNC()->D,i,j) == NULL ) /* quasicommutative case */ 2713 3074 { 2714 3075 /* 1x1 mult.matrix */ 2715 r-> nc->MTsize[UPMATELEM(i,j,r->N)] = 1;2716 r-> nc->MT[UPMATELEM(i,j,r->N)] = mpNew(1,1);3076 r->GetNC()->MTsize[UPMATELEM(i,j,r->N)] = 1; 3077 r->GetNC()->MT[UPMATELEM(i,j,r->N)] = mpNew(1,1); 2717 3078 } 2718 3079 else /* pure noncommutative case */ … … 2722 3083 p_Delete(&(MATELEM(COM,i,j)),r); 2723 3084 //MATELEM(COM,i,j) = NULL; // done by p_Delete 2724 r-> nc->MTsize[UPMATELEM(i,j,r->N)] = DefMTsize; /* default sizes */2725 r-> nc->MT[UPMATELEM(i,j,r->N)] = mpNew(DefMTsize, DefMTsize);3085 r->GetNC()->MTsize[UPMATELEM(i,j,r->N)] = DefMTsize; /* default sizes */ 3086 r->GetNC()->MT[UPMATELEM(i,j,r->N)] = mpNew(DefMTsize, DefMTsize); 2726 3087 } 2727 3088 /* set MT[i,j,1,1] to c_i_j*x_i*x_j + D_i_j */ 2728 3089 p = p_ISet(1,r); /* instead of p = pOne(); */ 2729 if (MATELEM(r-> nc->C,i,j)!=NULL)2730 p_SetCoeff(p,n_Copy(pGetCoeff(MATELEM(r-> nc->C,i,j)),r),r);3090 if (MATELEM(r->GetNC()->C,i,j)!=NULL) 3091 p_SetCoeff(p,n_Copy(pGetCoeff(MATELEM(r->GetNC()->C,i,j)),r),r); 2731 3092 p_SetExp(p,i,1,r); 2732 3093 p_SetExp(p,j,1,r); 2733 3094 p_Setm(p,r); 2734 p_Test(MATELEM(r-> nc->D,i,j),r->nc->basering);2735 q = nc_p_CopyGet(MATELEM(r-> nc->D,i,j),r);3095 p_Test(MATELEM(r->GetNC()->D,i,j),r->GetNC()->basering); 3096 q = nc_p_CopyGet(MATELEM(r->GetNC()->D,i,j),r); 2736 3097 p = p_Add_q(p,q,r); 2737 MATELEM(r-> nc->MT[UPMATELEM(i,j,r->N)],1,1) = nc_p_CopyPut(p,r);3098 MATELEM(r->GetNC()->MT[UPMATELEM(i,j,r->N)],1,1) = nc_p_CopyPut(p,r); 2738 3099 p_Delete(&p,r); 2739 3100 // p = NULL;// done by p_Delete … … 2745 3106 { 2746 3107 // assume(pN!=NULL); 2747 // if ((tmpIsSkewConstant==1) && (nIsOne(pGetCoeff(pN)))) r-> nc->type=nc_lie;2748 // else r-> nc->type=nc_general;3108 // if ((tmpIsSkewConstant==1) && (nIsOne(pGetCoeff(pN)))) r->GetNC()->type=nc_lie; 3109 // else r->GetNC()->type=nc_general; 2749 3110 } 2750 3111 if (IsNonComm==0) 2751 3112 { 2752 3113 ncRingType(r, nc_skew); /* TODO: check whether it is commutative */ 2753 r->nc->IsSkewConstant=tmpIsSkewConstant; 2754 } 2755 } 2756 r->nc->COM=COM; 2757 2758 gnc_p_ProcsSet(r, r->p_Procs); 2759 2760 if (WeChangeRing) 2761 { 3114 r->GetNC()->IsSkewConstant=tmpIsSkewConstant; 3115 } 3116 } 3117 r->GetNC()->COM=COM; 3118 3119 nc_p_ProcsSet(r, r->p_Procs); 3120 3121 if(bSetupQuotient) // Test me!!! 3122 { 3123 nc_SetupQuotient(r); 3124 } 3125 3126 if (save != currRing) 2762 3127 rChangeCurrRing(save); 2763 } 3128 2764 3129 return FALSE; 2765 3130 } … … 2768 3133 { 2769 3134 // "commutative" 2770 rGR->p_Procs->p_Mult_mm = gnc_p_Mult_mm; 2771 rGR->p_Procs->pp_Mult_mm = gnc_pp_Mult_mm; 2772 rGR->p_Procs->p_Minus_mm_Mult_qq = NULL; // gnc_p_Minus_mm_Mult_qq_ign; // should not be used!!! 2773 2774 p_Procs->p_Mult_mm = gnc_p_Mult_mm; 2775 p_Procs->pp_Mult_mm = gnc_pp_Mult_mm; 2776 p_Procs->p_Minus_mm_Mult_qq = NULL; // gnc_p_Minus_mm_Mult_qq_ign; // should not be used!!! 3135 p_Procs->p_Mult_mm = rGR->p_Procs->p_Mult_mm = gnc_p_Mult_mm; 3136 p_Procs->pp_Mult_mm = rGR->p_Procs->pp_Mult_mm = gnc_pp_Mult_mm; 3137 p_Procs->p_Minus_mm_Mult_qq = rGR->p_Procs->p_Minus_mm_Mult_qq = NULL; 3138 // gnc_p_Minus_mm_Mult_qq_ign; // should not be used!!!??? 3139 2777 3140 2778 3141 2779 3142 // non-commutaitve multiplication by monomial from the left 2780 rGR-> nc->p_Procs.mm_Mult_p = gnc_mm_Mult_p;2781 rGR-> nc->p_Procs.mm_Mult_pp = gnc_mm_Mult_pp;2782 2783 rGR-> nc->p_Procs.GB = gnc_gr_bba; // bba even for local case!2784 2785 // rGR-> nc->p_Procs.GlobalGB = gnc_gr_bba;2786 // rGR-> nc->p_Procs.LocalGB = gnc_gr_mora;3143 rGR->GetNC()->p_Procs.mm_Mult_p = gnc_mm_Mult_p; 3144 rGR->GetNC()->p_Procs.mm_Mult_pp = gnc_mm_Mult_pp; 3145 3146 rGR->GetNC()->p_Procs.GB = gnc_gr_bba; // bba even for local case! 3147 3148 // rGR->GetNC()->p_Procs.GlobalGB = gnc_gr_bba; 3149 // rGR->GetNC()->p_Procs.LocalGB = gnc_gr_mora; 2787 3150 2788 3151 2789 3152 #if 0 2790 3153 // Previous Plural's implementation... 2791 rGR-> nc->p_Procs.SPoly = gnc_CreateSpolyOld;2792 rGR-> nc->p_Procs.ReduceSPoly = gnc_ReduceSpolyOld;2793 2794 rGR-> nc->p_Procs.BucketPolyRed = gnc_kBucketPolyRedOld;2795 rGR-> nc->p_Procs.BucketPolyRed_Z= gnc_kBucketPolyRed_ZOld;3154 rGR->GetNC()->p_Procs.SPoly = gnc_CreateSpolyOld; 3155 rGR->GetNC()->p_Procs.ReduceSPoly = gnc_ReduceSpolyOld; 3156 3157 rGR->GetNC()->p_Procs.BucketPolyRed = gnc_kBucketPolyRedOld; 3158 rGR->GetNC()->p_Procs.BucketPolyRed_Z= gnc_kBucketPolyRed_ZOld; 2796 3159 #else 2797 3160 // A bit cleaned up and somewhat rewritten functions... 2798 rGR-> nc->p_Procs.SPoly = gnc_CreateSpolyNew;2799 rGR-> nc->p_Procs.ReduceSPoly = gnc_ReduceSpolyNew;2800 2801 rGR-> nc->p_Procs.BucketPolyRed = gnc_kBucketPolyRedNew;2802 rGR-> nc->p_Procs.BucketPolyRed_Z= gnc_kBucketPolyRed_ZNew;3161 rGR->GetNC()->p_Procs.SPoly = gnc_CreateSpolyNew; 3162 rGR->GetNC()->p_Procs.ReduceSPoly = gnc_ReduceSpolyNew; 3163 3164 rGR->GetNC()->p_Procs.BucketPolyRed = gnc_kBucketPolyRedNew; 3165 rGR->GetNC()->p_Procs.BucketPolyRed_Z= gnc_kBucketPolyRed_ZNew; 2803 3166 #endif 2804 3167 … … 2817 3180 _p_procs->p_Minus_mm_Mult_qq= NULL; // gnc_p_Minus_mm_Mult_qq_ign; 2818 3181 2819 r-> nc->mmMultP() = gnc_mm_Mult_p;2820 r-> nc->mmMultPP() = gnc_mm_Mult_pp;2821 2822 r-> nc->GB() = gnc_gr_bba;2823 2824 r-> nc->SPoly() = gnc_CreateSpoly;2825 r-> nc->ReduceSPoly() = gnc_ReduceSpoly;3182 r->GetNC()->mmMultP() = gnc_mm_Mult_p; 3183 r->GetNC()->mmMultPP() = gnc_mm_Mult_pp; 3184 3185 r->GetNC()->GB() = gnc_gr_bba; 3186 3187 r->GetNC()->SPoly() = gnc_CreateSpoly; 3188 r->GetNC()->ReduceSPoly() = gnc_ReduceSpoly; 2826 3189 2827 3190 #endif … … 3114 3477 3115 3478 3479 // creates a commutative nc extension; "converts" comm.ring to a Plural ring 3116 3480 ring nc_rCreateNCcomm(ring r) 3117 /* creates a commutative nc extension; "converts" comm.ring to a Plural ring */3118 3481 { 3119 3482 if (rIsPluralRing(r)) return r; 3120 ring save = currRing; 3121 int WeChangeRing = 0; 3122 if (currRing!=r) 3123 { 3124 rChangeCurrRing(r); 3125 WeChangeRing = 1; 3126 } 3127 r->nc = (nc_struct *)omAlloc0(sizeof(nc_struct)); 3128 r->nc->ref = 1; 3129 r->nc->basering = r; 3130 ncRingType(r, nc_comm); 3131 r->nc->IsSkewConstant = 1; 3132 3133 // no reference increment to the base commutative ring??? 3134 3135 matrix C = mpNew(r->N,r->N); 3483 3484 matrix C = mpNew(r->N,r->N); // ring-independent!?! 3136 3485 matrix D = mpNew(r->N,r->N); 3137 int i,j; 3138 for(i=1; i<r->N; i++) 3139 { 3140 for(j=i+1; j<=r->N; j++) 3141 { 3142 MATELEM(C,i,j) = pOne(); 3143 } 3144 } 3145 r->nc->C = C; 3146 r->nc->D = D; 3147 if (nc_InitMultiplication(r)) 3148 { 3149 WarnS("Error initializing multiplication!"); 3150 } 3151 if (WeChangeRing) 3152 { 3153 rChangeCurrRing(save); 3154 } 3486 3487 for(int i=1; i<r->N; i++) 3488 for(int j=i+1; j<=r->N; j++) 3489 MATELEM(C,i,j) = p_ISet(1, r); 3490 3491 if (nc_CallPlural(C, D, NULL, NULL, r)) // TODO: what about quotient ideal? 3492 WarnS("Error initializing multiplication!"); // No reaction!??? 3493 3155 3494 return r; 3156 3495 } … … 3284 3623 3285 3624 3286 #endif3287 3288 3625 3289 3626 // int Commutative_Context(ring r, leftv expression) … … 3296 3633 // int Comm_Context_Poly(ring r, poly p) 3297 3634 // { 3298 // poly COMM=r-> nc->COMM;3635 // poly COMM=r->GetNC()->COMM; 3299 3636 // poly pp=pOne(); 3300 3637 // memset(pp->exp,0,r->ExpL_Size*sizeof(long)); -
kernel/gring.h
rf2b5839 r52e2f6 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: gring.h,v 1.2 0 2007-02-16 11:07:10motsak Exp $ */6 /* $Id: gring.h,v 1.21 2008-06-10 10:17:31 motsak Exp $ */ 7 7 /* 8 8 * ABSTRACT additional defines etc for --with-plural … … 11 11 #ifdef HAVE_PLURAL 12 12 13 13 14 #include <structs.h> 14 15 #include <ring.h> 15 16 16 /* the part, related to the interface */ 17 BOOLEAN nc_CallPlural(matrix CC, matrix DD, poly CN, poly DN, ring r); 18 19 BOOLEAN nc_CheckOrdCondition(matrix D, ring r); 17 // the part, related to the interface 18 // Changes r, Assumes that all other input belongs to currRing 19 BOOLEAN nc_CallPlural(matrix CC, matrix DD, poly CN, poly DN, ring r, 20 bool bSetupQuotient = false, 21 bool bCopyInput = true, 22 bool bBeQuiet = false, 23 ring curr = currRing); 24 25 // BOOLEAN nc_CheckOrdCondition(matrix D, ring r); 26 // BOOLEAN nc_CheckOrdCondition(ring r); // with D == r->GetNC()->D 27 20 28 BOOLEAN nc_CheckSubalgebra(poly PolyVar, ring r); 21 BOOLEAN nc_InitMultiplication(ring r); // should call nc_p_ProcsSet! 29 30 // BOOLEAN nc_InitMultiplication(ring r); // should call nc_p_ProcsSet! 31 // NOTE: instead of constructing nc_struct and calling nc_InitMultiplication yourself - just create C, D and call nc_CallPlural!!! 32 33 22 34 BOOLEAN rIsLikeOpposite(ring rBase, ring rCandidate); 23 35 … … 29 41 // this function should be used inside QRing definition! 30 42 // we go from rG into factor ring rGR with factor ideal rGR->qideal. 31 bool nc_SetupQuotient(ring rGR, const ring rG );43 bool nc_SetupQuotient(ring rGR, const ring rG = NULL); // rG == NULL means that there is no base G-algebra 32 44 33 45 … … 37 49 ring nc_rCreateNCcomm(ring r); 38 50 39 void ncCleanUp(ring r); /* smaller than kill */ 40 void ncKill(ring r); 41 51 void ncCleanUp(nc_struct* p); // just free memory! 52 void ncCleanUp(ring r); // smaller than kill: just free mem 53 void ncKill(ring r); // complete destructor 54 55 BOOLEAN nc_rComplete(const ring src, ring dest, bool bSetupQuotient = true); // in ring.cc 56 57 58 // share the same nc-structure with a new copy ``res'' of ``r''. 59 // used by rCopy only. 60 // additionally inits multipication on ``res''! 61 void nc_rCopy0(ring res, const ring r); 42 62 43 63 // for p_Minus_mm_Mult_qq in pInline2.h … … 90 110 91 111 112 113 // returns the LCM of the head terms of a and b with given component 114 poly p_Lcm(const poly a, const poly b, const long lCompM, const ring r); 115 116 // returns the LCM of the head terms of a and b with component = max comp. of a & b 117 poly p_Lcm(const poly a, const poly b, const ring r); 118 119 120 92 121 // //////////////////////////////////////////////////////////////////////// // 93 122 // NC inlines 94 123 95 96 97 inline void ncRingType(ring r, nc_type t) 98 { 99 assume((r != NULL) && (r->nc != NULL)); 100 r->nc->type = t; 124 inline nc_type& ncRingType(nc_struct* p) 125 { 126 assume(p!=NULL); 127 return (p->type); 101 128 }; 102 129 103 inline nc_type ncRingType(ring r) 104 { 105 assume(rIsPluralRing(r)); 106 107 return (r->nc->type); 130 inline nc_type& ncRingType(ring r) // get and set 131 { 132 assume(rIsPluralRing(r)); 133 return (ncRingType(r->GetNC())); 108 134 }; 135 136 inline void ncRingType(ring r, nc_type t) // Set 137 { 138 assume((r != NULL) && (r->GetNC() != NULL)); 139 ncRingType(r) = t; 140 }; 141 142 inline nc_struct*& GetNC(ring r) 143 { 144 return r->GetNC(); 145 }; 109 146 110 147 … … 117 154 { 118 155 assume(rIsPluralRing(r)); 119 assume(r-> nc->p_Procs.mm_Mult_pp!=NULL);120 return r-> nc->p_Procs.mm_Mult_pp(m, p, r);156 assume(r->GetNC()->p_Procs.mm_Mult_pp!=NULL); 157 return r->GetNC()->p_Procs.mm_Mult_pp(m, p, r); 121 158 // return pp_Mult_mm( p, m, r); 122 159 } … … 127 164 { 128 165 assume(rIsPluralRing(r)); 129 assume(r-> nc->p_Procs.mm_Mult_p!=NULL);130 return r-> nc->p_Procs.mm_Mult_p(m, p, r);166 assume(r->GetNC()->p_Procs.mm_Mult_p!=NULL); 167 return r->GetNC()->p_Procs.mm_Mult_p(m, p, r); 131 168 // return p_Mult_mm( p, m, r); 132 169 } … … 135 172 { 136 173 assume(rIsPluralRing(r)); 137 assume(r-> nc->p_Procs.SPoly!=NULL);138 return r-> nc->p_Procs.SPoly(p1, p2, r);174 assume(r->GetNC()->p_Procs.SPoly!=NULL); 175 return r->GetNC()->p_Procs.SPoly(p1, p2, r); 139 176 } 140 177 … … 142 179 { 143 180 assume(rIsPluralRing(r)); 144 assume(r->nc->p_Procs.ReduceSPoly!=NULL); 145 return r->nc->p_Procs.ReduceSPoly(p1, p2, r); 181 assume(r->GetNC()->p_Procs.ReduceSPoly!=NULL); 182 #ifdef PDEBUG 183 // assume(p_LmDivisibleBy(p1, p2, r)); 184 #endif 185 return r->GetNC()->p_Procs.ReduceSPoly(p1, p2, r); 146 186 } 147 187 … … 150 190 { 151 191 assume(rIsPluralRing(r)); 152 // assume(r-> nc->p_Procs.PolyReduce!=NULL);153 // r-> nc->p_Procs.PolyReduce(b, p, c, r);192 // assume(r->GetNC()->p_Procs.PolyReduce!=NULL); 193 // r->GetNC()->p_Procs.PolyReduce(b, p, c, r); 154 194 } 155 195 */ … … 161 201 // return gnc_kBucketPolyRedNew(b, p, c); 162 202 163 assume(currRing-> nc->p_Procs.BucketPolyRed!=NULL);164 return currRing-> nc->p_Procs.BucketPolyRed(b, p, c);203 assume(currRing->GetNC()->p_Procs.BucketPolyRed!=NULL); 204 return currRing->GetNC()->p_Procs.BucketPolyRed(b, p, c); 165 205 } 166 206 … … 171 211 // return gnc_kBucketPolyRed_ZNew(b, p, c); 172 212 173 assume(currRing-> nc->p_Procs.BucketPolyRed_Z!=NULL);174 return currRing-> nc->p_Procs.BucketPolyRed_Z(b, p, c);213 assume(currRing->GetNC()->p_Procs.BucketPolyRed_Z!=NULL); 214 return currRing->GetNC()->p_Procs.BucketPolyRed_Z(b, p, c); 175 215 176 216 } … … 180 220 assume(rIsPluralRing(currRing)); 181 221 182 assume(currRing-> nc->p_Procs.GB!=NULL);183 return currRing-> nc->p_Procs.GB(F, Q, w, hilb, strat);222 assume(currRing->GetNC()->p_Procs.GB!=NULL); 223 return currRing->GetNC()->p_Procs.GB(F, Q, w, hilb, strat); 184 224 185 225 /* 186 226 if (pOrdSgn==-1) 187 227 { 188 assume(currRing-> nc->p_Procs.LocalGB!=NULL);189 return currRing-> nc->p_Procs.LocalGB(F, Q, w, hilb, strat);228 assume(currRing->GetNC()->p_Procs.LocalGB!=NULL); 229 return currRing->GetNC()->p_Procs.LocalGB(F, Q, w, hilb, strat); 190 230 } else 191 231 { 192 assume(currRing-> nc->p_Procs.GlobalGB!=NULL);193 return currRing-> nc->p_Procs.GlobalGB(F, Q, w, hilb, strat);232 assume(currRing->GetNC()->p_Procs.GlobalGB!=NULL); 233 return currRing->GetNC()->p_Procs.GlobalGB(F, Q, w, hilb, strat); 194 234 } 195 235 */ … … 205 245 // we need nc_gr_initBba for sca_gr_bba and gr_bba. 206 246 void nc_gr_initBba(ideal F,kStrategy strat); 247 BOOLEAN gnc_InitMultiplication(ring r, bool bSetupQuotient = false); // just for a moment 207 248 208 249 #endif // PLURAL_INTERNAL_DECLARATIONS -
kernel/ideals.cc
rf2b5839 r52e2f6 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ideals.cc,v 1.5 5 2008-04-04 09:51:37 SingularExp $ */4 /* $Id: ideals.cc,v 1.56 2008-06-10 10:17:31 motsak Exp $ */ 5 5 /* 6 6 * ABSTRACT - all basic methods to manipulate ideals … … 26 26 27 27 28 #define MYTEST 0 29 30 28 31 /* #define WITH_OLD_MINOR */ 29 32 #define pCopy_noCheck(p) pCopy(p) … … 65 68 void idShow(ideal id) 66 69 { 67 Print("Module of rank %d,real rank %d and %d generators.\n", 68 id->rank,idRankFreeModule(id),IDELEMS(id)); 69 for (int i=0;i<id->ncols*id->nrows;i++) 70 { 71 if (id->m[i]!=NULL) 72 { 73 Print("generator %d: ",i);pWrite(id->m[i]); 70 if( id == NULL ) 71 Print("(NULL)"); 72 else 73 { 74 Print("Module of rank %d,real rank %d and %d generators.\n", 75 id->rank,idRankFreeModule(id),IDELEMS(id)); 76 for (int i=0;i<id->ncols*id->nrows;i++) 77 { 78 if (id->m[i]!=NULL) 79 { 80 Print("generator %d: ",i);pWrite(id->m[i]); 81 } 74 82 } 75 83 } … … 1299 1307 } 1300 1308 h2->rank = syzcomp+i+1; 1309 1310 #if MYTEST 1311 #ifdef RDEBUG 1312 Print("Prepare::h2: "); 1313 idPrint(h2); 1314 #endif 1315 #endif 1316 1301 1317 for (j=0; j<=i; j++) 1302 1318 { … … 1316 1332 #ifdef PDEBUG 1317 1333 for(j=0;j<IDELEMS(h2);j++) pTest(h2->m[j]); 1334 1335 #if MYTEST 1336 #ifdef RDEBUG 1337 Print("Prepare::Input: "); 1338 idPrint(h2); 1339 1340 Print("Prepare::currQuotient: "); 1341 idPrint(currQuotient); 1342 #endif 1318 1343 #endif 1319 h3=kStd(h2,currQuotient,h,w,NULL,syzcomp); 1344 1345 #endif 1346 1347 1348 h3 = kStd(h2,currQuotient,h,w,NULL,syzcomp); 1320 1349 idDelete(&h2); 1321 1350 return h3; … … 1528 1557 if (k==1) verbose |=Sy_bit(V_IDLIFT); 1529 1558 1530 ring orig_ring =currRing;1531 ring syz_ring =rCurrRingAssure_SyzComp();1559 ring orig_ring = currRing; 1560 ring syz_ring = rCurrRingAssure_SyzComp(); 1532 1561 rSetSyzComp(k); 1533 1562 1563 1564 #if MYTEST 1565 #ifdef RDEBUG 1566 rWrite(syz_ring); 1567 rDebugPrint(syz_ring); 1568 #endif 1569 #endif 1570 1534 1571 ideal s_h1=h1; 1535 1572 … … 1539 1576 s_h1 = h1; 1540 1577 1578 #if MYTEST 1579 #ifdef RDEBUG 1580 Print("Input: "); 1581 idPrint(s_h1); 1582 #endif 1583 #endif 1584 1585 1541 1586 ideal s_h3=idPrepare(s_h1,h,k,&w); 1587 1588 #if MYTEST 1589 #ifdef RDEBUG 1590 Print("Prepare: "); 1591 idPrint(s_h3); 1592 #endif 1593 #endif 1594 1542 1595 ideal s_h2 = idInit(IDELEMS(s_h3), s_h3->rank); 1543 1596 1597 #if MYTEST 1598 #ifdef RDEBUG 1599 Print("Temp: "); 1600 idPrint(s_h2); 1601 #endif 1602 #endif 1603 1544 1604 if (w!=NULL) delete w; 1545 1605 i = 0; 1606 1546 1607 for (j=0; j<IDELEMS(s_h3); j++) 1547 1608 { … … 1571 1632 1572 1633 idSkipZeroes(s_h3); 1634 1635 #if MYTEST 1636 #ifdef RDEBUG 1637 Print("Input'': "); 1638 idPrint(s_h3); 1639 #endif 1640 #endif 1641 1573 1642 j = IDELEMS(s_h1); 1574 1643 1644 1645 #if MYTEST 1646 #ifdef RDEBUG 1647 Print("Temp Result: "); 1648 idPrint(s_h2); 1649 #endif 1650 #endif 1651 1652 1575 1653 if (syz_ring!=orig_ring) 1576 1654 { … … 1609 1687 s_h3->m[i] = prMoveR_NoSort(s_h3->m[i], syz_ring); 1610 1688 } 1689 1690 #if MYTEST 1691 #ifdef RDEBUG 1692 Print("Output STD Ideal: "); 1693 idPrint(s_h3); 1694 1695 Print("Output Matrix: "); 1696 iiWriteMatrix(*ma, "ma", 2, 4); 1697 #endif 1698 #endif 1699 1611 1700 1612 1701 if (syz_ring!=orig_ring) rKill(syz_ring); … … 2328 2417 if (idIs0(h1)) return idInit(1,h1->rank); 2329 2418 #ifdef HAVE_PLURAL 2330 if (rIsPluralRing( currRing))2419 if (rIsPluralRing(origR)) 2331 2420 /* in the NC case, we have to check the admissibility of */ 2332 2421 /* the subalgebra to be intersected with */ 2333 2422 { 2334 if ( ncRingType(currRing)!=nc_skew) /* in (quasi)-commutative algebras every subalgebra is admissible */2335 { 2336 if (nc_CheckSubalgebra(delVar, currRing))2423 if ((ncRingType(origR) != nc_skew) && (ncRingType(origR) != nc_exterior)) /* in (quasi)-commutative algebras every subalgebra is admissible */ 2424 { 2425 if (nc_CheckSubalgebra(delVar,origR)) 2337 2426 { 2338 2427 WerrorS("no elimination is possible: subalgebra is not admissible"); … … 2362 2451 block0[0] = 1; 2363 2452 block1[0] = rVar(origR); 2364 wv[0]=(int*)omAlloc(( pVariables+1)*sizeof(int));2365 memset(wv[0],0,( pVariables+1)*sizeof(int));2453 wv[0]=(int*)omAlloc((rVar(origR) + 1)*sizeof(int)); 2454 memset(wv[0],0,(rVar(origR) + 1)*sizeof(int)); 2366 2455 for (j=0;j<rVar(origR);j++) 2367 2456 if (pGetExp(delVar,j+1)!=0) wv[0][j]=1; … … 2376 2465 tmpR->block1 = block1; 2377 2466 tmpR->wvhdl = wv; 2467 2378 2468 rComplete(tmpR, 1); 2379 2469 2380 2470 #ifdef HAVE_PLURAL 2381 2471 /* update nc structure on tmpR */ 2382 if (rIsPluralRing(currRing)) 2383 { 2384 BOOLEAN bBAD = FALSE; 2385 if ( nc_rComplete(origR, tmpR) ) 2472 if (rIsPluralRing(origR)) 2473 { 2474 if ( nc_rComplete(origR, tmpR, false) ) // no quotient ideal! 2386 2475 { 2387 2476 Werror("error in nc_rComplete"); 2388 bBAD = TRUE;2389 }2390 if (!bBAD)2391 {2392 /* tests the admissibility of the new elim. ordering */2393 if ( nc_CheckOrdCondition( tmpR->nc->D, tmpR) )2394 {2395 Werror("no elimination is possible: ordering condition is violated");2396 bBAD = TRUE;2397 }2398 }2399 if (bBAD)2400 {2401 2477 // cleanup 2402 2478 rDelete(tmpR); 2403 2479 if (w!=NULL) 2404 {2405 2480 delete w; 2406 }2407 2481 return idCopy(h1); 2408 2482 } -
kernel/kstd1.cc
rf2b5839 r52e2f6 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kstd1.cc,v 1.3 4 2008-03-20 11:22:44 SingularExp $ */4 /* $Id: kstd1.cc,v 1.35 2008-06-10 10:17:31 motsak Exp $ */ 5 5 /* 6 6 * ABSTRACT: … … 1959 1959 kStrategy strat=new skStrategy; 1960 1960 strat->syzComp = syzComp; 1961 1962 poly pp = p; 1963 1964 #ifdef HAVE_PLURAL 1965 if(rIsSCA(currRing)) 1966 { 1967 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing); 1968 const unsigned int m_iLastAltVar = scaLastAltVar(currRing); 1969 pp = p_KillSquares(pp, m_iFirstAltVar, m_iLastAltVar, currRing); 1970 1971 if(Q == currQuotient) 1972 Q = SCAQuotient(currRing); 1973 } 1974 #endif 1975 1976 poly res; 1977 1961 1978 if (pOrdSgn==-1) 1962 p=kNF1(F,Q,p,strat,lazyReduce);1979 res=kNF1(F,Q,pp,strat,lazyReduce); 1963 1980 else 1964 p=kNF2(F,Q,p,strat,lazyReduce);1981 res=kNF2(F,Q,pp,strat,lazyReduce); 1965 1982 delete(strat); 1966 return p; 1983 1984 #ifdef HAVE_PLURAL 1985 if(pp != p) 1986 p_Delete(&pp, currRing); 1987 #endif 1988 1989 return res; 1967 1990 } 1968 1991 … … 1976 1999 kStrategy strat=new skStrategy; 1977 2000 strat->syzComp = syzComp; 2001 2002 ideal pp = p; 2003 #ifdef HAVE_PLURAL 2004 if(rIsSCA(currRing)) 2005 { 2006 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing); 2007 const unsigned int m_iLastAltVar = scaLastAltVar(currRing); 2008 pp = id_KillSquares(pp, m_iFirstAltVar, m_iLastAltVar, currRing); 2009 2010 if(Q == currQuotient) 2011 Q = SCAQuotient(currRing); 2012 } 2013 #endif 2014 1978 2015 if (pOrdSgn==-1) 1979 res=kNF1(F,Q,p ,strat,lazyReduce);2016 res=kNF1(F,Q,pp,strat,lazyReduce); 1980 2017 else 1981 res=kNF2(F,Q,p ,strat,lazyReduce);2018 res=kNF2(F,Q,pp,strat,lazyReduce); 1982 2019 delete(strat); 2020 2021 #ifdef HAVE_PLURAL 2022 if(pp != p) 2023 id_Delete(&pp, currRing); 2024 #endif 2025 2026 1983 2027 return res; 1984 2028 } … … 2244 2288 2245 2289 // this should be done on the upper level!!! : 2246 // tempQ = currRing->nc->SCAQuotient();2290 // tempQ = SCAQuotient(currRing); 2247 2291 2248 2292 if(Q == currQuotient) 2249 tempQ = currRing->nc->SCAQuotient();2293 tempQ = SCAQuotient(currRing); 2250 2294 } 2251 2295 #endif -
kernel/kutil.cc
rf2b5839 r52e2f6 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kutil.cc,v 1.9 0 2008-05-20 15:30:00 SingularExp $ */4 /* $Id: kutil.cc,v 1.91 2008-06-10 10:17:32 motsak Exp $ */ 5 5 /* 6 6 * ABSTRACT: kernel: utils for kStd … … 1377 1377 pSetm(Lp.lcm); 1378 1378 1379 #define MYTEST 0 1380 1379 1381 #ifdef HAVE_PLURAL 1380 1382 const BOOLEAN bIsPluralRing = rIsPluralRing(currRing); 1381 1383 const BOOLEAN bIsSCA = rIsSCA(currRing) && strat->homog; // for prod-crit 1382 1384 const BOOLEAN bNCProdCrit = ( !bIsPluralRing || bIsSCA ); // commutative or homogeneous SCA 1385 1383 1386 #else 1384 1387 const BOOLEAN bIsPluralRing = FALSE; … … 1386 1389 const BOOLEAN bNCProdCrit = TRUE; 1387 1390 #endif 1391 1388 1392 1389 1393 if (strat->sugarCrit && bNCProdCrit) … … 1521 1525 if (strat->fromT && !TEST_OPT_INTSTRATEGY) 1522 1526 pNorm(p); 1527 1523 1528 if ((strat->S[i]==NULL) || (p==NULL)) 1524 1529 return; 1530 1525 1531 if ((strat->fromQ!=NULL) && (isFromQ!=0) && (strat->fromQ[i]!=0)) 1526 1532 Lp.p=NULL; … … 1532 1538 if(pHasNotCF(p, strat->S[i])) 1533 1539 { 1534 if(ncRingType(currRing) == nc_lie)1535 {1536 // generalized prod-crit for lie-type1537 strat->cp++;1538 Lp.p = nc_p_Bracket_qq(pCopy(p),strat->S[i]);1539 }1540 else1540 // if(ncRingType(currRing) == nc_lie) 1541 // { 1542 // // generalized prod-crit for lie-type 1543 // strat->cp++; 1544 // Lp.p = nc_p_Bracket_qq(pCopy(p),strat->S[i]); 1545 // } 1546 // else 1541 1547 if( bIsSCA ) 1542 1548 { … … 1546 1552 } 1547 1553 else 1548 Lp.p = nc_CreateSpoly(strat->S[i],p,currRing); // ? 1549 } 1550 else Lp.p = nc_CreateSpoly(strat->S[i],p,currRing); 1554 Lp.p = nc_CreateSpoly(strat->S[i],p,currRing); 1555 // nc_CreateShortSpoly(strat->S[i], p, strat->tailRing); // how to mark a short spoly? 1556 } 1557 else Lp.p = nc_CreateSpoly(strat->S[i],p,currRing); 1558 // nc_CreateShortSpoly(strat->S[i], p, strat->tailRing); // how to mark a short spoly? 1559 1560 1561 #if MYTEST 1562 if (TEST_OPT_DEBUG) 1563 { 1564 PrintS("strat->S[i]: "); pWrite(strat->S[i]); 1565 PrintS("p: "); pWrite(p); 1566 PrintS("SPoly: "); pWrite(Lp.p); 1567 } 1568 #endif 1569 1551 1570 } 1552 1571 else 1553 1572 #endif 1554 1573 { 1574 assume(!rIsPluralRing(currRing)); 1555 1575 Lp.p = ksCreateShortSpoly(strat->S[i],p, strat->tailRing); 1556 } 1576 #if MYTEST 1577 if (TEST_OPT_DEBUG) 1578 { 1579 PrintS("strat->S[i]: "); pWrite(strat->S[i]); 1580 PrintS("p: "); pWrite(p); 1581 PrintS("commutative SPoly: "); pWrite(Lp.p); 1582 } 1583 #endif 1584 1585 } 1557 1586 } 1558 1587 if (Lp.p == NULL) … … 1655 1684 if (rIsPluralRing(currRing)) 1656 1685 { 1657 Lp.p = nc_CreateShortSpoly(strat->S[i],p); // ??? 1686 Lp.p = nc_CreateShortSpoly(strat->S[i],p); // ??? strat->tailRing? 1658 1687 } 1659 1688 else … … 2784 2813 assume (!rField_is_Ring(currRing)); 2785 2814 #endif 2815 2786 2816 initenterpairs(h,k,ecart,0,strat, atR); 2787 2817 if ( (!strat->fromT) … … 4073 4103 else 4074 4104 { 4075 assume (j >= 0 && j <= strat->tl && strat->S_2_T(j) != NULL && 4076 strat->S_2_T(j)->p == strat->S[j]); 4105 ///// assume (j >= 0 && j <= strat->tl && strat->S_2_T(j) != NULL 4106 ///// && strat->S_2_T(j)->p == strat->S[j]); // wrong? 4107 // assume (j >= 0 && j <= strat->sl && strat->S_2_T(j) != NULL && strat->S_2_T(j)->p == strat->S[j]); 4077 4108 return strat->S_2_T(j); 4078 4109 } -
kernel/longalg.cc
rf2b5839 r52e2f6 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: longalg.cc,v 1.3 2 2008-03-19 17:44:09 SingularExp $ */4 /* $Id: longalg.cc,v 1.33 2008-06-10 10:17:32 motsak Exp $ */ 5 5 /* 6 6 * ABSTRACT: algebraic numbers … … 1673 1673 } 1674 1674 else 1675 #if 01675 #ifndef HAVE_FACTORY 1676 1676 result->z = napGcd(x->z, y->z); // change from napGcd0 1677 1677 #else -
kernel/maps.cc
rf2b5839 r52e2f6 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: maps.cc,v 1. 8 2008-04-21 14:18:16 SingularExp $ */4 /* $Id: maps.cc,v 1.9 2008-06-10 10:17:32 motsak Exp $ */ 5 5 /* 6 6 * ABSTRACT - the mapping of polynomials to other rings … … 21 21 #include "prCopy.h" 22 22 23 #ifdef HAVE_PLURAL 24 #include "gring.h" 25 #endif 26 23 27 // This is a very dirty way to "normalize" numbers w.r.t. a 24 28 // MinPoly … … 197 201 ideal maGetPreimage(ring theImageRing, map theMap, ideal id) 198 202 { 203 ring sourcering = currRing; 204 205 #ifdef HAVE_PLURAL 206 if (rIsPluralRing(theImageRing)) 207 { 208 if ((rIsPluralRing(sourcering)) && (ncRingType(sourcering)!=nc_comm)) 209 { 210 Werror("Sorry, not yet implemented for noncomm. rings"); 211 return NULL; 212 } 213 } 214 #endif 215 199 216 int i,j; 200 217 poly p,pp,q; … … 203 220 204 221 int imagepvariables = theImageRing->N; 205 ring sourcering = currRing;206 222 int N = pVariables+imagepvariables; 207 223 … … 213 229 } 214 230 215 #ifdef HAVE_PLURAL216 if (rIsPluralRing(theImageRing))217 {218 if ((rIsPluralRing(sourcering)) && (ncRingType(sourcering)!=nc_comm))219 {220 Werror("Sorry, not yet implemented for noncomm. rings");221 return NULL;222 }223 }224 231 if (nSetMap(theImageRing) != nCopy) 225 232 { … … 227 234 return NULL; 228 235 } 229 #endif230 236 231 237 // change to new ring -
kernel/matpol.cc
rf2b5839 r52e2f6 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: matpol.cc,v 1.1 3 2006-11-20 11:10:39 SingularExp $ */4 /* $Id: matpol.cc,v 1.14 2008-06-10 10:17:32 motsak Exp $ */ 5 5 6 6 /* … … 24 24 #include "sparsmat.h" 25 25 #include "matpol.h" 26 26 #include "prCopy.h" 27 27 28 28 //omBin ip_smatrix_bin = omGetSpecBin(sizeof(ip_smatrix)); … … 101 101 return b; 102 102 } 103 104 /*2 105 *copies matrix a from rSrc into rDst 106 */ 107 matrix mpCopy(const matrix a, const ring rSrc, const ring rDst) 108 { 109 const ring save = currRing; 110 111 if( save != currRing ) 112 rChangeCurrRing(rSrc); 113 114 idTest((ideal)a); 115 116 rChangeCurrRing(rDst); 117 118 poly t; 119 int i, m=MATROWS(a), n=MATCOLS(a); 120 121 matrix b = mpNew(m, n); 122 123 for (i=m*n-1; i>=0; i--) 124 { 125 t = a->m[i]; 126 if (t!=NULL) 127 { 128 b->m[i] = prCopyR_NoSort(t, rSrc, rDst); 129 p_Normalize(b->m[i], rDst); 130 } 131 } 132 b->rank=a->rank; 133 134 idTest((ideal)b); 135 136 if( save != currRing ) 137 rChangeCurrRing(save); 138 139 return b; 140 } 141 142 103 143 104 144 /*2 … … 416 456 /*--- look for an optimal row and bring it to last position ------------*/ 417 457 if(mpPrepareRow(a,lr,lc)==0) break; 418 /*--- now take all pivot Žs from the last row ------------*/458 /*--- now take all pivots from the last row ------------*/ 419 459 k = lc; 420 460 loop … … 1877 1917 } 1878 1918 1919 void mpDelete(matrix* a, const ring r) 1920 { 1921 id_Delete((ideal *) a, r); 1922 } -
kernel/matpol.h
rf2b5839 r52e2f6 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: matpol.h,v 1. 1.1.1 2003-10-06 12:15:57 SingularExp $ */6 /* $Id: matpol.h,v 1.2 2008-06-10 10:17:32 motsak Exp $ */ 7 7 /* 8 8 * ABSTRACT … … 30 30 31 31 matrix mpNew(int r, int c); 32 matrix mpCopy (matrix a); 32 matrix mpCopy(matrix a); 33 void mpDelete(matrix* a, const ring r = currRing); 34 matrix mpCopy(const matrix a, const ring rSrc, const ring rDst = currRing); 33 35 matrix mpInitP(int r, int c, poly p); 34 36 matrix mpInitI(int r, int c, int v); -
kernel/pInline2.h
rf2b5839 r52e2f6 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: pInline2.h,v 1.1 2 2007-03-10 15:41:49 levandovExp $9 * Version: $Id: pInline2.h,v 1.13 2008-06-10 10:17:32 motsak Exp $ 10 10 *******************************************************************/ 11 11 #ifndef PINLINE2_H … … 128 128 return __p_GetComp(p,r) -= v; 129 129 } 130 PINLINE2 int p_Comp_k_n(poly a, poly b, int k, ring r) 131 { 132 if ((a==NULL) || (b==NULL) ) return FALSE; 133 p_LmCheckPolyRing2(a, r); 134 p_LmCheckPolyRing2(b, r); 135 pAssume2(k > 0 && k <= r->N); 136 int i=k; 137 for(;i<=r->N;i++) 138 { 139 if (p_GetExp(a,i,r) != p_GetExp(b,i,r)) return FALSE; 140 // if (a->exp[(r->VarOffset[i] & 0xffffff)] != b->exp[(r->VarOffset[i] & 0xffffff)]) return FALSE; 141 } 142 return TRUE; 143 } 144 145 146 #ifndef HAVE_EXPSIZES 130 147 131 148 // exponent … … 147 164 #endif 148 165 } 166 149 167 // partial compare exponent 150 168 // r->VarOffset encodes the position in p->exp (lower 24 bits) 151 169 // and number of bits to shift to the right in the upper 8 bits 152 PINLINE2 int p_Comp_k_n(poly a, poly b, int k, ring r)153 {154 if ((a==NULL) || (b==NULL) ) return FALSE;155 p_LmCheckPolyRing2(a, r);156 p_LmCheckPolyRing2(b, r);157 pAssume2(k > 0 && k <= r->N);158 int i=k;159 for(;i<=r->N;i++)160 {161 if (p_GetExp(a,i,r) != p_GetExp(b,i,r)) return FALSE;162 // if (a->exp[(r->VarOffset[i] & 0xffffff)] != b->exp[(r->VarOffset[i] & 0xffffff)]) return FALSE;163 }164 return TRUE;165 }166 170 PINLINE2 int p_SetExp(poly p, int v, int e, ring r) 167 171 { … … 182 186 return e; 183 187 } 188 189 #else // #ifdef HAVE_EXPSIZES 190 191 inline int BitMask(int bitmask, int twobits) 192 { 193 // bitmask = 00000111111111111 194 // 0 must give bitmask! 195 // 1, 2, 3 - anything like 00011..11 196 pAssume2((twobits >> 2) == 0); 197 const int _bitmasks[4] = {0xffffffff, 0x7fff, 0x7f, 0x3}; 198 return bitmask & _bitmasks[twobits]; 199 } 200 201 PINLINE2 int p_GetExp(poly p, int v, ring r) 202 { 203 p_LmCheckPolyRing2(p, r); 204 pAssume2(v > 0 && v <= r->N); 205 #if 1 // new!! 206 int pos =(r->VarOffset[v] & 0xffffff); 207 int hbyte= (r->VarOffset[v] >> 24); // the highest byte 208 int bitpos = hbyte & 0x3f; // last 6 bits 209 int bitmask = BitMask(r->bitmask, hbyte >> 6); 210 211 int exp=(p->exp[pos] >> bitpos) & bitmask; 212 return exp; 213 #else 214 // old 215 return (int) 216 ((p->exp[(r->VarOffset[v] & 0xffffff)] >> (r->VarOffset[v] >> 24)) 217 & r->bitmask; 218 #endif 219 } 220 221 222 // partial compare exponent 223 // r->VarOffset encodes the position in p->exp (lower 24 bits) 224 // and number of bits to shift to the right in the upper 8 bits 225 PINLINE2 int p_SetExp(poly p, int v, int e, ring r) 226 { 227 p_LmCheckPolyRing2(p, r); 228 pAssume2(v>0 && v <= r->N); 229 pAssume2(e>=0); 230 pAssume2((unsigned int) e <= BitMask(r->bitmask, r->VarOffset[v] >> 30)); 231 232 // shift e to the left: 233 register int hbyte = r->VarOffset[v] >> 24; 234 int bitmask = BitMask(r->bitmask, hbyte >> 6); 235 register int shift = hbyte & 0x3f; 236 unsigned long ee = ((unsigned long)e) << shift; 237 // find the bits in the exponent vector 238 register int offset = (r->VarOffset[v] & 0xffffff); 239 // clear the bits in the exponent vector: 240 p->exp[offset] &= ~( bitmask << shift ); 241 // insert e with | 242 p->exp[ offset ] |= ee; 243 return e; 244 } 245 246 #endif // #ifndef HAVE_EXPSIZES 184 247 185 248 // the following should be implemented more efficiently -
kernel/p_Procs_Set.h
rf2b5839 r52e2f6 12 12 * Author: obachman (Olaf Bachmann) 13 13 * Created: 12/00 14 * Version: $Id: p_Procs_Set.h,v 1.1 4 2008-03-19 17:44:10 SingularExp $14 * Version: $Id: p_Procs_Set.h,v 1.15 2008-06-10 10:17:32 motsak Exp $ 15 15 *******************************************************************/ 16 16 #include "modulop.h" … … 185 185 #ifdef HAVE_PLURAL 186 186 if (rIsPluralRing(r)) 187 nc_p_ProcsSet(r, _p_procs); // Setup non-commutative p_Procs table! 187 { 188 WarnS("Setting pProcs in p_ProcsSet (rDebugPrint!?)!!!"); 189 nc_p_ProcsSet(r, _p_procs); // Setup non-commutative p_Procs table! 190 } 188 191 #endif 189 192 } … … 204 207 { 205 208 set_names = 1; 206 p_ProcsSet(r, p_Procs); 209 p_ProcsSet(r, p_Procs); // changes p_Procs!!! 207 210 set_names = 0; 208 211 } -
kernel/ratgring.cc
rf2b5839 r52e2f6 7 7 * Author: levandov (Viktor Levandovsky) 8 8 * Created: 8/00 - 11/00 9 * Version: $Id: ratgring.cc,v 1. 9 2008-01-31 13:23:25 SingularExp $9 * Version: $Id: ratgring.cc,v 1.10 2008-06-10 10:17:32 motsak Exp $ 10 10 *******************************************************************/ 11 11 #include "mod2.h" … … 379 379 poly H = NULL; 380 380 HH = p_Copy(p_HeadRat(p1,is,r),r); // lm_D(g) 381 H = r->nc->p_Procs.mm_Mult_p(m, p_Copy(HH, r), r); // d^aplha lm_D(g) 381 // H = r->nc->p_Procs.mm_Mult_p(m, p_Copy(HH, r), r); // d^aplha lm_D(g) 382 H = nc_mm_Mult_pp(m, HH, r); // d^aplha lm_D(g) 382 383 383 384 poly K = p_Copy( p_GetCoeffRat(H, is, r), r); … … 427 428 Print("k' t_f: "); p_wrp(p2,r); 428 429 429 out = r->nc->p_Procs.mm_Mult_p(m, out, r); // d^aplha t_g 430 // out = r->nc->p_Procs.mm_Mult_p(m, out, r); // d^aplha t_g 431 out = nc_mm_Mult_p(m, out, r); // d^aplha t_g 432 430 433 p_Delete(&m,r); 431 434 -
kernel/ring.cc
rf2b5839 r52e2f6 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ring.cc,v 1.8 1 2008-04-22 16:14:14 SingularExp $ */4 /* $Id: ring.cc,v 1.82 2008-06-10 10:17:32 motsak Exp $ */ 5 5 6 6 /* … … 390 390 } 391 391 #ifdef HAVE_PLURAL 392 if (r->nc!=NULL)392 if(rIsPluralRing(r)) 393 393 { 394 394 PrintS("\n// noncommutative relations:"); … … 398 398 int nl; 399 399 int i,j; 400 // Print("\n// noncommutative relations (type %d):",(int)r->nc->type);401 400 for (i = 1; i<r->N; i++) 402 401 { 403 402 for (j = i+1; j<=r->N; j++) 404 403 { 405 nl = nIsOne(p_GetCoeff(MATELEM(r-> nc->C,i,j),r));406 if ( (MATELEM(r-> nc->D,i,j)!=NULL) || (!nl) )404 nl = nIsOne(p_GetCoeff(MATELEM(r->GetNC()->C,i,j),r)); 405 if ( (MATELEM(r->GetNC()->D,i,j)!=NULL) || (!nl) ) 407 406 { 408 407 Print("\n// %s%s=",r->names[j-1],r->names[i-1]); 409 pl = MATELEM(r-> nc->MT[UPMATELEM(i,j,r->N)],1,1);408 pl = MATELEM(r->GetNC()->MT[UPMATELEM(i,j,r->N)],1,1); 410 409 pWrite0(pl); 411 410 } … … 416 415 #ifdef PDEBUG 417 416 Print("\n// noncommutative type:%d", (int)ncRingType(r)); 418 Print("\n// is skew constant:%d",r-> nc->IsSkewConstant);417 Print("\n// is skew constant:%d",r->GetNC()->IsSkewConstant); 419 418 if( rIsSCA(r) ) 420 419 { 421 420 Print("\n// alternating variables: [%d, %d]", scaFirstAltVar(r), scaLastAltVar(r)); 422 const ideal Q = r->nc->SCAQuotient(); // resides within r!421 const ideal Q = SCAQuotient(r); // resides within r! 423 422 if (Q!=NULL) 424 423 { … … 432 431 } 433 432 } 434 Print("\n// ref:%d",r-> nc->ref);433 Print("\n// ref:%d",r->GetNC()->ref); 435 434 #endif 436 435 } … … 455 454 456 455 #ifdef HAVE_PLURAL 457 if (r->nc != NULL) 458 { 459 if (r->nc->ref>1) /* in use by somebody else */ 460 { 461 r->nc->ref--; 462 } 463 else 464 { 465 ncKill(r); 466 } 467 } 468 #endif 456 if (rIsPluralRing(r)) 457 ncKill(r); 458 #endif 459 469 460 nKillChar(r); 470 461 rUnComplete(r); … … 1065 1056 tmpR.OrdSgn=1; 1066 1057 if (dp_dp 1067 && !rIsPluralRing(r1) && !rIsPluralRing(r2)) 1058 #ifdef HAVE_PLURAL 1059 && !rIsPluralRing(r1) && !rIsPluralRing(r2) 1060 #endif 1061 ) 1068 1062 { 1069 1063 tmpR.order=(int*)omAlloc(4*sizeof(int)); … … 1225 1219 memcpy(sum,&tmpR,sizeof(ip_sring)); 1226 1220 rComplete(sum); 1221 1227 1222 //#ifdef RDEBUG 1228 1223 // rDebugPrint(sum); 1229 1224 //#endif 1225 1230 1226 #ifdef HAVE_PLURAL 1231 ring old_ring = currRing; 1232 BOOLEAN R1_is_nc = rIsPluralRing(r1); 1233 BOOLEAN R2_is_nc = rIsPluralRing(r2); 1234 if ( (R1_is_nc) || (R2_is_nc)) 1235 { 1236 rChangeCurrRing(r1); /* since rCopy works well only in currRing */ 1237 ring R1 = rCopy(r1); 1238 rChangeCurrRing(r2); 1239 ring R2 = rCopy(r2); 1240 rChangeCurrRing(sum); 1241 /* basic nc constructions */ 1242 sum->nc = (nc_struct *)omAlloc0(sizeof(nc_struct)); 1243 sum->nc->ref = 1; 1244 sum->nc->basering = sum; 1245 if ( !R1_is_nc ) nc_rCreateNCcomm(R1); 1246 if ( !R2_is_nc ) nc_rCreateNCcomm(R2); 1247 /* nc->type's */ 1248 ncRingType(sum, nc_undef); 1249 nc_type t1 = ncRingType(R1), t2 = ncRingType(R2); 1250 if ( t1==t2) ncRingType(sum, t1); 1251 else 1252 { 1253 if ( (t1==nc_general) || (t2==nc_general) ) ncRingType(sum, nc_general); 1254 } 1255 if (ncRingType(sum) == nc_undef) /* not yet done */ 1256 { 1257 switch (t1) 1258 { 1259 case nc_comm: 1260 ncRingType(sum, t2); 1261 break; 1262 case nc_lie: 1263 switch(t2) 1264 { 1265 case nc_skew: 1266 ncRingType(sum, nc_general); break; 1267 case nc_comm: 1268 ncRingType(sum, nc_lie); break; 1269 default: 1270 /*sum->nc->type = nc_undef;*/ break; 1271 } 1272 break; 1273 case nc_skew: 1274 switch(t2) 1275 { 1276 case nc_lie: 1277 ncRingType(sum, nc_lie); break; 1278 case nc_comm: 1279 ncRingType(sum, nc_skew); break; 1280 default: 1281 /*sum->nc->type = nc_undef;*/ break; 1282 } 1283 default: 1284 /*sum->nc->type = nc_undef;*/ 1285 break; 1286 } 1287 } 1288 if (ncRingType(sum) == nc_undef) 1289 WarnS("Error on recognizing nc types"); 1290 /* multiplication matrices business: */ 1291 /* find permutations of vars and pars */ 1292 int *perm1 = (int *)omAlloc0((rVar(R1)+1)*sizeof(int)); 1293 int *par_perm1 = NULL; 1294 if (rPar(R1)!=0) par_perm1=(int *)omAlloc0((rPar(R1)+1)*sizeof(int)); 1295 int *perm2 = (int *)omAlloc0((rVar(R2)+1)*sizeof(int)); 1296 int *par_perm2 = NULL; 1297 if (rPar(R2)!=0) par_perm2=(int *)omAlloc0((rPar(R2)+1)*sizeof(int)); 1298 maFindPerm(R1->names, rVar(R1), R1->parameter, rPar(R1), 1299 sum->names, rVar(sum), sum->parameter, rPar(sum), 1300 perm1, par_perm1, sum->ch); 1301 maFindPerm(R2->names, rVar(R2), R2->parameter, rPar(R2), 1302 sum->names, rVar(sum), sum->parameter, rPar(sum), 1303 perm2, par_perm2, sum->ch); 1304 nMapFunc nMap1 = nSetMap(R1); 1305 nMapFunc nMap2 = nSetMap(R2); 1306 matrix C1 = R1->nc->C, C2 = R2->nc->C; 1307 matrix D1 = R1->nc->D, D2 = R2->nc->D; 1308 1309 // !!!! BUG? C1 and C2 might live in different baserings!!! 1310 // it cannot be both the currRing! :) 1311 // the currRing is sum! 1312 1313 int l = rVar(R1) + rVar(R2); 1314 matrix C = mpNew(l,l); 1315 matrix D = mpNew(l,l); 1316 int param_shift = 0; 1317 for (i=1; i<= rVar(R1) + rVar(R2); i++) 1318 { 1319 for (j= i+1; j<= rVar(R1) + rVar(R2); j++) 1320 { 1321 MATELEM(C,i,j) = pOne(); 1322 } 1323 } 1324 sum->nc->C = C; 1325 sum->nc->D = D; 1326 if (nc_InitMultiplication(sum)) 1327 WarnS("Error initializing multiplication!"); 1328 for (i=1; i< rVar(R1); i++) 1329 { 1330 for (j=i+1; j<=rVar(R1); j++) 1331 { 1332 1333 MATELEM(C,i,j) = pPermPoly(MATELEM(C1,i,j),perm1,R1,nMap1,par_perm1,rPar(R1)); 1334 if (MATELEM(D1,i,j) != NULL) 1335 { 1336 MATELEM(D,i,j) = pPermPoly(MATELEM(D1,i,j),perm1,R1,nMap1,par_perm1,rPar(R1)); 1337 } 1338 } 1339 } 1340 idTest((ideal)C); 1341 for (i=1; i< rVar(R2); i++) 1342 { 1343 for (j=i+1; j<=rVar(R2); j++) 1344 { 1345 MATELEM(C,rVar(R1)+i,rVar(R1)+j) = pPermPoly(MATELEM(C2,i,j),perm2,R2,nMap2,par_perm2,rPar(R2)); 1346 if (MATELEM(D2,i,j) != NULL) 1347 { 1348 MATELEM(D,rVar(R1)+i,rVar(R1)+j) = pPermPoly(MATELEM(D2,i,j),perm2,R2,nMap2,par_perm2,rPar(R2)); 1349 } 1350 } 1351 } 1352 idTest((ideal)D); 1353 if (nc_InitMultiplication(sum)) 1354 WarnS("Error initializing multiplication!"); 1355 sum->nc->IsSkewConstant =(int)((R1->nc->IsSkewConstant) && (R2->nc->IsSkewConstant)); 1356 /* delete R1, R2*/ 1357 rDelete(R1); 1358 rDelete(R2); 1359 /* delete perm arrays */ 1360 if (perm1!=NULL) omFree((ADDRESS)perm1); 1361 if (perm2!=NULL) omFree((ADDRESS)perm2); 1362 if (par_perm1!=NULL) omFree((ADDRESS)par_perm1); 1363 if (par_perm2!=NULL) omFree((ADDRESS)par_perm2); 1364 rChangeCurrRing(old_ring); 1365 } 1366 #endif 1227 if(1) 1228 { 1229 ring old_ring = currRing; 1230 1231 BOOLEAN R1_is_nc = rIsPluralRing(r1); 1232 BOOLEAN R2_is_nc = rIsPluralRing(r2); 1233 1234 if ( (R1_is_nc) || (R2_is_nc)) 1235 { 1236 rChangeCurrRing(r1); /* since rCopy works well only in currRing */ 1237 ring R1 = rCopy(r1); 1238 if ( !R1_is_nc ) nc_rCreateNCcomm(R1); 1239 1240 #if 0 1241 #ifdef RDEBUG 1242 rWrite(R1); 1243 rDebugPrint(R1); 1244 #endif 1245 #endif 1246 rChangeCurrRing(r2); 1247 ring R2 = rCopy(r2); 1248 if ( !R2_is_nc ) nc_rCreateNCcomm(R2); 1249 1250 #if 0 1251 #ifdef RDEBUG 1252 rWrite(R2); 1253 rDebugPrint(R2); 1254 #endif 1255 #endif 1256 1257 rChangeCurrRing(sum); // ? 1258 1259 // Projections from R_i into Sum: 1260 /* multiplication matrices business: */ 1261 /* find permutations of vars and pars */ 1262 int *perm1 = (int *)omAlloc0((rVar(R1)+1)*sizeof(int)); 1263 int *par_perm1 = NULL; 1264 if (rPar(R1)!=0) par_perm1=(int *)omAlloc0((rPar(R1)+1)*sizeof(int)); 1265 1266 int *perm2 = (int *)omAlloc0((rVar(R2)+1)*sizeof(int)); 1267 int *par_perm2 = NULL; 1268 if (rPar(R2)!=0) par_perm2=(int *)omAlloc0((rPar(R2)+1)*sizeof(int)); 1269 1270 maFindPerm(R1->names, rVar(R1), R1->parameter, rPar(R1), 1271 sum->names, rVar(sum), sum->parameter, rPar(sum), 1272 perm1, par_perm1, sum->ch); 1273 1274 maFindPerm(R2->names, rVar(R2), R2->parameter, rPar(R2), 1275 sum->names, rVar(sum), sum->parameter, rPar(sum), 1276 perm2, par_perm2, sum->ch); 1277 1278 nMapFunc nMap1 = nSetMap(R1); 1279 nMapFunc nMap2 = nSetMap(R2); 1280 1281 matrix C1 = R1->GetNC()->C, C2 = R2->GetNC()->C; 1282 matrix D1 = R1->GetNC()->D, D2 = R2->GetNC()->D; 1283 1284 // !!!! BUG? C1 and C2 might live in different baserings!!! 1285 // it cannot be both the currRing! :) 1286 // the currRing is sum! 1287 1288 int l = rVar(R1) + rVar(R2); 1289 1290 matrix C = mpNew(l,l); 1291 matrix D = mpNew(l,l); 1292 1293 int param_shift = 0; 1294 1295 for (i = 1; i <= rVar(R1); i++) 1296 for (j= rVar(R1)+1; j <= l; j++) 1297 MATELEM(C,i,j) = p_ISet(1, sum); // in 'sum' 1298 1299 idTest((ideal)C); 1300 1301 // Create blocked C and D matrices: 1302 for (i=1; i<= rVar(R1); i++) 1303 for (j=i+1; j<=rVar(R1); j++) 1304 { 1305 assume(MATELEM(C1,i,j) != NULL); 1306 MATELEM(C,i,j) = pPermPoly(MATELEM(C1,i,j), perm1, R1, nMap1, par_perm1, rPar(R1)); // need ADD + CMP ops. 1307 1308 if (MATELEM(D1,i,j) != NULL) 1309 MATELEM(D,i,j) = pPermPoly(MATELEM(D1,i,j),perm1,R1,nMap1,par_perm1,rPar(R1)); 1310 } 1311 1312 idTest((ideal)C); 1313 idTest((ideal)D); 1314 1315 1316 for (i=1; i<= rVar(R2); i++) 1317 for (j=i+1; j<=rVar(R2); j++) 1318 { 1319 assume(MATELEM(C2,i,j) != NULL); 1320 MATELEM(C,rVar(R1)+i,rVar(R1)+j) = pPermPoly(MATELEM(C2,i,j),perm2,R2,nMap2,par_perm2,rPar(R2)); 1321 1322 if (MATELEM(D2,i,j) != NULL) 1323 MATELEM(D,rVar(R1)+i,rVar(R1)+j) = pPermPoly(MATELEM(D2,i,j),perm2,R2,nMap2,par_perm2,rPar(R2)); 1324 } 1325 1326 idTest((ideal)C); 1327 idTest((ideal)D); 1328 1329 // Now sum is non-commutative with blocked structure constants! 1330 if (nc_CallPlural(C, D, NULL, NULL, sum, false, false, true, sum)) 1331 WarnS("Error initializing non-commutative multiplication!"); 1332 1333 /* delete R1, R2*/ 1334 1335 #if 0 1336 #ifdef RDEBUG 1337 rWrite(sum); 1338 rDebugPrint(sum); 1339 1340 Print("\nRefs: R1: %d, R2: %d\n", R1->GetNC()->ref, R2->GetNC()->ref); 1341 1342 #endif 1343 #endif 1344 1345 1346 rDelete(R1); 1347 rDelete(R2); 1348 1349 /* delete perm arrays */ 1350 if (perm1!=NULL) omFree((ADDRESS)perm1); 1351 if (perm2!=NULL) omFree((ADDRESS)perm2); 1352 if (par_perm1!=NULL) omFree((ADDRESS)par_perm1); 1353 if (par_perm2!=NULL) omFree((ADDRESS)par_perm2); 1354 1355 rChangeCurrRing(old_ring); 1356 } 1357 1358 } 1359 #endif 1360 1367 1361 ideal Q=NULL; 1368 1362 ideal Q1=NULL, Q2=NULL; … … 1414 1408 } 1415 1409 sum->qideal = Q; 1410 1411 #ifdef HAVE_PLURAL 1412 if( rIsPluralRing(sum) ) 1413 nc_SetupQuotient( sum ); 1414 #endif 1416 1415 return 1; 1417 1416 } … … 1506 1505 } 1507 1506 #ifdef HAVE_PLURAL 1508 if (rIsPluralRing(r)) 1509 { 1510 res->nc=r->nc; 1511 res->nc->ref++; 1512 } 1507 res->GetNC() = NULL; // copy is purely commutative!!! 1508 // if (rIsPluralRing(r)) 1509 // nc_rCopy0(res, r); // is this correct??? imho: no! 1513 1510 #endif 1514 1511 return res; … … 1525 1522 if (r == NULL) return NULL; 1526 1523 ring res=rCopy0(r); 1527 rComplete(res, 1); 1524 rComplete(res, 1); // res is purely commutative so far 1525 1526 #ifdef HAVE_PLURAL 1527 // update nc structure on res: share NC structure of r with res since they are the same!!! 1528 // i.e. no data copy!!! Multiplications will be setuped as well! 1529 if (rIsPluralRing(r)) 1530 nc_rCopy0(res, r); 1531 #endif 1532 1528 1533 return res; 1529 1534 } … … 2436 2441 ring res=(ring)omAlloc0Bin(ip_sring_bin); 2437 2442 *res = *r; 2443 2444 #ifdef HAVE_PLURAL 2445 res->GetNC() = NULL; 2446 #endif 2447 2438 2448 // res->qideal, res->idroot ??? 2439 2449 res->wvhdl=wvhdl; … … 2477 2487 // it comes from dp 2478 2488 res->OrdSgn=r->OrdSgn; 2489 2490 2491 #ifdef HAVE_PLURAL 2492 if (rIsPluralRing(r)) 2493 { 2494 if ( nc_rComplete(r, res, false) ) // no qideal! 2495 { 2496 WarnS("error in nc_rComplete"); 2497 // cleanup? 2498 2499 // rDelete(res); 2500 // return r; 2501 2502 // just go on.. 2503 } 2504 } 2505 #endif 2506 2479 2507 return res; 2480 2508 } … … 2485 2513 ring res=(ring)omAlloc0Bin(ip_sring_bin); 2486 2514 *res = *r; 2515 #ifdef HAVE_PLURAL 2516 res->GetNC() = NULL; 2517 #endif 2518 2487 2519 /*weights: entries for 3 blocks: NULL*/ 2488 2520 res->wvhdl = (int **)omAlloc0(3 * sizeof(int_ptr)); … … 2506 2538 rComplete(res, 1); 2507 2539 r->cf->ref=tmpref; 2540 #ifdef HAVE_PLURAL 2541 if (rIsPluralRing(r)) 2542 { 2543 if ( nc_rComplete(r, res, false) ) // no qideal! 2544 { 2545 WarnS("error in nc_rComplete"); 2546 // cleanup? 2547 2548 // rDelete(res); 2549 // return r; 2550 2551 // just go on.. 2552 } 2553 } 2554 #endif 2508 2555 return res; 2509 2556 } … … 2538 2585 ring res=(ring)omAlloc0Bin(ip_sring_bin); 2539 2586 *res = *r; 2587 #ifdef HAVE_PLURAL 2588 res->GetNC() = NULL; 2589 #endif 2540 2590 // res->qideal, res->idroot ??? 2541 2591 res->wvhdl=wvhdl; … … 2547 2597 rComplete(res, 1); 2548 2598 r->cf->ref=tmpref; 2599 2600 #ifdef HAVE_PLURAL 2601 if (rIsPluralRing(r)) 2602 { 2603 if ( nc_rComplete(r, res, false) ) // no qideal! 2604 { 2605 WarnS("error in nc_rComplete"); 2606 // cleanup? 2607 2608 // rDelete(res); 2609 // return r; 2610 2611 // just go on.. 2612 } 2613 } 2614 #endif 2549 2615 2550 2616 rOptimizeLDeg(res); … … 3279 3345 r->p_Procs = (p_Procs_s*)omAlloc(sizeof(p_Procs_s)); 3280 3346 p_ProcsSet(r, r->p_Procs); 3281 3282 3347 return FALSE; 3283 3348 } … … 3506 3571 const char* length; 3507 3572 const char* ord; 3508 p_Debug_GetProcNames(r, &proc_names); 3573 p_Debug_GetProcNames(r, &proc_names); // changes p_Procs!!! 3509 3574 p_Debug_GetSpecNames(r, field, length, ord); 3510 3575 … … 3597 3662 static ring rAssure_SyzComp(ring r, BOOLEAN complete = TRUE); 3598 3663 3664 #define MYTEST 0 3665 3599 3666 ring rCurrRingAssure_SyzComp() 3600 3667 { 3668 #ifdef HAVE_PLURAL 3669 #if MYTEST 3670 PrintS("rCurrRingAssure_SyzComp(), currRing: \n"); 3671 rWrite(currRing); 3672 #ifdef RDEBUG 3673 rDebugPrint(currRing); 3674 #endif 3675 #endif 3676 #endif 3677 3601 3678 ring r = rAssure_SyzComp(currRing); 3679 3602 3680 if (r != currRing) 3603 3681 { 3604 3682 ring old_ring = currRing; 3605 3683 rChangeCurrRing(r); 3684 assume(currRing == r); 3685 3686 #ifdef HAVE_PLURAL 3687 #if MYTEST 3688 PrintS("rCurrRingAssure_SyzComp(): currRing': "); 3689 rWrite(currRing); 3690 #ifdef RDEBUG 3691 rDebugPrint(currRing); 3692 #endif 3693 #endif 3694 #endif 3695 3696 3606 3697 if (old_ring->qideal != NULL) 3607 3698 { … … 3609 3700 assume(idRankFreeModule(r->qideal) == 0); 3610 3701 currQuotient = r->qideal; 3611 } 3612 } 3702 3703 #ifdef HAVE_PLURAL 3704 if( rIsPluralRing(r) ) 3705 nc_SetupQuotient(r); 3706 #endif 3707 } 3708 } 3709 3710 assume(currRing == r); 3711 #ifdef HAVE_PLURAL 3712 #if MYTEST 3713 PrintS("\nrCurrRingAssure_SyzComp(): new currRing: \n"); 3714 rWrite(currRing); 3715 #ifdef RDEBUG 3716 rDebugPrint(currRing); 3717 #endif 3718 #endif 3719 #endif 3720 3613 3721 return r; 3614 3722 } … … 3641 3749 res->wvhdl = wvhdl; 3642 3750 3643 if (complete) rComplete(res, 1); 3751 if (complete) 3752 { 3753 rComplete(res, 1); 3754 3755 #ifdef HAVE_PLURAL 3756 if (rIsPluralRing(r)) 3757 { 3758 if ( nc_rComplete(r, res, false) ) // no qideal! 3759 { 3760 WarnS("error in nc_rComplete"); 3761 // cleanup? 3762 3763 // rDelete(res); 3764 // return r; 3765 3766 // just go on.. 3767 } 3768 } 3769 #endif 3770 3771 } 3644 3772 return res; 3645 3773 } … … 3683 3811 3684 3812 rComplete(new_r, 1); 3813 3814 #ifdef HAVE_PLURAL 3815 if (rIsPluralRing(r)) 3816 { 3817 if ( nc_rComplete(r, new_r, false) ) // no qideal! 3818 { 3819 WarnS("error in nc_rComplete"); 3820 // cleanup? 3821 3822 // rDelete(res); 3823 // return r; 3824 3825 // just go on.. 3826 } 3827 } 3828 #endif 3829 3685 3830 return new_r; 3686 3831 } … … 3717 3862 new_r->block1[last_block] = r->block1[c_pos]; 3718 3863 new_r->wvhdl[last_block] = r->wvhdl[c_pos]; 3719 if (complete) rComplete(new_r, 1); 3864 if (complete) 3865 { 3866 rComplete(new_r, 1); 3867 3868 #ifdef HAVE_PLURAL 3869 if (rIsPluralRing(r)) 3870 { 3871 if ( nc_rComplete(r, new_r, false) ) // no qideal! 3872 { 3873 WarnS("error in nc_rComplete"); 3874 // cleanup? 3875 3876 // rDelete(res); 3877 // return r; 3878 3879 // just go on.. 3880 } 3881 } 3882 #endif 3883 3884 } 3720 3885 return new_r; 3721 3886 } … … 3750 3915 if (new_r_1 != new_r && new_r_1 != old_r) rDelete(new_r_1); 3751 3916 rComplete(new_r, 1); 3917 #ifdef HAVE_PLURAL 3918 if (rIsPluralRing(old_r)) 3919 { 3920 if ( nc_rComplete(old_r, new_r, false) ) // no qideal! 3921 { 3922 WarnS("error in nc_rComplete"); 3923 // cleanup? 3924 3925 // rDelete(res); 3926 // return r; 3927 3928 // just go on.. 3929 } 3930 } 3931 #endif 3932 3752 3933 rChangeCurrRing(new_r); 3753 3934 if (old_r->qideal != NULL) … … 3755 3936 new_r->qideal = idrCopyR(old_r->qideal, old_r); 3756 3937 currQuotient = new_r->qideal; 3938 3939 #ifdef HAVE_PLURAL 3940 if( rIsPluralRing(old_r) ) 3941 nc_SetupQuotient( new_r ); 3942 #endif 3943 3757 3944 } 3758 3945 rTest(new_r); … … 3984 4171 ring save = currRing; 3985 4172 rChangeCurrRing(src); 4173 3986 4174 ring r = rCopy0(src,TRUE); /* TRUE for copy the qideal */ 3987 4175 /* rChangeCurrRing(r); */ … … 4193 4381 } 4194 4382 rComplete(r); 4383 4384 4195 4385 #ifdef RDEBUG 4196 4386 // rDebugPrint(r); 4197 #endif4198 4387 rTest(r); 4388 #endif 4389 4390 rChangeCurrRing(r); 4391 4199 4392 #ifdef HAVE_PLURAL 4200 /* now, we initialize a non-comm structure on r */ 4201 if (!rIsPluralRing(src)) 4202 { 4203 return r; 4204 } 4205 rChangeCurrRing(r); /* we were not in r */ 4206 /* basic nc constructions */ 4207 r->nc = (nc_struct *)omAlloc0(sizeof(nc_struct)); 4208 r->nc->ref = 1; /* in spite of rCopy(src)? */ 4209 r->nc->basering = r; 4210 ncRingType(r, ncRingType(src)); 4211 int *perm = (int *)omAlloc0((rVar(r)+1)*sizeof(int)); 4212 int *par_perm = NULL; 4213 nMapFunc nMap = nSetMap(src); 4214 int ni,nj; 4215 for(i=1; i<=r->N; i++) 4216 { 4217 perm[i] = rOppVar(r,i); 4218 } 4219 matrix C = mpNew(rVar(r),rVar(r)); 4220 matrix D = mpNew(rVar(r),rVar(r)); 4221 r->nc->C = C; 4222 r->nc->D = D; 4223 if (nc_InitMultiplication(r)) 4224 WarnS("Error initializing multiplication!"); 4225 for (i=1; i< rVar(r); i++) 4226 { 4227 for (j=i+1; j<=rVar(r); j++) 4228 { 4229 ni = r->N +1 - i; 4230 nj = r->N +1 - j; /* i<j ==> nj < ni */ 4231 MATELEM(C,nj,ni) = pPermPoly(MATELEM(src->nc->C,i,j),perm,src,nMap,par_perm,src->P); 4232 MATELEM(D,nj,ni) = pPermPoly(MATELEM(src->nc->D,i,j),perm,src,nMap,par_perm,src->P); 4233 } 4234 } 4235 idTest((ideal)C); 4236 idTest((ideal)D); 4237 if (nc_InitMultiplication(r)) 4238 WarnS("Error initializing multiplication!"); 4239 r->nc->IsSkewConstant = src->nc->IsSkewConstant; 4240 omFreeSize((ADDRESS)perm,(rVar(r)+1)*sizeof(int)); 4393 // now, we initialize a non-comm structure on r 4394 if (rIsPluralRing(src)) 4395 { 4396 assume( currRing == r); 4397 4398 int *perm = (int *)omAlloc0((rVar(r)+1)*sizeof(int)); 4399 int *par_perm = NULL; 4400 nMapFunc nMap = nSetMap(src); 4401 int ni,nj; 4402 for(i=1; i<=r->N; i++) 4403 { 4404 perm[i] = rOppVar(r,i); 4405 } 4406 4407 matrix C = mpNew(rVar(r),rVar(r)); 4408 matrix D = mpNew(rVar(r),rVar(r)); 4409 4410 for (i=1; i< rVar(r); i++) 4411 { 4412 for (j=i+1; j<=rVar(r); j++) 4413 { 4414 ni = r->N +1 - i; 4415 nj = r->N +1 - j; /* i<j ==> nj < ni */ 4416 4417 assume(MATELEM(src->GetNC()->C,i,j) != NULL); 4418 MATELEM(C,nj,ni) = pPermPoly(MATELEM(src->GetNC()->C,i,j),perm,src,nMap,par_perm,src->P); 4419 4420 if(MATELEM(src->GetNC()->D,i,j) != NULL) 4421 MATELEM(D,nj,ni) = pPermPoly(MATELEM(src->GetNC()->D,i,j),perm,src,nMap,par_perm,src->P); 4422 } 4423 } 4424 4425 idTest((ideal)C); 4426 idTest((ideal)D); 4427 4428 if (nc_CallPlural(C, D, NULL, NULL, r, false, false, true, r)) 4429 WarnS("Error initializing non-commutative multiplication!"); 4430 4431 assume( r->GetNC()->IsSkewConstant == src->GetNC()->IsSkewConstant); 4432 assume( ncRingType(r) == ncRingType(src) ); 4433 4434 omFreeSize((ADDRESS)perm,(rVar(r)+1)*sizeof(int)); 4435 4436 rChangeCurrRing(save); 4437 4438 } 4439 #endif /* HAVE_PLURAL */ 4440 4441 4241 4442 /* now oppose the qideal for qrings */ 4242 4443 if (src->qideal != NULL) … … 4244 4445 idDelete(&(r->qideal)); 4245 4446 r->qideal = idOppose(src, src->qideal); 4246 } 4447 4448 #ifdef HAVE_PLURAL 4449 if( rIsPluralRing(r) ) 4450 nc_SetupQuotient(r); 4451 #endif 4452 } 4453 4247 4454 rTest(r); 4455 4248 4456 rChangeCurrRing(save); 4249 #endif /* HAVE_PLURAL */4250 4457 return r; 4251 4458 } … … 4263 4470 return Renv; 4264 4471 } 4472 4265 4473 #ifdef HAVE_PLURAL 4266 BOOLEAN nc_rComplete( ring src, ring dest)4474 BOOLEAN nc_rComplete(const ring src, ring dest, bool bSetupQuotient) 4267 4475 /* returns TRUE is there were errors */ 4268 4476 /* dest is actualy equals src with the different ordering */ 4269 4477 /* we map src->nc correctly to dest->src */ 4270 4478 /* to be executed after rComplete, before rChangeCurrRing */ 4271 4272 { 4479 { 4480 // NOTE: Originally used only by idElimination to transfer NC structure to dest 4481 // ring created by dirty hack (without nc_CallPlural) 4482 4483 assume(!rIsPluralRing(dest)); // destination must be a newly constructed commutative ring 4484 4273 4485 if (!rIsPluralRing(src)) 4486 { 4274 4487 return FALSE; 4275 int i,j; 4276 int N = dest->N; 4277 if (src->N != N) 4278 { 4279 /* should not happen */ 4280 WarnS("wrong nc_rComplete call"); 4281 return TRUE; 4282 } 4488 } 4489 4490 const int N = dest->N; 4491 4492 assume(src->N == N); 4493 4283 4494 ring save = currRing; 4284 int WeChangeRing = 0; 4285 if (dest != currRing) 4286 { 4287 WeChangeRing = 1; 4495 4496 if (dest != save) 4288 4497 rChangeCurrRing(dest); 4289 } 4290 matrix C = mpNew(N,N); 4498 4499 const ring srcBase = src->GetNC()->basering; 4500 4501 assume( nSetMap(srcBase) == nSetMap(currRing) ); // currRing is important here! 4502 4503 matrix C = mpNew(N,N); // ring independent 4291 4504 matrix D = mpNew(N,N); 4292 matrix C0 = src->nc->C; 4293 matrix D0 = src->nc->D; 4505 4506 matrix C0 = src->GetNC()->C; 4507 matrix D0 = src->GetNC()->D; 4508 4509 4294 4510 poly p = NULL; 4295 4511 number n = NULL; 4296 for (i=1; i< N; i++) 4297 { 4298 for (j= i+1; j<= N; j++) 4299 { 4300 n = n_Copy(p_GetCoeff(MATELEM(C0,i,j), src),src); 4301 p = p_ISet(1,dest); 4302 p_SetCoeff(p,n,dest); 4512 4513 // map C and D into dest 4514 for (int i = 1; i < N; i++) 4515 { 4516 for (int j = i + 1; j <= N; j++) 4517 { 4518 const number n = n_Copy(p_GetCoeff(MATELEM(C0,i,j), srcBase), srcBase); // src, mapping for coeffs into currRing = dest! 4519 const poly p = p_NSet(n, dest); 4303 4520 MATELEM(C,i,j) = p; 4304 p = NULL;4305 4521 if (MATELEM(D0,i,j) != NULL) 4306 { 4307 p = prCopyR(MATELEM(D0,i,j), src->nc->basering, dest); 4308 MATELEM(D,i,j) = nc_p_CopyPut(p, dest); 4309 p_Delete(&p, dest); 4310 p = NULL; 4311 } 4312 } 4313 } 4314 /* One must test C and D _only_ in r->nc->basering!!! not in r!!! */ 4315 // idTest((ideal)C); 4316 // idTest((ideal)D); 4317 id_Delete((ideal *)&(dest->nc->C),dest->nc->basering); 4318 id_Delete((ideal *)&(dest->nc->D),dest->nc->basering); 4319 dest->nc->C = C; 4320 dest->nc->D = D; 4321 if ( WeChangeRing ) 4522 MATELEM(D,i,j) = prCopyR(MATELEM(D0,i,j), srcBase, dest); // ? 4523 } 4524 } 4525 /* One must test C and D _only_ in r->GetNC()->basering!!! not in r!!! */ 4526 4527 idTest((ideal)C); // in dest! 4528 idTest((ideal)D); 4529 4530 if (nc_CallPlural(C, D, NULL, NULL, dest, bSetupQuotient, false, true, dest)) // also takes care about quotient ideal 4531 { 4532 WarnS("Error transferring non-commutative structure"); 4533 4534 mpDelete(&C, dest); 4535 mpDelete(&D, dest); 4536 4537 return TRUE; 4538 } 4539 4540 // mpDelete(&C, dest); // used by nc_CallPlural! 4541 // mpDelete(&D, dest); 4542 4543 if (dest != save) 4322 4544 rChangeCurrRing(save); 4323 if (nc_InitMultiplication(dest)) 4324 { 4325 WarnS("Error initializing multiplication!"); 4326 return TRUE; 4327 } 4545 4328 4546 return FALSE; 4329 4547 } -
kernel/ring.h
rf2b5839 r52e2f6 7 7 * ABSTRACT - the interpreter related ring operations 8 8 */ 9 /* $Id: ring.h,v 1.2 8 2008-04-21 11:23:12 SingularExp $ */9 /* $Id: ring.h,v 1.29 2008-06-10 10:17:33 motsak Exp $ */ 10 10 11 11 /* includes */ … … 37 37 { 38 38 #ifdef HAVE_PLURAL 39 return (r != NULL) && (r-> nc != NULL) && (r->nc->type != nc_error);39 return (r != NULL) && (r->GetNC() != NULL) && (r->GetNC()->type != nc_error); 40 40 #else 41 41 return false; … … 247 247 // use this to free fields created by rComplete 248 248 249 BOOLEAN nc_rComplete(ring src, ring dest);250 251 void rUnComplete(ring r);252 249 inline int rBlocks(ring r) 253 250 { … … 379 376 void rDebugPrint(ring r); 380 377 void pDebugPrint(poly p); 378 void pDebugPrintR(poly p, const ring r); 381 379 382 380 int64 * rGetWeightVec(ring r); -
kernel/sca.cc
rf2b5839 r52e2f6 7 7 * Author: motsak (Oleksandr Motsak) 8 8 * Created: 2006/12/18 9 * Version: $Id: sca.cc,v 1.1 5 2008-05-15 17:24:36motsak Exp $9 * Version: $Id: sca.cc,v 1.16 2008-06-10 10:17:33 motsak Exp $ 10 10 *******************************************************************/ 11 12 #define OM_CHECK 4 13 #define OM_TRACK 5 11 14 12 15 // #define PDEBUG 2 … … 17 20 #define PLURAL_INTERNAL_DECLARATIONS 18 21 #include "sca.h" 22 #include "gring.h" 19 23 20 24 … … 384 388 if(iComponentMonomM==0 ) 385 389 { 386 WarnS(" Multiplication in the left module from the right");390 WarnS("sca_p_Mult_mm: Multiplication in the left module from the right"); 387 391 } 388 392 #endif … … 466 470 if(iComponentMonomM==0 ) 467 471 { 468 WarnS(" Multiplication in the left module from the right");472 WarnS("sca_pp_Mult_mm: Multiplication in the left module from the right"); 469 473 } 470 474 #endif … … 576 580 if(iComponent==0 ) 577 581 { 578 WarnS("Multiplication in the left module from the right"); 582 WarnS("sca_mm_Mult_pp: Multiplication in the left module from the right!"); 583 // PrintS("mm = "); p_Write(pMonom, rRing); 584 // PrintS("pp = "); p_Write(pPoly, rRing); 585 // assume(iComponent!=0); 579 586 } 580 587 #endif … … 637 644 if( iComponentMonomM!=0 ) 638 645 { 639 if( iComponent!=0 ) // TODO: make global if on iComponentMonomM =?= 0646 if( iComponent!=0 ) 640 647 { 641 648 // REPORT_ERROR … … 647 654 } 648 655 #ifdef PDEBUG 649 if(iComponent==0 656 if(iComponent==0) 650 657 { 651 WarnS("Multiplication in the left module from the right"); 658 WarnS("sca_mm_Mult_p: Multiplication in the left module from the right!"); 659 // PrintS("mm = "); p_Write(pMonom, rRing); 660 // PrintS("p = "); p_Write(pPoly, rRing); 661 // assume(iComponent!=0); 652 662 } 653 663 #endif … … 700 710 701 711 // GB computation routines: 702 703 /*2704 * returns the LCM of the head terms of a and b705 */706 inline poly p_Lcm(const poly a, const poly b, const long lCompM, const ring r)707 {708 poly m = p_ISet(1, r);709 710 const int N = r->N;711 712 for (int i = N; i>0; i--)713 {714 const int lExpA = p_GetExp (a, i, r);715 const int lExpB = p_GetExp (b, i, r);716 717 p_SetExp (m, i, si_max(lExpA, lExpB), r);718 }719 720 p_SetComp (m, lCompM, r);721 722 p_Setm(m,r);723 724 #ifdef PDEBUG725 p_Test(m,r);726 #endif727 728 return(m);729 }730 712 731 713 /*4 … … 970 952 #endif 971 953 954 #define OUTPUT 0 972 955 973 956 … … 975 958 { 976 959 #if MYTEST 977 PrintS("<sca_gr_bba>\n");960 // PrintS("<sca_gr_bba>\n"); 978 961 #endif 979 962 … … 985 968 #endif 986 969 970 #ifdef HAVE_PLURAL 971 #if MYTEST 972 PrintS("currRing: \n"); 973 rWrite(currRing); 974 #ifdef RDEBUG 975 rDebugPrint(currRing); 976 #endif 977 978 PrintS("F: \n"); 979 idPrint(F); 980 PrintS("Q: \n"); 981 idPrint(Q); 982 #endif 983 #endif 984 985 987 986 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing); 988 987 const unsigned int m_iLastAltVar = scaLastAltVar(currRing); … … 992 991 993 992 if(Q == currQuotient) 994 tempQ = currRing->nc->SCAQuotient();993 tempQ = SCAQuotient(currRing); 995 994 996 995 bool bIdHomog = id_IsSCAHomogeneous(tempF, NULL, NULL, currRing); // wCx == wCy == NULL! … … 1000 999 strat->homog = strat->homog && bIdHomog; 1001 1000 1002 1003 1001 assume( strat->homog == bIdHomog ); 1004 1002 1005 1006 1003 #if MYTEST 1007 /* 1008 { 1009 Print("ideal F: \n"); 1010 idPrint(F); 1004 { 1011 1005 Print("ideal tempF: \n"); 1012 idPrint(F); 1013 } 1014 */ 1015 #endif 1016 1017 1018 1019 1006 idPrint(tempF); 1007 Print("ideal tempQ: \n"); 1008 idPrint(tempQ); 1009 } 1010 #endif 1020 1011 1021 1012 int srmax, lrmax; … … 1034 1025 // ?? set spSpolyShort, reduce ??? 1035 1026 1036 initBuchMora(tempF, tempQ, strat); // currRing->nc->SCAQuotient() instead of Q == squares!!!!!!!1027 initBuchMora(tempF, tempQ, strat); // SCAQuotient(currRing) instead of Q == squares!!!!!!! 1037 1028 1038 1029 strat->posInT=posInT110; // !!! … … 1076 1067 //kTest(strat); 1077 1068 1078 assume(pNext(strat->P.p) != strat->tail); 1079 1080 // if( pNext(strat->P.p) == strat->tail ) 1081 // { 1082 // // deletes the int spoly and computes SPoly 1083 // pLmFree(strat->P.p); // ??? 1084 // strat->P.p = sca_SPoly(strat->P.p1, strat->P.p2, currRing); 1085 // } 1069 // assume(pNext(strat->P.p) != strat->tail); // !??? 1070 if(strat->P.IsNull()) continue; 1071 1072 1073 if( pNext(strat->P.p) == strat->tail ) 1074 { 1075 // deletes the int spoly and computes SPoly 1076 pLmFree(strat->P.p); // ??? 1077 strat->P.p = nc_CreateSpoly(strat->P.p1, strat->P.p2, currRing); 1078 } 1086 1079 1087 1080 if(strat->P.IsNull()) continue; … … 1222 1215 1223 1216 #if MYTEST 1224 PrintS("</sca_gr_bba>\n");1217 // PrintS("</sca_gr_bba>\n"); 1225 1218 #endif 1226 1219 … … 1236 1229 // if yes, make rGR a super-commutative algebra! 1237 1230 // NOTE: Factors of SuperCommutative Algebras are supported this way! 1238 bool sca_SetupQuotient(ring rGR, const ring rG) 1231 // 1232 // rG == NULL means that there is no separate base G-algebra in this case take rGR == rG 1233 bool sca_SetupQuotient(ring rGR, ring rG) 1239 1234 { 1240 1235 // return false; // test Plural … … 1243 1238 // checks... 1244 1239 ////////////////////////////////////////////////////////////////////////// 1240 if( rG == NULL ) 1241 rG = rGR; 1242 1245 1243 assume(rGR != NULL); 1246 1244 assume(rG != NULL); 1247 1248 1245 assume(rIsPluralRing(rG)); 1246 1247 1248 #if MYTEST 1249 PrintS("sca_SetupQuotient(rGR, rG)"); 1250 #endif 1249 1251 1250 1252 const int N = rG->N; … … 1253 1255 return false; 1254 1256 1255 #if MYTEST 1256 PrintS("sca_SetupQuotient(rGR, rG)"); 1257 #endif 1258 1259 1257 1260 1258 // if( (ncRingType(rG) != nc_skew) || (ncRingType(rG) != nc_comm) ) 1261 1259 // return false; 1262 1260 1261 #if OUTPUT 1262 PrintS("sca_SetupQuotient: qring?\n"); 1263 #endif 1264 1263 1265 if(rGR->qideal == NULL) // there will be a factor! 1264 1266 return false; 1265 1267 1266 if(rG->qideal != NULL) // we cannot change from factor to factor! 1268 #if OUTPUT 1269 PrintS("sca_SetupQuotient: qideal!!!\n"); 1270 #endif 1271 1272 if((rG->qideal != NULL) && (rG != rGR) ) // we cannot change from factor to factor at the time, sorry! 1267 1273 return false; 1268 1274 … … 1271 1277 int iAltVarStart = N+1; 1272 1278 1273 const ring rBase = rG->nc->basering; 1274 const matrix C = rG->nc->C; // live in rBase! 1275 1279 const ring rBase = rG->GetNC()->basering; 1280 const matrix C = rG->GetNC()->C; // live in rBase! 1281 1282 #if OUTPUT 1283 PrintS("sca_SetupQuotient: AltVars?!\n"); 1284 #endif 1285 1276 1286 for(int i = 1; i < N; i++) 1277 1287 { … … 1292 1302 if( !n_IsOne(c, rBase) ) 1293 1303 { 1304 #if OUTPUT 1305 Print("Wrong Coeff at: [%d, %d]\n", i, j); 1306 #endif 1294 1307 #if MYTEST 1295 1308 Print("Wrong Coeff at: [%d, %d]\n", i, j); … … 1301 1314 } 1302 1315 1316 #if MYTEST 1317 Print("AltVars?1: [%d, %d]\n", iAltVarStart, iAltVarEnd); 1318 #endif 1319 1320 1303 1321 if( (iAltVarEnd == -1) || (iAltVarStart == (N+1)) ) 1304 1322 return false; // either no alternating varables, or a single one => we are in commutative case! 1305 1323 1324 1306 1325 for(int i = 1; i < N; i++) 1307 1326 { … … 1315 1334 if( !n_IsMOne(c, rBase) ) 1316 1335 { 1336 #ifdef PDEBUG 1337 #if OUTPUT 1338 Print("Wrong Coeff at: [%d, %d]\n", i, j); 1339 #endif 1340 #endif 1341 1317 1342 #if MYTEST 1318 1343 Print("Wrong Coeff at: [%d, %d]\n", i, j); … … 1324 1349 if( !n_IsOne(c, rBase) ) 1325 1350 { 1351 #ifdef PDEBUG 1352 #if OUTPUT 1353 Print("Wrong Coeff at: [%d, %d]\n", i, j); 1354 #endif 1355 #endif 1326 1356 #if MYTEST 1327 1357 Print("Wrong Coeff at: [%d, %d]\n", i, j); … … 1333 1363 } 1334 1364 1365 #if MYTEST 1366 Print("AltVars!?: [%d, %d]\n", iAltVarStart, iAltVarEnd); 1367 #endif 1368 1335 1369 assume( 1 <= iAltVarStart ); 1336 1370 assume( iAltVarStart < iAltVarEnd ); 1337 1371 assume( iAltVarEnd <= N ); 1338 1372 1373 1374 1339 1375 bool bWeChangeRing = false; 1340 1376 // for sanity … … 1347 1383 } 1348 1384 1385 1349 1386 assume(rGR->qideal != NULL); 1350 assume(rG->qideal == NULL); 1387 // assume(rG->qideal == NULL); // ? 1351 1388 1352 1389 const ideal idQuotient = rGR->qideal; 1353 1390 1391 1392 #if MYTEST 1393 Print("Analyzing quotient ideal:\n"); 1394 idPrint(idQuotient); // in rG!!! 1395 #endif 1396 1397 1354 1398 // check for 1355 1399 // y_{iAltVarStart}^2, y_{iAltVarStart+1}^2, \ldots, y_{iAltVarEnd}^2 (iAltVarEnd > iAltVarStart) … … 1360 1404 for ( int i = iAltVarStart; (i <= iAltVarEnd) && bSCA; i++ ) 1361 1405 { 1362 poly square = p_ISet(1, r SaveRing);1363 p_SetExp(square, i, 2, r SaveRing); // square = var(i)^2.1364 p_Setm(square, r SaveRing);1406 poly square = p_ISet(1, rG); 1407 p_SetExp(square, i, 2, rG); // square = var(i)^2. 1408 p_Setm(square, rG); 1365 1409 1366 1410 // square = NF( var(i)^2 | Q ) 1367 1411 // NOTE: rSaveRing == currRing now! 1368 1412 // NOTE: there is no better way to check this in general! 1369 square = kNF(idQuotient, NULL, square, 0, 0); 1413 square = kNF(idQuotient, NULL, square, 0, 0); // must ran in currRing == rG! 1370 1414 1371 1415 if( square != NULL ) // var(i)^2 is not in Q? 1372 1416 { 1373 p_Delete(&square, r SaveRing);1417 p_Delete(&square, rG); 1374 1418 bSCA = false; 1375 1419 } … … 1385 1429 1386 1430 1387 1388 #if MYTEST 1389 Print("AltVars: [%d, %d]\n", iAltVarStart, iAltVarEnd); 1390 #endif 1391 1431 #ifdef PDEBUG 1432 #if OUTPUT 1433 Print("ScaVars!: [%d, %d]\n", iAltVarStart, iAltVarEnd); 1434 #endif 1435 #endif 1436 1392 1437 1393 1438 ////////////////////////////////////////////////////////////////////////// … … 1399 1444 1400 1445 if( idIs0(tempQ) ) 1401 rGR-> nc->SCAQuotient() = NULL;1446 rGR->GetNC()->SCAQuotient() = NULL; 1402 1447 else 1403 rGR-> nc->SCAQuotient() = idrMoveR(tempQ, rG, rGR); // deletes tempQ!1448 rGR->GetNC()->SCAQuotient() = idrMoveR(tempQ, rG, rGR); // deletes tempQ! 1404 1449 1405 1450 ncRingType( rGR, nc_exterior ); … … 1409 1454 1410 1455 1411 sca_p_ProcsSet(rGR, rGR->p_Procs); 1412 1456 nc_p_ProcsSet(rGR, rGR->p_Procs); // !!!!!!!!!!!!!!!!! 1413 1457 1414 1458 return true; … … 1440 1484 1441 1485 if( idIs0(tempQ) ) 1442 rGR-> nc->SCAQuotient() = NULL;1486 rGR->GetNC()->SCAQuotient() = NULL; 1443 1487 else 1444 rGR-> nc->SCAQuotient() = tempQ;1488 rGR->GetNC()->SCAQuotient() = tempQ; 1445 1489 1446 1490 ncRingType( rGR, nc_exterior ); … … 1450 1494 1451 1495 1452 sca_p_ProcsSet(rGR, rGR->p_Procs);1496 nc_p_ProcsSet(rGR, rGR->p_Procs); 1453 1497 1454 1498 if(rSaveRing != rGR) … … 1500 1544 1501 1545 if(Q == currQuotient) 1502 tempQ = currRing->nc->SCAQuotient();1546 tempQ = SCAQuotient(currRing); 1503 1547 1504 1548 // Q or tempQ will not be used below :((( … … 1603 1647 1604 1648 1605 assume(pNext(strat->P.p) != strat->tail); 1606 1607 /* if (pNext(strat->P.p) == strat->tail) 1649 // assume(pNext(strat->P.p) != strat->tail); 1650 1651 if(strat->P.IsNull()) continue; 1652 1653 if (pNext(strat->P.p) == strat->tail) 1608 1654 { 1609 1655 // deletes the short spoly 1610 1656 pLmFree(strat->P.p); 1657 1658 strat->P.p = nc_CreateSpoly(strat->P.p1, strat->P.p2, currRing); 1659 1660 /* 1611 1661 strat->P.p = NULL; 1662 1663 1612 1664 poly m1 = NULL, m2 = NULL; 1613 1665 … … 1629 1681 ksCreateSpoly(&(strat->P), NULL, strat->use_buckets, 1630 1682 strat->tailRing, m1, m2, strat->R); //????????? 1631 } 1632 else */1683 */ 1684 }// else 1633 1685 1634 1686 if (strat->P.p1 == NULL) … … 1920 1972 1921 1973 if(Q == currQuotient) 1922 tempQ = currRing->nc->SCAQuotient();1974 tempQ = SCAQuotient(currRing); 1923 1975 1924 1976 bool bIdHomog = id_IsSCAHomogeneous(tempF, NULL, NULL, currRing); // wCx == wCy == NULL! … … 2028 2080 2029 2081 // create the real Spoly 2030 assume(pNext(strat->P.p) != strat->tail); 2082 // assume(pNext(strat->P.p) != strat->tail); 2083 2084 if(strat->P.IsNull()) continue; 2085 2086 2087 if( pNext(strat->P.p) == strat->tail ) 2088 { 2089 // deletes the int spoly and computes SPoly 2090 pLmFree(strat->P.p); // ??? 2091 strat->P.p = nc_CreateSpoly(strat->P.p1, strat->P.p2, currRing); 2092 } 2093 2094 2031 2095 2032 2096 if (strat->P.p1 == NULL) … … 2203 2267 2204 2268 // non-commutaitve 2205 rGR-> nc->p_Procs.mm_Mult_p = sca_mm_Mult_p;2206 rGR-> nc->p_Procs.mm_Mult_pp = sca_mm_Mult_pp;2269 rGR->GetNC()->p_Procs.mm_Mult_p = sca_mm_Mult_p; 2270 rGR->GetNC()->p_Procs.mm_Mult_pp = sca_mm_Mult_pp; 2207 2271 2208 2272 … … 2212 2276 // Print("Local case => GB == mora!\n"); 2213 2277 #endif 2214 rGR-> nc->p_Procs.GB = sca_mora; // local ordering => Mora, otherwise - Buchberger!2278 rGR->GetNC()->p_Procs.GB = sca_mora; // local ordering => Mora, otherwise - Buchberger! 2215 2279 } 2216 2280 else … … 2219 2283 // Print("Global case => GB == bba!\n"); 2220 2284 #endif 2221 rGR-> nc->p_Procs.GB = sca_gr_bba; // sca_bba?2222 } 2223 2224 2225 // rGR-> nc->p_Procs.GlobalGB = sca_gr_bba;2226 // rGR-> nc->p_Procs.LocalGB = sca_mora;2227 2228 2229 // rGR-> nc->p_Procs.SPoly = sca_SPoly;2230 // rGR-> nc->p_Procs.ReduceSPoly = sca_ReduceSpoly;2285 rGR->GetNC()->p_Procs.GB = sca_bba; // sca_gr_bba; // sca_bba? // sca_bba; 2286 } 2287 2288 2289 // rGR->GetNC()->p_Procs.GlobalGB = sca_gr_bba; 2290 // rGR->GetNC()->p_Procs.LocalGB = sca_mora; 2291 2292 2293 // rGR->GetNC()->p_Procs.SPoly = sca_SPoly; 2294 // rGR->GetNC()->p_Procs.ReduceSPoly = sca_ReduceSpoly; 2231 2295 2232 2296 #if 0 … … 2240 2304 _p_procs->pp_Mult_mm = sca_pp_Mult_mm; 2241 2305 2242 r-> nc->mmMultP() = sca_mm_Mult_p;2243 r-> nc->mmMultPP() = sca_mm_Mult_pp;2244 2245 r-> nc->GB() = sca_gr_bba;2306 r->GetNC()->mmMultP() = sca_mm_Mult_p; 2307 r->GetNC()->mmMultPP() = sca_mm_Mult_pp; 2308 2309 r->GetNC()->GB() = sca_gr_bba; 2246 2310 /* 2247 2311 // ??????????????????????????????????????? coefficients swell... 2248 r-> nc->SPoly() = sca_SPoly;2249 r-> nc->ReduceSPoly() = sca_ReduceSpoly;2312 r->GetNC()->SPoly() = sca_SPoly; 2313 r->GetNC()->ReduceSPoly() = sca_ReduceSpoly; 2250 2314 */ 2251 // r-> nc->BucketPolyRed() = gnc_kBucketPolyRed;2252 // r-> nc->BucketPolyRed_Z()= gnc_kBucketPolyRed_Z;2315 // r->GetNC()->BucketPolyRed() = gnc_kBucketPolyRed; 2316 // r->GetNC()->BucketPolyRed_Z()= gnc_kBucketPolyRed_Z; 2253 2317 2254 2318 #endif -
kernel/sca.h
rf2b5839 r52e2f6 5 5 * Computer Algebra System SINGULAR * 6 6 ****************************************/ 7 /* $Id: sca.h,v 1.1 1 2008-05-15 17:24:37motsak Exp $ */7 /* $Id: sca.h,v 1.12 2008-06-10 10:17:33 motsak Exp $ */ 8 8 9 9 #include <ring.h> … … 32 32 // SCA! 33 33 #ifdef HAVE_PLURAL 34 return r-> nc->SCAQuotient();34 return r->GetNC()->SCAQuotient(); 35 35 #else 36 36 // for sainity … … 48 48 assume(rIsSCA(r)); 49 49 50 return (r-> nc->FirstAltVar());50 return (r->GetNC()->FirstAltVar()); 51 51 }; 52 52 … … 55 55 assume(rIsSCA(r)); 56 56 57 return (r-> nc->LastAltVar());57 return (r->GetNC()->LastAltVar()); 58 58 }; 59 59 … … 64 64 assume(rIsSCA(r)); 65 65 66 r-> nc->FirstAltVar() = n;66 r->GetNC()->FirstAltVar() = n; 67 67 }; 68 68 … … 71 71 assume(rIsSCA(r)); 72 72 73 r-> nc->LastAltVar() = n;73 r->GetNC()->LastAltVar() = n; 74 74 }; 75 75 … … 184 184 // should be used only inside nc_SetupQuotient! 185 185 // Check whether this our case: 186 // 1. rG is a commutative polynomial ring \otimes anticommutative algebra 186 // 1. rG is a commutative polynomial ring \otimes anticommutative algebra 187 187 // 2. factor ideal rGR->qideal contains squares of all alternating variables. 188 188 // 189 189 // if yes, make rGR a super-commutative algebra! 190 190 // NOTE: Factors of SuperCommutative Algebras are supported this way! 191 bool sca_SetupQuotient(ring rGR, const ring rG); 191 // 192 // rG == NULL means that there is no separate base G-algebra in this case take rGR == rG 193 bool sca_SetupQuotient(ring rGR, ring rG); 192 194 193 195 #endif // PLURAL_INTERNAL_DECLARATIONS -
kernel/structs.h
rf2b5839 r52e2f6 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: structs.h,v 1.4 4 2008-05-09 09:17:57 SingularExp $ */6 /* $Id: structs.h,v 1.45 2008-06-10 10:17:33 motsak Exp $ */ 7 7 /* 8 8 * ABSTRACT … … 474 474 int *MTsize; // size 0.. (rVar()*rVar()-1)/2 475 475 476 // IsSkewConstantindicates whethere coeffs C_ij are all equal, effective together with nc_type=nc_skew 476 // IsSkewConstant indicates whethere coeffs C_ij are all equal, 477 // effective together with nc_type=nc_skew 477 478 int IsSkewConstant; 478 479 … … 631 632 ring algring; 632 633 #ifdef HAVE_PLURAL 633 nc_struct *nc; 634 private: 635 nc_struct* _nc; // private 636 public: 637 inline const nc_struct* GetNC() const { return _nc; }; // public!!! 638 inline nc_struct*& GetNC() { return _nc; }; // public!!! 634 639 #endif 635 640 }; -
kernel/syz.cc
rf2b5839 r52e2f6 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: syz.cc,v 1.1 2 2007-02-02 15:19:46motsak Exp $ */4 /* $Id: syz.cc,v 1.13 2008-06-10 10:17:33 motsak Exp $ */ 5 5 6 6 /* … … 621 621 if( rIsSCA(currRing) ) 622 622 { 623 currQuotient = currRing->nc->SCAQuotient();623 currQuotient = SCAQuotient(currRing); 624 624 currRing->qideal = currQuotient; 625 625
Note: See TracChangeset
for help on using the changeset viewer.