Changeset 52e2f6 in git


Ignore:
Timestamp:
Jun 10, 2008, 12:17:33 PM (16 years ago)
Author:
Motsak Oleksandr <motsak@…>
Branches:
(u'spielwiese', 'd1b01e9d51ade4b46b745d3bada5c5f3696be3a8')
Children:
28325ab307b0d45f178c4ce869547de7d3f3faa7
Parents:
f2b58394b7c0b28984794adfcef85f56f72e35bf
Message:
*motsak: major redesign of NC Subsystem, maybe something more...


git-svn-id: file:///usr/local/Singular/svn/trunk@10739 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
kernel
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • kernel/RULES

    rf2b5839 r52e2f6  
    11* never use fopen, but myfopen, in order to open text files
    22
    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
    46
    57* never allocate memory with 0 as size request
  • kernel/gr_kstd2.cc

    rf2b5839 r52e2f6  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: gr_kstd2.cc,v 1.13 2007-02-07 10:49:39 Singular Exp $ */
     4/* $Id: gr_kstd2.cc,v 1.14 2008-06-10 10:17:31 motsak Exp $ */
    55/*
    66*  ABSTRACT -  Kernel: noncomm. alg. of Buchberger
     
    500500      {
    501501        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);
    503503      }
    504504      else
     
    814814}
    815815
     816#define MYTEST 0
     817
    816818ideal gnc_gr_bba(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat)
    817819{
     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   
    818841  assume(pOrdSgn != -1); // no mora!!! it terminates only for global ordering!!! (?)
    819842
     
    835858  srmax = strat->sl;
    836859  reduc = olddeg = lrmax = 0;
     860
    837861  /* compute------------------------------------------------------- */
    838862  while (strat->Ll >= 0)
    839863  {
    840864    if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/
     865
    841866    if (TEST_OPT_DEBUG) messageSets(strat);
     867
    842868    if (strat->Ll== 0) strat->interpt=TRUE;
    843869    if (TEST_OPT_DEGBOUND
     
    858884    strat->Ll--;
    859885    //kTest(strat);
     886
     887    if (strat->P.p != NULL)
    860888    if (pNext(strat->P.p) == strat->tail)
    861889    {
     
    863891      pLmFree(strat->P.p);
    864892      /* 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     
    870900      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   
    872917    if (strat->P.p != NULL)
    873918    {
    874919      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(),
    876921              &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
    877932      /* reduction of the element chosen from L */
    878933      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
    879942    }
    880943    if (strat->P.p != NULL)
     
    913976              if (TEST_OPT_DEBUG)
    914977              {
    915                 PrintS("new s:");
    916                 wrp(strat->P.p);
     978                PrintS("new s:"); wrp(strat->P.p);
    917979                PrintLn();
     980#if MYTEST
     981                Print("s: "); pWrite(strat->P.p);
     982#endif
     983               
    918984              }
    919985              // kTest(strat);
    920986              //
    921987              enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat);
     988             
    922989              if (strat->sl==-1) pos=0;
    923990              else pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
     991             
    924992              strat->enterS(strat->P,pos,strat,-1);
    925993            }
     
    9771045/*   Print("Total pairs considered:%d\n",zaehler); zaehler=0; */
    9781046#endif /*PDEBUG*/
     1047
     1048#if MYTEST
     1049  PrintS("</gnc_gr_bba>\n");
     1050#endif
     1051
    9791052  return (strat->Shdl);
    9801053}
  • kernel/gring.cc

    rf2b5839 r52e2f6  
    77 *  Author:  levandov (Viktor Levandovsky)
    88 *  Created: 8/00 - 11/00
    9  *  Version: $Id: gring.cc,v 1.53 2008-05-15 17:24:36 motsak Exp $
     9 *  Version: $Id: gring.cc,v 1.54 2008-06-10 10:17:31 motsak Exp $
    1010 *******************************************************************/
     11
     12#define OM_CHECK 4
     13#define OM_TRACK 5
     14
    1115#include "mod2.h"
    1216
     
    2630#include "p_Mult_q.h"
    2731
     32#include "pInline1.h"
     33   
    2834#include "gring.h"
    2935#include "sca.h"
     36
     37
     38#define MYTEST 0
     39#define OUTPUT 0
     40
    3041
    3142// dirty tricks:
     
    8596//  poly nc_p_Plus_mm_Mult_qq (poly p, const poly m, const poly q, int &lp, int lq, const ring r);
    8697#endif
     98
     99
     100
     101/*2
     102* returns the LCM of the head terms of a and b
     103*/
     104poly 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
     129poly 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};
    87146
    88147
     
    254313    if (side)
    255314        {
    256       Print("Multiplication in the left module from the right");
     315      Print("gnc_p_Mult_mm: Multiplication in the left module from the right");
    257316    }
    258317#endif
     
    379438  if (ncRingType(r)==nc_skew)
    380439  {
    381     if (r->nc->IsSkewConstant==1)
     440    if (r->GetNC()->IsSkewConstant==1)
    382441    {
    383442      int tpower=0;
     
    395454        }
    396455      }
    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);
    398457      nPower(cff,tpower,&tmp_num);
    399458      n_Delete(&cff,r);
     
    413472            {
    414473              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);
    416475              nPower(cff,cpower,&tmp_num);
    417476              cff = nMult(totcff,tmp_num);
     
    443502    /* g is univariate monomial */
    444503  {
    445     /*    if (ri->nc->type==nc_skew) -- postpone to TU */
     504    /*    if (ri->GetNC()->type==nc_skew) -- postpone to TU */
    446505    out = gnc_mm_Mult_uu(F,jG,G[jG],r);
    447506    freeT(F,rN);
     
    627686  /* Now: F is mono with >=2 exponents, jG<iF */
    628687  /* check the quasi-commutative case */
    629 //   matrix LCOM=r->nc->COM;
     688//   matrix LCOM=r->GetNC()->COM;
    630689//   number rescoef=n_Init(1,r);
    631690//   number tmpcoef=n_Init(1,r);
     
    826885  int k,m;
    827886  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 */
    829888
    830889  poly x=pOne();p_SetExp(x,j,1,r);p_Setm(x,r);
     
    897956  /*  if ((a==0)||(b==0)||(i<=j)) return(out); */
    898957
    899   if (MATELEM(r->nc->COM,j,i)!=NULL)
     958  if (MATELEM(r->GetNC()->COM,j,i)!=NULL)
    900959    /* commutative or quasicommutative case */
    901960  {
     
    903962    p_AddExp(out,j,b,r);
    904963    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 */
    906965    {
    907966      return(out);
     
    909968    else
    910969    {
    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 */
    912971      nPower(tmp_number,a*b,&tmp_number);
    913972      p_SetCoeff(out,tmp_number,r);
     
    922981  int rN=r->N;
    923982  int vik = UPMATELEM(j,i,rN);
    924   int cMTsize=r->nc->MTsize[vik];
     983  int cMTsize=r->GetNC()->MTsize[vik];
    925984  int newcMTsize=0;
    926985  newcMTsize=si_max(a,b);
     
    928987  if (newcMTsize<=cMTsize)
    929988  {
    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);
    931990    if (out !=NULL) return (out);
    932991  }
     
    9441003      for (m=1;m<=cMTsize;m++)
    9451004      {
    946     out = MATELEM(r->nc->MT[UPMATELEM(j,i,rN)],k,m);
     1005    out = MATELEM(r->GetNC()->MT[UPMATELEM(j,i,rN)],k,m);
    9471006        if ( out != NULL )
    9481007        {
    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)*/
    9501009          //           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);
    9531012        }
    9541013      }
    9551014    }
    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;
    9581017    tmp=NULL;
    959     r->nc->MTsize[UPMATELEM(j,i,rN)] = newcMTsize;
     1018    r->GetNC()->MTsize[UPMATELEM(j,i,rN)] = newcMTsize;
    9601019  }
    9611020  /* The update of multiplication matrix is finished */
     
    9711030  int k,m;
    9721031  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 */
    9741033
    9751034  poly x=pOne();p_SetExp(x,j,1,r);p_Setm(x,r);/* var(j); */
     
    11661225poly gnc_ReduceSpolyOld(const poly p1, poly p2/*,poly spNoether*/, const ring r)
    11671226{
     1227  assume(p_LmDivisibleBy(p1, p2, r));
     1228
    11681229  if (p_GetComp(p1,r)!=p_GetComp(p2,r)
    11691230  && (p_GetComp(p1,r)!=0)
     
    12171278poly gnc_ReduceSpolyNew(const poly p1, poly p2, const ring r)
    12181279{
     1280  assume(p_LmDivisibleBy(p1, p2, r));
     1281
    12191282  const long lCompP1 = p_GetComp(p1,r);
    12201283  const long lCompP2 = p_GetComp(p2,r);
     
    13651428poly gnc_CreateSpolyNew(poly p1, poly p2/*,poly spNoether*/, const ring r)
    13661429{
     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 
    13671441  const long lCompP1 = p_GetComp(p1,r);
    13681442  const long lCompP2 = p_GetComp(p2,r);
     
    13761450  }
    13771451
    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 */
    13791461//   {
    13801462//     return(nc_p_Bracket_qq(pCopy(p2),p1));
    13811463//   }
    13821464
    1383   poly pL=pOne();
    1384 
    1385   poly m1=pOne();
    1386   poly m2=pOne();
    1387 
    1388   pLcm(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);
    13911473
    13921474#ifdef PDEBUG
     
    13941476#endif
    13951477
    1396   p_ExpVectorDiff(m1,pL,p1,r);                  // m1 = pL / lm(p1)
     1478  p_ExpVectorDiff(m1, pL, p1, r);                  // m1 = pL / lm(p1)
    13971479  //p_SetComp(m1,0,r);
    13981480  //p_Setm(m1,r);
     1481
    13991482#ifdef PDEBUG
    14001483  p_Test(m1,r);
    14011484#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)
    14041488
    14051489  //p_SetComp(m2,0,r);
     
    14081492  p_Test(m2,r);
    14091493#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
    14101535
    14111536  p_Delete(&pL,r);
     
    14151540  poly M2    = nc_mm_Mult_p(m2,p_Head(p2,r),r); // M2 = m2 * lt(p2)
    14161541
     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 
    14171552  if(M1 == NULL || M2 == NULL)
    14181553  {
     
    14591594//   {
    14601595  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
    14611601  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
    14621616  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!
    14641628//   }
    14651629//   n_Delete(&MinusOne,r);
     
    14681632  p_SetCoeff(m2,C1,r);                           // lc(m2) = C1!!!
    14691633
    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 
    14761656  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
    14791694                                                 // delete M1
    14801695
     
    14861701#endif
    14871702
    1488   if (M2!=NULL) pCleardenom(M2);
     1703  if (M2!=NULL) pCleardenom(M2); //?
    14891704//  if (M2!=NULL) pContent(M2);
    14901705
     
    15421757poly nc_CreateShortSpoly(poly p1, poly p2, const ring r)
    15431758{
    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!"); // !!!!
    15481771#endif
    15491772    return(NULL);
    15501773  }
    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
    15541780#ifdef PDEBUG
    15551781  p_Test(m,r);
    15561782#endif
     1783 
    15571784  return(m);
    15581785}
     
    16021829#ifdef PDEBUG
    16031830  pTest(p);
    1604 //   Print("p: "); pWrite(p);
     1831#if MYTEST
     1832  Print("p: "); pWrite(p);
     1833#endif
    16051834#endif
    16061835
     
    16111840  const poly pLmB = kBucketGetLm(b); // no new copy!
    16121841
    1613 
     1842  assume( pLmB != NULL );
     1843 
    16141844#ifdef PDEBUG
    16151845  pTest(pLmB);
    1616 //   Print("pLmB: "); pWrite(pLmB);
     1846
     1847#if MYTEST
     1848  Print("pLmB: "); pWrite(pLmB);
     1849#endif
    16171850#endif
    16181851
     
    16221855#ifdef PDEBUG
    16231856  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);
    16271863  pDelete(&m);
    16281864
    1629   const number n = pGetCoeff(pp);
     1865  assume( pp != NULL );
     1866  const number n = pGetCoeff(pp); // bug!
    16301867  number nn;
    16311868
     
    17491986
    17501987
    1751 #define MYTEST 0
    1752 
    17531988inline void nc_PolyPolyRedNew(poly &b, poly p, number *c)
    17541989  // reduces b with p, do not delete both
     
    18642099  /* returns [p,q], destroys p */
    18652100{
     2101 
    18662102  if (!rIsPluralRing(currRing)) return(NULL);
    18672103  if (pComparePolys(p,q)) return(NULL);
     
    19352171          /* compute [ x_j^M1[j],x_i^M2[i] ] */
    19362172          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)*/
    19382174          { bres=NULL; }
    19392175          else
     
    20512287        Print("Reducing p: "); // !
    20522288        p_Write(p, currRing);
    2053 
    20542289        Print("With q: "); // !
    20552290        p_Write(q, currRing);
     
    22032438  /* i<j */
    22042439  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)];
    22072442  /*  return(M); */
    22082443  int sizeofres;
     
    22582493}
    22592494
    2260 void ncKill(ring r)
    2261   /* kills the nc extension of ring r */
    2262 {
     2495void 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
    22632508  int i,j;
    22642509  int rN=r->N;
     
    22692514      for(j=i+1;j<=rN;j++)
    22702515      {
    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);
    22722517      }
    22732518    }
    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);
    22912536  }
    22922537
     
    22942539}
    22952540
    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 }
     2541inline void ncCleanUp(nc_struct* p)
     2542{
     2543  assume(p != NULL);
     2544  omFreeSize((ADDRESS)p,sizeof(nc_struct));
     2545}
     2546
     2547inline 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
     2556void 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
    23022567
    23032568poly nc_p_CopyGet(poly a, const ring r)
    23042569/* for use in getting the mult. matrix elements*/
    23052570/* 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 */
    23072572/* to its image in NC ring */
    23082573{
     
    23152580  }
    23162581  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));
    23182583  else
    23192584  {
    2320     return(prCopyR_NoSort(a,r->nc->basering,r));
     2585    return(prCopyR_NoSort(a,r->GetNC()->basering,r));
    23212586  }
    23222587}
     
    23262591/* ring r must be a currRing! */
    23272592/* 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 */
    23292594{
    23302595  if (r != currRing)
     
    23372602
    23382603  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));
    23402605  else
    23412606  {
    2342     return(prCopyR_NoSort(a,r,r->nc->basering));
     2607    return(prCopyR_NoSort(a,r,r->GetNC()->basering));
    23432608  }
    23442609}
     
    23722637    if (ExpVar[j]==0)
    23732638    {
    2374       test = nc_p_CopyGet(MATELEM(r->nc->D,i,j),r);
     2639      test = nc_p_CopyGet(MATELEM(r->GetNC()->D,i,j),r);
    23752640      while (test!=NULL)
    23762641      {
     
    23992664}
    24002665
    2401 BOOLEAN nc_CheckOrdCondition(matrix D, ring r)
     2666
     2667BOOLEAN gnc_CheckOrdCondition(matrix D, ring r)
    24022668/* returns TRUE if there were errors */
    24032669/* 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 */
    24052671/* to be executed in a currRing */
    24062672{
     
    24502716
    24512717
    2452 BOOLEAN nc_CallPlural(matrix CCC, matrix DDD, poly CCN, poly DDN, ring r)
     2718BOOLEAN 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)
    24532724  /* returns TRUE if there were errors */
    24542725  /* analyze inputs, check them for consistency */
    24552726  /* detects nc_type, DO NOT initialize multiplication but call for it at the end*/
    24562727  /* 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 
    24612774#ifndef NDEBUG
    24622775  idTest((ideal)CCC);
     
    24662779#endif
    24672780
    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);
    25022786
    25032787#ifndef NDEBUG
     
    25082792#endif
    25092793
    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
    25172815  if ((CCC != NULL) && ( (MATCOLS(CCC)==1) || MATROWS(CCC)==1 ) )
    25182816  {
     
    25232821    if ((CCC != NULL) && ( (MATCOLS(CCC)!=r->N) || (MATROWS(CCC)!=r->N) ))
    25242822    {
    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);
    25282827      return TRUE;
    25292828    }
     
    25322831  if (( CCN != NULL) && (CN == NULL)) CN = CCN;
    25332832
    2534   /* initialition of the matrix D */
    2535   /* check the correctness of arguments */
    2536 
     2833  // check D
    25372834  if ((DDD != NULL) && ( (MATCOLS(DDD)==1) || MATROWS(DDD)==1 ) )
    25382835  {
     
    25442841    {
    25452842      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);
    25482846      return TRUE;
    25492847    }
    25502848  }
     2849
    25512850  if (( DDD != NULL) && (DD == NULL)) DD = DDD; // mpCopy(DDD); // ???
    25522851  if (( DDN != NULL) && (DN == NULL)) DN = DDN;
    25532852
    2554   /* further checks */
    2555 
    2556   // all data in 'save'!
    2557 
     2853  // further checks and some analysis:
     2854  // all data in 'curr'!
    25582855  if (CN != NULL)       /* create matrix C = CN * Id */
    25592856  {
    2560     nN = p_GetCoeff(CN,save);
    2561     if (n_IsZero(nN,save))
     2857    nN = p_GetCoeff(CN, curr);
     2858    if (n_IsZero(nN, curr))
    25622859    {
    25632860      Werror("Incorrect input : zero coefficients are not allowed");
    2564       ncCleanUp(r);
    2565       rChangeCurrRing(save);
     2861
     2862      if( currRing != save )
     2863        rChangeCurrRing(save);
    25662864      return TRUE;
    25672865    }
    2568     if (n_IsOne(nN, save))
    2569     {
    2570       ncRingType(r, nc_lie);
    2571     }
     2866
     2867    if (n_IsOne(nN, curr))
     2868      nctype = nc_lie;
    25722869    else
    2573     {
    2574       ncRingType(r, nc_general);
    2575     }
    2576     r->nc->IsSkewConstant = 1;
     2870      nctype = nc_general;
     2871
     2872    IsSkewConstant = true;
     2873
    25772874    C = mpNew(r->N,r->N); // ring independent!
     2875    bCnew = true;
     2876
    25782877    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++)
    25802894      for(j=i+1; j<=r->N; j++)
    25812895      {
    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)
    26002897          qN = NULL;
    26012898        else
    2602           qN = p_GetCoeff(MATELEM(C,i,j),r);
     2899          qN = p_GetCoeff(MATELEM(CC,i,j),curr);
    26032900
    26042901        if ( qN == NULL )   /* check the consistency: Cij!=0 */
    2605           // find also illegal pN
     2902        // find also illegal pN
    26062903        {
    26072904          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);
    26102908          return TRUE;
    26112909        }
    2612         if (!n_Equal(pN,qN, r)) tmpIsSkewConstant = 0;
     2910
     2911        if (!n_Equal(pN, qN, curr)) tmpIsSkewConstant = false;
    26132912      }
    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;
    26192918    }
    26202919    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;
    26242928  }
    26252929
    26262930  /* 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
    26312935    if (DN  == NULL)
    26322936    {
    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)
    26342954      {
    2635         ncRingType(r, nc_comm); /* it was nc_skew earlier */
     2955        b = false;
     2956        break;
    26362957      }
     2958
     2959    if (b) // D == NULL!!!
     2960    {
     2961      if ( (nctype == nc_lie) || (nctype == nc_undef) )
     2962        nctype = nc_comm; /* it was nc_skew earlier */
    26372963      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 )
    26633029    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);
    26733032}
    26743033
    26753034//////////////////////////////////////////////////////////////////////////////
    2676 BOOLEAN nc_InitMultiplication(ring r)
     3035BOOLEAN gnc_InitMultiplication(ring r, bool bSetupQuotient)
    26773036{
    26783037  /* returns TRUE if there were errors */
    26793038  /* 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 */
    26823041  if (rVar(r)==1)
    26833042  {
    26843043    ncRingType(r, nc_comm);
    2685     r->nc->IsSkewConstant=1;
     3044    r->GetNC()->IsSkewConstant=1;
    26863045    return FALSE;
    26873046  }
     3047
    26883048  ring save = currRing;
     3049
    26893050  int WeChangeRing = 0;
    26903051  if (currRing!=r)
     
    26933054    WeChangeRing = 1;
    26943055  }
    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!
    26973058
    26983059  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);
    27033064  poly p,q;
    27043065  short DefMTsize=7;
     
    27103071    for(j=i+1; j<=r->N; j++)
    27113072    {
    2712       if ( MATELEM(r->nc->D,i,j) == NULL ) /* quasicommutative case */
     3073      if ( MATELEM(r->GetNC()->D,i,j) == NULL ) /* quasicommutative case */
    27133074      {
    27143075        /* 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);
    27173078      }
    27183079      else /* pure noncommutative case */
     
    27223083        p_Delete(&(MATELEM(COM,i,j)),r);
    27233084        //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);
    27263087      }
    27273088      /* set MT[i,j,1,1] to c_i_j*x_i*x_j + D_i_j */
    27283089      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);
    27313092      p_SetExp(p,i,1,r);
    27323093      p_SetExp(p,j,1,r);
    27333094      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);
    27363097      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);
    27383099      p_Delete(&p,r);
    27393100      // p = NULL;// done by p_Delete
     
    27453106    {
    27463107      //      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;
    27493110    }
    27503111    if (IsNonComm==0)
    27513112    {
    27523113      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)
    27623127    rChangeCurrRing(save);
    2763   }
     3128
    27643129  return FALSE;
    27653130}
     
    27683133{
    27693134  // "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
    27773140
    27783141
    27793142  // 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;
    27873150
    27883151
    27893152#if 0
    27903153  // 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;
    27963159#else
    27973160  // 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;
    28033166#endif
    28043167
     
    28173180    _p_procs->p_Minus_mm_Mult_qq= NULL; // gnc_p_Minus_mm_Mult_qq_ign;
    28183181
    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;
    28263189
    28273190#endif
     
    31143477
    31153478
     3479// creates a commutative nc extension; "converts" comm.ring to a Plural ring
    31163480ring nc_rCreateNCcomm(ring r)
    3117   /* creates a commutative nc extension; "converts" comm.ring to a Plural ring */
    31183481{
    31193482  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!?!
    31363485  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 
    31553494  return r;
    31563495}
     
    32843623
    32853624
    3286 #endif
    3287 
    32883625
    32893626// int Commutative_Context(ring r, leftv expression)
     
    32963633// int Comm_Context_Poly(ring r, poly p)
    32973634// {
    3298 //   poly COMM=r->nc->COMM;
     3635//   poly COMM=r->GetNC()->COMM;
    32993636//   poly pp=pOne();
    33003637//   memset(pp->exp,0,r->ExpL_Size*sizeof(long));
  • kernel/gring.h

    rf2b5839 r52e2f6  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: gring.h,v 1.20 2007-02-16 11:07:10 motsak Exp $ */
     6/* $Id: gring.h,v 1.21 2008-06-10 10:17:31 motsak Exp $ */
    77/*
    88* ABSTRACT additional defines etc for --with-plural
     
    1111#ifdef HAVE_PLURAL
    1212
     13
    1314#include <structs.h>
    1415#include <ring.h>
    1516
    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
     19BOOLEAN 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
    2028BOOLEAN 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
    2234BOOLEAN rIsLikeOpposite(ring rBase, ring rCandidate);
    2335
     
    2941// this function should be used inside QRing definition!
    3042// we go from rG into factor ring rGR with factor ideal rGR->qideal.
    31 bool nc_SetupQuotient(ring rGR, const ring rG);
     43bool nc_SetupQuotient(ring rGR, const ring rG = NULL); // rG == NULL means that there is no base G-algebra
    3244
    3345
     
    3749ring nc_rCreateNCcomm(ring r);
    3850
    39 void ncCleanUp(ring r); /* smaller than kill */
    40 void ncKill(ring r);
    41 
     51void ncCleanUp(nc_struct* p); // just free memory!
     52void ncCleanUp(ring r); // smaller than kill: just free mem
     53void ncKill(ring r); // complete destructor
     54
     55BOOLEAN 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''!
     61void nc_rCopy0(ring res, const ring r);
    4262
    4363// for p_Minus_mm_Mult_qq in pInline2.h
     
    90110
    91111
     112
     113// returns the LCM of the head terms of a and b with given component
     114poly 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
     117poly p_Lcm(const poly a, const poly b, const ring r);
     118
     119
     120
    92121// //////////////////////////////////////////////////////////////////////// //
    93122// NC inlines
    94123
    95 
    96 
    97 inline void ncRingType(ring r, nc_type t)
    98 {
    99   assume((r != NULL) && (r->nc != NULL));
    100   r->nc->type = t;
     124inline nc_type& ncRingType(nc_struct* p)
     125{
     126  assume(p!=NULL);
     127  return (p->type);
    101128};
    102129
    103 inline nc_type ncRingType(ring r)
    104 {
    105   assume(rIsPluralRing(r));
    106 
    107   return (r->nc->type);
     130inline nc_type& ncRingType(ring r) // get and set
     131{
     132  assume(rIsPluralRing(r));
     133  return (ncRingType(r->GetNC()));
    108134};
     135
     136inline void ncRingType(ring r, nc_type t) // Set
     137{
     138  assume((r != NULL) && (r->GetNC() != NULL));
     139  ncRingType(r) = t;
     140};
     141
     142inline nc_struct*& GetNC(ring r)
     143{
     144  return r->GetNC();
     145};
    109146
    110147
     
    117154{
    118155  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);
    121158//  return pp_Mult_mm( p, m, r);
    122159}
     
    127164{
    128165  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);
    131168//   return p_Mult_mm( p, m, r);
    132169}
     
    135172{
    136173  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);
    139176}
    140177
     
    142179{
    143180  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);
    146186}
    147187
     
    150190{
    151191  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);
    154194}
    155195*/
     
    161201//   return gnc_kBucketPolyRedNew(b, p, c);
    162202
    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);
    165205}
    166206
     
    171211//   return gnc_kBucketPolyRed_ZNew(b, p, c);
    172212
    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);
    175215
    176216}
     
    180220  assume(rIsPluralRing(currRing));
    181221
    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);
    184224
    185225/*
    186226  if (pOrdSgn==-1)
    187227  {
    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);
    190230  } else
    191231  {
    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);
    194234  }
    195235*/
     
    205245// we need nc_gr_initBba for sca_gr_bba and gr_bba.
    206246void nc_gr_initBba(ideal F,kStrategy strat);
     247BOOLEAN gnc_InitMultiplication(ring r, bool bSetupQuotient = false); // just for a moment
    207248
    208249#endif // PLURAL_INTERNAL_DECLARATIONS
  • kernel/ideals.cc

    rf2b5839 r52e2f6  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: ideals.cc,v 1.55 2008-04-04 09:51:37 Singular Exp $ */
     4/* $Id: ideals.cc,v 1.56 2008-06-10 10:17:31 motsak Exp $ */
    55/*
    66* ABSTRACT - all basic methods to manipulate ideals
     
    2626
    2727
     28#define MYTEST 0
     29
     30
    2831/* #define WITH_OLD_MINOR */
    2932#define pCopy_noCheck(p) pCopy(p)
     
    6568void idShow(ideal id)
    6669{
    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      }
    7482    }
    7583  }
     
    12991307  }
    13001308  h2->rank = syzcomp+i+1;
     1309
     1310#if MYTEST
     1311#ifdef RDEBUG
     1312  Print("Prepare::h2: ");
     1313  idPrint(h2);
     1314#endif 
     1315#endif
     1316 
    13011317  for (j=0; j<=i; j++)
    13021318  {
     
    13161332#ifdef PDEBUG
    13171333  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 
    13181343#endif
    1319   h3=kStd(h2,currQuotient,h,w,NULL,syzcomp);
     1344 
     1345#endif
     1346
     1347 
     1348  h3 = kStd(h2,currQuotient,h,w,NULL,syzcomp);
    13201349  idDelete(&h2);
    13211350  return h3;
     
    15281557  if (k==1) verbose |=Sy_bit(V_IDLIFT);
    15291558
    1530   ring orig_ring=currRing;
    1531   ring syz_ring=rCurrRingAssure_SyzComp();
     1559  ring orig_ring = currRing;
     1560  ring syz_ring = rCurrRingAssure_SyzComp();
    15321561  rSetSyzComp(k);
    15331562
     1563 
     1564#if MYTEST
     1565#ifdef RDEBUG
     1566  rWrite(syz_ring);
     1567  rDebugPrint(syz_ring);
     1568#endif 
     1569#endif
     1570 
    15341571  ideal s_h1=h1;
    15351572
     
    15391576    s_h1 = h1;
    15401577
     1578#if MYTEST
     1579#ifdef RDEBUG
     1580  Print("Input: ");
     1581  idPrint(s_h1);
     1582#endif 
     1583#endif
     1584 
     1585
    15411586  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
    15421595  ideal s_h2 = idInit(IDELEMS(s_h3), s_h3->rank);
    15431596
     1597#if MYTEST
     1598#ifdef RDEBUG
     1599  Print("Temp: ");
     1600  idPrint(s_h2);
     1601#endif 
     1602#endif
     1603 
    15441604  if (w!=NULL) delete w;
    15451605  i = 0;
     1606
    15461607  for (j=0; j<IDELEMS(s_h3); j++)
    15471608  {
     
    15711632
    15721633  idSkipZeroes(s_h3);
     1634
     1635#if MYTEST
     1636#ifdef RDEBUG
     1637  Print("Input'': ");
     1638  idPrint(s_h3);
     1639#endif 
     1640#endif
     1641
    15731642  j = IDELEMS(s_h1);
    15741643
     1644
     1645#if MYTEST
     1646#ifdef RDEBUG
     1647  Print("Temp Result: ");
     1648  idPrint(s_h2);
     1649#endif 
     1650#endif
     1651
     1652 
    15751653  if (syz_ring!=orig_ring)
    15761654  {
     
    16091687    s_h3->m[i] = prMoveR_NoSort(s_h3->m[i], syz_ring);
    16101688  }
     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 
    16111700
    16121701  if (syz_ring!=orig_ring) rKill(syz_ring);
     
    23282417  if (idIs0(h1)) return idInit(1,h1->rank);
    23292418#ifdef HAVE_PLURAL
    2330   if (rIsPluralRing(currRing))
     2419  if (rIsPluralRing(origR))
    23312420    /* in the NC case, we have to check the admissibility of */
    23322421    /* the subalgebra to be intersected with */
    23332422  {
    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))
    23372426      {
    23382427        WerrorS("no elimination is possible: subalgebra is not admissible");
     
    23622451  block0[0] = 1;
    23632452  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));
    23662455  for (j=0;j<rVar(origR);j++)
    23672456    if (pGetExp(delVar,j+1)!=0) wv[0][j]=1;
     
    23762465  tmpR->block1 = block1;
    23772466  tmpR->wvhdl = wv;
     2467
    23782468  rComplete(tmpR, 1);
    23792469
    23802470#ifdef HAVE_PLURAL
    23812471  /* 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!
    23862475    {
    23872476      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     {
    24012477      // cleanup
    24022478      rDelete(tmpR);
    24032479      if (w!=NULL)
    2404       {
    24052480        delete w;
    2406       }
    24072481      return idCopy(h1);
    24082482    }
  • kernel/kstd1.cc

    rf2b5839 r52e2f6  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kstd1.cc,v 1.34 2008-03-20 11:22:44 Singular Exp $ */
     4/* $Id: kstd1.cc,v 1.35 2008-06-10 10:17:31 motsak Exp $ */
    55/*
    66* ABSTRACT:
     
    19591959  kStrategy strat=new skStrategy;
    19601960  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
    19611978  if (pOrdSgn==-1)
    1962     p=kNF1(F,Q,p,strat,lazyReduce);
     1979    res=kNF1(F,Q,pp,strat,lazyReduce);
    19631980  else
    1964     p=kNF2(F,Q,p,strat,lazyReduce);
     1981    res=kNF2(F,Q,pp,strat,lazyReduce);
    19651982  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;
    19671990}
    19681991
     
    19761999  kStrategy strat=new skStrategy;
    19772000  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
    19782015  if (pOrdSgn==-1)
    1979     res=kNF1(F,Q,p,strat,lazyReduce);
     2016    res=kNF1(F,Q,pp,strat,lazyReduce);
    19802017  else
    1981     res=kNF2(F,Q,p,strat,lazyReduce);
     2018    res=kNF2(F,Q,pp,strat,lazyReduce);
    19822019  delete(strat);
     2020
     2021#ifdef HAVE_PLURAL
     2022  if(pp != p)
     2023    id_Delete(&pp, currRing);
     2024#endif
     2025
     2026 
    19832027  return res;
    19842028}
     
    22442288
    22452289    // this should be done on the upper level!!! :
    2246     //    tempQ = currRing->nc->SCAQuotient();
     2290    //    tempQ = SCAQuotient(currRing);
    22472291
    22482292    if(Q == currQuotient)
    2249       tempQ = currRing->nc->SCAQuotient();
     2293      tempQ = SCAQuotient(currRing);
    22502294  }
    22512295#endif
  • kernel/kutil.cc

    rf2b5839 r52e2f6  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kutil.cc,v 1.90 2008-05-20 15:30:00 Singular Exp $ */
     4/* $Id: kutil.cc,v 1.91 2008-06-10 10:17:32 motsak Exp $ */
    55/*
    66* ABSTRACT: kernel: utils for kStd
     
    13771377  pSetm(Lp.lcm);
    13781378
     1379#define MYTEST 0
     1380
    13791381#ifdef HAVE_PLURAL
    13801382  const BOOLEAN bIsPluralRing = rIsPluralRing(currRing);
    13811383  const BOOLEAN bIsSCA        = rIsSCA(currRing) && strat->homog; // for prod-crit
    13821384  const BOOLEAN bNCProdCrit   = ( !bIsPluralRing || bIsSCA ); // commutative or homogeneous SCA
     1385
    13831386#else
    13841387  const BOOLEAN bIsPluralRing = FALSE;
     
    13861389  const BOOLEAN bNCProdCrit   = TRUE;
    13871390#endif
     1391
    13881392
    13891393  if (strat->sugarCrit && bNCProdCrit)
     
    15211525  if (strat->fromT && !TEST_OPT_INTSTRATEGY)
    15221526    pNorm(p);
     1527
    15231528  if ((strat->S[i]==NULL) || (p==NULL))
    15241529    return;
     1530
    15251531  if ((strat->fromQ!=NULL) && (isFromQ!=0) && (strat->fromQ[i]!=0))
    15261532    Lp.p=NULL;
     
    15321538      if(pHasNotCF(p, strat->S[i]))
    15331539      {
    1534         if(ncRingType(currRing) == nc_lie)
    1535         {
    1536             // generalized prod-crit for lie-type
    1537             strat->cp++;
    1538             Lp.p = nc_p_Bracket_qq(pCopy(p),strat->S[i]);
    1539         }
    1540         else
     1540//         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
    15411547        if( bIsSCA )
    15421548        {
     
    15461552        }
    15471553        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     
    15511570    }
    15521571    else
    15531572    #endif
    15541573    {
     1574      assume(!rIsPluralRing(currRing));
    15551575      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      }
    15571586  }
    15581587  if (Lp.p == NULL)
     
    16551684  if (rIsPluralRing(currRing))
    16561685  {
    1657     Lp.p = nc_CreateShortSpoly(strat->S[i],p); // ???
     1686    Lp.p = nc_CreateShortSpoly(strat->S[i],p); // ??? strat->tailRing?
    16581687  }
    16591688  else
     
    27842813  assume (!rField_is_Ring(currRing));
    27852814#endif
     2815
    27862816  initenterpairs(h,k,ecart,0,strat, atR);
    27872817  if ( (!strat->fromT)
     
    40734103    else
    40744104    {
    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]);
    40774108      return strat->S_2_T(j);
    40784109    }
  • kernel/longalg.cc

    rf2b5839 r52e2f6  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: longalg.cc,v 1.32 2008-03-19 17:44:09 Singular Exp $ */
     4/* $Id: longalg.cc,v 1.33 2008-06-10 10:17:32 motsak Exp $ */
    55/*
    66* ABSTRACT:   algebraic numbers
     
    16731673  }
    16741674  else
    1675 #if 0
     1675#ifndef HAVE_FACTORY
    16761676    result->z = napGcd(x->z, y->z); // change from napGcd0
    16771677#else
  • kernel/maps.cc

    rf2b5839 r52e2f6  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: maps.cc,v 1.8 2008-04-21 14:18:16 Singular Exp $ */
     4/* $Id: maps.cc,v 1.9 2008-06-10 10:17:32 motsak Exp $ */
    55/*
    66* ABSTRACT - the mapping of polynomials to other rings
     
    2121#include "prCopy.h"
    2222
     23#ifdef HAVE_PLURAL
     24#include "gring.h"
     25#endif
     26
    2327// This is a very dirty way to "normalize" numbers w.r.t. a
    2428// MinPoly
     
    197201ideal maGetPreimage(ring theImageRing, map theMap, ideal id)
    198202{
     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 
    199216  int i,j;
    200217  poly p,pp,q;
     
    203220
    204221  int imagepvariables = theImageRing->N;
    205   ring sourcering = currRing;
    206222  int N = pVariables+imagepvariables;
    207223
     
    213229  }
    214230
    215 #ifdef HAVE_PLURAL
    216   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   }
    224231  if (nSetMap(theImageRing) != nCopy)
    225232  {
     
    227234    return NULL;
    228235  }
    229 #endif
    230236
    231237  // change to new ring
  • kernel/matpol.cc

    rf2b5839 r52e2f6  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: matpol.cc,v 1.13 2006-11-20 11:10:39 Singular Exp $ */
     4/* $Id: matpol.cc,v 1.14 2008-06-10 10:17:32 motsak Exp $ */
    55
    66/*
     
    2424#include "sparsmat.h"
    2525#include "matpol.h"
    26 
     26#include "prCopy.h"
    2727
    2828//omBin ip_smatrix_bin = omGetSpecBin(sizeof(ip_smatrix));
     
    101101  return b;
    102102}
     103
     104/*2
     105*copies matrix a from rSrc into rDst
     106*/
     107matrix 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
    103143
    104144/*2
     
    416456/*--- look for an optimal row and bring it to last position ------------*/
    417457    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 ------------*/
    419459    k = lc;
    420460    loop
     
    18771917}
    18781918
     1919void   mpDelete(matrix* a, const ring r)
     1920{
     1921  id_Delete((ideal *) a, r);
     1922}
  • kernel/matpol.h

    rf2b5839 r52e2f6  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: matpol.h,v 1.1.1.1 2003-10-06 12:15:57 Singular Exp $ */
     6/* $Id: matpol.h,v 1.2 2008-06-10 10:17:32 motsak Exp $ */
    77/*
    88* ABSTRACT
     
    3030
    3131matrix mpNew(int r, int c);
    32 matrix mpCopy (matrix a);
     32matrix mpCopy(matrix a);
     33void   mpDelete(matrix* a, const ring r = currRing);
     34matrix mpCopy(const matrix a, const ring rSrc, const ring rDst = currRing);
    3335matrix mpInitP(int r, int c, poly p);
    3436matrix mpInitI(int r, int c, int v);
  • kernel/pInline2.h

    rf2b5839 r52e2f6  
    77 *  Author:  obachman (Olaf Bachmann)
    88 *  Created: 8/00
    9  *  Version: $Id: pInline2.h,v 1.12 2007-03-10 15:41:49 levandov Exp $
     9 *  Version: $Id: pInline2.h,v 1.13 2008-06-10 10:17:32 motsak Exp $
    1010 *******************************************************************/
    1111#ifndef PINLINE2_H
     
    128128  return __p_GetComp(p,r) -= v;
    129129}
     130PINLINE2 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
    130147
    131148// exponent
     
    147164#endif
    148165}
     166
    149167// partial compare exponent
    150168// r->VarOffset encodes the position in p->exp (lower 24 bits)
    151169// 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 }
    166170PINLINE2 int p_SetExp(poly p, int v, int e, ring r)
    167171{
     
    182186  return e;
    183187}
     188
     189#else // #ifdef HAVE_EXPSIZES
     190
     191inline 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
     201PINLINE2 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
     225PINLINE2 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
    184247
    185248// the following should be implemented more efficiently
  • kernel/p_Procs_Set.h

    rf2b5839 r52e2f6  
    1212 *  Author:  obachman (Olaf Bachmann)
    1313 *  Created: 12/00
    14  *  Version: $Id: p_Procs_Set.h,v 1.14 2008-03-19 17:44:10 Singular Exp $
     14 *  Version: $Id: p_Procs_Set.h,v 1.15 2008-06-10 10:17:32 motsak Exp $
    1515 *******************************************************************/
    1616#include "modulop.h"
     
    185185#ifdef HAVE_PLURAL
    186186  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  }
    188191#endif
    189192}
     
    204207{
    205208  set_names = 1;
    206   p_ProcsSet(r, p_Procs);
     209  p_ProcsSet(r, p_Procs); // changes p_Procs!!!
    207210  set_names = 0;
    208211}
  • kernel/ratgring.cc

    rf2b5839 r52e2f6  
    77 *  Author:  levandov (Viktor Levandovsky)
    88 *  Created: 8/00 - 11/00
    9  *  Version: $Id: ratgring.cc,v 1.9 2008-01-31 13:23:25 Singular Exp $
     9 *  Version: $Id: ratgring.cc,v 1.10 2008-06-10 10:17:32 motsak Exp $
    1010 *******************************************************************/
    1111#include "mod2.h"
     
    379379  poly H  = NULL;
    380380  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)
    382383
    383384  poly K  = p_Copy( p_GetCoeffRat(H,  is, r), r);
     
    427428  Print("k' t_f: "); p_wrp(p2,r);
    428429
    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 
    430433  p_Delete(&m,r);
    431434
  • kernel/ring.cc

    rf2b5839 r52e2f6  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: ring.cc,v 1.81 2008-04-22 16:14:14 Singular Exp $ */
     4/* $Id: ring.cc,v 1.82 2008-06-10 10:17:32 motsak Exp $ */
    55
    66/*
     
    390390  }
    391391#ifdef HAVE_PLURAL
    392   if (r->nc!=NULL)
     392  if(rIsPluralRing(r))
    393393  {
    394394    PrintS("\n//   noncommutative relations:");
     
    398398      int nl;
    399399      int i,j;
    400       //    Print("\n//   noncommutative relations (type %d):",(int)r->nc->type);
    401400      for (i = 1; i<r->N; i++)
    402401      {
    403402        for (j = i+1; j<=r->N; j++)
    404403        {
    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) )
    407406          {
    408407            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);
    410409            pWrite0(pl);
    411410          }
     
    416415#ifdef PDEBUG
    417416    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);
    419418    if( rIsSCA(r) )
    420419    {
    421420      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!
    423422      if (Q!=NULL)
    424423      {
     
    432431      }
    433432    }
    434     Print("\n//   ref:%d",r->nc->ref);
     433    Print("\n//   ref:%d",r->GetNC()->ref);
    435434#endif
    436435  }
     
    455454
    456455#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
    469460  nKillChar(r);
    470461  rUnComplete(r);
     
    10651056  tmpR.OrdSgn=1;
    10661057  if (dp_dp
    1067   && !rIsPluralRing(r1) && !rIsPluralRing(r2))
     1058#ifdef HAVE_PLURAL
     1059      && !rIsPluralRing(r1) && !rIsPluralRing(r2)
     1060#endif     
     1061     )
    10681062  {
    10691063    tmpR.order=(int*)omAlloc(4*sizeof(int));
     
    12251219  memcpy(sum,&tmpR,sizeof(ip_sring));
    12261220  rComplete(sum);
     1221
    12271222//#ifdef RDEBUG
    12281223//  rDebugPrint(sum);
    12291224//#endif
     1225
    12301226#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
    13671361  ideal Q=NULL;
    13681362  ideal Q1=NULL, Q2=NULL;
     
    14141408  }
    14151409  sum->qideal = Q;
     1410
     1411#ifdef HAVE_PLURAL
     1412  if( rIsPluralRing(sum) )
     1413    nc_SetupQuotient( sum );
     1414#endif
    14161415  return 1;
    14171416}
     
    15061505  }
    15071506#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!
    15131510#endif
    15141511  return res;
     
    15251522  if (r == NULL) return NULL;
    15261523  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
    15281533  return res;
    15291534}
     
    24362441  ring res=(ring)omAlloc0Bin(ip_sring_bin);
    24372442  *res = *r;
     2443
     2444#ifdef HAVE_PLURAL
     2445  res->GetNC() = NULL;
     2446#endif
     2447 
    24382448  // res->qideal, res->idroot ???
    24392449  res->wvhdl=wvhdl;
     
    24772487  // it comes from dp
    24782488  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 
    24792507  return res;
    24802508}
     
    24852513  ring res=(ring)omAlloc0Bin(ip_sring_bin);
    24862514  *res = *r;
     2515#ifdef HAVE_PLURAL
     2516  res->GetNC() = NULL;
     2517#endif
     2518 
    24872519  /*weights: entries for 3 blocks: NULL*/
    24882520  res->wvhdl = (int **)omAlloc0(3 * sizeof(int_ptr));
     
    25062538  rComplete(res, 1);
    25072539  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
    25082555  return res;
    25092556}
     
    25382585    ring res=(ring)omAlloc0Bin(ip_sring_bin);
    25392586    *res = *r;
     2587#ifdef HAVE_PLURAL
     2588    res->GetNC() = NULL;
     2589#endif   
    25402590    // res->qideal, res->idroot ???
    25412591    res->wvhdl=wvhdl;
     
    25472597    rComplete(res, 1);
    25482598    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
    25492615
    25502616    rOptimizeLDeg(res);
     
    32793345  r->p_Procs = (p_Procs_s*)omAlloc(sizeof(p_Procs_s));
    32803346  p_ProcsSet(r, r->p_Procs);
    3281 
    32823347  return FALSE;
    32833348}
     
    35063571  const char* length;
    35073572  const char* ord;
    3508   p_Debug_GetProcNames(r, &proc_names);
     3573  p_Debug_GetProcNames(r, &proc_names); // changes p_Procs!!!
    35093574  p_Debug_GetSpecNames(r, field, length, ord);
    35103575
     
    35973662static ring rAssure_SyzComp(ring r, BOOLEAN complete = TRUE);
    35983663
     3664#define MYTEST 0
     3665
    35993666ring rCurrRingAssure_SyzComp()
    36003667{
     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
    36013678  ring r = rAssure_SyzComp(currRing);
     3679
    36023680  if (r != currRing)
    36033681  {
    36043682    ring old_ring = currRing;
    36053683    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
    36063697    if (old_ring->qideal != NULL)
    36073698    {
     
    36093700      assume(idRankFreeModule(r->qideal) == 0);
    36103701      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     
    36133721  return r;
    36143722}
     
    36413749  res->wvhdl = wvhdl;
    36423750
    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  }
    36443772  return res;
    36453773}
     
    36833811
    36843812  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 
    36853830  return new_r;
    36863831}
     
    37173862      new_r->block1[last_block] = r->block1[c_pos];
    37183863      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      }
    37203885      return new_r;
    37213886    }
     
    37503915    if (new_r_1 != new_r && new_r_1 != old_r) rDelete(new_r_1);
    37513916    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   
    37523933    rChangeCurrRing(new_r);
    37533934    if (old_r->qideal != NULL)
     
    37553936      new_r->qideal = idrCopyR(old_r->qideal, old_r);
    37563937      currQuotient = new_r->qideal;
     3938
     3939#ifdef HAVE_PLURAL
     3940      if( rIsPluralRing(old_r) )
     3941        nc_SetupQuotient( new_r );
     3942#endif
     3943     
    37573944    }
    37583945    rTest(new_r);
     
    39844171  ring save = currRing;
    39854172  rChangeCurrRing(src);
     4173 
    39864174  ring r = rCopy0(src,TRUE); /* TRUE for copy the qideal */
    39874175  /*  rChangeCurrRing(r); */
     
    41934381  }
    41944382  rComplete(r);
     4383
     4384 
    41954385#ifdef RDEBUG
    41964386  //   rDebugPrint(r);
    4197 #endif
    41984387  rTest(r);
     4388#endif
     4389
     4390  rChangeCurrRing(r);
     4391
    41994392#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
    42414442  /* now oppose the qideal for qrings */
    42424443  if (src->qideal != NULL)
     
    42444445    idDelete(&(r->qideal));
    42454446    r->qideal = idOppose(src, src->qideal);
    4246   }
     4447
     4448#ifdef HAVE_PLURAL
     4449    if( rIsPluralRing(r) )
     4450      nc_SetupQuotient(r);
     4451#endif
     4452  }
     4453
    42474454  rTest(r);
     4455
    42484456  rChangeCurrRing(save);
    4249 #endif /* HAVE_PLURAL */
    42504457  return r;
    42514458}
     
    42634470  return Renv;
    42644471}
     4472
    42654473#ifdef HAVE_PLURAL
    4266 BOOLEAN nc_rComplete(ring src, ring dest)
     4474BOOLEAN nc_rComplete(const ring src, ring dest, bool bSetupQuotient)
    42674475/* returns TRUE is there were errors */
    42684476/* dest is actualy equals src with the different ordering */
    42694477/* we map src->nc correctly to dest->src */
    42704478/* 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
    42734485  if (!rIsPluralRing(src))
     4486  {
    42744487    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
    42834494  ring save = currRing;
    4284   int WeChangeRing = 0;
    4285   if (dest != currRing)
    4286   {
    4287     WeChangeRing = 1;
     4495
     4496  if (dest != save)
    42884497    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
    42914504  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
    42944510  poly p = NULL;
    42954511  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);
    43034520      MATELEM(C,i,j) = p;
    4304       p = NULL;
    43054521      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)
    43224544    rChangeCurrRing(save);
    4323   if (nc_InitMultiplication(dest))
    4324   {
    4325     WarnS("Error initializing multiplication!");
    4326     return TRUE;
    4327   }
     4545 
    43284546  return FALSE;
    43294547}
  • kernel/ring.h

    rf2b5839 r52e2f6  
    77* ABSTRACT - the interpreter related ring operations
    88*/
    9 /* $Id: ring.h,v 1.28 2008-04-21 11:23:12 Singular Exp $ */
     9/* $Id: ring.h,v 1.29 2008-06-10 10:17:33 motsak Exp $ */
    1010
    1111/* includes */
     
    3737{
    3838#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);
    4040#else
    4141  return false;
     
    247247// use this to free fields created by rComplete
    248248
    249 BOOLEAN nc_rComplete(ring src, ring dest);
    250 
    251 void rUnComplete(ring r);
    252249inline int rBlocks(ring r)
    253250{
     
    379376void rDebugPrint(ring r);
    380377void pDebugPrint(poly p);
     378void pDebugPrintR(poly p, const ring r);
    381379
    382380int64 * rGetWeightVec(ring r);
  • kernel/sca.cc

    rf2b5839 r52e2f6  
    77 *  Author:  motsak (Oleksandr Motsak)
    88 *  Created: 2006/12/18
    9  *  Version: $Id: sca.cc,v 1.15 2008-05-15 17:24:36 motsak Exp $
     9 *  Version: $Id: sca.cc,v 1.16 2008-06-10 10:17:33 motsak Exp $
    1010 *******************************************************************/
     11
     12#define OM_CHECK 4
     13#define OM_TRACK 5
    1114
    1215// #define PDEBUG 2
     
    1720#define PLURAL_INTERNAL_DECLARATIONS
    1821#include "sca.h"
     22#include "gring.h"
    1923
    2024
     
    384388      if(iComponentMonomM==0 )
    385389      {
    386         WarnS("Multiplication in the left module from the right");
     390        WarnS("sca_p_Mult_mm: Multiplication in the left module from the right");
    387391      }
    388392#endif
     
    466470      if(iComponentMonomM==0 )
    467471      {
    468         WarnS("Multiplication in the left module from the right");
     472        WarnS("sca_pp_Mult_mm: Multiplication in the left module from the right");
    469473      }
    470474#endif
     
    576580      if(iComponent==0 )
    577581      {
    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);       
    579586      }
    580587#endif
     
    637644    if( iComponentMonomM!=0 )
    638645    {
    639       if( iComponent!=0 ) // TODO: make global if on iComponentMonomM =?= 0
     646      if( iComponent!=0 )
    640647      {
    641648        // REPORT_ERROR
     
    647654      }
    648655#ifdef PDEBUG
    649       if(iComponent==0 )
     656      if(iComponent==0)
    650657      {
    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);       
    652662      }
    653663#endif
     
    700710
    701711// GB computation routines:
    702 
    703 /*2
    704 * returns the LCM of the head terms of a and b
    705 */
    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 PDEBUG
    725   p_Test(m,r);
    726 #endif
    727 
    728   return(m);
    729 }
    730712
    731713/*4
     
    970952#endif
    971953
     954#define OUTPUT 0
    972955
    973956
     
    975958{
    976959#if MYTEST
    977    PrintS("<sca_gr_bba>\n");
     960//   PrintS("<sca_gr_bba>\n");
    978961#endif
    979962
     
    985968#endif
    986969
     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 
    987986  const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
    988987  const unsigned int m_iLastAltVar  = scaLastAltVar(currRing);
     
    992991
    993992  if(Q == currQuotient)
    994     tempQ = currRing->nc->SCAQuotient();
     993    tempQ = SCAQuotient(currRing);
    995994
    996995  bool bIdHomog = id_IsSCAHomogeneous(tempF, NULL, NULL, currRing); // wCx == wCy == NULL!
     
    1000999  strat->homog = strat->homog && bIdHomog;
    10011000
    1002 
    10031001  assume( strat->homog == bIdHomog );
    10041002
    1005 
    10061003#if MYTEST
    1007 /*
    1008   {
    1009     Print("ideal F: \n");
    1010     idPrint(F);
     1004  {
    10111005    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
    10201011
    10211012  int srmax, lrmax;
     
    10341025  // ?? set spSpolyShort, reduce ???
    10351026
    1036   initBuchMora(tempF, tempQ, strat); // currRing->nc->SCAQuotient() instead of Q == squares!!!!!!!
     1027  initBuchMora(tempF, tempQ, strat); // SCAQuotient(currRing) instead of Q == squares!!!!!!!
    10371028
    10381029  strat->posInT=posInT110; // !!!
     
    10761067    //kTest(strat);
    10771068
    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    }
    10861079
    10871080    if(strat->P.IsNull()) continue;
     
    12221215
    12231216#if MYTEST
    1224    PrintS("</sca_gr_bba>\n");
     1217//   PrintS("</sca_gr_bba>\n");
    12251218#endif
    12261219
     
    12361229// if yes, make rGR a super-commutative algebra!
    12371230// 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
     1233bool sca_SetupQuotient(ring rGR, ring rG)
    12391234{
    12401235//   return false; // test Plural
     
    12431238  // checks...
    12441239  //////////////////////////////////////////////////////////////////////////
     1240  if( rG == NULL )
     1241    rG = rGR;
     1242
    12451243  assume(rGR != NULL);
    12461244  assume(rG  != NULL);
    1247 
    12481245  assume(rIsPluralRing(rG));
     1246 
     1247
     1248#if MYTEST
     1249   PrintS("sca_SetupQuotient(rGR, rG)");
     1250#endif
    12491251
    12501252  const int N = rG->N;
     
    12531255    return false;
    12541256
    1255 #if MYTEST
    1256    PrintS("sca_SetupQuotient(rGR, rG)");
    1257 #endif
    1258 
    1259 
     1257 
    12601258//  if( (ncRingType(rG) != nc_skew) || (ncRingType(rG) != nc_comm) )
    12611259//    return false;
    12621260
     1261#if OUTPUT
     1262  PrintS("sca_SetupQuotient: qring?\n");
     1263#endif
     1264
    12631265  if(rGR->qideal == NULL) // there will be a factor!
    12641266    return false;
    12651267
    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!
    12671273    return false;
    12681274
     
    12711277  int iAltVarStart   = N+1;
    12721278
    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 
    12761286  for(int i = 1; i < N; i++)
    12771287  {
     
    12921302        if( !n_IsOne(c, rBase) )
    12931303        {
     1304#if OUTPUT
     1305          Print("Wrong Coeff at: [%d, %d]\n", i, j);
     1306#endif
    12941307#if MYTEST
    12951308           Print("Wrong Coeff at: [%d, %d]\n", i, j);
     
    13011314  }
    13021315
     1316#if MYTEST
     1317  Print("AltVars?1: [%d, %d]\n", iAltVarStart, iAltVarEnd);
     1318#endif
     1319
     1320 
    13031321  if( (iAltVarEnd == -1) || (iAltVarStart == (N+1)) )
    13041322    return false; // either no alternating varables, or a single one => we are in commutative case!
    13051323
     1324 
    13061325  for(int i = 1; i < N; i++)
    13071326  {
     
    13151334        if( !n_IsMOne(c, rBase) )
    13161335        {
     1336#ifdef PDEBUG
     1337#if OUTPUT
     1338           Print("Wrong Coeff at: [%d, %d]\n", i, j);
     1339#endif
     1340#endif
     1341
    13171342#if MYTEST
    13181343           Print("Wrong Coeff at: [%d, %d]\n", i, j);
     
    13241349        if( !n_IsOne(c, rBase) )
    13251350        {
     1351#ifdef PDEBUG
     1352#if OUTPUT
     1353          Print("Wrong Coeff at: [%d, %d]\n", i, j);
     1354#endif
     1355#endif
    13261356#if MYTEST
    13271357           Print("Wrong Coeff at: [%d, %d]\n", i, j);
     
    13331363  }
    13341364
     1365#if MYTEST
     1366  Print("AltVars!?: [%d, %d]\n", iAltVarStart, iAltVarEnd);
     1367#endif
     1368
    13351369  assume( 1            <= iAltVarStart );
    13361370  assume( iAltVarStart < iAltVarEnd   );
    13371371  assume( iAltVarEnd   <= N            );
    13381372
     1373
     1374
    13391375  bool bWeChangeRing = false;
    13401376  // for sanity
     
    13471383  }
    13481384
     1385 
    13491386  assume(rGR->qideal != NULL);
    1350   assume(rG->qideal == NULL);
     1387//  assume(rG->qideal == NULL); // ?
    13511388
    13521389  const ideal idQuotient = rGR->qideal;
    13531390
     1391
     1392#if MYTEST
     1393  Print("Analyzing quotient ideal:\n");
     1394  idPrint(idQuotient); // in rG!!!
     1395#endif
     1396
     1397 
    13541398  // check for
    13551399  // y_{iAltVarStart}^2, y_{iAltVarStart+1}^2, \ldots, y_{iAltVarEnd}^2  (iAltVarEnd > iAltVarStart)
     
    13601404  for ( int i = iAltVarStart; (i <= iAltVarEnd) && bSCA; i++ )
    13611405  {
    1362     poly square = p_ISet(1, rSaveRing);
    1363     p_SetExp(square, i, 2, rSaveRing); // square = var(i)^2.
    1364     p_Setm(square, rSaveRing);
     1406    poly square = p_ISet(1, rG);
     1407    p_SetExp(square, i, 2, rG); // square = var(i)^2.
     1408    p_Setm(square, rG);
    13651409
    13661410    // square = NF( var(i)^2 | Q )
    13671411    // NOTE: rSaveRing == currRing now!
    13681412    // 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!
    13701414
    13711415    if( square != NULL ) // var(i)^2 is not in Q?
    13721416    {
    1373       p_Delete(&square, rSaveRing);
     1417      p_Delete(&square, rG);
    13741418      bSCA = false;
    13751419    }
     
    13851429
    13861430
    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 
    13921437
    13931438  //////////////////////////////////////////////////////////////////////////
     
    13991444
    14001445  if( idIs0(tempQ) )
    1401     rGR->nc->SCAQuotient() = NULL;
     1446    rGR->GetNC()->SCAQuotient() = NULL;
    14021447  else
    1403     rGR->nc->SCAQuotient() = idrMoveR(tempQ, rG, rGR); // deletes tempQ!
     1448    rGR->GetNC()->SCAQuotient() = idrMoveR(tempQ, rG, rGR); // deletes tempQ!
    14041449
    14051450  ncRingType( rGR, nc_exterior );
     
    14091454
    14101455
    1411   sca_p_ProcsSet(rGR, rGR->p_Procs);
    1412 
     1456  nc_p_ProcsSet(rGR, rGR->p_Procs); // !!!!!!!!!!!!!!!!!
    14131457
    14141458  return true;
     
    14401484
    14411485  if( idIs0(tempQ) )
    1442     rGR->nc->SCAQuotient() = NULL;
     1486    rGR->GetNC()->SCAQuotient() = NULL;
    14431487  else
    1444     rGR->nc->SCAQuotient() = tempQ;
     1488    rGR->GetNC()->SCAQuotient() = tempQ;
    14451489 
    14461490  ncRingType( rGR, nc_exterior );
     
    14501494
    14511495
    1452   sca_p_ProcsSet(rGR, rGR->p_Procs);
     1496  nc_p_ProcsSet(rGR, rGR->p_Procs);
    14531497
    14541498  if(rSaveRing != rGR)
     
    15001544
    15011545  if(Q == currQuotient)
    1502     tempQ = currRing->nc->SCAQuotient();
     1546    tempQ = SCAQuotient(currRing);
    15031547
    15041548  // Q or tempQ will not be used below :(((
     
    16031647
    16041648
    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)
    16081654    {
    16091655      // deletes the short spoly
    16101656      pLmFree(strat->P.p);
     1657
     1658      strat->P.p = nc_CreateSpoly(strat->P.p1, strat->P.p2, currRing);
     1659
     1660/*     
    16111661      strat->P.p = NULL;
     1662
     1663
    16121664      poly m1 = NULL, m2 = NULL;
    16131665
     
    16291681      ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
    16301682                    strat->tailRing, m1, m2, strat->R); //?????????
    1631     }
    1632     else */
     1683*/                   
     1684    }//    else
    16331685
    16341686    if (strat->P.p1 == NULL)
     
    19201972
    19211973  if(Q == currQuotient)
    1922     tempQ = currRing->nc->SCAQuotient();
     1974    tempQ = SCAQuotient(currRing);
    19231975
    19241976  bool bIdHomog = id_IsSCAHomogeneous(tempF, NULL, NULL, currRing); // wCx == wCy == NULL!
     
    20282080
    20292081    // 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   
    20312095
    20322096    if (strat->P.p1 == NULL)
     
    22032267
    22042268  // 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;
    22072271
    22082272
     
    22122276//           Print("Local case => GB == mora!\n");
    22132277#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!
    22152279  }
    22162280  else
     
    22192283//           Print("Global case => GB == bba!\n");
    22202284#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;
    22312295
    22322296#if 0
     
    22402304        _p_procs->pp_Mult_mm = sca_pp_Mult_mm;
    22412305
    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;
    22462310/*
    22472311        // ??????????????????????????????????????? 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;
    22502314*/
    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;
    22532317
    22542318#endif
  • kernel/sca.h

    rf2b5839 r52e2f6  
    55*  Computer Algebra System SINGULAR     *
    66****************************************/
    7 /* $Id: sca.h,v 1.11 2008-05-15 17:24:37 motsak Exp $ */
     7/* $Id: sca.h,v 1.12 2008-06-10 10:17:33 motsak Exp $ */
    88
    99#include <ring.h>
     
    3232  // SCA!
    3333#ifdef HAVE_PLURAL
    34   return r->nc->SCAQuotient();
     34  return r->GetNC()->SCAQuotient();
    3535#else
    3636  // for sainity
     
    4848  assume(rIsSCA(r));
    4949
    50   return (r->nc->FirstAltVar());
     50  return (r->GetNC()->FirstAltVar());
    5151};
    5252
     
    5555  assume(rIsSCA(r));
    5656
    57   return (r->nc->LastAltVar());
     57  return (r->GetNC()->LastAltVar());
    5858};
    5959
     
    6464  assume(rIsSCA(r));
    6565
    66   r->nc->FirstAltVar() = n;
     66  r->GetNC()->FirstAltVar() = n;
    6767};
    6868
     
    7171  assume(rIsSCA(r));
    7272
    73   r->nc->LastAltVar() = n;
     73  r->GetNC()->LastAltVar() = n;
    7474};
    7575
     
    184184// should be used only inside nc_SetupQuotient!
    185185// 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 
    187187//  2. factor ideal rGR->qideal contains squares of all alternating variables.
    188188//
    189189// if yes, make rGR a super-commutative algebra!
    190190// 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
     193bool sca_SetupQuotient(ring rGR, ring rG);
    192194
    193195#endif // PLURAL_INTERNAL_DECLARATIONS
  • kernel/structs.h

    rf2b5839 r52e2f6  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: structs.h,v 1.44 2008-05-09 09:17:57 Singular Exp $ */
     6/* $Id: structs.h,v 1.45 2008-06-10 10:17:33 motsak Exp $ */
    77/*
    88* ABSTRACT
     
    474474  int *MTsize; // size 0.. (rVar()*rVar()-1)/2
    475475
    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
    477478  int IsSkewConstant;
    478479
     
    631632  ring          algring;
    632633#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!!!
    634639#endif
    635640};
  • kernel/syz.cc

    rf2b5839 r52e2f6  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: syz.cc,v 1.12 2007-02-02 15:19:46 motsak Exp $ */
     4/* $Id: syz.cc,v 1.13 2008-06-10 10:17:33 motsak Exp $ */
    55
    66/*
     
    621621  if( rIsSCA(currRing) )
    622622  {
    623     currQuotient = currRing->nc->SCAQuotient();
     623    currQuotient = SCAQuotient(currRing);
    624624    currRing->qideal = currQuotient;
    625625
Note: See TracChangeset for help on using the changeset viewer.