Changeset c1a0fc in git


Ignore:
Timestamp:
Oct 23, 2018, 10:30:45 AM (6 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
Children:
3e40698da5deaf816542e4d0e16cd3a7e99e4145
Parents:
bf2a471a7ccc420f3cf5a55dd1454967b35fd6234ab28ee27b200665a3b67d61dddfca2c136e0552
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2018-10-23 10:30:45+02:00
git-committer:
GitHub <noreply@github.com>2018-10-23 10:30:45+02:00
Message:
Merge pull request #886 from kabouzeid/invalid-lp-warnings

Warn when invalid letterplace polynom is printed
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • kernel/GBEngine/kstd2.cc

    rbf2a471 rc1a0fc  
    7474// #include "timer.h"
    7575
    76 /* shiftgb stuff */
    77 #include "kernel/GBEngine/shiftgb.h"
     76#ifdef HAVE_SHIFTBBA
     77#include "polys/shiftop.h"
     78#endif
    7879
    7980  int (*test_PosInT)(const TSet T,const int tl,LObject &h);
     
    43344335{
    43354336  assume(rIsLPRing(currRing));
    4336   assume(ideal_isInV(I, currRing));
     4337  assume(idIsInV(I));
    43374338  ideal RS = kStdShift(I,NULL, testHomog, NULL,NULL,0,0,NULL);
    43384339  idSkipZeroes(RS); // is this even necessary?
    4339   assume(ideal_isInV(RS, currRing));
     4340  assume(idIsInV(RS));
    43404341  return(RS);
    43414342}
  • kernel/GBEngine/kutil.cc

    rbf2a471 rc1a0fc  
    6666#include "polys/operations/pShallowCopyDelete.h"
    6767
    68 /* shiftgb stuff */
    69 #include "kernel/GBEngine/shiftgb.h"
     68#ifdef HAVE_SHIFTBBA
     69#include "polys/shiftop.h"
     70#endif
     71
    7072#include "polys/prCopy.h"
    7173
     
    1216312165
    1216412166  /* apply the V criterion */
    12165   if (!isInV(Lp.lcm, currRing))
     12167  if (!pIsInV(Lp.lcm))
    1216612168  {
    1216712169#ifdef KDEBUG
  • kernel/GBEngine/shiftgb.cc

    rbf2a471 rc1a0fc  
    4343}
    4444
    45 /* there should be two routines: */
    46 /* 1. test place-squarefreeness: in homog this suffices: isInV */
    47 /* 2. test the presence of a hole -> in the tail??? */
    48 
    49 int isInV(poly p, const ring r)
    50 {
    51   int lV = r->isLPring;
    52   /* investigate only the leading monomial of p in currRing */
    53   if ( pTotaldegree(p)==0 ) return(1);
    54   /* returns 1 iff p is in V */
    55   /* that is in each block up to a certain one there is only one nonzero exponent */
    56   /* lV = the length of V = the number of orig vars */
    57   int *e = (int *)omAlloc0((currRing->N+1)*sizeof(int));
    58   int  b = (int)((currRing->N +lV-1)/lV); /* the number of blocks */
    59   //int b  = (int)(currRing->N)/lV;
    60   int *B = (int *)omAlloc0((b+1)*sizeof(int)); /* the num of elements in a block */
    61   p_GetExpV(p,e,currRing);
    62   int i,j;
    63   for (j=1; j<=b; j++)
    64   {
    65     /* we go through all the vars */
    66     /* by blocks in lV vars */
    67     for (i=(j-1)*lV + 1; i<= j*lV; i++)
    68     {
    69       if (e[i]) B[j] = B[j]+1;
    70     }
    71   }
    72   //  j = b;
    73   //  while ( (!B[j]) && (j>=1)) j--;
    74   for (j=b; j>=1; j--)
    75   {
    76     if (B[j]!=0) break;
    77   }
    78   /* do not need e anymore */
    79   omFreeSize((ADDRESS) e, (currRing->N+1)*sizeof(int));
    80 
    81   if (j==0) goto ret_true;
    82 //   {
    83 //     /* it is a zero exp vector, which is in V */
    84 //     freeT(B, b);
    85 //     return(1);
    86 //   }
    87   /* now B[j] != 0 and we test place-squarefreeness */
    88   for (; j>=1; j--)
    89   {
    90     if (B[j]!=1)
    91     {
    92       omFreeSize((ADDRESS) B, (b+1)*sizeof(int));
    93       return(0);
    94     }
    95   }
    96  ret_true:
    97   omFreeSize((ADDRESS) B, (b+1)*sizeof(int));
    98   return(1);
    99 }
    100 
    101 /* tests whether the whole polynomial p in in V */
    102 int poly_isInV(poly p, const ring r)
    103 {
    104   poly q = p;
    105   while (q!=NULL)
    106   {
    107     if ( !isInV(q, r) )
    108     {
    109       return(0);
    110     }
    111     q = pNext(q);
    112   }
    113   return(1);
    114 }
    115 
    116 /* tests whether each polynomial of an ideal I lies in in V */
    117 int ideal_isInV(ideal I, const ring r)
    118 {
    119   int i;
    120   int s    = IDELEMS(I)-1;
    121   for(i = 0; i <= s; i++)
    122   {
    123     if ( !poly_isInV(I->m[i], r) )
    124     {
    125       return(0);
    126     }
    127   }
    128   return(1);
    129 }
    130 
    131 
    13245/* for poly in lmCR/tailTR presentation */
    13346int itoInsert(poly p, const ring r)
  • kernel/GBEngine/shiftgb.h

    rbf2a471 rc1a0fc  
    1515#define pLPCopyAndShiftLM(p, sh) p_LPCopyAndShiftLM(p, sh, currRing)
    1616
    17 int isInV(poly p, const ring r);
    18 int poly_isInV(poly p, const ring r);
    19 int ideal_isInV(ideal I, const ring r);
    20 
    2117int itoInsert(poly p, const ring r);
    2218
  • libpolys/polys/polys0.cc

    rbf2a471 rc1a0fc  
    1414#include "polys/monomials/ring.h"
    1515#include "polys/monomials/p_polys.h"
     16#ifdef HAVE_SHIFTBBA
     17#include "polys/shiftop.h"
     18#endif
    1619
    1720/*2
     
    2427  const coeffs C = r->cf;
    2528  assume(C != NULL);
     29
     30#ifdef HAVE_SHIFTBBA
     31  if (r->isLPring)
     32  {
     33    if (!p_mIsInV(p, r))
     34    {
     35      /*
     36      * the monomial is not a valid letterplace monomial
     37      * without this warning one cannot distinguish between
     38      * x(1)*x(3) and x(1)*x(2) because they would both be displayed
     39      * as x*x
     40      */
     41      int *expV = (int *) omAlloc((r->N+1)*sizeof(int));
     42      p_GetExpV(p, expV, r);
     43      char* s = LPExpVString(expV, r);
     44      Warn("invalid letterplace monomial: (%s)", s);
     45      omFreeSize((ADDRESS) expV, (r->N+1)*sizeof(int));
     46      omFree(s);
     47    }
     48  }
     49#endif
    2650
    2751  BOOLEAN wroteCoef=FALSE,writeGen=FALSE;
  • libpolys/polys/shiftop.cc

    rbf2a471 rc1a0fc  
    55#include "templates/p_MemCopy.h"
    66#include "monomials/p_polys.h"
     7#include "polys/simpleideals.h"
    78
    89/* #define SHIFT_MULT_DEBUG */
     
    551552void WriteLPExpV(int *expV, ring ri)
    552553{
     554  char *s = LPExpVString(expV, ri);
     555  PrintS(s);
     556  omFree(s);
     557}
     558
     559char* LPExpVString(int *expV, ring ri)
     560{
     561  StringSetS("");
    553562  for (int i = 0; i <= ri->N; ++i)
    554563  {
    555     Print("%d", expV[i]);
     564    StringAppend("%d", expV[i]);
    556565    if (i == 0)
    557566    {
    558       Print("| ");
     567      StringAppendS("| ");
    559568    }
    560569    if (i % ri->isLPring == 0)
    561570    {
    562       Print(" ");
    563     }
    564   }
    565 }
    566 
    567 #endif
     571      StringAppendS(" ");
     572    }
     573  }
     574  return StringEndS();
     575}
     576
     577/* tests whether each polynomial of an ideal I lies in in V */
     578int id_IsInV(ideal I, const ring r)
     579{
     580  int i;
     581  int s    = IDELEMS(I)-1;
     582  for(i = 0; i <= s; i++)
     583  {
     584    if ( !p_IsInV(I->m[i], r) )
     585    {
     586      return(0);
     587    }
     588  }
     589  return(1);
     590}
     591
     592/* tests whether the whole polynomial p in in V */
     593int p_IsInV(poly p, const ring r)
     594{
     595  poly q = p;
     596  while (q!=NULL)
     597  {
     598    if ( !p_mIsInV(q, r) )
     599    {
     600      return(0);
     601    }
     602    q = pNext(q);
     603  }
     604  return(1);
     605}
     606
     607/* there should be two routines: */
     608/* 1. test place-squarefreeness: in homog this suffices: isInV */
     609/* 2. test the presence of a hole -> in the tail??? */
     610
     611int p_mIsInV(poly p, const ring r)
     612{
     613  int lV = r->isLPring;
     614  /* investigate only the leading monomial of p in currRing */
     615  if ( p_Totaldegree(p, r)==0 ) return(1);
     616  /* returns 1 iff p is in V */
     617  /* that is in each block up to a certain one there is only one nonzero exponent */
     618  /* lV = the length of V = the number of orig vars */
     619  int *e = (int *)omAlloc0((r->N+1)*sizeof(int));
     620  int  b = (int)((r->N+lV-1)/lV); /* the number of blocks */
     621  //int b  = (int)(currRing->N)/lV;
     622  int *B = (int *)omAlloc0((b+1)*sizeof(int)); /* the num of elements in a block */
     623  p_GetExpV(p,e,r);
     624  int i,j;
     625  for (j=1; j<=b; j++)
     626  {
     627    /* we go through all the vars */
     628    /* by blocks in lV vars */
     629    for (i=(j-1)*lV + 1; i<= j*lV; i++)
     630    {
     631      if (e[i]) B[j] = B[j]+1;
     632    }
     633  }
     634  //  j = b;
     635  //  while ( (!B[j]) && (j>=1)) j--;
     636  for (j=b; j>=1; j--)
     637  {
     638    if (B[j]!=0) break;
     639  }
     640  /* do not need e anymore */
     641  omFreeSize((ADDRESS) e, (r->N+1)*sizeof(int));
     642
     643  if (j==0) goto ret_true;
     644//   {
     645//     /* it is a zero exp vector, which is in V */
     646//     freeT(B, b);
     647//     return(1);
     648//   }
     649  /* now B[j] != 0 and we test place-squarefreeness */
     650  for (; j>=1; j--)
     651  {
     652    if (B[j]!=1)
     653    {
     654      omFreeSize((ADDRESS) B, (b+1)*sizeof(int));
     655      return(0);
     656    }
     657  }
     658 ret_true:
     659  omFreeSize((ADDRESS) B, (b+1)*sizeof(int));
     660  return(1);
     661}
     662
     663#endif
  • libpolys/polys/shiftop.h

    rbf2a471 rc1a0fc  
    3939
    4040void WriteLPExpV(int *expV, ring ri);
     41char* LPExpVString(int *expV, ring ri);
     42
     43int id_IsInV(ideal I, const ring r);
     44int p_IsInV(poly p, const ring r);
     45int p_mIsInV(poly p, const ring r);
     46#define idIsInV(I) id_IsInV(I, currRing)
     47#define pIsInV(p) p_IsInV(p, currRing)
     48#define pmIsInV(p) p_mIsInV(p, currRing)
    4149
    4250#endif
Note: See TracChangeset for help on using the changeset viewer.