Ignore:
Timestamp:
May 14, 2014, 4:02:50 PM (10 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '98550b669234b32be762076c32b3be2c35188ac4')
Children:
0f74a1d360bc1f2c80ba740d66bcf0a755b6e43d
Parents:
8b5fff53b54b8c7889b6490e4871793cfd8e4efe
Message:
removed currQuotient
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/dyn_modules/syzextra/syzextra.cc

    r8b5fff rac00e2f  
    11// -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
    22/*****************************************************************************\
    3  * Computer Algebra System SINGULAR   
     3 * Computer Algebra System SINGULAR
    44\*****************************************************************************/
    55/** @file syzextra.cc
    6  * 
     6 *
    77 * Here we implement the Computation of Syzygies
    88 *
     
    5050#include <Singular/attrib.h>
    5151
    52 #include <Singular/ipid.h> 
     52#include <Singular/ipid.h>
    5353#include <Singular/ipshell.h> // For iiAddCproc
    5454
     
    7373static int cmp_c_ds(const void *p1, const void *p2)
    7474{
    75   void *R = currRing; 
     75  void *R = currRing;
    7676#endif
    7777
     
    151151  }
    152152
    153   return 0; 
    154 }
    155 
    156    
     153  return 0;
     154}
     155
     156
    157157static int cmp_poly(const poly &a, const poly &b)
    158158{
     
    171171  assume( p_GetComp(a, r) == 0 );
    172172  assume( p_GetComp(b, r) == 0 );
    173    
     173
    174174#ifndef NDEBUG
    175175  const int __DEBUG__ = 0;
     
    198198  }
    199199
    200   return 0; 
    201 }
    202    
     200  return 0;
     201}
     202
    203203END_NAMESPACE
    204204/* namespace SORT_c_ds */
     
    213213    return;
    214214  }
    215    
     215
    216216  assume( r != NULL );
    217217  const coeffs C = r->cf; assume(C != NULL);
     
    221221
    222222  do {
    223   assume( p != NULL );   
    224        
     223  assume( p != NULL );
     224
    225225  // write coef...
    226226  number& n = p_GetCoeff(p, r);
    227227
    228228  n_Normalize(n, C);
    229      
     229
    230230  BOOLEAN writeMult = FALSE; ///< needs * before pp or module generator
    231231
    232232  BOOLEAN writeOne = FALSE; ///< need to write something after '-'!
    233      
     233
    234234  if( n_IsZero(n, C) )
    235235  {
     
    237237//    return; // yes?
    238238  }
    239  
     239
    240240  if (n_IsMOne(n, C))
    241   {     
     241  {
    242242    PrintS(" - "); writeOne = TRUE; writePlus = FALSE;
    243   }     
     243  }
    244244  else if (!n_IsOne(n, C))
    245245  {
    246246    if( writePlus && n_GreaterZero(n, C) )
    247247      PrintS(" + ");
    248    
    249     StringSetS(""); n_WriteLong(n, C); 
    250     if (true) 
     248
     249    StringSetS(""); n_WriteLong(n, C);
     250    if (true)
    251251    {
    252252      char *s = StringEndS(); PrintS(s); omFree(s);
    253253    }
    254      
    255      
     254
     255
    256256    writeMult = TRUE;
    257257    writePlus = TRUE;
    258258  } else
    259259     writeOne = TRUE;
    260    
     260
    261261  // missing '1' if no PP and gen...!?
    262262  // write monom...
     
    268268  {
    269269    const long ee = p_GetExp(p, i+1, r);
    270    
     270
    271271    if (ee!=0L)
    272272    {
     
    285285      else
    286286        Print(" %s ", rRingVar(i, r));
    287        
     287
    288288      writeOne = FALSE;
    289289      wrotePP = TRUE;
     
    292292
    293293  writePlus = writePlus || wrotePP;
    294   writeMult = writeMult || wrotePP; 
     294  writeMult = writeMult || wrotePP;
    295295
    296296  // write module gen...
    297297  const long comp = p_GetComp(p, r);
    298  
     298
    299299  if (comp > 0 )
    300300  {
    301301    if (writeMult)
    302302      PrintS(" \\\\cdot ");
    303      else 
     303     else
    304304      if( writePlus )
    305305        PrintS(" + ");
     
    309309    else
    310310      Print(" \\\\GENP{%ld} ", comp);
    311      
    312       writeOne = FALSE; 
    313   }
    314      
     311
     312      writeOne = FALSE;
     313  }
     314
    315315  if ( writeOne )
    316316    PrintS( writePlus? " + 1 " : " 1 " );
    317        
     317
    318318
    319319  pIter(p);
    320      
     320
    321321  writePlus = TRUE;
    322322  } while( (!bLTonly) && (p != NULL) );
    323    
    324 }
    325 
    326 
    327 
    328 
    329    
     323
     324}
     325
     326
     327
     328
     329
    330330/// return a new term: leading coeff * leading monomial of p
    331331/// with 0 leading component!
     
    346346    p_Setm(m, r);
    347347
    348    
     348
    349349    assume( m != NULL );
    350350    assume( pNext(m) == NULL );
    351351    assume( p_LmTest(m, r) );
    352    
     352
    353353    if( bSetZeroComp )
    354354      assume( p_GetComp(m, r) == 0 );
     
    359359
    360360
    361    
     361
    362362poly p_Tail(const poly p, const ring r)
    363363{
     
    375375
    376376  const ideal newid = idInit(IDELEMS(id),id->rank);
    377  
     377
    378378  for (int i=IDELEMS(id) - 1; i >= 0; i--)
    379379    newid->m[i] = p_Tail( id->m[i], r );
     
    381381  newid->rank = id_RankFreeModule(newid, currRing);
    382382
    383   return newid; 
     383  return newid;
    384384}
    385385
     
    395395#define qsort_my(m, s, ss, r, cmp) qsort_r(m, s, ss, cmp)
    396396#endif
    397  
     397
    398398  if( sizeNew >= 2 )
    399399    qsort_my(id->m, sizeNew, sizeof(poly), r, FROM_NAMESPACE(SORT_c_ds, cmp_c_ds));
     
    408408{
    409409  extern void id_Delete (ideal*, const ring);
    410    
     410
    411411  id_Delete(const_cast<ideal*>(&m_idTails), m_rBaseRing); // TODO!!!
    412412
     
    422422    m_spoly_bucket = NULL;
    423423  }
    424    
     424
    425425  for( TCache::iterator it = m_cache.begin(); it != m_cache.end(); it++ )
    426426  {
    427427    TP2PCache& T = it->second;
    428      
     428
    429429    for(TP2PCache::iterator vit = T.begin(); vit != T.end(); vit++ )
    430     {   
     430    {
    431431      p_Delete( (&(vit->second)), m_rBaseRing);
    432432      p_Delete( const_cast<poly*>(&(vit->first)), m_rBaseRing);
     
    465465  CReducersHash::const_iterator itr = m_hash.find(comp);
    466466
    467   if ( itr == m_hash.end() ) 
     467  if ( itr == m_hash.end() )
    468468    return 2; // no such leading component!!!
    469    
     469
    470470  assume( itr->first == comp );
    471    
    472   const bool bIdealCase = (comp == 0);   
     471
     472  const bool bIdealCase = (comp == 0);
    473473  const bool bSyzCheck = syzChecker.IsNonempty(); // need to check even in ideal case????? proof?  "&& !bIdealCase"
    474474
     
    485485      const poly p = (*vit)->m_lt;
    486486
    487       assume( p_GetComp(p, r) == comp ); 
     487      assume( p_GetComp(p, r) == comp );
    488488
    489489      // TODO: check if coprime with Leads... if __TAILREDSYZ__ !
    490490      for( int var = N; var > 0; --var )
    491491        if( (p_GetExp(p, var, r) != 0) && (p_GetExp(t, var, r) != 0) )
    492         {       
     492        {
    493493#ifndef NDEBUG
    494494          if( __DEBUG__ | 0)
    495           {         
     495          {
    496496            PrintS("CReducerFinder::PreProcessTerm, 't' is NOT co-prime with the following leading term: \n");
    497497            dPrint(p, r, r, 1);
    498498          }
    499 #endif     
     499#endif
    500500          coprime = false; // t not coprime with p!
    501501          break;
     
    513513#ifndef NDEBUG
    514514        if( __DEBUG__ && !coprime)
    515         {         
     515        {
    516516          PrintS("CReducerFinder::PreProcessTerm, 't' is co-prime with p but may lead to NOT divisible syz.term: \n");
    517517          dPrint(ss, r, r, 1);
    518518        }
    519519#endif
    520          
     520
    521521        p_LmDelete(&ss, r); // deletes coeff as well???
    522522      }
     
    528528      PrintS("CReducerFinder::PreProcessTerm, the following 't' is 'co-prime' with all of leading terms! \n");
    529529#endif
    530      
    531     return coprime? 3: 0; // t was coprime with all of leading terms!!! 
     530
     531    return coprime? 3: 0; // t was coprime with all of leading terms!!!
    532532
    533533  }
     
    536536  return 0;
    537537}
    538  
    539    
     538
     539
    540540void SchreyerSyzygyComputation::SetUpTailTerms()
    541541{
    542   const ideal idTails = m_idTails; 
     542  const ideal idTails = m_idTails;
    543543  assume( idTails != NULL );
    544544  assume( idTails->m != NULL );
     
    557557  for( int p = IDELEMS(idTails) - 1; p >= 0; --p )
    558558    for( poly* tt = &(idTails->m[p]); (*tt) != NULL;  )
    559     {   
     559    {
    560560      const poly t = *tt;
    561561      const int k = m_div.PreProcessTerm(t, m_checker); // 0..3
     
    565565      pp[k]++;
    566566#endif
    567        
     567
    568568      if( k )
    569569      {
    570570#ifndef NDEBUG
    571571        if( __DEBUG__)
    572         {         
     572        {
    573573          Print("SchreyerSyzygyComputation::SetUpTailTerms(): PP (%d) the following TT: \n", k);
    574574          dPrint(t, r, r, 1);
     
    577577
    578578        (*tt) = p_LmDeleteAndNext(t, r); // delete the lead and next...
    579       }   
    580       else 
     579      }
     580      else
    581581        tt = &pNext(t); // go next?
    582582
     
    588588    Print("%%      **!!**      SchreyerSyzygyComputation::SetUpTailTerms()::PreProcessing(): X: {c: %lu, C: %lu, P: %lu} + %lu\n", pp[1], pp[2], pp[3], pp[0]);
    589589#endif
    590    
     590
    591591#ifndef NDEBUG
    592592  if( !__TREEOUTPUT__ )
     
    597597  }
    598598#endif
    599    
    600 }
    601 /* 
     599
     600}
     601/*
    602602  m_idTailTerms.resize( IDELEMS(idTails) );
    603  
     603
    604604  for( unsigned int p = IDELEMS(idTails) - 1; p >= 0; p -- )
    605605  {
     
    609609
    610610    unsigned int pp = 0;
    611    
     611
    612612    while( t != NULL )
    613613    {
    614614      assume( t != NULL );
    615615      // TODO: compute L:t!
    616 //      ideal reducers;     
     616//      ideal reducers;
    617617//      CReducerFinder m_reducers
    618      
     618
    619619      CTailTerm* d = v[pp] = new CTailTerm();
    620      
     620
    621621      ++pp; pIter(t);
    622622    }
     
    649649  if( size < 2 )
    650650  {
    651     const ideal newid = idInit(1, 0); newid->m[0] = NULL; // zero ideal...       
     651    const ideal newid = idInit(1, 0); newid->m[0] = NULL; // zero ideal...
    652652    return newid;
    653653  }
     
    745745  const ring& r = m_rBaseRing;
    746746//  const SchreyerSyzygyComputationFlags& attributes = m_atttributes;
    747  
     747
    748748//   const BOOLEAN __DEBUG__      = attributes.__DEBUG__;
    749749//   const BOOLEAN __SYZCHECK__   = attributes.__SYZCHECK__;
     
    751751//   const BOOLEAN __HYBRIDNF__   = attributes.__HYBRIDNF__;
    752752//  const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;
    753  
     753
    754754
    755755  // 1. set of components S?
     
    762762  if( size < 2 )
    763763  {
    764     const ideal newid = idInit(1, 1); newid->m[0] = NULL; // zero module...   
     764    const ideal newid = idInit(1, 1); newid->m[0] = NULL; // zero module...
    765765    return newid;
    766766  }
     
    768768
    769769  // TODO/NOTE: input is supposed to be sorted wrt "C,ds"!??
    770  
     770
    771771  // components should come in groups: count elements in each group
    772772  // && estimate the real size!!!
     
    863863      //      TEST_OPT_REDTAIL
    864864    assume( r == currRing );
    865  
     865
    866866    BITSET _save_test; SI_SAVE_OPT1(_save_test);
    867867    SI_RESTORE_OPT1(Sy_bit(OPT_REDTAIL) | Sy_bit(OPT_REDSB) | _save_test);
    868868
    869869    intvec* w=new intvec(IDELEMS(newid));
    870     ideal tmp = kStd(newid, currQuotient, isHomog, &w);
     870    ideal tmp = kStd(newid, currRing->qideal, isHomog, &w);
    871871    delete w;
    872872
     
    887887
    888888  Sort_c_ds(newid, r);
    889  
     889
    890890  return newid;
    891891}
     
    898898  const ring& R = m_rBaseRing;
    899899
    900   const int r = p_GetComp(a, R) - 1; 
     900  const int r = p_GetComp(a, R) - 1;
    901901
    902902  assume( r >= 0 && r < IDELEMS(T) );
    903903  assume( r >= 0 && r < IDELEMS(L) );
    904    
    905   assume( a != NULL );   
     904
     905  assume( a != NULL );
    906906
    907907  if( __TREEOUTPUT__ )
     
    909909     PrintS("{ \"nodelabel\": \""); writeLatexTerm(a, R); PrintS("\", \"children\": [");
    910910  }
    911    
     911
    912912
    913913  poly aa = leadmonom(a, R); assume( aa != NULL); // :(
    914914
    915   poly t = TraverseTail(aa, r); 
    916    
     915  poly t = TraverseTail(aa, r);
     916
    917917  if( a2 != NULL )
    918918  {
     
    929929    assume( r2 >= 0 && r2 < IDELEMS(T) );
    930930
    931     t = p_Add_q(a2, p_Add_q(t, TraverseTail(aa2, r2), R), R); 
     931    t = p_Add_q(a2, p_Add_q(t, TraverseTail(aa2, r2), R), R);
    932932
    933933    p_Delete(&aa2, R);
    934      
     934
    935935    if( __TREEOUTPUT__ )
    936936       PrintS("]},");
     
    946946  {
    947947     PrintS("], \"noderesult\": \""); writeLatexTerm(t, R, true, false); PrintS("\" },");
    948   }   
     948  }
    949949  return t;
    950950}
     
    971971  assume( IDELEMS(L) == IDELEMS(T) );
    972972#ifndef NDEBUG
    973   int t, r; 
     973  int t, r;
    974974#endif
    975975
    976976  if( __TREEOUTPUT__ )
    977977  {
    978     Print("\n{ \"syzygylayer\": \"%d\", \"hybridnf\": \"%d\", \"diagrams\": \n[", __SYZNUMBER__, __HYBRIDNF__ ); 
    979   } 
    980    
     978    Print("\n{ \"syzygylayer\": \"%d\", \"hybridnf\": \"%d\", \"diagrams\": \n[", __SYZNUMBER__, __HYBRIDNF__ );
     979  }
     980
    981981  if( m_syzLeads == NULL )
    982   {   
     982  {
    983983#ifndef NDEBUG
    984984    if( !__TREEOUTPUT__ )
     
    988988      Print("%% %5d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::ComputeLeadingSyzygyTerms: t: %d, r: %d\n", r, t, r);
    989989    }
    990 #endif     
     990#endif
    991991    ComputeLeadingSyzygyTerms( __LEAD2SYZ__ && !__IGNORETAILS__ ); // 2 terms OR 1 term!
    992992#ifndef NDEBUG
     
    998998    }
    999999#endif
    1000      
     1000
    10011001  }
    10021002
     
    10101010  {
    10111011     if( __TREEOUTPUT__ )
    1012        PrintS("]},"); 
     1012       PrintS("]},");
    10131013     return;
    10141014  }
    1015    
     1015
    10161016
    10171017  // use hybrid method?
     
    10301030      }
    10311031#endif
    1032        
     1032
    10331033      SetUpTailTerms();
    10341034#ifndef NDEBUG
     
    10401040      }
    10411041#endif
    1042     }     
     1042    }
    10431043  }
    10441044
     
    10511051  }
    10521052#endif
    1053    
     1053
    10541054  for( int k = size - 1; k >= 0; k-- )
    10551055  {
    10561056    const poly a = LL->m[k]; assume( a != NULL );
    10571057
    1058     poly a2 = pNext(a);   
     1058    poly a2 = pNext(a);
    10591059
    10601060    // Splitting 2-terms Leading syzygy module
    10611061    if( a2 != NULL )
    10621062      pNext(a) = NULL;
    1063      
     1063
    10641064    if( __IGNORETAILS__ )
    10651065    {
     
    10891089    Print("%% %5d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::SyzygyLift: dt: %d, dr: %d\n", getRTimer(), t, r);
    10901090  }
    1091 #endif   
     1091#endif
    10921092
    10931093  TT->rank = id_RankFreeModule(TT, R);
    1094    
     1094
    10951095  if( __TREEOUTPUT__ )
    10961096    PrintS("\n]},");
     
    11151115  {
    11161116    assume( !__LEAD2SYZ__ );
    1117    
     1117
    11181118    m_syzLeads = Compute1LeadingSyzygyTerms();
    11191119  }
    11201120//    m_syzLeads = FROM_NAMESPACE(INTERNAL, _ComputeLeadingSyzygyTerms(m_idLeads, m_rBaseRing, m_atttributes));
    1121  
     1121
    11221122  // NOTE: set m_LS if tails are to be reduced!
    11231123  assume( m_syzLeads!= NULL );
     
    11271127    m_LS = m_syzLeads;
    11281128    m_checker.Initialize(m_syzLeads);
    1129 #ifndef NDEBUG   
     1129#ifndef NDEBUG
    11301130    if( __DEBUG__ )
    11311131    {
     
    11461146poly SchreyerSyzygyComputation::SchreyerSyzygyNF(const poly syz_lead, poly syz_2) const
    11471147{
    1148  
     1148
    11491149  assume( !__IGNORETAILS__ );
    11501150
     
    11601160    PrintS("{   \"nodelabel\": \""); writeLatexTerm(syz_lead, r); PrintS("\", \"children\": [");
    11611161  }
    1162    
     1162
    11631163  if( syz_2 == NULL )
    11641164  {
    1165     const int rr = p_GetComp(syz_lead, r) - 1; 
     1165    const int rr = p_GetComp(syz_lead, r) - 1;
    11661166
    11671167    assume( rr >= 0 && rr < IDELEMS(T) );
     
    11751175      PrintS("{ \"nodelabel\": \""); writeLatexTerm(syz_2, r); PrintS("\" },");
    11761176    }
    1177 #else   
     1177#else
    11781178    poly aa = leadmonom(syz_lead, r); assume( aa != NULL); // :(
    11791179    aa = p_Mult_mm(aa, L->m[rr], r);
     
    11831183      PrintS("{ \"nodelabel\": \""); writeLatexTerm(syz_2, r); PrintS("\", \"edgelable\": \""); writeLatexTerm(aa, r, false); PrintS("\" },");
    11841184    }
    1185      
     1185
    11861186    syz_2 = m_div.FindReducer(aa, syz_lead, m_checker);
    11871187
    11881188    p_Delete(&aa, r);
    11891189#endif
    1190    
    1191   }
    1192    
    1193   assume( syz_2 != NULL ); // by construction of S-Polynomial   
     1190
     1191  }
     1192
     1193  assume( syz_2 != NULL ); // by construction of S-Polynomial
    11941194
    11951195  assume( L != NULL );
     
    12131213
    12141214//  kBucketInit(bucket, NULL, 0); // not needed!?
    1215      
    1216   poly p = leadmonom(syz_lead, r); // :( 
    1217 //  poly spoly = pp_Mult_qq(p, T->m[c], r); 
    1218   kBucket_Plus_mm_Mult_pp(bucket, p, T->m[c], 0); // TODO: store pLength(T->m[c]) separately!? 
     1215
     1216  poly p = leadmonom(syz_lead, r); // :(
     1217//  poly spoly = pp_Mult_qq(p, T->m[c], r);
     1218  kBucket_Plus_mm_Mult_pp(bucket, p, T->m[c], 0); // TODO: store pLength(T->m[c]) separately!?
    12191219  p_Delete(&p, r);
    1220  
    1221   kbTest(bucket); 
     1220
     1221  kbTest(bucket);
    12221222
    12231223  c = p_GetComp(syz_2, r) - 1;
     
    12321232  // TODO: use bucket!?
    12331233//  const bool bUsePolynomial = TEST_OPT_NOT_BUCKETS; //  || (pLength(spoly) < MIN_LENGTH_BUCKET);
    1234 //  CPolynomialSummator tail(r, bUsePolynomial);                       
    1235   sBucket_Add_p(tail, syz_2, 1); // tail.AddAndDelete(syz_2, 1); 
    1236  
     1234//  CPolynomialSummator tail(r, bUsePolynomial);
     1235  sBucket_Add_p(tail, syz_2, 1); // tail.AddAndDelete(syz_2, 1);
     1236
    12371237  kbTest(bucket);
    12381238  for( poly spoly = kBucketExtractLm(bucket); spoly != NULL; p_LmDelete(&spoly, r), spoly = kBucketExtractLm(bucket))
    1239   {   
     1239  {
    12401240    kbTest(bucket);
    1241     poly t = m_div.FindReducer(spoly, NULL, m_checker);   
     1241    poly t = m_div.FindReducer(spoly, NULL, m_checker);
    12421242
    12431243    if( t != NULL )
     
    12471247
    12481248      assume( c >= 0 && c < IDELEMS(T) );
    1249        
     1249
    12501250      if( __TREEOUTPUT__ )
    12511251      {
     
    12701270  sBucketClearAdd(tail, &result, &len); // TODO: use Merge with sBucket???
    12711271  assume( pLength(result) == len );
    1272      
     1272
    12731273  if( __TREEOUTPUT__ )
    1274   {   
     1274  {
    12751275    PrintS("]},");
    12761276  }
    1277    
     1277
    12781278
    12791279  return result;
    12801280}
    12811281
    1282 // namespace     {   
     1282// namespace     {
    12831283
    12841284// };
     
    12911291{
    12921292  const ring& r = m_rBaseRing;
    1293    
     1293
    12941294  assume(m_idTails !=  NULL && m_idTails->m != NULL);
    12951295  assume( tail >= 0 && tail < IDELEMS(m_idTails) );
    1296    
     1296
    12971297/*  return ComputeImage(multiplier, tail); */
    1298  
     1298
    12991299  // TODO: store (multiplier, tail) -.-^-.-^-.--> !
    13001300  TCache::iterator top_itr = m_cache.find(tail);
    1301    
     1301
    13021302  if ( top_itr != m_cache.end() )
    13031303  {
     
    13051305
    13061306     TP2PCache& T = top_itr->second;
    1307      
     1307
    13081308     TP2PCache::iterator itr = T.find(multiplier);
    1309      
     1309
    13101310     if( itr != T.end() ) // Yey - Reuse!!!
    13111311     {
    13121312       assume( p_LmEqual(itr->first, multiplier, r) );
    1313        
     1313
    13141314       if( itr->second == NULL )
    1315         return (NULL);
    1316        
     1315        return (NULL);
     1316
    13171317       poly p = p_Copy(itr->second, r); // no copy???
    1318        
     1318
    13191319       if( __TREEOUTPUT__ )
    13201320       {
    1321 //         PrintS("{ \"nodelabel\": \""); writeLatexTerm(multiplier, r, false); 
     1321//         PrintS("{ \"nodelabel\": \""); writeLatexTerm(multiplier, r, false);
    13221322//         Print(" \\\\cdot \\\\GEN{%d}\", \"children\": [ ", tail + 1);
    1323           Print("{ \"lookedupnode\": \"1\", \"nodelabel\": \"");
    1324           writeLatexTerm(p, r, true, false);
     1323          Print("{ \"lookedupnode\": \"1\", \"nodelabel\": \"");
     1324          writeLatexTerm(p, r, true, false);
    13251325       }
    1326        
     1326
    13271327       if( !n_Equal( pGetCoeff(multiplier), pGetCoeff(itr->first), r) ) // normalize coeffs!?
    13281328       {
    1329          number n = n_Div( pGetCoeff(multiplier), pGetCoeff(itr->first), r); 
    1330          p = p_Mult_nn(p, n, r); 
     1329         number n = n_Div( pGetCoeff(multiplier), pGetCoeff(itr->first), r);
     1330         p = p_Mult_nn(p, n, r);
    13311331         n_Delete(&n, r);
    1332          
     1332
    13331333         if( __TREEOUTPUT__ )
    13341334           Print("\", \"RESCALEDRESULT\": \"1\" },");
     
    13381338           Print("\", \"RESCALEDRESULT\": \"0\" },");
    13391339       }
    1340        
     1340
    13411341       return p;
    13421342     }
     
    13451345     {
    13461346//        PrintS("{ \"nodelabel\": \""); writeLatexTerm(multiplier, r, false); Print(" \\\\cdot \\\\GEN{%d}\", \"children\": [", tail + 1);
    1347      }     
    1348      
     1347     }
     1348
    13491349     const poly p = ComputeImage(multiplier, tail);
    13501350     T.insert( TP2PCache::value_type(p_Copy(multiplier, r), p) ); //     T[ multiplier ] = p;
     
    13521352//     if( p == NULL )
    13531353//        return (NULL);
    1354      
     1354
    13551355     if( __TREEOUTPUT__ )
    13561356     {
    1357 //      PrintS("], \"storedResult\": \""); writeLatexTerm(p, r, true, false); PrintS("\" },");
     1357//        PrintS("], \"storedResult\": \""); writeLatexTerm(p, r, true, false); PrintS("\" },");
    13581358     }
    1359      
     1359
    13601360     return p_Copy(p, r);
    13611361  }
    1362    
     1362
    13631363  CCacheCompare o(r); TP2PCache T(o);
    13641364
     
    13671367//     PrintS("{ \"nodelabel\": \""); writeLatexTerm(multiplier, r, false); Print(" \\\\cdot \\\\GEN{%d}\", \"children\": [", tail + 1);
    13681368  }
    1369    
    1370    
     1369
     1370
    13711371  const poly p = ComputeImage(multiplier, tail);
    13721372
    13731373  T.insert( TP2PCache::value_type(p_Copy(multiplier, r), p) );
    1374    
     1374
    13751375  m_cache.insert( TCache::value_type(tail, T) );
    13761376
    13771377//  if( p == NULL )
    13781378//    return (NULL);
    1379    
     1379
    13801380  if( __TREEOUTPUT__ )
    13811381  {
    13821382//     PrintS("], \"storedResult\": \""); writeLatexTerm(p, r, true, false); PrintS("\" },");
    13831383  }
    1384    
     1384
    13851385  return p_Copy(p, r);
    13861386}
     
    13961396}
    13971397
    1398    
     1398
    13991399poly SchreyerSyzygyComputation::TraverseTail(poly multiplier, poly tail) const
    14001400{
     
    14191419    sBucket_pt& sum   = m_sum_bucket; assume( sum != NULL );
    14201420    poly s; int len;
    1421    
     1421
    14221422//    CPolynomialSummator sum(r, bUsePolynomial);
    14231423//    poly s = NULL;
     
    14311431      // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    14321432      // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1433      
     1433
    14341434      const int lp = pLength(rt);
    14351435      if( rt != NULL && lp != 0 )
    1436         sBucket_Add_p(sum, rt, lp); 
     1436        sBucket_Add_p(sum, rt, lp);
    14371437    }
    14381438
     
    14741474    if( s == NULL ) // No Reducer?
    14751475     return s;
    1476      
     1476
    14771477    if( __TREEOUTPUT__ )
    14781478    {
    1479       PrintS("{ \"nodelabel\": \""); writeLatexTerm(s, r); 
    1480     }
    1481    
    1482 #else   
     1479      PrintS("{ \"nodelabel\": \""); writeLatexTerm(s, r);
     1480    }
     1481
     1482#else
    14831483    // NOTE: only LT(term4reduction) should be used in the following:
    14841484    poly product = pp_Mult_mm(multiplier, term4reduction, r);
     
    14871487    if( s == NULL ) // No Reducer?
    14881488     return s;
    1489      
     1489
    14901490    if( __TREEOUTPUT__ )
    14911491    {
    1492       PrintS("{ \"nodelabel\": \""); writeLatexTerm(s, r); PrintS("\", \"edgelable\": \""); writeLatexTerm(product, r, false); 
    1493     }
    1494      
     1492      PrintS("{ \"nodelabel\": \""); writeLatexTerm(s, r); PrintS("\", \"edgelable\": \""); writeLatexTerm(product, r, false);
     1493    }
     1494
    14951495    p_Delete(&product, r);
    14961496#endif
     
    14991499  if( s == NULL ) // No Reducer?
    15001500    return s;
    1501    
     1501
    15021502
    15031503  poly b = leadmonom(s, r);
     
    15061506  assume( c >= 0 && c < IDELEMS(T) );
    15071507
    1508    
     1508
    15091509  if( __TREEOUTPUT__ )
    15101510     PrintS("\", \"children\": [");
    1511    
     1511
    15121512  const poly t = TraverseTail(b, c); // T->m[c];
    15131513
    15141514  if( t != NULL )
    1515     s = p_Add_q(s, t, r); 
     1515    s = p_Add_q(s, t, r);
    15161516
    15171517  if( __TREEOUTPUT__ )
    15181518  {
    1519        
     1519
    15201520    PrintS("], \"noderesult\": \"");
    1521     writeLatexTerm(s, r, true, false); 
     1521    writeLatexTerm(s, r, true, false);
    15221522    PrintS("\" },");
    15231523  }
    1524    
     1524
    15251525  return s;
    15261526}
     
    15311531
    15321532BEGIN_NAMESPACE_NONAME
    1533    
     1533
    15341534static inline int atGetInt(idhdl rootRingHdl, const char* attribute, long def)
    15351535{
     
    15371537}
    15381538
    1539 END_NAMESPACE   
    1540 
    1541      
     1539END_NAMESPACE
     1540
     1541
    15421542SchreyerSyzygyComputationFlags::SchreyerSyzygyComputationFlags(idhdl rootRingHdl):
    15431543#ifndef NDEBUG
     
    15471547#endif
    15481548//    __SYZCHECK__( (BOOLEAN)atGetInt(rootRingHdl, "SYZCHECK", __DEBUG__) ),
    1549     __LEAD2SYZ__( atGetInt(rootRingHdl, "LEAD2SYZ", 1) ), 
    1550     __TAILREDSYZ__( atGetInt(rootRingHdl, "TAILREDSYZ", 1) ), 
     1549    __LEAD2SYZ__( atGetInt(rootRingHdl, "LEAD2SYZ", 1) ),
     1550    __TAILREDSYZ__( atGetInt(rootRingHdl, "TAILREDSYZ", 1) ),
    15511551    __HYBRIDNF__( atGetInt(rootRingHdl, "HYBRIDNF", 2) ),
    15521552    __IGNORETAILS__( atGetInt(rootRingHdl, "IGNORETAILS", 0) ),
     
    15541554    __TREEOUTPUT__( atGetInt(rootRingHdl, "TREEOUTPUT", 0) ),
    15551555    m_rBaseRing( rootRingHdl->data.uring )
    1556 {   
     1556{
    15571557#ifndef NDEBUG
    15581558  if( __DEBUG__ )
     
    15681568  }
    15691569#endif
    1570    
     1570
    15711571  // TODO: just current setting!
    15721572  assume( rootRingHdl == currRingHdl );
     
    15761576}
    15771577
    1578    
     1578
    15791579
    15801580CLeadingTerm::CLeadingTerm(unsigned int _label,  const poly _lt, const ring R):
     
    16011601
    16021602  assume( m_L == L );
    1603  
     1603
    16041604  if( L != NULL )
    16051605  {
    16061606    const ring& R = m_rBaseRing;
    16071607    assume( R != NULL );
    1608    
     1608
    16091609    for( int k = IDELEMS(L) - 1; k >= 0; k-- )
    16101610    {
     
    16851685  const unsigned long p_sev = m_sev;
    16861686
    1687   assume( p_sev == p_GetShortExpVector(p, r) );     
     1687  assume( p_sev == p_GetShortExpVector(p, r) );
    16881688
    16891689  return p_LmShortDivisibleByNoComp(p, p_sev, product, not_sev, r);
     
    17041704
    17051705  const unsigned long p_sev = m_sev;
    1706   assume( p_sev == p_GetShortExpVector(p, r) );     
     1706  assume( p_sev == p_GetShortExpVector(p, r) );
    17071707
    17081708  if (p_sev & not_sev)
     
    17201720class CDivisorEnumerator: public SchreyerSyzygyComputationFlags
    17211721{
    1722   private: 
     1722  private:
    17231723    const CReducerFinder& m_reds;
    17241724    const poly m_product;
     
    17421742    {
    17431743      assume( m_comp >= 0 );
    1744       assume( m_reds.m_L != NULL ); 
     1744      assume( m_reds.m_L != NULL );
    17451745    }
    17461746
     
    17481748    {
    17491749      m_active = false;
    1750      
     1750
    17511751      m_itr = m_reds.m_hash.find(m_comp);
    17521752
     
    17631763
    17641764//      m_active = true;
    1765       return true;     
     1765      return true;
    17661766    }
    17671767
     
    17731773      return *(*m_current);
    17741774    }
    1775  
     1775
    17761776    inline bool MoveNext()
    17771777    {
     
    17821782      else
    17831783        m_active = true; // for Current()
    1784      
     1784
    17851785      // looking for the next good entry
    17861786      for( ; m_current != m_finish; ++m_current )
     
    18041804      // the end... :(
    18051805      assume( m_current == m_finish );
    1806      
     1806
    18071807      m_active = false;
    18081808      return false;
     
    18191819
    18201820  return itr.MoveNext();
    1821  
    1822 /* 
     1821
     1822/*
    18231823  const ring& r = m_rBaseRing;
    1824  
     1824
    18251825  const long comp = p_GetComp(product, r);
    18261826  const unsigned long not_sev = ~p_GetShortExpVector(product, r);
     
    18301830  CReducersHash::const_iterator it = m_hash.find(comp); // same module component
    18311831
    1832   assume( m_L != NULL ); 
     1832  assume( m_L != NULL );
    18331833
    18341834  if( it == m_hash.end() )
    18351835    return false;
    18361836  // assume comp!
    1837  
     1837
    18381838  const TReducers& reducers = it->second;
    18391839
     
    18551855
    18561856  return false;
    1857 */ 
     1857*/
    18581858}
    18591859
     
    18921892class CDivisorEnumerator2: public SchreyerSyzygyComputationFlags
    18931893{
    1894   private: 
     1894  private:
    18951895    const CReducerFinder& m_reds;
    18961896    const poly m_multiplier, m_term;
     
    19141914    {
    19151915      assume( m_comp >= 0 );
    1916       assume( m_reds.m_L != NULL ); 
    1917       assume( m_multiplier != NULL ); 
     1916      assume( m_reds.m_L != NULL );
     1917      assume( m_multiplier != NULL );
    19181918      assume( m_term != NULL );
    19191919//      assume( p_GetComp(m_multiplier, m_rBaseRing) == 0 );
     
    19231923    {
    19241924      m_active = false;
    1925      
    1926       m_itr = m_reds.m_hash.find(m_comp); 
     1925
     1926      m_itr = m_reds.m_hash.find(m_comp);
    19271927
    19281928      if( m_itr == m_reds.m_hash.end() )
     
    19371937        return false;
    19381938
    1939       return true;     
     1939      return true;
    19401940    }
    19411941
     
    19471947      return *(*m_current);
    19481948    }
    1949  
     1949
    19501950    inline bool MoveNext()
    19511951    {
     
    19541954      if( m_active )
    19551955        ++m_current;
    1956       else 
     1956      else
    19571957        m_active = true;
    1958    
    1959      
     1958
     1959
    19601960      // looking for the next good entry
    19611961      for( ; m_current != m_finish; ++m_current )
     
    19741974//          m_active = true;
    19751975          return true;
    1976          
     1976
    19771977        }
    19781978      }
     
    19801980      // the end... :(
    19811981      assume( m_current == m_finish );
    1982      
     1982
    19831983      m_active = false;
    19841984      return false;
    19851985    }
    19861986};
    1987    
     1987
    19881988poly CReducerFinder::FindReducer(const poly multiplier, const poly t,
    19891989                                 const poly syzterm,
     
    20182018
    20192019    poly pr = p_Mult_q( leadmonom(multiplier, r, false), leadmonom(t, r, false), r);
    2020    
     2020
    20212021    assume( p_EqualPolys(lm, pr, r) );
    20222022
     
    20242024    //  def @@product = leadmonomial(syzterm) * L[@@r];
    20252025
    2026     p_Delete(&lm, r);   
    2027     p_Delete(&pr, r);   
    2028   }
    2029    
    2030   const BOOLEAN to_check = (syz_checker.IsNonempty()); // __TAILREDSYZ__ && 
     2026    p_Delete(&lm, r);
     2027    p_Delete(&pr, r);
     2028  }
     2029
     2030  const BOOLEAN to_check = (syz_checker.IsNonempty()); // __TAILREDSYZ__ &&
    20312031
    20322032  const poly q = p_New(r); pNext(q) = NULL;
     
    20392039    const poly p = itr.Current().m_lt;
    20402040    const int k  = itr.Current().m_label;
    2041      
     2041
    20422042    p_ExpVectorSum(q, multiplier, t, r); // q == product == multiplier * t // TODO: do it once?
    20432043    p_ExpVectorDiff(q, q, p, r); // (LM(product) / LM(L[k]))
    2044    
     2044
    20452045    p_SetComp(q, k + 1, r);
    20462046    p_Setm(q, r);
     
    20552055          Print("_FindReducer::Test SYZTERM: q == syzterm !:((, syzterm is: ");
    20562056          dPrint(syzterm, r, r, 1);
    2057         }   
     2057        }
    20582058#endif
    20592059        continue;
    20602060      }
    20612061
    2062     // while the complement (the fraction) is not reducible by leading syzygies 
    2063     if( to_check && syz_checker.IsDivisible(q) ) 
     2062    // while the complement (the fraction) is not reducible by leading syzygies
     2063    if( to_check && syz_checker.IsDivisible(q) )
    20642064    {
    20652065#ifndef NDEBUG
     
    20752075    p_SetCoeff0(q, n_Neg( n_Div(n, p_GetCoeff(p, r), r), r), r);
    20762076    n_Delete(&n, r);
    2077    
     2077
    20782078    return q;
    20792079  }
    2080    
     2080
    20812081/*
    20822082  const long comp = p_GetComp(t, r); assume( comp >= 0 );
     
    20862086//   {
    20872087//     const poly p = L->m[k];
    2088 // 
     2088//
    20892089//     if ( p_GetComp(p, r) != comp )
    20902090//       continue;
    2091 // 
     2091//
    20922092//     const unsigned long p_sev = p_GetShortExpVector(p, r); // to be stored in m_hash!!!
    20932093
     
    20992099
    21002100  // assume comp!
    2101  
     2101
    21022102  assume( m_L != NULL );
    21032103
     
    21132113
    21142114//    const unsigned long p_sev = (*vit)->m_sev;
    2115 //    assume( p_sev == p_GetShortExpVector(p, r) );     
     2115//    assume( p_sev == p_GetShortExpVector(p, r) );
    21162116
    21172117//    if( !p_LmShortDivisibleByNoComp(p, p_sev, product, not_sev, r) )
    2118 //      continue;     
     2118//      continue;
    21192119
    21202120    if( !(*vit)->DivisibilityCheck(multiplier, t, not_sev, r) )
    21212121      continue;
    2122    
    2123    
     2122
     2123
    21242124//    if (p_sev & not_sev) continue;
    2125 //    if( !_p_LmDivisibleByNoComp(p, multiplier, t, r) ) continue;     
    2126 
    2127 
    2128     p_ExpVectorSum(q, multiplier, t, r); // q == product == multiplier * t       
     2125//    if( !_p_LmDivisibleByNoComp(p, multiplier, t, r) ) continue;
     2126
     2127
     2128    p_ExpVectorSum(q, multiplier, t, r); // q == product == multiplier * t
    21292129    p_ExpVectorDiff(q, q, p, r); // (LM(product) / LM(L[k]))
    2130    
     2130
    21312131    p_SetComp(q, k + 1, r);
    21322132    p_Setm(q, r);
     
    21402140          Print("_FindReducer::Test SYZTERM: q == syzterm !:((, syzterm is: ");
    21412141          dPrint(syzterm, r, r, 1);
    2142         }   
     2142        }
    21432143
    21442144        continue;
    21452145      }
    21462146
    2147     // while the complement (the fraction) is not reducible by leading syzygies 
    2148     if( to_check && syz_checker.IsDivisible(q) ) 
     2147    // while the complement (the fraction) is not reducible by leading syzygies
     2148    if( to_check && syz_checker.IsDivisible(q) )
    21492149    {
    21502150      if( __DEBUG__ )
     
    21592159    p_SetCoeff0(q, n_Neg( n_Div(n, p_GetCoeff(p, r), r), r), r);
    21602160    n_Delete(&n, r);
    2161    
     2161
    21622162    return q;
    21632163  }
    2164 */ 
     2164*/
    21652165
    21662166  p_LmFree(q, r);
    21672167
    21682168  return NULL;
    2169  
     2169
    21702170}
    21712171
     
    22032203    //  def @@product = leadmonomial(syzterm) * L[@@r];
    22042204
    2205     p_Delete(&lm, r);   
    2206   }
    2207 
    2208 
    2209   const BOOLEAN to_check = (syz_checker.IsNonempty()); // __TAILREDSYZ__ && 
     2205    p_Delete(&lm, r);
     2206  }
     2207
     2208
     2209  const BOOLEAN to_check = (syz_checker.IsNonempty()); // __TAILREDSYZ__ &&
    22102210
    22112211  const poly q = p_New(r); pNext(q) = NULL;
     
    22182218    const poly p = itr.Current().m_lt;
    22192219    const int k  = itr.Current().m_label;
    2220      
     2220
    22212221    p_ExpVectorDiff(q, product, p, r); // (LM(product) / LM(L[k]))
    22222222    p_SetComp(q, k + 1, r);
     
    22322232          Print("_FindReducer::Test SYZTERM: q == syzterm !:((, syzterm is: ");
    22332233          dPrint(syzterm, r, r, 1);
    2234         }   
     2234        }
    22352235#endif
    22362236        continue;
    22372237      }
    22382238
    2239     // while the complement (the fraction) is not reducible by leading syzygies 
    2240     if( to_check && syz_checker.IsDivisible(q) ) 
     2239    // while the complement (the fraction) is not reducible by leading syzygies
     2240    if( to_check && syz_checker.IsDivisible(q) )
    22412241    {
    22422242#ifndef NDEBUG
     
    22502250
    22512251    p_SetCoeff0(q, n_Neg( n_Div( p_GetCoeff(product, r), p_GetCoeff(p, r), r), r), r);
    2252    
     2252
    22532253    return q;
    22542254  }
    2255    
    2256    
    2257    
    2258 /*   
     2255
     2256
     2257
     2258/*
    22592259  const long comp = p_GetComp(product, r);
    22602260  const unsigned long not_sev = ~p_GetShortExpVector(product, r);
     
    22652265//   {
    22662266//     const poly p = L->m[k];
    2267 // 
     2267//
    22682268//     if ( p_GetComp(p, r) != comp )
    22692269//       continue;
    2270 // 
     2270//
    22712271//     const unsigned long p_sev = p_GetShortExpVector(p, r); // to be stored in m_hash!!!
    2272  
     2272
    22732273   // looking for an appropriate diviser p = L[k]...
    22742274  CReducersHash::const_iterator it = m_hash.find(comp); // same module component
     
    22812281  const TReducers& reducers = it->second;
    22822282
    2283   const BOOLEAN to_check = (syz_checker.IsNonempty()); // __TAILREDSYZ__ && 
     2283  const BOOLEAN to_check = (syz_checker.IsNonempty()); // __TAILREDSYZ__ &&
    22842284
    22852285  const poly q = p_New(r); pNext(q) = NULL;
     
    22872287  if( __DEBUG__ )
    22882288    p_SetCoeff0(q, 0, r); // for printing q
    2289  
     2289
    22902290  for(TReducers::const_iterator vit = reducers.begin(); vit != reducers.end(); vit++ )
    22912291  {
     
    23002300    const unsigned long p_sev = (*vit)->m_sev;
    23012301
    2302     assume( p_sev == p_GetShortExpVector(p, r) );     
     2302    assume( p_sev == p_GetShortExpVector(p, r) );
    23032303
    23042304    if( !p_LmShortDivisibleByNoComp(p, p_sev, product, not_sev, r) )
    2305       continue;     
     2305      continue;
    23062306
    23072307//     // ... which divides the product, looking for the _1st_ appropriate one!
     
    23212321          Print("_FindReducer::Test SYZTERM: q == syzterm !:((, syzterm is: ");
    23222322          dPrint(syzterm, r, r, 1);
    2323         }   
     2323        }
    23242324
    23252325        continue;
    23262326      }
    23272327
    2328     // while the complement (the fraction) is not reducible by leading syzygies 
    2329     if( to_check && syz_checker.IsDivisible(q) ) 
     2328    // while the complement (the fraction) is not reducible by leading syzygies
     2329    if( to_check && syz_checker.IsDivisible(q) )
    23302330    {
    23312331      if( __DEBUG__ )
     
    23332333        PrintS("_FindReducer::Test LS: q is divisible by LS[?] !:((: ");
    23342334      }
    2335      
     2335
    23362336      continue;
    23372337    }
     
    23762376    }
    23772377
    2378     m_compute = true;   
     2378    m_compute = true;
    23792379  }
    23802380}
     
    23852385  assume( m != NULL );
    23862386  if( m_compute && (m != NULL))
    2387   { 
     2387  {
    23882388    const ring& R = m_rBaseRing;
    23892389
     
    24002400}
    24012401
    2402 CCacheCompare::CCacheCompare(): m_ring(currRing) {} 
     2402CCacheCompare::CCacheCompare(): m_ring(currRing) {}
    24032403
    24042404
Note: See TracChangeset for help on using the changeset viewer.