Changeset 4ab28ee in git for libpolys


Ignore:
Timestamp:
Oct 23, 2018, 12:28:23 AM (6 years ago)
Author:
Karim Abou Zeid <karim@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'd08f5f0bb3329b8ca19f23b74cb1473686415c3a')
Children:
c1a0fc472e1b2a3117380bb8870a7b353858901c
Parents:
bf2a471a7ccc420f3cf5a55dd1454967b35fd623
Message:
Warn when invalid letterplace polynom is printed
Location:
libpolys/polys
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/polys0.cc

    rbf2a471 r4ab28ee  
    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 r4ab28ee  
    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 r4ab28ee  
    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.