Changeset bc947c9 in git


Ignore:
Timestamp:
Apr 25, 2019, 7:55:05 PM (4 years ago)
Author:
Karim Abou Zeid <karim23697@…>
Branches:
(u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
Children:
7ea5de9643c52c85381a5d31f1c56130fc656ff9
Parents:
1a4a5cca1fc236a8841234e826efbd00bbc02b4c
Message:
Improve ufnarovskiGraph performance
Files:
2 edited

Legend:

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

    r1a4a5cc rbc947c9  
    8181}
    8282
     83static BOOLEAN p_LPDivisibleBy(ideal I, poly p, ring r)
     84{
     85  for(int i = 0; i < IDELEMS(I); i++)
     86  {
     87    if (p_LPDivisibleBy(I->m[i], p, r))
     88    {
     89      return TRUE;
     90    }
     91  }
     92  return FALSE;
     93}
     94
    8395static BOOLEAN lpLmDivides(leftv res, leftv h)
    8496{
     
    98110    poly q=(poly)h->next->Data();
    99111    res->rtyp = INT_CMD;
    100     for(int i=0;i<IDELEMS(I);i++)
    101     {
    102       if (p_LPDivisibleBy(I->m[i],q, currRing))
    103       {
    104         res->data=(void*)(long)1;
    105         return FALSE;
    106       }
    107     }
    108     res->data=(void*)(long)0;
     112    res->data=(void*)(long) p_LPDivisibleBy(I, q, currRing);
    109113    return FALSE;
    110114  }
     
    124128  }
    125129  else return TRUE;
     130}
     131
     132static void _computeStandardWords(ideal words, int n, ideal M, int& last)
     133{
     134  if (n <= 0){
     135    words->m[0] = pOne();
     136    last = 0;
     137    return;
     138  }
     139
     140  _computeStandardWords(words, n - 1, M, last);
     141
     142  int nVars = currRing->isLPring;
     143
     144  for (int j = nVars - 1; j >= 0; j--)
     145  {
     146    for (int i = last; i >= 0; i--)
     147    {
     148      int index = (j * (last + 1)) + i;
     149
     150      if (words->m[i] != NULL)
     151      {
     152        if (j > 0) {
     153          words->m[index] = pCopy(words->m[i]);
     154        }
     155
     156        int varOffset = ((n - 1) * nVars) + 1;
     157        pSetExp(words->m[index], varOffset + j, 1);
     158        pSetm(words->m[index]);
     159        pTest(words->m[index]);
     160
     161        if (p_LPDivisibleBy(M, words->m[index], currRing))
     162        {
     163          pDelete(&words->m[index]);
     164          words->m[index] = NULL;
     165        }
     166      }
     167    }
     168  }
     169
     170  last = nVars * last + nVars - 1;
     171}
     172
     173static ideal computeStandardWords(int n, ideal M)
     174{
     175  int nVars = currRing->isLPring;
     176
     177  int maxElems = 1;
     178  for (int i = 0; i < n; i++) // maxElems = nVars^n
     179    maxElems *= nVars;
     180  ideal words = idInit(maxElems);
     181  int last;
     182  _computeStandardWords(words, n, M, last);
     183  idSkipZeroes(words);
     184  return words;
    126185}
    127186
     
    140199  int lV = currRing->isLPring;
    141200
    142   ideal words = idMaxIdeal(l);
    143   ideal standardWords = kNF(G, currRing->qideal, words);
    144   idSkipZeroes(standardWords);
     201  ideal standardWords = computeStandardWords(l, G);
    145202
    146203  int n = IDELEMS(standardWords);
     
    278335
    279336// -1 is infinity, -2 is error
    280 static int id_LPGkDim(const ideal _G)
     337static int gkDim(const ideal _G)
    281338{
    282339  if (rField_is_Ring(currRing)) {
     
    338395    ideal G = (ideal) h->Data();
    339396    res->rtyp = INT_CMD;
    340     res->data = (void*)(long) id_LPGkDim(G);
     397    res->data = (void*)(long) gkDim(G);
    341398    if (errorreported) return TRUE;
    342399    return FALSE;
  • libpolys/polys/shiftop.cc

    r1a4a5cc rbc947c9  
    718718BOOLEAN _p_LPLmDivisibleByNoComp(poly a, poly b, const ring r)
    719719{
    720   if(p_LmIsConstantComp(a, r))
    721     return TRUE;
    722720#ifdef SHIFT_MULT_COMPAT_MODE
    723721  a = p_Head(a, r);
     
    726724  p_mLPunshift(b, r);
    727725#endif
    728   int i = (r->N / r->isLPring) - p_LastVblock(a, r);
    729   do {
    730     int j = r->N - (i * r->isLPring);
     726  for (int i = (r->N / r->isLPring) - p_LastVblock(a, r); i >= 0; i--)
     727  {
    731728    bool divisible = true;
    732     do
     729    for (int j = r->N - (i * r->isLPring); j >= 0; j--)
    733730    {
    734731      if (p_GetExp(a, j, r) > p_GetExp(b, j + (i * r->isLPring), r))
     
    737734        break;
    738735      }
    739       j--;
    740     }
    741     while (j);
     736    }
    742737    if (divisible) return TRUE;
    743     i--;
    744   }
    745   while (i > -1);
     738  }
    746739#ifdef SHIFT_MULT_COMPAT_MODE
    747740  p_Delete(&a, r);
Note: See TracChangeset for help on using the changeset viewer.