Changeset 86016d in git


Ignore:
Timestamp:
Feb 1, 2007, 12:51:25 AM (16 years ago)
Author:
Motsak Oleksandr <motsak@…>
Branches:
(u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
Children:
c591ad0eb4ed9f5be86c0c85d2412be2ad6be556
Parents:
1cc61e18c0d6c70b177099c23a52159afb280bb4
Message:
*motsak:
 !+!: factors of SCA, debug print for SCA, "kill squares" in std.
  * : ncRingType, naming, formatting, unified NC setup.


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

Legend:

Unmodified
Added
Removed
  • kernel/gr_kstd2.cc

    r1cc61e r86016d  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: gr_kstd2.cc,v 1.10 2007-01-11 10:10:37 Singular Exp $ */
     4/* $Id: gr_kstd2.cc,v 1.11 2007-01-31 23:51:23 motsak Exp $ */
    55/*
    66*  ABSTRACT -  Kernel: noncomm. alg. of Buchberger
     
    1111#ifdef HAVE_PLURAL
    1212
     13#define PLURAL_INTERNAL_DECLARATIONS
    1314
    1415#include "omalloc.h"
     
    750751#endif
    751752
    752 void gr_initBba(ideal F, kStrategy strat)
     753void nc_gr_initBba(ideal F, kStrategy strat)
    753754{
    754755  assume(rIsPluralRing(currRing));
     
    826827  // initHilbCrit(F,Q,&hilb,strat);
    827828  /* in plural we don't need Hilb yet */
    828   gr_initBba(F,strat);
     829  nc_gr_initBba(F,strat);
    829830  initBuchMoraPos(strat);
    830831  /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
     
    861862      pLmFree(strat->P.p);
    862863      /* the real one */
    863       if ((currRing->nc->type==nc_lie) && pHasNotCF(strat->P.p1,strat->P.p2)) /* prod crit */
     864      if ((ncRingType(currRing)==nc_lie) && pHasNotCF(strat->P.p1,strat->P.p2)) /* prod crit */
    864865      {
    865866        strat->cp++;
     
    922923              strat->enterS(strat->P,pos,strat,-1);
    923924            }
    924             if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
     925//            if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
    925926          }
    926927          if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm);
     
    933934  }
    934935  if (TEST_OPT_DEBUG) messageSets(strat);
     936
    935937  /* complete reduction of the standard basis--------- */
    936   if (TEST_OPT_REDSB) completeReduce(strat);
     938  if (TEST_OPT_REDSB){
     939     completeReduce(strat); // ???
     940
     941//    ideal I = strat->Shdl;
     942//    ideal erg = kInterRed(I,Q);
     943//    assume(I!=erg);
     944//    id_Delete(&I, currRing);
     945//    strat->Shdl = erg;
     946  }
     947
    937948  /* release temp data-------------------------------- */
    938949  exitBuchMora(strat);
     
    949960  if (TEST_OPT_PROT) messageStat(srmax,lrmax,hilbcount,strat);
    950961  if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
     962
     963
    951964#ifdef PDEBUG
    952965/* for counting number of pairs [enterL] in Plural */
  • kernel/gring.cc

    r1cc61e r86016d  
    77 *  Author:  levandov (Viktor Levandovsky)
    88 *  Created: 8/00 - 11/00
    9  *  Version: $Id: gring.cc,v 1.38 2007-01-25 19:42:26 motsak Exp $
     9 *  Version: $Id: gring.cc,v 1.39 2007-01-31 23:51:23 motsak Exp $
    1010 *******************************************************************/
    1111#include "mod2.h"
     12
    1213#ifdef HAVE_PLURAL
    1314#define PLURAL_INTERNAL_DECLARATIONS
     
    2627
    2728#include "gring.h"
     29#include "sca.h"
    2830
    2931// dirty tricks:
     
    3638
    3739
    38 
     40// some forward declarations:
     41
     42
     43// polynomial multiplication functions for p_Procs :
     44poly gnc_pp_Mult_mm(const poly p, const poly m, const ring r, poly &last);
     45poly gnc_p_Mult_mm(poly p, const poly m, const ring r);
     46poly gnc_mm_Mult_p(const poly m, poly p, const ring r);
     47poly gnc_mm_Mult_pp(const poly m, const poly p, const ring r);
     48
     49
     50// set pProcs for r and global variable p_Procs as for general non-commutative algebras.
     51void gnc_p_ProcsSet(ring rGR, p_Procs_s* p_Procs);
     52
     53/* syzygies : */
     54poly gnc_CreateSpolyOld(const poly p1, const poly p2/*, poly spNoether*/, const ring r);
     55poly gnc_ReduceSpolyOld(const poly p1, poly p2/*, poly spNoether*/, const ring r);
     56
     57poly gnc_CreateSpolyNew(const poly p1, const poly p2/*, poly spNoether*/, const ring r);
     58poly gnc_ReduceSpolyNew(const poly p1, poly p2/*, poly spNoether*/, const ring r);
     59
     60
     61
     62void gnc_kBucketPolyRedNew(kBucket_pt b, poly p, number *c);
     63void gnc_kBucketPolyRed_ZNew(kBucket_pt b, poly p, number *c);
     64
     65void gnc_kBucketPolyRedOld(kBucket_pt b, poly p, number *c);
     66void gnc_kBucketPolyRed_ZOld(kBucket_pt b, poly p, number *c);
     67
     68
     69// poly gnc_ReduceSpolyNew(poly p1, poly p2, poly spNoether, const ring r);
     70// void gnc_ReduceSpolyTail(poly p1, poly q, poly q2, poly spNoether, const ring r);
     71
     72// void nc_kBucketPolyRed(kBucket_pt b, poly p);
     73
     74ideal gnc_gr_mora(const ideal, const ideal, const intvec *, const intvec *, kStrategy); // Not yet!
     75ideal gnc_gr_bba (const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat);
     76
     77
     78#if 0
     79// deprecated functions:
     80//  poly gnc_p_Minus_mm_Mult_qq_ign(poly p, const poly m, poly q, int & d1, poly d2, const ring ri, poly &d3);
     81//  poly gnc_p_Minus_mm_Mult_qq(poly p, const poly m, poly q, const ring r);
     82//  poly nc_p_Minus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp, int lq, const ring r);
     83//  poly nc_p_Plus_mm_Mult_qq (poly p, const poly m, const poly q, int &lp, int lq, const ring r);
     84#endif
     85
     86
     87
     88///////////////////////////////////////////////////////////////////////////////
    3989poly nc_p_Minus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp,
    4090                                    const int, const poly, const ring r)
     
    325375  int cpower=0;
    326376
    327   if (r->nc->type==nc_skew)
     377  if (ncRingType(r)==nc_skew)
    328378  {
    329379    if (r->nc->IsSkewConstant==1)
     
    11301180#endif
    11311181  /* pSetComp(m,r)=0? */
    1132   poly   N  = mm_Mult_p(m, p_Head(p1,r), r);
     1182  poly   N  = nc_mm_Mult_p(m, p_Head(p1,r), r);
    11331183  number C  = n_Copy( p_GetCoeff(N,  r), r);
    11341184  number cF = n_Copy( p_GetCoeff(p2, r),r);
     
    11841234
    11851235  /* pSetComp(m,r)=0? */
    1186   poly   N  = mm_Mult_p(m, p_Head(p1,r), r);
     1236  poly   N  = nc_mm_Mult_p(m, p_Head(p1,r), r);
    11871237
    11881238  number C  = n_Copy( p_GetCoeff(N,  r), r);
     
    12381288    return(NULL);
    12391289  }
    1240   if ((r->nc->type==nc_lie) && pHasNotCF(p1,p2)) /* prod crit */
     1290  if ((ncRingType(r)==nc_lie) && pHasNotCF(p1,p2)) /* prod crit */
    12411291  {
    12421292    return(nc_p_Bracket_qq(pCopy(p2),p1));
     
    12641314  p_Delete(&pL,r);
    12651315  /* zero exponents ! */
    1266   poly M1    = mm_Mult_p(m1,p_Head(p1,r),r);
     1316  poly M1    = nc_mm_Mult_p(m1,p_Head(p1,r),r);
    12671317  number C1  = n_Copy(p_GetCoeff(M1,r),r);
    1268   poly M2    = mm_Mult_p(m2,p_Head(p2,r),r);
     1318  poly M2    = nc_mm_Mult_p(m2,p_Head(p2,r),r);
    12691319  number C2  = n_Copy(p_GetCoeff(M2,r),r);
    12701320  /* GCD stuff */
     
    12921342  poly tmp=p_Copy(p1,r);
    12931343  tmp=p_LmDeleteAndNext(tmp,r);
    1294   M1=mm_Mult_p(m1,tmp,r);
     1344  M1=nc_mm_Mult_p(m1,tmp,r);
    12951345  tmp=p_Copy(p2,r);
    12961346  tmp=p_LmDeleteAndNext(tmp,r);
    12971347  M2=p_Add_q(M2,M1,r);
    1298   M1=mm_Mult_p(m2,tmp,r);
     1348  M1=nc_mm_Mult_p(m2,tmp,r);
    12991349  M2=p_Add_q(M2,M1,r);
    13001350  p_Delete(&m1,r);
     
    13601410
    13611411  /* zero exponents !? */
    1362   poly M1    = mm_Mult_p(m1,p_Head(p1,r),r); // M1 = m1 * lt(p1)
    1363   poly M2    = mm_Mult_p(m2,p_Head(p2,r),r); // M2 = m2 * lt(p2)
     1412  poly M1    = nc_mm_Mult_p(m1,p_Head(p1,r),r); // M1 = m1 * lt(p1)
     1413  poly M2    = nc_mm_Mult_p(m2,p_Head(p2,r),r); // M2 = m2 * lt(p2)
    13641414
    13651415  if(M1 == NULL || M2 == NULL)
     
    14191469  poly tmp=p_Copy(p1,r);                         // tmp = p1
    14201470  tmp=p_LmDeleteAndNext(tmp,r);                  // tmp = tail(p1)
    1421   M1 = mm_Mult_p(m1,tmp,r);                      // M1 = m1 * tail(p1), delete tmp
     1471  M1 = nc_mm_Mult_p(m1,tmp,r);                      // M1 = m1 * tail(p1), delete tmp
    14221472  tmp=p_Copy(p2,r);                              // tmp = p2
    14231473  tmp=p_LmDeleteAndNext(tmp,r);                  // tmp = tail(p2)
    14241474  M2=p_Add_q(M2,M1,r);                           // M2 = spoly(lt(p1), lt(p2)) + m1 * tail(p1), delete M1
    1425   M1 = mm_Mult_p(m2,tmp,r);                      // M1 = m2 * tail(p2), detele tmp
     1475  M1 = nc_mm_Mult_p(m2,tmp,r);                      // M1 = m2 * tail(p2), detele tmp
    14261476  M2=p_Add_q(M2,M1,r);                           // M2 = spoly(lt(p1), lt(p2)) + m1 * tail(p1) + m2*tail(p2)
    14271477                                                 // delete M1
     
    14641514  poly M = nc_mm_Mult_pp(m, p1,r);
    14651515  number C=p_GetCoeff(M,r);
    1466   M=p_Add_q(M,mm_Mult_p(m,p_LmDeleteAndNext(p_Copy(p1,r),r),r),r); // _pp?
     1516  M=p_Add_q(M,nc_mm_Mult_p(m,p_LmDeleteAndNext(p_Copy(p1,r),r),r),r); // _pp?
    14671517  q=p_Mult_nn(q,C,r);
    14681518  number MinusOne=n_Init(-1,r);
     
    20432093      for(j=i+1;j<=rN;j++)
    20442094      {
    2045     id_Delete((ideal *)&(r->nc->MT[UPMATELEM(i,j,rN)]),r->nc->basering);
     2095        id_Delete((ideal *)&(r->nc->MT[UPMATELEM(i,j,rN)]),r->nc->basering);
    20462096      }
    20472097    }
     
    20522102  id_Delete((ideal *)&(r->nc->C),r->nc->basering);
    20532103  id_Delete((ideal *)&(r->nc->D),r->nc->basering);
     2104 
     2105  if( rIsSCA(r) && (r->nc->SCAQuotient() != NULL) )
     2106  {
     2107    id_Delete(&r->nc->SCAQuotient(), r->nc->basering);   
     2108  }
     2109
    20542110  r->nc->basering->ref--;
    2055   if (r->nc->basering<=0)
     2111 
     2112  if (r->nc->basering->ref<=0)
    20562113  {
    20572114    rKill(r->nc->basering);
    20582115  }
    2059   omFreeSize((ADDRESS)r->nc,sizeof(nc_struct));
    2060   r->nc=NULL;
     2116 
     2117  ncCleanUp(r);
    20612118}
    20622119
     
    22542311  r->nc->basering = r;
    22552312  r->ref++;
    2256   r->nc->type = nc_undef;
     2313  ncRingType(r, nc_undef);
    22572314
    22582315  /* initialition of the matrix C */
     
    23132370    if (nIsOne(nN))
    23142371    {
    2315       r->nc->type = nc_lie;
     2372      ncRingType(r, nc_lie);
    23162373    }
    23172374    else
    23182375    {
    2319       r->nc->type = nc_general;
     2376      ncRingType(r, nc_general);
    23202377    }
    23212378    r->nc->IsSkewConstant = 1;
     
    23612418    if ( (tmpIsSkewConstant) && (nIsOne(pN)) )
    23622419    {
    2363       r->nc->type = nc_lie;
     2420      ncRingType(r, nc_lie);
    23642421    }
    23652422    else
    23662423    {
    2367       r->nc->type = nc_general;
     2424      ncRingType(r, nc_general);
    23682425    }
    23692426  }
     
    23762433    if (DN  == NULL)
    23772434    {
    2378       if ( (r->nc->type == nc_lie) || (r->nc->type == nc_undef) )
    2379       {
    2380     r->nc->type = nc_comm; /* it was nc_skew earlier */
     2435      if ( (ncRingType(r) == nc_lie) || (ncRingType(r) == nc_undef) )
     2436      {
     2437        ncRingType(r, nc_comm); /* it was nc_skew earlier */
    23812438      }
    23822439      else /* nc_general, nc_skew */
    23832440      {
    2384     r->nc->type = nc_skew;
     2441        ncRingType(r, nc_skew);
    23852442      }
    23862443    }
     
    24182475}
    24192476
     2477//////////////////////////////////////////////////////////////////////////////
    24202478BOOLEAN nc_InitMultiplication(ring r)
    24212479{
     
    24262484  if (rVar(r)==1)
    24272485  {
    2428     r->nc->type=nc_comm;
     2486    ncRingType(r, nc_comm);
    24292487    r->nc->IsSkewConstant=1;
    24302488    return FALSE;
     
    24832541    }
    24842542  }
    2485   if (r->nc->type==nc_undef)
     2543  if (ncRingType(r)==nc_undef)
    24862544  {
    24872545    if (IsNonComm==1)
     
    24932551    if (IsNonComm==0)
    24942552    {
    2495       r->nc->type=nc_skew; /* TODO: check whether it is commutative */
     2553      ncRingType(r, nc_skew); /* TODO: check whether it is commutative */
    24962554      r->nc->IsSkewConstant=tmpIsSkewConstant;
    24972555    }
     
    24992557  r->nc->COM=COM;
    25002558
    2501   SetProcsGNC(r, r->p_Procs);
    2502 
     2559  gnc_p_ProcsSet(r, r->p_Procs);
    25032560
    25042561  if (WeChangeRing)
     
    25092566}
    25102567
    2511 void SetProcsGNC(ring& rGR, p_Procs_s* p_Procs)
    2512 {
    2513 
     2568void gnc_p_ProcsSet(ring rGR, p_Procs_s* p_Procs)
     2569{
    25142570  // "commutative"
    25152571  rGR->p_Procs->p_Mult_mm  = gnc_p_Mult_mm;
     
    25222578
    25232579
    2524   // non-commutaitve
     2580  // non-commutaitve multiplication by monomial from the left
    25252581  rGR->nc->p_Procs.mm_Mult_p   = gnc_mm_Mult_p;
    25262582  rGR->nc->p_Procs.mm_Mult_pp  = gnc_mm_Mult_pp;
     
    25402596  rGR->nc->p_Procs.BucketPolyRed_Z= gnc_kBucketPolyRed_ZOld;
    25412597#else
     2598  // A bit cleaned up and somewhat rewritten functions...
    25422599  rGR->nc->p_Procs.SPoly       = gnc_CreateSpolyNew;
    25432600  rGR->nc->p_Procs.ReduceSPoly = gnc_ReduceSpolyNew;
     
    25512608
    25522609#if 0
     2610    // Old Stuff
    25532611    p_Procs->p_Mult_mm   = gnc_p_Mult_mm;
    25542612    _p_procs->p_Mult_mm  = gnc_p_Mult_mm;
     
    25702628#endif
    25712629}
     2630
     2631
     2632// set pProcs table for rGR and global variable p_Procs
     2633void nc_p_ProcsSet(ring rGR, p_Procs_s* p_Procs)
     2634{
     2635  assume(rIsPluralRing(rGR));
     2636  assume(p_Procs!=NULL);
     2637
     2638  gnc_p_ProcsSet(rGR, p_Procs);
     2639
     2640  if(rIsSCA(rGR))
     2641  {
     2642    sca_p_ProcsSet(rGR, p_Procs);
     2643  }
     2644}
     2645
    25722646
    25732647
     
    26042678      pSetExpV(pre,PRE);
    26052679      pSetm(pre);
    2606       res = mm_Mult_p(pre,res,currRing);
     2680      res = nc_mm_Mult_p(pre,res,currRing);
    26072681      /* multiply with suffix */
    26082682      suf = pOne();
     
    28552929  r->nc->ref = 1;
    28562930  r->nc->basering = r;
    2857   r->nc->type = nc_comm;
     2931  ncRingType(r, nc_comm);
    28582932  r->nc->IsSkewConstant = 1;
     2933 
     2934  // no reference increment to the base commutative ring???
     2935 
    28592936  matrix C = mpNew(r->N,r->N);
    28602937  matrix D = mpNew(r->N,r->N);
     
    29963073}
    29973074
     3075
     3076
     3077bool nc_SetupQuotient(ring rGR, const ring rG)
     3078{
     3079  // currently only super-commutative extension deals with factors.
     3080  return sca_SetupQuotient(rGR, rG);
     3081}
     3082
     3083
    29983084#endif
    29993085
  • kernel/gring.h

    r1cc61e r86016d  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: gring.h,v 1.17 2007-01-11 11:27:25 Singular Exp $ */
     6/* $Id: gring.h,v 1.18 2007-01-31 23:51:24 motsak Exp $ */
    77/*
    88* ABSTRACT additional defines etc for --with-plural
     
    1010
    1111#ifdef HAVE_PLURAL
    12 #include "structs.h"
    13 #include "ring.h"
     12
     13#include <structs.h>
     14#include <ring.h>
    1415
    1516/* the part, related to the interface */
    1617BOOLEAN nc_CallPlural(matrix CC, matrix DD, poly CN, poly DN, ring r);
     18
    1719BOOLEAN nc_CheckOrdCondition(matrix D, ring r);
    1820BOOLEAN nc_CheckSubalgebra(poly PolyVar, ring r);
    19 BOOLEAN nc_InitMultiplication(ring r);
     21BOOLEAN nc_InitMultiplication(ring r); // should call nc_p_ProcsSet!
    2022BOOLEAN rIsLikeOpposite(ring rBase, ring rCandidate);
    2123
    22 // set pProcs for r and global variable p_Procs
    23 void SetProcsGNC(ring& rGR, p_Procs_s* p_Procs);
    2424
    25 ring nc_rCreateNCcomm(ring r);
    26 void ncKill(ring r);
    27 void ncCleanUp(ring r); /* smaller than kill */
     25// set pProcs table for rGR and global variable p_Procs
     26// this should be used by p_ProcsSet in p_Procs_Set.h
     27void nc_p_ProcsSet(ring rGR, p_Procs_s* p_Procs);
    2828
    29 /* poly functions defined in p_Procs : */
    30 
    31 /* other routines we need in addition : */
    32 // poly gnc_p_Minus_mm_Mult_qq(poly p, const poly m, poly q, const ring r);
    33 
    34 // #define PLURAL_INTERNAL_DECLARATIONS
    35 
    36 #ifdef PLURAL_INTERNAL_DECLARATIONS
    37 // // poly gnc_p_Minus_mm_Mult_qq_ign(poly p, const poly m, poly q, int & d1, poly d2, const ring ri, poly &d3);
     29// this function should be used inside QRing definition!
     30// we go from rG into factor ring rGR with factor ideal rGR->qideal.
     31bool nc_SetupQuotient(ring rGR, const ring rG);
    3832
    3933
    40 poly gnc_pp_Mult_mm(const poly p, const poly m, const ring r, poly &last);
    41 poly gnc_p_Mult_mm(poly p, const poly m, const ring r);
    42 poly gnc_mm_Mult_p(const poly m, poly p, const ring r);
    43 poly gnc_mm_Mult_pp(const poly m, const poly p, const ring r);
    44 #endif
     34// used by "rSum" from ring.cc only!
     35// purpose init nc structure for initially commutative ring:
     36// "creates a commutative nc extension; "converts" comm.ring to a Plural ring"
     37ring nc_rCreateNCcomm(ring r);
     38
     39void ncCleanUp(ring r); /* smaller than kill */
     40void ncKill(ring r);
    4541
    4642
    47 
    48 // // for p_Minus_mm_Mult_qq in pInline2.h
    49 // poly nc_p_Minus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp, int lq, const ring r);
    50 // // for p_Plus_mm_Mult_qq in pInline2.h
    51 // poly nc_p_Plus_mm_Mult_qq (poly p, const poly m, const poly q, int &lp, int lq, const ring r);
    52 
    53 
    54 //
     43// for p_Minus_mm_Mult_qq in pInline2.h
    5544poly nc_p_Minus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp,
    5645                                    const int, const poly, const ring r);
     46
     47// // for p_Plus_mm_Mult_qq in pInline2.h
    5748// returns p + m*q destroys p, const: q, m
    5849poly nc_p_Plus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp,
     
    7667void nc_PolyPolyRed(poly &b, poly p, number *c);
    7768poly nc_CreateShortSpoly(poly p1, poly p2, const ring r=currRing);
    78 
    79 
    80 #define PLURAL_INTERNAL_DECLARATIONS
    81 #ifdef PLURAL_INTERNAL_DECLARATIONS
    82 /* syzygies : */
    83 poly gnc_CreateSpolyOld(const poly p1, const poly p2/*, poly spNoether*/, const ring r);
    84 poly gnc_ReduceSpolyOld(const poly p1, poly p2/*, poly spNoether*/, const ring r);
    85 
    86 poly gnc_CreateSpolyNew(const poly p1, const poly p2/*, poly spNoether*/, const ring r);
    87 poly gnc_ReduceSpolyNew(const poly p1, poly p2/*, poly spNoether*/, const ring r);
    88 
    89 
    90 
    91 void gnc_kBucketPolyRedNew(kBucket_pt b, poly p, number *c);
    92 void gnc_kBucketPolyRed_ZNew(kBucket_pt b, poly p, number *c);
    93 
    94 void gnc_kBucketPolyRedOld(kBucket_pt b, poly p, number *c);
    95 void gnc_kBucketPolyRed_ZOld(kBucket_pt b, poly p, number *c);
    96 
    97 
    98 // poly gnc_ReduceSpolyNew(poly p1, poly p2, poly spNoether, const ring r);
    99 // void gnc_ReduceSpolyTail(poly p1, poly q, poly q2, poly spNoether, const ring r);
    100 
    101 /* void nc_kBucketPolyRed(kBucket_pt b, poly p); */
    102 void gr_initBba(ideal F,kStrategy strat);
    103 
    104 ideal gnc_gr_bba (const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat);
    105 ideal gnc_gr_mora(const ideal, const ideal, const intvec *, const intvec *, kStrategy); // Not yet!
    106 #endif
    10769
    10870
     
    159121
    160122// returns m*p, does destroy p, preserves m
    161 inline poly mm_Mult_p(const poly m, poly p, const ring r)
     123inline poly nc_mm_Mult_p(const poly m, poly p, const ring r)
    162124{
    163125  assume(rIsPluralRing(r));
     
    226188#define UPMATELEM(i,j,nVar) ( (nVar * ((i)-1) - ((i) * ((i)-1))/2 + (j)-1)-(i) )
    227189
    228 #endif
    229 #endif
     190
     191#ifdef PLURAL_INTERNAL_DECLARATIONS
     192
     193// we need nc_gr_initBba for sca_gr_bba and gr_bba.
     194void nc_gr_initBba(ideal F,kStrategy strat);
     195
     196#endif // PLURAL_INTERNAL_DECLARATIONS
     197
     198#endif // HAVE_PLURAL :(
     199#endif //
  • kernel/ideals.cc

    r1cc61e r86016d  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: ideals.cc,v 1.37 2007-01-24 10:00:55 Singular Exp $ */
     4/* $Id: ideals.cc,v 1.38 2007-01-31 23:51:24 motsak Exp $ */
    55/*
    66* ABSTRACT - all basic methods to manipulate ideals
     
    23142314    /* the subalgebra to be intersected with */
    23152315  {
    2316     if (currRing->nc->type!=nc_skew) /* in (quasi)-commutative algebras every subalgebra is admissible */
     2316    if (ncRingType(currRing)!=nc_skew) /* in (quasi)-commutative algebras every subalgebra is admissible */
    23172317    {
    23182318      if (nc_CheckSubalgebra(delVar,currRing))
  • kernel/maps.cc

    r1cc61e r86016d  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: maps.cc,v 1.5 2005-09-05 12:30:29 Singular Exp $ */
     4/* $Id: maps.cc,v 1.6 2007-01-31 23:51:24 motsak Exp $ */
    55/*
    66* ABSTRACT - the mapping of polynomials to other rings
     
    258258    omFreeSize(names, (currRing->N)*sizeof(char*)); names=NULL;
    259259    memset(&tmpR,0,sizeof(tmpR));
    260     if ((rIsPluralRing(sourcering)) && (sourcering->nc->type!=nc_comm))
     260    if ((rIsPluralRing(sourcering)) && (ncRingType(sourcering)!=nc_comm))
    261261    {
    262262      Werror("Sorry, not yet implemented for noncomm. rings");
  • kernel/pInline2.h

    r1cc61e r86016d  
    77 *  Author:  obachman (Olaf Bachmann)
    88 *  Created: 8/00
    9  *  Version: $Id: pInline2.h,v 1.9 2007-01-11 11:27:25 Singular Exp $
     9 *  Version: $Id: pInline2.h,v 1.10 2007-01-31 23:51:24 motsak Exp $
    1010 *******************************************************************/
    1111#ifndef PINLINE2_H
     
    596596#ifdef HAVE_PLURAL
    597597    if (rIsPluralRing(r))
    598       q = mm_Mult_p(p, q, r);
     598      q = nc_mm_Mult_p(p, q, r);
    599599    else
    600600#endif /* HAVE_PLURAL */
  • kernel/p_Procs_Set.h

    r1cc61e r86016d  
    1212 *  Author:  obachman (Olaf Bachmann)
    1313 *  Created: 12/00
    14  *  Version: $Id: p_Procs_Set.h,v 1.11 2007-01-15 17:13:59 Singular Exp $
     14 *  Version: $Id: p_Procs_Set.h,v 1.12 2007-01-31 23:51:24 motsak Exp $
    1515 *******************************************************************/
    1616#include "modulop.h"
    1717
    18 #include "sca.h"
     18#ifdef HAVE_PLURAL
     19// for nc_p_ProcsSet:
     20#include "gring.h"
     21#endif
    1922
    2023
     
    176179         r->OrdSgn == 1 || r->LexOrder);
    177180*/
    178   #ifdef HAVE_PLURAL
     181#ifdef HAVE_PLURAL
    179182  if (rIsPluralRing(r))
    180   {
    181     SetProcsGNC(r, _p_procs);
    182 
    183     if(rIsSCA(r))
    184     {
    185       SetProcsSCA(r, _p_procs);
    186     }
    187   }
    188   #endif
     183    nc_p_ProcsSet(r, _p_procs); // Setup non-commutative p_Procs table!
     184#endif
    189185}
    190186
  • kernel/ring.cc

    r1cc61e r86016d  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: ring.cc,v 1.55 2007-01-29 18:08:21 Singular Exp $ */
     4/* $Id: ring.cc,v 1.56 2007-01-31 23:51:24 motsak Exp $ */
    55
    66/*
     
    2626#ifdef HAVE_PLURAL
    2727#include "gring.h"
     28#include "sca.h"
    2829#endif
    2930#include "maps.h"
     
    390391    else PrintS(" ...");
    391392#ifdef PDEBUG
    392     Print("\n//   noncommutative type:%d",r->nc->type);
     393    Print("\n//   noncommutative type:%d", (int)ncRingType(r));
    393394    Print("\n//   is skew constant:%d",r->nc->IsSkewConstant);
     395    if( rIsSCA(r) )
     396    {
     397      Print("\n//   alternating variables: [%d, %d]", scaFirstAltVar(r), scaLastAltVar(r));
     398      const ideal Q = r->nc->SCAQuotient(); // resides within r!
     399      if (Q!=NULL)
     400      {
     401        PrintS("\n//   quotient of sca by ideal");
     402        if (r==currRing)
     403        {
     404          PrintLn();
     405          iiWriteMatrix((matrix)Q,"__",1);
     406        }
     407        else PrintS(" ...");
     408      }
     409    }
    394410    Print("\n//   ref:%d",r->nc->ref);
    395411#endif
     
    11571173    if ( !R2_is_nc ) nc_rCreateNCcomm(R2);
    11581174    /* nc->type's */
    1159     sum->nc->type = nc_undef;
    1160     nc_type t1 = R1->nc->type, t2 = R2->nc->type;
    1161     if ( t1==t2) sum->nc->type = t1;
     1175    ncRingType(sum, nc_undef);
     1176    nc_type t1 = ncRingType(R1), t2 = ncRingType(R2);
     1177    if ( t1==t2) ncRingType(sum, t1);
    11621178    else
    11631179    {
    1164       if ( (t1==nc_general) || (t2==nc_general) ) sum->nc->type = nc_general;
    1165     }
    1166     if (sum->nc->type == nc_undef) /* not yet done */
     1180      if ( (t1==nc_general) || (t2==nc_general) ) ncRingType(sum, nc_general);
     1181    }
     1182    if (ncRingType(sum) == nc_undef) /* not yet done */
    11671183    {
    11681184      switch (t1)
    11691185      {
    11701186        case nc_comm:
    1171           sum->nc->type = t2;
     1187          ncRingType(sum, t2);
    11721188          break;
    11731189        case nc_lie:
     
    11751191          {
    11761192            case nc_skew:
    1177               sum->nc->type = nc_general;  break;
     1193              ncRingType(sum, nc_general);  break;
    11781194            case nc_comm:
    1179               sum->nc->type = nc_lie;  break;
     1195              ncRingType(sum, nc_lie);  break;
    11801196            default:
    11811197              /*sum->nc->type = nc_undef;*/  break;
     
    11861202          {
    11871203            case nc_lie:
    1188               sum->nc->type = nc_lie;  break;
     1204              ncRingType(sum, nc_lie);  break;
    11891205            case nc_comm:
    1190               sum->nc->type = nc_skew;  break;
     1206              ncRingType(sum, nc_skew);  break;
    11911207            default:
    11921208              /*sum->nc->type = nc_undef;*/  break;
     
    11971213      }
    11981214    }
    1199     if (sum->nc->type == nc_undef)
     1215    if (ncRingType(sum) == nc_undef)
    12001216      WarnS("Error on recognizing nc types");
    12011217    /* multiplication matrices business: */
     
    39503966  r->nc->ref      = 1; /* in spite of rCopy(src)? */
    39513967  r->nc->basering = r;
    3952   r->nc->type     =  src->nc->type;
     3968  ncRingType(r, ncRingType(src));
    39533969  int *perm       = (int *)omAlloc0((rVar(r)+1)*sizeof(int));
    39543970  int *par_perm   = NULL;
  • kernel/ring.h

    r1cc61e r86016d  
    77* ABSTRACT - the interpreter related ring operations
    88*/
    9 /* $Id: ring.h,v 1.16 2007-01-11 10:27:04 Singular Exp $ */
     9/* $Id: ring.h,v 1.17 2007-01-31 23:51:25 motsak Exp $ */
    1010
    1111/* includes */
     
    3333ring   rEnvelope(ring r);
    3434
     35// we must always have this test!
     36inline bool rIsPluralRing(const ring r)
     37{
    3538#ifdef HAVE_PLURAL
    36 inline BOOLEAN rIsPluralRing(ring r)
    37 {
    38   return ((r != NULL) && (r->nc != NULL) && (r->nc->type != nc_error));
    39 }
    40 #else
    41 #define rIsPluralRing(R) 0
    42 #endif
     39  return (r != NULL) && (r->nc != NULL) && (r->nc->type != nc_error);
     40#else
     41  return false;
     42#endif
     43}
    4344
    4445
  • kernel/sca.cc

    r1cc61e r86016d  
    77 *  Author:  motsak (Oleksandr Motsak)
    88 *  Created: 2006/12/18
    9  *  Version: $Id: sca.cc,v 1.7 2007-01-25 16:36:50 Singular Exp $
     9 *  Version: $Id: sca.cc,v 1.8 2007-01-31 23:51:25 motsak Exp $
    1010 *******************************************************************/
    1111
     
    4343
    4444
    45 //   scaFirstAltVar( r, 0 );
    46 //   scaLastAltVar( r, 0 );
     45// poly functions defined in p_Procs :
     46
     47// return pPoly * pMonom; preserve pPoly and pMonom.
     48poly sca_pp_Mult_mm(const poly pPoly, const poly pMonom, const ring rRing, poly &);
     49
     50// return pMonom * pPoly; preserve pPoly and pMonom.
     51poly sca_mm_Mult_pp(const poly pMonom, const poly pPoly, const ring rRing);
     52
     53// return pPoly * pMonom; preserve pMonom, destroy or reuse pPoly.
     54poly sca_p_Mult_mm(poly pPoly, const poly pMonom, const ring rRing);
     55
     56// return pMonom * pPoly; preserve pMonom, destroy or reuse pPoly.
     57poly sca_mm_Mult_p(const poly pMonom, poly pPoly, const ring rRing);
     58
     59
     60// compute the spolynomial of p1 and p2
     61poly sca_SPoly(const poly p1, const poly p2, const ring r);
     62poly sca_ReduceSpoly(const poly p1, poly p2, const ring r);
     63
     64// Modified Plural's Buchberger's algorithmus.
     65ideal sca_gr_bba(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat);
     66
     67// Modified modern Sinuglar Buchberger's algorithm.
     68ideal sca_bba(const ideal F, const ideal Q, const intvec *w, const intvec *, kStrategy strat);
     69
     70// Modified modern Sinuglar Mora's algorithm.
     71ideal sca_mora(const ideal F, const ideal Q, const intvec *w, const intvec *, kStrategy strat);
    4772
    4873
     
    280305    assume( scaFirstAltVar(rRing) <= i );
    281306
    282     if( p_GetExp(pMonom, i, rRing) ) // result is zero!
     307    if( p_GetExp(pMonom, i, rRing) != 0 ) // => result is zero!
    283308      return NULL;
    284309
     
    939964  assume(rIsSCA(currRing));
    940965
    941   BOOLEAN bIdHomog = id_IsYHomogeneous(F, currRing);
     966  const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
     967  const unsigned int m_iLastAltVar  = scaLastAltVar(currRing);
     968 
     969  ideal tempF = id_KillSquares(F, m_iFirstAltVar, m_iLastAltVar, currRing);
     970  const ideal tempQ = currRing->nc->SCAQuotient();
     971
     972  BOOLEAN bIdHomog = id_IsBiHomogeneous(tempF, m_iFirstAltVar, m_iLastAltVar, currRing);
     973
     974  assume( !bIdHomog || strat->homog ); //  bIdHomog =====[implies]>>>>> strat->homog
    942975
    943976  strat->homog = strat->homog && bIdHomog;
     
    952985  {
    953986    Print("ideal F: \n");
    954     for (int i = 0; i < F->idelems(); i++)
     987    for (int i = 0; i < tempF->idelems(); i++)
    955988    {
    956989      Print("; F[%d] = ", i+1);
    957       p_Write(F->m[i], currRing);
     990      p_Write(tempF->m[i], currRing);
    958991    }
    959992    Print(";\n");
     
    9761009  initBuchMoraCrit(strat); // set Gebauer, honey, sugarCrit
    9771010
    978   gr_initBba(F,strat); // set enterS, red, initEcart, initEcartPair
     1011  nc_gr_initBba(tempF,strat); // set enterS, red, initEcart, initEcartPair
    9791012
    9801013  initBuchMoraPos(strat);
     
    9831016  // ?? set spSpolyShort, reduce ???
    9841017
    985   initBuchMora(F, NULL, strat); // Q  = squares!!!!!!!
     1018  initBuchMora(tempF, tempQ, strat); // currRing->nc->SCAQuotient() instead of Q == squares!!!!!!!
    9861019
    9871020  strat->posInT=posInT110; // !!!
     
    9891022  srmax = strat->sl;
    9901023  reduc = olddeg = lrmax = 0;
    991 
    992 
    993   const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
    994   const unsigned int m_iLastAltVar  = scaLastAltVar(currRing);
    995 
    996 
    9971024
    9981025
     
    10611088    if (strat->sl > srmax) srmax = strat->sl;
    10621089
    1063     ////////////// children !!!!!!!!!!!!!
    1064 
    10651090    const poly save = strat->P.p;
    10661091
    1067 //     if( save != NULL )
    1068     {
    1069 
    10701092#ifdef PDEBUG
    10711093      p_Test(save, currRing);
    10721094#endif
    1073 
     1095    assume( save != NULL );
     1096   
     1097    // SCA Specials:
     1098
     1099    {
    10741100      const poly pNext = pNext(save);
    1075 
     1101     
     1102      if( pNext != NULL )
    10761103      for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ )
    1077       if( pGetExp(save, i)!=0 )
     1104      if( p_GetExp(save, i, currRing) != 0 )
    10781105      {
     1106        assume(p_GetExp(save, i, currRing) == 1);
     1107       
    10791108        const poly tt = sca_pp_Mult_xi_pp(i, pNext, currRing);
    10801109
     
    11141143//         if(h.IsNull()) continue;
    11151144
    1116 
    1117   //       poly save = p_Copy(h.p, currRing);
     1145//         poly save = p_Copy(h.p, currRing);
    11181146
    11191147        int pos;
     
    11581186  if (TEST_OPT_PROT) messageStat(srmax,lrmax,hilbcount,strat);
    11591187
    1160 //  if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
     1188  if (tempQ!=NULL) updateResult(strat->Shdl,tempQ,strat);
     1189 
     1190  id_Delete(&tempF, currRing);
    11611191
    11621192
     
    11661196
    11671197    ideal I = strat->Shdl;
    1168     ideal erg = kInterRed(I,NULL);
     1198    ideal erg = kInterRed(I,tempQ);
    11691199    assume(I!=erg);
    11701200    id_Delete(&I, currRing);
     
    11741204
    11751205#if 0
    1176   {
    1177     Print("ideal S: \n");
    1178     for (int i = 0; i < F->idelems(); i++)
    1179     {
    1180       Print("; S[%d] = ", 1+i);
    1181       p_Write(F->m[i], currRing);
    1182     }
    1183     Print(";\n");
    1184     PrintLn();
    1185   }
    1186 
    11871206   PrintS("</sca::bba>\n");
    11881207#endif
     
    11921211
    11931212
    1194 // is this an exterior algebra or a commuunative polynomial ring \otimes exterior algebra?
    1195 // we should check whether qr->qideal is of the form: y_i^2, y_{i+1}^2, \ldots, y_j^2 (j > i)
    1196 //.if yes, setup qr->nc->type, etc.
    1197 bool sca_SetupSCA(ring& rGR, const ring rG)
     1213// should be used only inside nc_SetupQuotient!
     1214// Check whether this our case:
     1215//  1. rG is  a commutative polynomial ring \otimes anticommutative algebra
     1216//  2. factor ideal rGR->qideal contains squares of all alternating variables.
     1217//
     1218// if yes, make rGR a super-commutative algebra!
     1219// NOTE: Factors of SuperCommutative Algebras are supported this way!
     1220bool sca_SetupQuotient(ring rGR, const ring rG)
    11981221{
    11991222//   return false; // test Plural
     
    12081231
    12091232  const int N = rG->N;
     1233
    12101234  if(N < 2)
    12111235    return false;
    12121236
    1213   // skew-commutative + constant skew? => no tensor products at the moment!!! Only exterior algebras are supported!
    1214 
    1215 //   if( rG->nc->D != NULL )
    1216 //     return false;
    1217 
    12181237  if(ncRingType(rG) != nc_skew)
    12191238    return false;
    12201239
    1221 //   if(rG->nc->IsSkewConstant != 1)
    1222 //     return false;
    1223 //
    1224 //   if(!n_IsMOne(p_GetCoeff(MATELEM(rG->nc->COM,1,2),rG->nc->basering), rG->nc->basering)) // COM live in basering!
    1225 //     return false;
    1226 
    1227 
    1228   assume(rGR->qideal != NULL);
    1229 
    1230   // sort qr->qideal:
    1231 
    1232   // for sanity
    1233   ring rSaveRing = currRing;
    1234 
    1235   bool bWeChangeRing = false;
    1236   if(currRing != rG)
    1237   {
    1238     rChangeCurrRing(rG);
    1239     bWeChangeRing = true;
    1240   }
    1241 
    1242   const ideal idQuotient = rGR->qideal;
    1243   const int   iQSize = idQuotient->idelems();
    1244 
    1245   intvec *iv = idSort(idQuotient, FALSE); // by lex, currRing dependent!!! :(
    1246   assume(iv != NULL);
    1247 
    1248   // check for y_{iAltVarStart}^2, y_{iAltVarStart+1}^2, \ldots, y_{iAltVarEnd}^2 (iAltVarEnd > iAltVarStart)
    1249   bool bSCA = true;
    1250 
    1251   int iAltVarStart = -1;
    1252   int iAltVarEnd   = -1;
    1253 
    1254   for(int i = 0; i < iQSize; i++)
    1255   {
    1256     const poly t = idQuotient->m[(*iv)[i]-1];
    1257 
    1258     if( pNext(t) != NULL )
    1259     {
    1260       bSCA = false;
    1261       break;
    1262     }
    1263 
    1264     const int iComp = p_GetComp(t, rG);
    1265 
    1266     if( iComp > 0 )
    1267     {
    1268       bSCA = false;
    1269       break;
    1270     }
    1271 
    1272     int iV = -1;
    1273 
    1274     for (int j = N; j; j--)
    1275     {
    1276       const int e = p_GetExp (t, j, rGR);
    1277 
    1278       if( e > 0 )
    1279       {
    1280         if( (e != 2) || (iV != -1) )
    1281         {
    1282           bSCA = false;
    1283           break;
    1284         }
    1285 
    1286         iV = j;
    1287       }
    1288     }
    1289 
    1290     if(!bSCA) break;
    1291 
    1292     if(iV == -1)
    1293     {
    1294       bSCA = false;
    1295       break;
    1296     }
    1297 
    1298     if(iAltVarStart == -1)
    1299     {
    1300       iAltVarStart = iV;
    1301       iAltVarEnd   = iV;
    1302     } else
    1303     {
    1304       if((iAltVarStart-1) == iV)
    1305       {
    1306         iAltVarStart = iV;
    1307       } else
    1308       if((iAltVarEnd+1) == iV)
    1309       {
    1310         iAltVarEnd = iV;
     1240  if(rGR->qideal == NULL) // there will be a factor!
     1241    return false;
     1242
     1243  if(rG->qideal != NULL) // we cannot change from factor to factor!
     1244    return false;
     1245
     1246
     1247  int iAltVarEnd = -1;
     1248  int iAltVarStart   = N+1;
     1249
     1250  const ring rBase = rG->nc->basering;
     1251  const matrix C   = rG->nc->C; // live in rBase!
     1252
     1253  for(int i = 1; i < N; i++)
     1254  {
     1255    for(int j = i + 1; j <= N; j++)
     1256    {
     1257      assume(MATELEM(C,i,j) != NULL); // after CallPlural!
     1258      number c = p_GetCoeff(MATELEM(C,i,j), rBase);
     1259     
     1260      if( n_IsMOne(c, rBase) )
     1261      {       
     1262        if( i < iAltVarStart)
     1263          iAltVarStart = i;
     1264         
     1265        if( j > iAltVarEnd)
     1266          iAltVarEnd = j;
    13111267      } else
    13121268      {
    1313         bSCA = false;
    1314         break;
     1269        if( !n_IsOne(c, rBase) )
     1270        {
     1271#ifdef PDEBUG
     1272//           Print("Wrong Coeff at: [%d, %d]\n", i, j);
     1273#endif
     1274          return false;
     1275        }
    13151276      }
    13161277    }
    13171278  }
    13181279
    1319   // cleanup:
    1320   delete iv;
    1321 
    1322   if (bWeChangeRing)
    1323   {
    1324     rChangeCurrRing(rSaveRing);
    1325   }
    1326 
    1327 
    1328   if(!bSCA) return false;
    1329 
    1330   assume( 1            <= iAltVarStart );
    1331   assume( iAltVarStart <= iAltVarEnd   );
    1332   assume( iAltVarEnd   <= N            );
    1333 
    1334 #ifdef PDEBUG
    1335 //   Print("AltVars: [%d, %d]\n", iAltVarStart, iAltVarEnd);
    1336 #endif
    1337 
    1338   const ring rBase = rG->nc->basering;
    1339   const matrix C   = rG->nc->C; // live in rBase!
    1340 
     1280  if( (iAltVarEnd == -1) || (iAltVarStart == (N+1)) )
     1281    return false; // either no alternating varables, or a single one => we are in commutative case!
     1282 
    13411283  for(int i = 1; i < N; i++)
    13421284  {
     
    13441286    {
    13451287      assume(MATELEM(C,i,j) != NULL); // after CallPlural!
    1346       number c = p_GetCoeff(MATELEM(C,i,j), rBase);
     1288      number c = p_GetCoeff(MATELEM(C,i,j), rBase);     
    13471289
    13481290      if( (iAltVarStart <= i) && (j <= iAltVarEnd) ) // S <= i < j <= E
     
    13681310  }
    13691311
     1312  assume( 1            <= iAltVarStart );
     1313  assume( iAltVarStart < iAltVarEnd   );
     1314  assume( iAltVarEnd   <= N            );
     1315
     1316  bool bWeChangeRing = false;
     1317  // for sanity
     1318  ring rSaveRing = currRing;
     1319
     1320  if(rSaveRing != rG)
     1321  {
     1322    rChangeCurrRing(rG);
     1323    bWeChangeRing = true;
     1324  }
     1325
     1326  assume(rGR->qideal != NULL);
     1327  assume(rG->qideal == NULL);
     1328 
     1329  const ideal idQuotient = rGR->qideal;
     1330
     1331  // check for
     1332  // y_{iAltVarStart}^2, y_{iAltVarStart+1}^2, \ldots, y_{iAltVarEnd}^2  (iAltVarEnd > iAltVarStart)
     1333  // to be within quotient ideal.
     1334
     1335  bool bSCA = true;
     1336
     1337  for ( int i = iAltVarStart; (i <= iAltVarEnd) && bSCA; i++ )
     1338  {
     1339    poly square = p_ISet(1, rSaveRing);
     1340    p_SetExp(square, i, 2, rSaveRing); // square = var(i)^2.
     1341    p_Setm(square, rSaveRing);
     1342
     1343    // square = NF( var(i)^2 | Q )
     1344    // NOTE: rSaveRing == currRing now!
     1345    // NOTE: there is no better way to check this in general!
     1346    square = kNF(idQuotient, NULL, square, 0, 0);
     1347   
     1348    if( square != NULL ) // var(i)^2 is not in Q?
     1349    {
     1350      p_Delete(&square, rSaveRing);
     1351      bSCA = false;     
     1352    }   
     1353  }
     1354 
     1355
     1356  if (bWeChangeRing)
     1357  {
     1358    rChangeCurrRing(rSaveRing);
     1359  }
     1360
     1361  if(!bSCA) return false;
     1362 
     1363
     1364
     1365#ifdef PDEBUG
     1366//  Print("AltVars: [%d, %d]\n", iAltVarStart, iAltVarEnd);
     1367#endif
     1368
     1369
    13701370  //////////////////////////////////////////////////////////////////////////
    1371   // ok... let's setup it!!!
     1371  // ok... here we go. let's setup it!!!
    13721372  //////////////////////////////////////////////////////////////////////////
     1373  ideal tempQ = id_KillSquares(idQuotient, iAltVarStart, iAltVarEnd, rG); // in rG!!!
     1374
     1375  rGR->nc->SCAQuotient() = idrMoveR(tempQ, rG, rGR); // deletes tempQ!
    13731376
    13741377  ncRingType( rGR, nc_exterior );
     
    13771380  scaLastAltVar( rGR, iAltVarEnd );
    13781381
    1379   // ????????????????????????????????????????????????????????????????????????????????
    1380   // check ordering!!! alternating variables must be bigger than all other variables?
    1381 
    1382   SetProcsSCA(rGR, rGR->p_Procs);
    1383 
     1382
     1383
     1384  sca_p_ProcsSet(rGR, rGR->p_Procs);
     1385
     1386 
    13841387  return true;
    13851388}
     
    14181421  assume(rIsSCA(currRing));
    14191422
    1420   BOOLEAN bIdHomog = id_IsYHomogeneous(F, currRing);
     1423  const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
     1424  const unsigned int m_iLastAltVar  = scaLastAltVar(currRing);
     1425
     1426  BOOLEAN bIdHomog = id_IsBiHomogeneous(F, m_iFirstAltVar, m_iLastAltVar, currRing);
     1427
     1428  assume( !bIdHomog || strat->homog ); //  bIdHomog =====[implies]>>>>> strat->homog
    14211429
    14221430  strat->homog = strat->homog && bIdHomog;
     
    14421450//   initHilbCrit(F, Q, &hilb, strat);
    14431451
    1444 //  gr_initBba(F,strat);
     1452//  nc_gr_initBba(F,strat);
    14451453  initBba(F, strat); // set enterS, red, initEcart, initEcartPair
    14461454
     
    14761484  ///////////////////////////////////////////////////////////////
    14771485  // SCA:
    1478   const unsigned short m_iFirstAltVar = scaFirstAltVar(currRing);
    1479   const unsigned short m_iLastAltVar  = scaLastAltVar(currRing);
    1480 
    1481 
    14821486
    14831487  /* compute------------------------------------------------------- */
     
    16431647
    16441648//       if(0)
    1645       for( unsigned short i = m_iFirstAltVar; i <= m_iLastAltVar; i++ )
    1646       if( p_GetExp(pSave, i, currRing) )
     1649      for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ )
     1650      if( p_GetExp(pSave, i, currRing) != 0 )
    16471651      {
     1652        assume(p_GetExp(pSave, i, currRing) == 1);
     1653       
    16481654        const poly pNew = sca_pp_Mult_xi_pp(i, pNext, currRing);
    16491655
     
    17831789
    17841790
    1785 
    1786 // y-Degree
    1787 inline long p_yDegree(const poly p, const ring r)
    1788 {
    1789   assume(rIsSCA(r));
    1790 
    1791   const unsigned short m_iFirstAltVar = scaFirstAltVar(r);
    1792   const unsigned short m_iLastAltVar  = scaLastAltVar(r);
    1793 
    1794   long sum = 0;
    1795 
    1796   for(int i = m_iFirstAltVar; i <= m_iLastAltVar; i++)
    1797     sum += p_GetExp(p, i, r);
    1798 
    1799   return sum;
    1800 }
    1801 
    1802 
    1803 
    1804 
    1805 /**2
    1806  * tests whether p is sca-homogeneous without respect to the actual weigths(=>all ones)
    1807  */
    1808 BOOLEAN p_IsYHomogeneous(const poly p, const ring r)
    1809 {
    1810   assume(rIsSCA(r));
    1811 
    1812   if( p == NULL ) return TRUE;
    1813 
    1814   poly q = p;
    1815 
    1816   const long o = p_yDegree(q, r);
    1817   pIter(q);
    1818 
    1819   while( q != NULL )
    1820   {
    1821     if (p_yDegree(q,r) != o) return FALSE;
    1822     pIter(q);
    1823   }
    1824 
    1825   return TRUE;
    1826 }
    1827 
    1828 
    1829 /*2
    1830 *returns true if id is y-homogenous without respect to the aktual weights(=> all ones)
    1831 */
    1832 BOOLEAN id_IsYHomogeneous(const ideal id, const ring r)
    1833 {
    1834   if (id == NULL) return TRUE;
    1835 
    1836   const int iSize = IDELEMS(id);
    1837 
    1838   if (iSize == 0) return TRUE;
    1839 
    1840   BOOLEAN b = TRUE;
    1841 
    1842   for(int i = iSize - 1; (i >= 0 ) && b; i--)
    1843     b = p_IsYHomogeneous(id->m[i], r);
    1844 
    1845   return b;
    1846 }
    1847 
    18481791// //////////////////////////////////////////////////////////////////////////////
    18491792// sca mora...
     
    18841827ideal sca_mora(const ideal F, const ideal Q, const intvec *w, const intvec *, kStrategy strat)
    18851828{
    1886   BOOLEAN bIdHomog = id_IsYHomogeneous(F, currRing);
     1829  assume(rIsSCA(currRing));
     1830
     1831  const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
     1832  const unsigned int m_iLastAltVar  = scaLastAltVar(currRing);
     1833 
     1834  ideal tempF = id_KillSquares(F, m_iFirstAltVar, m_iLastAltVar, currRing);
     1835 
     1836  const ideal tempQ = currRing->nc->SCAQuotient();
     1837
     1838  BOOLEAN bIdHomog = id_IsBiHomogeneous(tempF, m_iFirstAltVar, m_iLastAltVar, currRing);
     1839
     1840  assume( !bIdHomog || strat->homog ); //  bIdHomog =====[implies]>>>>> strat->homog
    18871841
    18881842  strat->homog = strat->homog && bIdHomog;
     
    18911845  assume( strat->homog == bIdHomog );
    18921846#endif /*PDEBUG*/
    1893 
    18941847
    18951848#ifdef HAVE_ASSUME
     
    18971850  sca_mora_loop_count = 0;
    18981851#endif
     1852
    18991853#ifdef KDEBUG
    19001854  om_Opts.MinTrack = 5;
     
    19111865  initBuchMoraCrit(strat);
    19121866//   initHilbCrit(F,NULL,&hilb,strat); // no Q!
    1913   initMora(F,strat);
     1867  initMora(tempF, strat);
    19141868  initBuchMoraPos(strat);
    1915   /*Shdl=*/initBuchMora(F,NULL,strat); // no Q!
     1869  /*Shdl=*/initBuchMora(tempF, tempQ, strat); // temp Q, F!
    19161870//   if (TEST_OPT_FASTHC) missingAxis(&strat->lastAxis,strat);
    19171871  /*updateS in initBuchMora has Hecketest
     
    19511905#endif
    19521906
    1953 
    1954   // 4SCA:
    1955   const unsigned short m_iFirstAltVar = scaFirstAltVar(currRing);
    1956   const unsigned short m_iLastAltVar  = scaLastAltVar(currRing);
    19571907
    19581908  while (strat->Ll >= 0)
     
    20522002      const poly pNext = pNext(pSave);
    20532003
    2054 //       if(0)
    2055       for( unsigned short i = m_iFirstAltVar; i <= m_iLastAltVar; i++ )
    2056       if( p_GetExp(pSave, i, currRing) )
     2004      if(pNext != NULL)
     2005      for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ )
     2006      if( p_GetExp(pSave, i, currRing) != 0 )
    20572007      {
    20582008
     
    21422092    }
    21432093  }
    2144 //   if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
     2094  if (tempQ!=NULL) updateResult(strat->Shdl,tempQ,strat);
    21452095  idTest(strat->Shdl);
     2096 
     2097  id_Delete( &tempF, currRing);
     2098 
    21462099  return (strat->Shdl);
    21472100}
     
    21522105
    21532106
    2154 void SetProcsSCA(ring& rGR, p_Procs_s* p_Procs)
     2107void sca_p_ProcsSet(ring rGR, p_Procs_s* p_Procs)
    21552108{
    21562109
     
    22142167#endif
    22152168}
    2216 #endif
     2169
     2170
     2171// bi-Degree (x, y) of lm(p)
     2172// Y are ones from iFirstAltVar up to iLastAltVar
     2173inline void p_GetSCADegree(const poly p,
     2174  const unsigned int iFirstAltVar, const unsigned int iLastAltVar,
     2175  long& dx, long& dy, const ring r)
     2176{
     2177  const unsigned int N  = r->N;
     2178
     2179  int i = 1;
     2180 
     2181  dx = 0;
     2182  dy = 0;
     2183 
     2184  for(; i < iFirstAltVar; i++)
     2185    dx += p_GetExp(p, i, r);
     2186
     2187  for(; i <= iLastAltVar; i++)
     2188    dy += p_GetExp(p, i, r);
     2189
     2190  for(; i <= N; i++)
     2191    dx += p_GetExp(p, i, r);
     2192}
     2193
     2194// tests whether p is bi-homogeneous without respect to the actual weigths(=>all ones)
     2195// Polynomial is bi-homogeneous iff all monomials have the same bi-degree (x,y).
     2196// Y are ones from iFirstAltVar up to iLastAltVar
     2197bool p_IsBiHomogeneous(const poly p,
     2198  const unsigned int iFirstAltVar, const unsigned int iLastAltVar,
     2199  const ring r)
     2200{
     2201  if( p == NULL ) return true;
     2202
     2203  poly q = p;
     2204
     2205
     2206  long dx, dy;
     2207
     2208  p_GetSCADegree( q, iFirstAltVar, iLastAltVar, dx, dy, r); // get bi degree of lm(p)
     2209
     2210  pIter(q);
     2211
     2212  for(; q != NULL; pIter(q) )
     2213  {
     2214    long x, y;   
     2215   
     2216    p_GetSCADegree( q, iFirstAltVar, iLastAltVar, x, y, r); // get bi degree of q
     2217   
     2218    if ( (x != dx) || (y != dy) ) return false;
     2219  }
     2220
     2221  return true;
     2222}
     2223
     2224
     2225// returns true if id is bi-homogenous without respect to the aktual weights(=> all ones)
     2226bool id_IsBiHomogeneous(const ideal id,
     2227  const unsigned int iFirstAltVar, const unsigned int iLastAltVar,
     2228  const ring r)
     2229{
     2230  if (id == NULL) return true; // zero ideal
     2231
     2232  const int iSize = IDELEMS(id);
     2233
     2234  if (iSize == 0) return true;
     2235
     2236  bool b = true;
     2237
     2238  for(int i = iSize - 1; (i >= 0 ) && b; i--)
     2239    b = p_IsBiHomogeneous(id->m[i], iFirstAltVar, iLastAltVar, r);
     2240
     2241  return b;
     2242}
     2243
     2244
     2245
     2246
     2247// reduce term lt(m) modulo <y_i^2> , i = iFirstAltVar .. iLastAltVar:
     2248// either create a copy of m or return NULL
     2249inline poly m_KillSquares(const poly m,
     2250  const unsigned int iFirstAltVar, const unsigned int iLastAltVar,
     2251  const ring r)
     2252
     2253#ifdef PDEBUG
     2254  p_Test(m, r);
     2255
     2256#if 0
     2257  Print("m_KillSquares, m = "); // !
     2258  p_Write(m, r);
     2259#endif
     2260#endif
     2261
     2262  assume( m != NULL );
     2263
     2264  for(int k = iFirstAltVar; k <= iLastAltVar; k++)
     2265    if( p_GetExp(m, k, r) > 1 )
     2266      return NULL; 
     2267 
     2268  return p_Head(m, r);
     2269}
     2270
     2271
     2272// reduce polynomial p modulo <y_i^2> , i = iFirstAltVar .. iLastAltVar
     2273poly p_KillSquares(const poly p,
     2274  const unsigned int iFirstAltVar, const unsigned int iLastAltVar,
     2275  const ring r)
     2276
     2277#ifdef PDEBUG
     2278  p_Test(p, r);
     2279
     2280#if 0
     2281  Print("p_KillSquares, p = "); // !
     2282  p_Write(p, r);
     2283#endif
     2284#endif
     2285
     2286
     2287  if( p == NULL )
     2288    return NULL;
     2289
     2290  poly pResult = NULL;
     2291  poly* ppPrev = &pResult;
     2292
     2293  for( poly q = p; q!= NULL; pIter(q) )
     2294  {
     2295#ifdef PDEBUG
     2296    p_Test(q, r);
     2297#endif
     2298
     2299    // terms will be in the same order because of quasi-ordering!   
     2300    poly v = m_KillSquares(q, iFirstAltVar, iLastAltVar, r);
     2301
     2302    if( v != NULL )
     2303    {
     2304      *ppPrev = v;
     2305      ppPrev = &pNext(v);
     2306    }
     2307
     2308  }
     2309
     2310#ifdef PDEBUG
     2311  p_Test(pResult, r);
     2312#if 0
     2313  Print("p_KillSquares => "); // !
     2314  p_Write(pResult, r);
     2315#endif
     2316#endif
     2317
     2318  return(pResult);
     2319}
     2320 
     2321
     2322
     2323
     2324// reduces ideal id modulo <y_i^2> , i = iFirstAltVar .. iLastAltVar
     2325// returns the reduced ideal or zero ideal.
     2326ideal id_KillSquares(const ideal id,
     2327  const unsigned int iFirstAltVar, const unsigned int iLastAltVar,
     2328  const ring r)
     2329{
     2330  if (id == NULL) return id; // zero ideal
     2331
     2332  const int iSize = id->idelems();
     2333
     2334  if (iSize == 0) return id;
     2335 
     2336  ideal temp = idInit(iSize, 1);
     2337 
     2338#if 0
     2339   PrintS("<id_KillSquares>\n");
     2340  {
     2341    Print("ideal id: \n");
     2342    for (int i = 0; i < id->idelems(); i++)
     2343    {
     2344      Print("; id[%d] = ", i+1);
     2345      p_Write(id->m[i], r);
     2346    }
     2347    Print(";\n");
     2348    PrintLn();
     2349  }
     2350#endif
     2351 
     2352
     2353  for (int j = 0; j < iSize; j++)
     2354    temp->m[j] = p_KillSquares(id->m[j], iFirstAltVar, iLastAltVar, r);
     2355
     2356  idSkipZeroes(temp);
     2357
     2358#if 0
     2359   PrintS("<id_KillSquares>\n");
     2360  {
     2361    Print("ideal temp: \n");
     2362    for (int i = 0; i < temp->idelems(); i++)
     2363    {
     2364      Print("; temp[%d] = ", i+1);
     2365      p_Write(temp->m[i], r);
     2366    }
     2367    Print(";\n");
     2368    PrintLn();
     2369  }
     2370   PrintS("</id_KillSquares>\n");
     2371#endif
     2372
     2373  return temp;
     2374}
     2375
     2376
     2377
     2378
     2379#endif
  • kernel/sca.h

    r1cc61e r86016d  
    55*  Computer Algebra System SINGULAR     *
    66****************************************/
    7 /* $Id: sca.h,v 1.6 2007-01-12 11:08:42 Singular Exp $ */
     7/* $Id: sca.h,v 1.7 2007-01-31 23:51:25 motsak Exp $ */
    88
     9#include <ring.h>
    910#include <gring.h>
     11#include <structs.h>
     12
     13
     14// we must always have this test!
     15inline bool rIsSCA(const ring r)
     16{
    1017#ifdef HAVE_PLURAL
    11 #include <structs.h>
    12 // #include <polys-impl.h>
    13 // #include <ring.h>
     18  return rIsPluralRing(r) && (ncRingType(r) == nc_exterior);
     19#else
     20  return false;
     21#endif
     22}
    1423
    15 inline bool rIsSCA(ring r)
    16 {
    17   if(!rIsPluralRing(r))
    18     return false;
    19 
    20   const bool result = (ncRingType(r) == nc_exterior);
    21 
    22 //   if( result )
    23 //     assume( ((scaFirstAltVar(r) != 0) && (scaLastAltVar(r) != 0)) );
    24 
    25   return(result);
    26 }
     24#ifdef HAVE_PLURAL
     25#include <gring.h>
    2726
    2827
     
    4140};
    4241
     42
     43// The following inlines are just helpers for setup functions.
    4344inline void scaFirstAltVar(ring r, int n)
    4445{
     
    6667
    6768// set pProcs for r and the variable p_Procs
    68 // should be used by p_ProcsSet in "p_Procs_Set.h"
    69 void SetProcsSCA(ring& rGR, p_Procs_s* p_Procs);
     69// should be used by nc_p_ProcsSet in "gring.h"
     70void sca_p_ProcsSet(ring rGR, p_Procs_s* p_Procs);
     71
     72//////////////////////////////////////////////////////////////////////////////////////
     73
     74// tests whether p is bi-homogeneous without respect to the actual weigths(=>all ones)
     75// Polynomial is bi-homogeneous iff all monomials have the same bi-degree (x,y).
     76// Y are ones from iFirstAltVar up to iLastAltVar
     77bool p_IsBiHomogeneous(const poly p,
     78  const unsigned int iFirstAltVar, const unsigned int iLastAltVar,
     79  const ring r);
     80
     81//////////////////////////////////////////////////////////////////////////////////////
     82
     83// returns true if id is bi-homogenous without respect to the aktual weights(=> all ones)
     84// Ideal is bi-homogeneous iff all its generators are bi-homogeneous.
     85bool id_IsBiHomogeneous(const ideal id,
     86  const unsigned int iFirstAltVar, const unsigned int iLastAltVar,
     87  const ring r);
     88
     89//////////////////////////////////////////////////////////////////////////////////////
     90
     91// reduce polynomial p modulo <y_i^2> , i = iFirstAltVar .. iLastAltVar
     92poly p_KillSquares(const poly p,
     93  const unsigned int iFirstAltVar, const unsigned int iLastAltVar,
     94  const ring r);
     95
     96//////////////////////////////////////////////////////////////////////////////////////
     97
     98// reduce ideal id modulo <y_i^2> , i = iFirstAltVar .. iLastAltVar
     99ideal id_KillSquares(const ideal id,
     100  const unsigned int iFirstAltVar, const unsigned int iLastAltVar,
     101  const ring r);
    70102
    71103
    72 // is this an exterior algebra or a commutative polynomial ring \otimes exterior algebra?
    73 // we should check whether qr->qideal is of the form: y_i^2, y_{i+1}^2, \ldots, y_j^2 (j > i)
    74 // if yes, setup qr->nc->type, etc.
    75 // should be used inside QRing definition!
    76 // NOTE: (&TODO): Factors of SuperCommutative Algebras are not supported this way!
    77 bool sca_SetupSCA(ring& rGR, const ring rG);
     104#ifdef PLURAL_INTERNAL_DECLARATIONS
    78105
     106// should be used only inside nc_SetupQuotient!
     107// Check whether this our case:
     108//  1. rG is  a commutative polynomial ring \otimes anticommutative algebra
     109//  2. factor ideal rGR->qideal contains squares of all alternating variables.
     110//
     111// if yes, make rGR a super-commutative algebra!
     112// NOTE: Factors of SuperCommutative Algebras are supported this way!
     113bool sca_SetupQuotient(ring rGR, const ring rG);
    79114
    80 
    81 
    82 // tests whether p is sca(y)-homogeneous without respect to the actual weigths(=>all ones)
    83 BOOLEAN p_IsYHomogeneous(const poly p, const ring r);
    84 
    85 // returns true if id is sca(y)-homogenous without respect to the aktual weights(=> all ones)
    86 BOOLEAN id_IsYHomogeneous(const ideal id, const ring r);
    87 
    88 
    89 
    90 // #define PLURAL_INTERNAL_DECLARATIONS
    91 
    92 #ifdef PLURAL_INTERNAL_DECLARATIONS
    93 // poly functions defined in p_Procs :
    94 
    95 // return pPoly * pMonom; preserve pPoly and pMonom.
    96 poly sca_pp_Mult_mm(const poly pPoly, const poly pMonom, const ring rRing, poly &);
    97 
    98 // return pMonom * pPoly; preserve pPoly and pMonom.
    99 poly sca_mm_Mult_pp(const poly pMonom, const poly pPoly, const ring rRing);
    100 
    101 // return pPoly * pMonom; preserve pMonom, destroy or reuse pPoly.
    102 poly sca_p_Mult_mm(poly pPoly, const poly pMonom, const ring rRing);
    103 
    104 // return pMonom * pPoly; preserve pMonom, destroy or reuse pPoly.
    105 poly sca_mm_Mult_p(const poly pMonom, poly pPoly, const ring rRing);
    106 
    107 
    108 // compute the spolynomial of p1 and p2
    109 poly sca_SPoly(const poly p1, const poly p2, const ring r);
    110 poly sca_ReduceSpoly(const poly p1, poly p2, const ring r);
    111 
    112 // Modified Plural's Buchberger's algorithmus.
    113 ideal sca_gr_bba(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat);
    114 
    115 // Modified modern Sinuglar Buchberger's algorithm.
    116 ideal sca_bba(const ideal F, const ideal Q, const intvec *w, const intvec *, kStrategy strat);
    117 
    118 // Modified modern Sinuglar Mora's algorithm.
    119 ideal sca_mora(const ideal F, const ideal Q, const intvec *w, const intvec *, kStrategy strat);
    120 #endif
     115#endif // PLURAL_INTERNAL_DECLARATIONS
    121116
    122117
    123118#else
    124 #define rIsSCA(R) 0
    125 #define scaFirstAltVar(R) 0
    126 #define scaLastAltVar(R) 0
     119// these must not be used at all.
     120// #define scaFirstAltVar(R) 0
     121// #define scaLastAltVar(R) 0
    127122#endif
    128123#endif // #ifndef GRING_SUPER_COMMUTATIVE_ALGEBRA_H
  • kernel/structs.h

    r1cc61e r86016d  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: structs.h,v 1.29 2007-01-11 11:27:26 Singular Exp $ */
     6/* $Id: structs.h,v 1.30 2007-01-31 23:51:25 motsak Exp $ */
    77/*
    88* ABSTRACT
     
    462462    // iAltVarsStart, iAltVarsEnd are only used together with nc_type=nc_exterior
    463463    // 1 <= iAltVarsStart <= iAltVarsEnd <= r->N
    464     unsigned int iFirstAltVar, iLastAltVar;
     464    unsigned int iFirstAltVar, iLastAltVar; // = 0 by default
     465   
     466    // for factors of super-commutative algebras we need
     467    // the part of general quotient ideal modulo squares!   
     468    ideal idSCAQuotient; // = NULL by default.
    465469
    466470  public:
     
    470474    inline unsigned int FirstAltVar() const { return (iFirstAltVar); };
    471475    inline unsigned int LastAltVar () const { return (iLastAltVar ); };
     476
     477    inline ideal& SCAQuotient() { return (idSCAQuotient); };
    472478
    473479  public:
Note: See TracChangeset for help on using the changeset viewer.