Changeset 4eba3ad in git


Ignore:
Timestamp:
Apr 28, 2014, 8:49:00 PM (9 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'ad2543eab51733612ba7d118afc77edca719600e')
Children:
c7d29b194535c9015230fc587b2ae178c075ef3e
Parents:
92992c08c2f387188f53d5f874a342fb60dccc06
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2014-04-28 20:49:00+02:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2014-05-07 04:41:46+02:00
Message:
introduced SchreyerSyzygyComputationFlags for storing and passing ring attributes within SchreyerSyzygyComputatio

chg: renamed internal functions to avoid name conflicts
chg: better namespace handling
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/schreyer.lib

    r92992c r4eba3ad  
    22272227*/ 
    22282228  kill S;
    2229   "\ ----------------------------------- / ", "options: ", attrib(SSinit, "LEAD2SYZ"), attrib(SSinit, "TAILREDSYZ"), attrib(SSinit, "HYBRIDNF"), ": ", "Time: ", tt - t;
     2229  "\\ ----------------------------------- / ", "options: ", attrib(SSinit, "LEAD2SYZ"), attrib(SSinit, "TAILREDSYZ"), attrib(SSinit, "HYBRIDNF"), ": ", "Time: ", tt - t;
    22302230}
    22312231
  • dyn_modules/syzextra/mod_main.cc

    r92992c r4eba3ad  
    506506
    507507
     508
    508509static BOOLEAN _ComputeLeadingSyzygyTerms(leftv res, leftv h)
    509510{
     511  const SchreyerSyzygyComputationFlags attributes(currRingHdl);
     512     
     513  const BOOLEAN __DEBUG__      = attributes.__DEBUG__;
     514//  const BOOLEAN __SYZCHECK__   = attributes.__SYZCHECK__;
     515  const BOOLEAN __LEAD2SYZ__   = attributes.__LEAD2SYZ__;
     516//  const BOOLEAN __HYBRIDNF__   = attributes.__HYBRIDNF__;
     517//  const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;
     518
    510519  const ring r = currRing;
    511520  NoReturn(res);
     
    518527
    519528  assume( h != NULL ); 
    520 
    521 #ifndef NDEBUG
    522   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE)));
    523 #else
    524   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE)));
    525 #endif
    526529
    527530  if( h->Typ() == IDEAL_CMD || h->Typ() == MODUL_CMD)
     
    533536    if( __DEBUG__ )
    534537    {
    535       PrintS("ComputeLeadingSyzygyTerms::Input: \n");
    536      
    537       const BOOLEAN __LEAD2SYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"LEAD2SYZ",INT_CMD, (void*)0)));
    538       const BOOLEAN __TAILREDSYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"TAILREDSYZ",INT_CMD, (void*)0)));
    539       const BOOLEAN __SYZCHECK__ = (BOOLEAN)((long)(atGet(currRingHdl,"SYZCHECK",INT_CMD, (void*)0)));
    540 
    541 
    542       Print("\nSYZCHECK: \t%d", __SYZCHECK__);
    543       Print(", DEBUG: \t%d", __DEBUG__);
    544       Print(", LEAD2SYZ: \t%d", __LEAD2SYZ__);
    545       Print(", TAILREDSYZ: \t%d\n", __TAILREDSYZ__);
    546 
     538      PrintS("ComputeLeadingSyzygyTerms::Input: \n");     
    547539      dPrint(id, r, r, 1);
    548 
    549       assume( !__LEAD2SYZ__ );
    550540    }
     541   
     542    assume( !__LEAD2SYZ__ );
    551543
    552544    h = h->Next(); assume (h == NULL);
    553545
    554     const ideal newid = ComputeLeadingSyzygyTerms(id, r);
     546    const ideal newid = ComputeLeadingSyzygyTerms(id, r, attributes);
    555547   
    556548    res->data = newid; res->rtyp = MODUL_CMD;
     
    567559static BOOLEAN _Sort_c_ds(leftv res, leftv h)
    568560{
     561  const SchreyerSyzygyComputationFlags attributes(currRingHdl);
     562
     563  const BOOLEAN __DEBUG__      = attributes.__DEBUG__;
     564//  const BOOLEAN __SYZCHECK__   = attributes.__SYZCHECK__;
     565//  const BOOLEAN __LEAD2SYZ__   = attributes.__LEAD2SYZ__;
     566//  const BOOLEAN __HYBRIDNF__   = attributes.__HYBRIDNF__;
     567//  const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;
     568
    569569  NoReturn(res);
    570570
     
    579579
    580580  assume( h != NULL ); 
    581 
    582 #ifndef NDEBUG
    583   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE)));
    584 #else
    585   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE)));
    586 #endif
    587581
    588582  if(    (h->Typ() == IDEAL_CMD || h->Typ() == MODUL_CMD)
     
    598592    {
    599593      PrintS("Sort_c_ds::Input: \n");
    600 
    601       const BOOLEAN __LEAD2SYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"LEAD2SYZ",INT_CMD, (void*)0)));
    602       const BOOLEAN __TAILREDSYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"TAILREDSYZ",INT_CMD, (void*)0)));
    603       const BOOLEAN __SYZCHECK__ = (BOOLEAN)((long)(atGet(currRingHdl,"SYZCHECK",INT_CMD, (void*)0)));   
    604 
    605       Print("\nSYZCHECK: \t%d", __SYZCHECK__);
    606       Print(", DEBUG: \t%d", __DEBUG__);
    607       Print(", LEAD2SYZ: \t%d", __LEAD2SYZ__);
    608       Print(", TAILREDSYZ: \t%d\n", __TAILREDSYZ__);
    609 
    610594      dPrint(id, r, r, 1);     
    611595    }
     
    637621static BOOLEAN _Compute2LeadingSyzygyTerms(leftv res, leftv h)
    638622{
     623  const SchreyerSyzygyComputationFlags attributes(currRingHdl);
     624
     625  const BOOLEAN __DEBUG__      = attributes.__DEBUG__;
     626//  const BOOLEAN __SYZCHECK__   = attributes.__SYZCHECK__;
     627  const BOOLEAN __LEAD2SYZ__   = attributes.__LEAD2SYZ__;
     628//  const BOOLEAN __HYBRIDNF__   = attributes.__HYBRIDNF__;
     629//  const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;
     630
    639631  const ring r = currRing;
    640632  NoReturn(res);
     
    648640  assume( h != NULL ); 
    649641
    650 #ifndef NDEBUG
    651   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE)));
    652 #else
    653   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE)));
    654 #endif
    655 
    656   const BOOLEAN __LEAD2SYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"LEAD2SYZ",INT_CMD, (void*)0)));
    657  
    658   assume( __LEAD2SYZ__ );
     642  assume( __LEAD2SYZ__ ); // ???
    659643 
    660644  if( h->Typ() == IDEAL_CMD || h->Typ() == MODUL_CMD)
     
    672656    h = h->Next(); assume (h == NULL);
    673657
    674     res->data = Compute2LeadingSyzygyTerms(id, r);
     658    res->data = Compute2LeadingSyzygyTerms(id, r, attributes);
    675659    res->rtyp = MODUL_CMD;
    676660
     
    687671static BOOLEAN _FindReducer(leftv res, leftv h)
    688672{
     673  const SchreyerSyzygyComputationFlags attributes(currRingHdl);
     674
     675  const BOOLEAN __DEBUG__      = attributes.__DEBUG__;
     676//   const BOOLEAN __SYZCHECK__   = attributes.__SYZCHECK__;
     677//   const BOOLEAN __LEAD2SYZ__   = attributes.__LEAD2SYZ__;
     678//   const BOOLEAN __HYBRIDNF__   = attributes.__HYBRIDNF__;
     679  const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;
     680
    689681  const char* usage = "`FindReducer(<poly/vector>, <vector/0>, <ideal/module>[,<module>])` expected";
    690682  const ring r = currRing;
     
    692684  NoReturn(res);
    693685
    694 
    695 #ifndef NDEBUG
    696   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE)));
    697 #else
    698   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE)));
    699 #endif
    700 
    701   const BOOLEAN __TAILREDSYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"TAILREDSYZ",INT_CMD, (void*)0)));
    702686
    703687  if ((h==NULL) || (h->Typ()!=VECTOR_CMD && h->Typ() !=POLY_CMD) || (h->Data() == NULL))
     
    766750
    767751  res->rtyp = VECTOR_CMD;
    768   res->data = FindReducer(product, syzterm, L, LS, r);
     752  res->data = FindReducer(product, syzterm, L, LS, r, attributes);
    769753
    770754  if( __DEBUG__ )
     
    781765static BOOLEAN _SchreyerSyzygyNF(leftv res, leftv h)
    782766{
     767  const SchreyerSyzygyComputationFlags attributes(currRingHdl);
     768
     769  const BOOLEAN __DEBUG__      = attributes.__DEBUG__;
     770//   const BOOLEAN __SYZCHECK__   = attributes.__SYZCHECK__;
     771//   const BOOLEAN __LEAD2SYZ__   = attributes.__LEAD2SYZ__;
     772  const BOOLEAN __HYBRIDNF__   = attributes.__HYBRIDNF__;
     773  const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;
     774
    783775  const char* usage = "`SchreyerSyzygyNF(<vector>, <vector>, <ideal/module>, <ideal/module>[,<module>])` expected";
    784776  const ring r = currRing;
     
    786778  NoReturn(res);
    787779
    788 #ifndef NDEBUG
    789   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE)));
    790 #else
    791   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE)));
    792 #endif
    793 
    794   const BOOLEAN __TAILREDSYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"TAILREDSYZ",INT_CMD, (void*)0)));
    795 //  const BOOLEAN __LEAD2SYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"LEAD2SYZ",INT_CMD, (void*)0)));
    796   const BOOLEAN __SYZCHECK__ = (BOOLEAN)((long)(atGet(currRingHdl,"SYZCHECK",INT_CMD, (void*)0)));   
    797 
    798   const BOOLEAN __HYBRIDNF__ = (BOOLEAN)((long)(atGet(currRingHdl,"HYBRIDNF",INT_CMD, (void*)0)));
    799 
    800   assume( __HYBRIDNF__ );
     780  assume( __HYBRIDNF__ ); // ???
    801781 
    802782  if ((h==NULL) || (h->Typ() != VECTOR_CMD) || (h->Data() == NULL))
     
    872852 
    873853  res->rtyp = VECTOR_CMD;
    874   res->data = SchreyerSyzygyNF(syz_lead, syz_2, L, T, LS, r);
     854  res->data = SchreyerSyzygyNF(syz_lead, syz_2, L, T, LS, r, attributes);
    875855
    876856  if( __DEBUG__ )
     
    890870static BOOLEAN _ReduceTerm(leftv res, leftv h)
    891871{
     872  const SchreyerSyzygyComputationFlags attributes(currRingHdl);
     873
     874  const BOOLEAN __DEBUG__      = attributes.__DEBUG__;
     875  const BOOLEAN __SYZCHECK__   = attributes.__SYZCHECK__;
     876//   const BOOLEAN __LEAD2SYZ__   = attributes.__LEAD2SYZ__;
     877//   const BOOLEAN __HYBRIDNF__   = attributes.__HYBRIDNF__;
     878  const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;
     879
    892880  const char* usage = "`ReduceTerm(<poly>, <poly/vector>, <vector/0>, <ideal/module>, <ideal/module>[,<module>])` expected";
    893881  const ring r = currRing;
    894882
    895883  NoReturn(res);
    896 
    897 #ifndef NDEBUG
    898   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE)));
    899 #else
    900   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE)));
    901 #endif
    902 
    903   const BOOLEAN __TAILREDSYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"TAILREDSYZ",INT_CMD, (void*)0)));
    904 //  const BOOLEAN __LEAD2SYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"LEAD2SYZ",INT_CMD, (void*)0)));
    905   const BOOLEAN __SYZCHECK__ = (BOOLEAN)((long)(atGet(currRingHdl,"SYZCHECK",INT_CMD, (void*)0)));   
    906884
    907885  if ((h==NULL) || (h->Typ() !=POLY_CMD) || (h->Data() == NULL))
     
    1014992
    1015993  res->rtyp = VECTOR_CMD;
    1016   res->data = ReduceTerm(multiplier, term4reduction, syztermCheck, L, T, LS, r);
     994  res->data = ReduceTerm(multiplier, term4reduction, syztermCheck, L, T, LS, r, attributes);
    1017995
    1018996
     
    10341012static BOOLEAN _TraverseTail(leftv res, leftv h)
    10351013{
     1014  const SchreyerSyzygyComputationFlags attributes(currRingHdl);
     1015
     1016  const BOOLEAN __DEBUG__      = attributes.__DEBUG__;
     1017//   const BOOLEAN __SYZCHECK__   = attributes.__SYZCHECK__;
     1018//   const BOOLEAN __LEAD2SYZ__   = attributes.__LEAD2SYZ__;
     1019//   const BOOLEAN __HYBRIDNF__   = attributes.__HYBRIDNF__;
     1020  const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;
     1021
    10361022  const char* usage = "`TraverseTail(<poly>, <poly/vector>, <ideal/module>, <ideal/module>[,<module>])` expected";
    10371023  const ring r = currRing;
    10381024
    10391025  NoReturn(res);
    1040 
    1041 #ifndef NDEBUG
    1042   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE)));
    1043 #else
    1044   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE)));
    1045 #endif
    1046 
    1047   const BOOLEAN __TAILREDSYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"TAILREDSYZ",INT_CMD, (void*)1)));
    10481026
    10491027  if ((h==NULL) || (h->Typ() !=POLY_CMD) || (h->Data() == NULL))
     
    11211099
    11221100  res->rtyp = VECTOR_CMD;
    1123   res->data = TraverseTail(multiplier, tail, L, T, LS, r);
     1101  res->data = TraverseTail(multiplier, tail, L, T, LS, r, attributes);
    11241102
    11251103
     
    11391117static BOOLEAN _ComputeSyzygy(leftv res, leftv h)
    11401118{
     1119  const SchreyerSyzygyComputationFlags attributes(currRingHdl);
     1120
     1121  const BOOLEAN __DEBUG__      = attributes.__DEBUG__;
     1122//   const BOOLEAN __SYZCHECK__   = attributes.__SYZCHECK__;
     1123//   const BOOLEAN __LEAD2SYZ__   = attributes.__LEAD2SYZ__;
     1124//   const BOOLEAN __HYBRIDNF__   = attributes.__HYBRIDNF__;
     1125//   const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;
     1126
    11411127  const char* usage = "`ComputeSyzygy(<ideal/module>, <ideal/module>])` expected";
    11421128  const ring r = currRing;
     
    11441130  NoReturn(res);
    11451131
    1146 #ifndef NDEBUG
    1147   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE)));
    1148 #else
    1149   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE)));
    1150 #endif
    1151 
    11521132  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
    11531133  {
     
    11831163  ideal LL, TT;
    11841164
    1185   ComputeSyzygy(L, T, LL, TT, r);
     1165  ComputeSyzygy(L, T, LL, TT, r, attributes);
    11861166
    11871167  lists l = (lists)omAllocBin(slists_bin); l->Init(2);
  • dyn_modules/syzextra/singularxx_defs.h

    r92992c r4eba3ad  
    2323#define SINGULAR_singular_defs_h_
    2424
     25
     26#ifdef HAVE_NAMESPACES
     27
    2528#define BEGIN_NAMESPACE(a) namespace a {
    2629#define END_NAMESPACE }
     30
    2731#define USING_NAMESPACE(a) using namespace a;
     32#define FROM_NAMESPACE(a, s) a :: s
     33
     34#else
     35
     36#define BEGIN_NAMESPACE(a)
     37#define END_NAMESPACE
     38
     39#define USING_NAMESPACE(a)
     40#define FROM_NAMESPACE(a, s) s
     41
     42#endif
     43
    2844
    2945#define SINGULARXXNAME Singular
     
    3147#define BEGIN_NAMESPACE_SINGULARXX BEGIN_NAMESPACE(SINGULARXXNAME)
    3248#define END_NAMESPACE_SINGULARXX END_NAMESPACE
     49
    3350#define USING_NAMESPACE_SINGULARXX USING_NAMESPACE(SINGULARXXNAME)
    34 
    35 #define FROM_NAMESPACE_SINGULARXXNAME(s) SINGULARXXNAME :: s
     51#define FROM_NAMESPACE_SINGULARXXNAME(s) FROM_NAMESPACE(SINGULARXXNAME, s)
    3652
    3753#define BEGIN_NAMESPACE_NONAME BEGIN_NAMESPACE()
  • dyn_modules/syzextra/syzextra.cc

    r92992c r4eba3ad  
    9292  //return -( compare (c, qsorts) )
    9393
     94#ifndef NDEBUG
    9495  const int __DEBUG__ = 0;
    95 
    96 #ifndef NDEBUG
    9796  if( __DEBUG__ )
    9897  {
     
    216215 
    217216  if( sizeNew >= 2 )
    218     qsort_my(id->m, sizeNew, sizeof(poly), r, SORT_c_ds::cmp_c_ds);
     217    qsort_my(id->m, sizeNew, sizeof(poly), r, FROM_NAMESPACE(SORT_c_ds, cmp_c_ds));
    219218
    220219#undef qsort_my
     
    226225BEGIN_NAMESPACE(INTERNAL)
    227226
    228 ideal ComputeLeadingSyzygyTerms(const ideal& id, const ring r)
    229 {
     227ideal _ComputeLeadingSyzygyTerms(const ideal& id,
     228                                const ring r,
     229                                const SchreyerSyzygyComputationFlags attributes)
     230{
     231//   const BOOLEAN __DEBUG__      = attributes.__DEBUG__;
     232//   const BOOLEAN __SYZCHECK__   = attributes.__SYZCHECK__;
     233   const BOOLEAN __LEAD2SYZ__   = attributes.__LEAD2SYZ__;
     234//   const BOOLEAN __HYBRIDNF__   = attributes.__HYBRIDNF__;
     235//   const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;
     236
     237   assume(!__LEAD2SYZ__);
     238
    230239  // 1. set of components S?
    231240  // 2. for each component c from S: set of indices of leading terms
     
    329338}
    330339
    331 
    332 
    333 
    334 ideal Compute2LeadingSyzygyTerms(const ideal& id, const ring r)
    335 {
    336 #ifndef NDEBUG
    337   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE)));
    338 #else
    339   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE)));
    340 #endif
    341 
    342   const BOOLEAN __TAILREDSYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"TAILREDSYZ",INT_CMD, (void*)0)));
    343   const BOOLEAN __SYZCHECK__ = (BOOLEAN)((long)(atGet(currRingHdl,"SYZCHECK",INT_CMD, (void*)0)));   
    344 
    345 
     340ideal _Compute2LeadingSyzygyTerms(const ideal& id,
     341                                 const ring r,
     342                                 const SchreyerSyzygyComputationFlags attributes)
     343{
     344//   const BOOLEAN __DEBUG__      = attributes.__DEBUG__;
     345//   const BOOLEAN __SYZCHECK__   = attributes.__SYZCHECK__;
     346//   const BOOLEAN __LEAD2SYZ__   = attributes.__LEAD2SYZ__;
     347//   const BOOLEAN __HYBRIDNF__   = attributes.__HYBRIDNF__;
     348  const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;
     349 
    346350
    347351  // 1. set of components S?
     
    482486}
    483487
    484 poly FindReducer(poly product, poly syzterm,
    485                         ideal L, ideal LS,
    486                         const ring r)
    487 {
     488poly _FindReducer(poly product, poly syzterm,
     489                 ideal L, ideal LS,
     490                 const ring r,
     491                 const SchreyerSyzygyComputationFlags attributes)
     492{
     493  const BOOLEAN __DEBUG__      = attributes.__DEBUG__;
     494  const BOOLEAN __SYZCHECK__   = attributes.__SYZCHECK__;
     495//   const BOOLEAN __LEAD2SYZ__   = attributes.__LEAD2SYZ__;
     496//   const BOOLEAN __HYBRIDNF__   = attributes.__HYBRIDNF__;
     497//   const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;
     498
    488499  assume( product != NULL );
    489500  assume( L != NULL );
     
    495506
    496507  assume( c >= 0 && c < IDELEMS(L) );
    497 
    498 #ifndef NDEBUG
    499   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE)));
    500 #else
    501   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE)));
    502 #endif
    503 
    504   long debug = __DEBUG__;
    505   const BOOLEAN __SYZCHECK__ = (BOOLEAN)((long)(atGet(currRingHdl,"SYZCHECK",INT_CMD, (void*)debug)));   
    506508
    507509  if (__SYZCHECK__ && syzterm != NULL)
     
    542544        if( __DEBUG__ )
    543545        {
    544           Print("FindReducer::Test SYZTERM: q == syzterm !:((, syzterm is: ");
     546          Print("_FindReducer::Test SYZTERM: q == syzterm !:((, syzterm is: ");
    545547          dPrint(syzterm, r, r, 1);
    546548        }   
     
    564566          if( __DEBUG__ )
    565567          {
    566             Print("FindReducer::Test LS: q is divisible by LS[%d] !:((, diviser is: ", kk+1);
     568            Print("_FindReducer::Test LS: q is divisible by LS[%d] !:((, diviser is: ", kk+1);
    567569            dPrint(pp, r, r, 1);
    568570          }   
     
    589591}
    590592
    591 poly TraverseTail(poly multiplier, poly tail,
    592                          ideal L, ideal T, ideal LS,
    593                          const ring r)
    594 {
     593poly _ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck,
     594                ideal L, ideal T, ideal LS,
     595                const ring r, const SchreyerSyzygyComputationFlags attributes);
     596
     597poly _TraverseTail(poly multiplier, poly tail,
     598                  ideal L, ideal T, ideal LS,
     599                  const ring r,
     600                  const SchreyerSyzygyComputationFlags attributes)
     601{
     602//   const BOOLEAN __DEBUG__      = attributes.__DEBUG__;
     603//   const BOOLEAN __SYZCHECK__   = attributes.__SYZCHECK__;
     604//   const BOOLEAN __LEAD2SYZ__   = attributes.__LEAD2SYZ__;
     605//   const BOOLEAN __HYBRIDNF__   = attributes.__HYBRIDNF__;
     606//   const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;
     607
    595608  assume( multiplier != NULL );
    596609
     
    602615  // iterate over the tail
    603616  for(poly p = tail; p != NULL; p = pNext(p))
    604     s = p_Add_q(s, ReduceTerm(multiplier, p, NULL, L, T, LS, r), r); 
     617    s = p_Add_q(s, _ReduceTerm(multiplier, p, NULL, L, T, LS, r, attributes), r); 
    605618
    606619  return s;
     
    608621
    609622
    610 poly ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck,
    611                        ideal L, ideal T, ideal LS, const ring r)
    612 {
     623poly _ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck,
     624                ideal L, ideal T, ideal LS,
     625                const ring r,
     626                const SchreyerSyzygyComputationFlags attributes)
     627{
     628//   const BOOLEAN __DEBUG__      = attributes.__DEBUG__;
     629//   const BOOLEAN __SYZCHECK__   = attributes.__SYZCHECK__;
     630//   const BOOLEAN __LEAD2SYZ__   = attributes.__LEAD2SYZ__;
     631//   const BOOLEAN __HYBRIDNF__   = attributes.__HYBRIDNF__;
     632//   const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;
     633
    613634  assume( multiplier != NULL );
    614635  assume( term4reduction != NULL );
     
    627648    // NOTE: only LT(term4reduction) should be used in the following:
    628649    poly product = pp_Mult_mm(multiplier, term4reduction, r);
    629     s = FindReducer(product, syztermCheck, L, LS, r);
     650    s = _FindReducer(product, syztermCheck, L, LS, r, attributes);
    630651    p_Delete(&product, r);
    631652  }
     
    642663
    643664  if( tail != NULL )
    644     s = p_Add_q(s, TraverseTail(b, tail, L, T, LS, r), r); 
     665    s = p_Add_q(s, _TraverseTail(b, tail, L, T, LS, r, attributes), r); 
    645666
    646667  return s;
     
    648669
    649670
    650 poly SchreyerSyzygyNF(poly syz_lead, poly syz_2, ideal L, ideal T, ideal LS, const ring r)
    651 {
     671poly _SchreyerSyzygyNF(poly syz_lead, poly syz_2,
     672                      ideal L, ideal T, ideal LS,
     673                      const ring r,
     674                      const SchreyerSyzygyComputationFlags attributes)
     675{
     676//   const BOOLEAN __DEBUG__      = attributes.__DEBUG__;
     677//   const BOOLEAN __SYZCHECK__   = attributes.__SYZCHECK__;
     678//   const BOOLEAN __LEAD2SYZ__   = attributes.__LEAD2SYZ__;
     679//   const BOOLEAN __HYBRIDNF__   = attributes.__HYBRIDNF__;
     680//   const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;
     681
    652682  assume( syz_lead != NULL );
    653683  assume( syz_2 != NULL );
     
    678708  while (spoly != NULL)
    679709  {
    680     poly t = FindReducer(spoly, NULL, L, LS, r);
     710    poly t = _FindReducer(spoly, NULL, L, LS, r, attributes);
    681711
    682712    p_LmDelete(&spoly, r);
     
    701731
    702732
    703 void ComputeSyzygy(const ideal L, const ideal T, ideal& LL, ideal& TT, const ring R)
    704 {
     733void _ComputeSyzygy(const ideal L, const ideal T,
     734                   ideal& LL, ideal& TT,
     735                   const ring R,
     736                   const SchreyerSyzygyComputationFlags attributes)
     737{
     738//  const BOOLEAN __DEBUG__      = attributes.__DEBUG__;
     739//  const BOOLEAN __SYZCHECK__   = attributes.__SYZCHECK__;
     740  const BOOLEAN __LEAD2SYZ__   = attributes.__LEAD2SYZ__;
     741  const BOOLEAN __HYBRIDNF__   = attributes.__HYBRIDNF__;
     742  const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;
     743
    705744  assume( R == currRing ); // For attributes :-/
    706745
    707746  assume( IDELEMS(L) == IDELEMS(T) );
    708747
    709 #ifndef NDEBUG
    710   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE)));
    711 #else
    712   const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE)));
    713 #endif
    714 
    715   const BOOLEAN __LEAD2SYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"LEAD2SYZ",INT_CMD, (void*)1)));
    716   const BOOLEAN __TAILREDSYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"TAILREDSYZ",INT_CMD, (void*)1)));
    717   const BOOLEAN __SYZCHECK__ = (BOOLEAN)((long)(atGet(currRingHdl,"SYZCHECK",INT_CMD, (void*)__DEBUG__)));
    718 
    719   const BOOLEAN __HYBRIDNF__ = (BOOLEAN)((long)(atGet(currRingHdl,"HYBRIDNF",INT_CMD, (void*)0)));
    720 
    721 
    722748  if( __LEAD2SYZ__ )
    723     LL = Compute2LeadingSyzygyTerms(L, R); // 2 terms!
     749    LL = _Compute2LeadingSyzygyTerms(L, R, attributes); // 2 terms!
    724750  else
    725     LL = ComputeLeadingSyzygyTerms(L, R); // 1 term!
     751    LL = _ComputeLeadingSyzygyTerms(L, R, attributes); // 1 term!
    726752
    727753  const int size = IDELEMS(LL);
     
    758784    if( ! __HYBRIDNF__ )
    759785    {
    760       poly t = TraverseTail(aa, T->m[r], L, T, LS, R);
     786      poly t = _TraverseTail(aa, T->m[r], L, T, LS, R, attributes);
    761787
    762788      if( a2 != NULL )
     
    768794        assume( r2 >= 0 && r2 < IDELEMS(T) );
    769795
    770         TT->m[k] = p_Add_q(a2, p_Add_q(t, TraverseTail(aa2, T->m[r2], L, T, LS, R), R), R);
     796        TT->m[k] = p_Add_q(a2, p_Add_q(t, _TraverseTail(aa2, T->m[r2], L, T, LS, R, attributes), R), R);
    771797
    772798        p_Delete(&aa2, R);
    773799      } else
    774         TT->m[k] = p_Add_q(t, ReduceTerm(aa, L->m[r], a, L, T, LS, R), R);
     800        TT->m[k] = p_Add_q(t, _ReduceTerm(aa, L->m[r], a, L, T, LS, R, attributes), R);
    775801
    776802    } else
     
    779805      {
    780806        aa = p_Mult_mm(aa, L->m[r], R);
    781         a2 = FindReducer(aa, a, L, LS, R);
     807        a2 = _FindReducer(aa, a, L, LS, R, attributes);
    782808      }
    783809      assume( a2 != NULL );
    784810
    785       TT->m[k] = SchreyerSyzygyNF(a, a2, L, T, LS, R); // will copy a2 :(
     811      TT->m[k] = _SchreyerSyzygyNF(a, a2, L, T, LS, R, attributes); // will copy a2 :(
    786812
    787813      p_Delete(&a2, R);
     
    796822
    797823
     824// TODO: wrapper layer, just for now... dissolve!
     825
    798826void SchreyerSyzygyComputation::ComputeSyzygy()
    799827{
    800828  /// assumes m_syzLeads == m_syzTails == NULL!
    801   INTERNAL::ComputeSyzygy(m_idLeads, m_idTails, m_syzLeads, m_syzTails, m_rBaseRing); // TODO: just a wrapper for now :/
     829  FROM_NAMESPACE(INTERNAL, _ComputeSyzygy(m_idLeads, m_idTails, m_syzLeads, m_syzTails, m_rBaseRing, m_atttributes)); // TODO: just a wrapper for now :/
    802830}
    803831
     
    805833{
    806834  if( bComputeSecondTerms )
    807     m_syzLeads = INTERNAL::Compute2LeadingSyzygyTerms(m_idLeads, m_rBaseRing);
     835    m_syzLeads = FROM_NAMESPACE(INTERNAL, _Compute2LeadingSyzygyTerms(m_idLeads, m_rBaseRing, m_atttributes));
    808836  else
    809     m_syzLeads = INTERNAL::ComputeLeadingSyzygyTerms(m_idLeads, m_rBaseRing);
     837    m_syzLeads = FROM_NAMESPACE(INTERNAL, _ComputeLeadingSyzygyTerms(m_idLeads, m_rBaseRing, m_atttributes));
    810838 
    811839  // NOTE: set m_LS if tails are to be reduced!
    812840}
    813841
    814 poly SchreyerSyzygyComputation::FindReducer(poly product, poly syzterm)
    815 {
    816   return INTERNAL::FindReducer(product, syzterm, m_idLeads, m_LS, m_rBaseRing);
    817 }
    818 
    819 poly SchreyerSyzygyComputation::SchreyerSyzygyNF(poly syz_lead, poly syz_2)
    820 {
    821   return INTERNAL::SchreyerSyzygyNF(syz_lead, syz_2, m_idLeads, m_idTails, m_LS, m_rBaseRing);
    822 }
    823 
    824 poly SchreyerSyzygyComputation::TraverseTail(poly multiplier, poly tail)
    825 {
    826   return INTERNAL::TraverseTail(multiplier, tail, m_idLeads, m_idTails, m_LS, m_rBaseRing);
    827 }
    828 
    829 poly SchreyerSyzygyComputation::ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck)
    830 {
    831   return INTERNAL::ReduceTerm(multiplier, term4reduction, syztermCheck, m_idLeads, m_idTails, m_LS, m_rBaseRing);
    832 }
    833 
     842poly SchreyerSyzygyComputation::FindReducer(poly product, poly syzterm) const
     843{
     844  return FROM_NAMESPACE(INTERNAL, _FindReducer(product, syzterm, m_idLeads, m_LS, m_rBaseRing, m_atttributes));
     845}
     846
     847poly SchreyerSyzygyComputation::SchreyerSyzygyNF(poly syz_lead, poly syz_2) const
     848{
     849  return FROM_NAMESPACE(INTERNAL, _SchreyerSyzygyNF(syz_lead, syz_2, m_idLeads, m_idTails, m_LS, m_rBaseRing, m_atttributes));
     850}
     851
     852poly SchreyerSyzygyComputation::TraverseTail(poly multiplier, poly tail) const
     853{
     854  return FROM_NAMESPACE(INTERNAL, _TraverseTail(multiplier, tail, m_idLeads, m_idTails, m_LS, m_rBaseRing, m_atttributes));
     855}
     856
     857poly SchreyerSyzygyComputation::ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck) const
     858{
     859  return FROM_NAMESPACE(INTERNAL, _ReduceTerm(multiplier, term4reduction, syztermCheck, m_idLeads, m_idTails, m_LS, m_rBaseRing, m_atttributes));
     860}
     861
     862
     863BEGIN_NAMESPACE_NONAME
    834864   
     865static inline int atGetInt(idhdl rootRingHdl, const char* attribute, int def)
     866{
     867  return ((int)(long)(atGet(rootRingHdl, attribute, INT_CMD, (void*)def)));
     868}
     869
     870END_NAMESPACE   
     871
     872SchreyerSyzygyComputationFlags::SchreyerSyzygyComputationFlags(idhdl rootRingHdl):
     873#ifndef NDEBUG
     874    __DEBUG__( (BOOLEAN)atGetInt(rootRingHdl,"DEBUG", TRUE) ),
     875#else
     876    __DEBUG__( (BOOLEAN)atGetInt(rootRingHdl,"DEBUG", FALSE) ),
     877#endif
     878    __SYZCHECK__( (BOOLEAN)atGetInt(rootRingHdl, "SYZCHECK", __DEBUG__) ),
     879    __LEAD2SYZ__( (BOOLEAN)atGetInt(rootRingHdl, "LEAD2SYZ", 1) ),
     880    __TAILREDSYZ__( (BOOLEAN)atGetInt(rootRingHdl, "TAILREDSYZ", 1) ),
     881    __HYBRIDNF__( (BOOLEAN)atGetInt(rootRingHdl, "HYBRIDNF", 0) )
     882{   
     883  if( __DEBUG__ )
     884  {
     885    PrintS("SchreyerSyzygyComputationFlags: \n");
     886    Print("   DEBUG     : \t%d\n", __DEBUG__);
     887    Print("   SYZCHECK  : \t%d\n", __SYZCHECK__);
     888    Print("   LEAD2SYZ  : \t%d\n", __LEAD2SYZ__);
     889    Print("   TAILREDSYZ: \t%d\n", __TAILREDSYZ__);
     890  }
     891
     892  // TODO: just current setting!
     893  assume( rootRingHdl == currRingHdl );
     894  assume( rootRingHdl->typ == RING_CMD );
     895  assume( rootRingHdl->data.uring == currRing );
     896  // move the global ring here inside???
     897}
     898
     899   
    835900
    836901
  • dyn_modules/syzextra/syzextra.h

    r92992c r4eba3ad  
    3030typedef struct sip_sideal *       ideal;
    3131
     32class idrec;
     33typedef idrec *   idhdl;
    3234
    3335BEGIN_NAMESPACE_SINGULARXX    BEGIN_NAMESPACE(SYZEXTRA)
     
    5153
    5254
     55
     56
     57
     58/// Computation attribute storage
     59struct SchreyerSyzygyComputationFlags
     60{
     61  SchreyerSyzygyComputationFlags(idhdl rootRingHdl);
     62 
     63  /// output all the intermediate states
     64  const bool __DEBUG__; // DebugOutput;
     65
     66  /// ?
     67  const bool __SYZCHECK__; // CheckSyzygyProperty;
     68
     69  /// ?
     70  const bool __LEAD2SYZ__; // TwoLeadingSyzygyTerms;
     71
     72  /// Reduce syzygy tails wrt the leading syzygy terms
     73  const bool __TAILREDSYZ__; // TailReducedSyzygies;
     74
     75  /// Use the usual NF's S-poly reduction while dropping lower order terms
     76  const bool __HYBRIDNF__; // UseHybridNF
     77
     78};
     79
     80
     81
    5382/** @class SchreyerSyzygyComputation syzextra.h
    5483 *
     
    6594  public:
    6695    /// Construct a global object for given input data (separated into leads & tails)
    67     SchreyerSyzygyComputation(const ideal idLeads, const ideal idTails, const ring rBaseRing):
    68         m_idLeads(idLeads), m_idTails(idTails), m_rBaseRing(rBaseRing),
    69         m_syzLeads(NULL), m_syzTails(NULL), m_LS(NULL) {}
     96    SchreyerSyzygyComputation(const ideal idLeads, const ideal idTails, const ring rBaseRing, const SchreyerSyzygyComputationFlags attribues):
     97        m_rBaseRing(rBaseRing),
     98        m_idLeads(idLeads), m_idTails(idTails),
     99        m_syzLeads(NULL), m_syzTails(NULL), m_LS(NULL), m_atttributes(attribues) {}
    70100
    71101
    72102    /// Construct a global object for given input data (separated into leads & tails)
    73     SchreyerSyzygyComputation(const ideal idLeads, const ideal idTails, const ideal syzLeads, const ring rBaseRing):
    74         m_idLeads(idLeads), m_idTails(idTails), m_rBaseRing(rBaseRing),
    75         m_syzLeads(NULL), m_syzTails(NULL), m_LS(syzLeads) {}
     103    SchreyerSyzygyComputation(const ideal idLeads, const ideal idTails, const ideal syzLeads, const ring rBaseRing, const SchreyerSyzygyComputationFlags attribues):
     104        m_rBaseRing(rBaseRing),
     105        m_idLeads(idLeads), m_idTails(idTails),
     106        m_syzLeads(NULL), m_syzTails(NULL), m_LS(syzLeads), m_atttributes(attribues) {}
    76107
    77108   
     
    96127
    97128    // TODO: save shortcut (syz: |-.->) LM(LM(m) * "t") -> syz?
    98     poly FindReducer(poly product, poly syzterm);
    99    
    100     poly SchreyerSyzygyNF(poly syz_lead, poly syz_2);
     129    poly FindReducer(poly product, poly syzterm) const;
     130   
     131    poly SchreyerSyzygyNF(poly syz_lead, poly syz_2) const;
    101132
    102133    // TODO: store m * @tail -.-^-.-^-.--> ?
    103     poly TraverseTail(poly multiplier, poly tail);
     134    poly TraverseTail(poly multiplier, poly tail) const;
    104135
    105136    // TODO: save shortcut (syz: |-.->) LM(m) * "t" -> ?
    106     poly ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck);
    107 
    108    
     137    poly ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck) const;
     138
    109139  protected:
    110140   
     
    129159
    130160    /*mutable?*/ ideal m_LS; ///< leading syzygy terms used for reducing syzygy tails
     161
     162    const SchreyerSyzygyComputationFlags m_atttributes;
    131163};
    132164
     
    134166// The following wrappers are just for testing separate functions on highest level (within schreyer.lib)
    135167
    136 static inline void ComputeSyzygy(const ideal L, const ideal T, ideal& LL, ideal& TT, const ring R)
    137 {
    138   SchreyerSyzygyComputation syz(L, T, R);
     168static inline void ComputeSyzygy(const ideal L, const ideal T, ideal& LL, ideal& TT, const ring R, const SchreyerSyzygyComputationFlags A)
     169{
     170  SchreyerSyzygyComputation syz(L, T, R, A);
    139171  syz.ComputeSyzygy();
    140172  syz.ReadOffResult(LL, TT);
    141173}
    142174
    143 static inline ideal ComputeLeadingSyzygyTerms(const ideal& L, const ring R)
    144 {
    145   SchreyerSyzygyComputation syz(L, NULL, R);
     175static inline ideal ComputeLeadingSyzygyTerms(const ideal& L, const ring R, const SchreyerSyzygyComputationFlags A)
     176{
     177  SchreyerSyzygyComputation syz(L, NULL, R, A);
    146178  syz.ComputeLeadingSyzygyTerms(false);
    147179  ideal LL, TT;
     
    150182}
    151183
    152 static inline ideal Compute2LeadingSyzygyTerms(const ideal& L, const ring R)
    153 {
    154   SchreyerSyzygyComputation syz(L, NULL, R);
     184static inline ideal Compute2LeadingSyzygyTerms(const ideal& L, const ring R, const SchreyerSyzygyComputationFlags A)
     185{
     186  SchreyerSyzygyComputation syz(L, NULL, R, A);
    155187  syz.ComputeLeadingSyzygyTerms(true);
    156188  ideal LL, TT;
     
    160192
    161193static inline poly FindReducer(poly product, poly syzterm,
    162                                ideal L, ideal LS, const ring R)
    163 {
    164   SchreyerSyzygyComputation syz(L, NULL, LS, R);
     194                               ideal L, ideal LS, const ring R, const SchreyerSyzygyComputationFlags A)
     195{
     196  SchreyerSyzygyComputation syz(L, NULL, LS, R, A);
    165197  return syz.FindReducer(product, syzterm);
    166198}
    167199
    168200static inline poly TraverseTail(poly multiplier, poly tail,
    169                                 ideal L, ideal T, ideal LS, const ring R)
    170 {
    171   SchreyerSyzygyComputation syz(L, T, LS, R);
     201                                ideal L, ideal T, ideal LS, const ring R, const SchreyerSyzygyComputationFlags A)
     202{
     203  SchreyerSyzygyComputation syz(L, T, LS, R, A);
    172204  return syz.TraverseTail(multiplier, tail);
    173205}
    174206
    175207static inline poly ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck,
    176                               ideal L, ideal T, ideal LS, const ring R)
    177 {
    178   SchreyerSyzygyComputation syz(L, T, LS, R);
     208                              ideal L, ideal T, ideal LS, const ring R, const SchreyerSyzygyComputationFlags A)
     209{
     210  SchreyerSyzygyComputation syz(L, T, LS, R, A);
    179211  return syz.ReduceTerm(multiplier, term4reduction, syztermCheck);
    180212}
     
    182214
    183215static inline poly SchreyerSyzygyNF(poly syz_lead, poly syz_2,
    184                                     ideal L, ideal T, ideal LS, const ring R)
    185 {
    186   SchreyerSyzygyComputation syz(L, T, LS, R);
     216                                    ideal L, ideal T, ideal LS, const ring R, const SchreyerSyzygyComputationFlags A)
     217{
     218  SchreyerSyzygyComputation syz(L, T, LS, R, A);
    187219  return syz.SchreyerSyzygyNF(syz_lead, syz_2);
    188220}
    189 
    190 
    191221
    192222END_NAMESPACE
Note: See TracChangeset for help on using the changeset viewer.