My Project  debian-1:4.1.2-p1+ds-2
Macros | Functions
shiftop.cc File Reference
#include "shiftop.h"
#include "templates/p_MemCopy.h"
#include "monomials/p_polys.h"
#include "polys/simpleideals.h"

Go to the source code of this file.

Macros

#define SHIFT_MULT_COMPAT_MODE
 

Functions

poly shift_pp_Mult_mm (poly p, const poly m, const ring ri)
 
poly shift_p_Mult_mm (poly p, const poly m, const ring ri)
 
poly shift_pp_mm_Mult (poly p, const poly m, const ring ri)
 
poly shift_p_mm_Mult (poly p, const poly m, const ring ri)
 
poly shift_p_Minus_mm_Mult_qq (poly p, poly m, poly q, int &Shorter, const poly spNoether, const ring ri)
 
poly shift_pp_Mult_mm_Noether_STUB (poly p, const poly m, const poly spNoether, int &ll, const ring ri)
 
poly shift_pp_Mult_Coeff_mm_DivSelectMult_STUB (poly p, const poly m, const poly a, const poly b, int &shorter, const ring r)
 
poly shift_pp_Mult_Coeff_mm_DivSelect_STUB (poly p, const poly m, int &shorter, const ring r)
 
void p_mLPunshift (poly m, const ring ri)
 
void p_LPunshift (poly p, const ring ri)
 
void p_mLPshift (poly m, int sh, const ring ri)
 
void p_LPshift (poly p, int sh, const ring ri)
 
int p_LastVblock (poly p, const ring r)
 
int p_mLastVblock (poly p, const ring ri)
 
int p_mLastVblock (poly p, int *expV, const ring ri)
 
int p_FirstVblock (poly p, const ring r)
 
int p_mFirstVblock (poly p, const ring ri)
 
int p_mFirstVblock (poly p, int *expV, const ring ri)
 
void p_LPExpVappend (int *m1ExpV, int *m2ExpV, int m1Length, int m2Length, const ring ri)
 
void p_LPExpVprepend (int *m1ExpV, int *m2ExpV, int m1Length, int m2Length, const ring ri)
 
void WriteLPExpV (int *expV, ring ri)
 
char * LPExpVString (int *expV, ring ri)
 
void k_SplitFrame (poly &m1, poly &m2, int at, const ring r)
 
int id_IsInV (ideal I, const ring r)
 
int p_IsInV (poly p, const ring r)
 
int p_mIsInV (poly p, const ring r)
 
BOOLEAN p_LPDivisibleBy (poly a, poly b, const ring r)
 
BOOLEAN p_LPLmDivisibleBy (poly a, poly b, const ring r)
 
BOOLEAN _p_LPLmDivisibleByNoComp (poly a, poly b, const ring r)
 
poly p_LPVarAt (poly p, int pos, const ring r)
 
static BOOLEAN freeAlgebra_weights (const ring old_ring, ring new_ring, int p, int d)
 substitute weights from orderings a,wp,Wp by d copies of it at position p More...
 
ring freeAlgebra (ring r, int d)
 create the letterplace ring corresponding to r up to degree d More...
 

Macro Definition Documentation

◆ SHIFT_MULT_COMPAT_MODE

#define SHIFT_MULT_COMPAT_MODE

Definition at line 15 of file shiftop.cc.

Function Documentation

◆ _p_LPLmDivisibleByNoComp()

BOOLEAN _p_LPLmDivisibleByNoComp ( poly  a,
poly  b,
const ring  r 
)

Definition at line 716 of file shiftop.cc.

717 {
718  if(p_LmIsConstantComp(a, r))
719  return TRUE;
720 #ifdef SHIFT_MULT_COMPAT_MODE
721  a = p_Head(a, r);
722  p_mLPunshift(a, r);
723  b = p_Head(b, r);
724  p_mLPunshift(b, r);
725 #endif
726  int i = (r->N / r->isLPring) - p_LastVblock(a, r);
727  do {
728  int j = r->N - (i * r->isLPring);
729  bool divisible = true;
730  do
731  {
732  if (p_GetExp(a, j, r) > p_GetExp(b, j + (i * r->isLPring), r))
733  {
734  divisible = false;
735  break;
736  }
737  j--;
738  }
739  while (j);
740  if (divisible) return TRUE;
741  i--;
742  }
743  while (i > -1);
744 #ifdef SHIFT_MULT_COMPAT_MODE
745  p_Delete(&a, r);
746  p_Delete(&b, r);
747 #endif
748  return FALSE;
749 }
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
int i
Definition: cfEzgcd.cc:125
CanonicalForm b
Definition: cfModGcd.cc:4044
int j
Definition: facHensel.cc:105
static poly p_Head(poly p, const ring r)
copy the i(leading) term of p
Definition: p_polys.h:825
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition: p_polys.h:965
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition: p_polys.h:468
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:860
void p_mLPunshift(poly m, const ring ri)
Definition: shiftop.cc:322
int p_LastVblock(poly p, const ring r)
Definition: shiftop.cc:401

◆ freeAlgebra()

ring freeAlgebra ( ring  r,
int  d 
)

create the letterplace ring corresponding to r up to degree d

Definition at line 783 of file shiftop.cc.

784 {
785  ring R=rCopy0(r);
786  int p;
787  if((r->order[0]==ringorder_C)
788  ||(r->order[0]==ringorder_c))
789  p=1;
790  else
791  p=0;
792  // create R->N
793  R->N=r->N*d;
794  R->isLPring=r->N;
795  // create R->order
796  BOOLEAN has_order_a=FALSE;
797  while (r->order[p]==ringorder_a)
798  {
799  if (freeAlgebra_weights(r,R,p,d))
800  {
801  WerrorS("weights must be positive");
802  return NULL;
803  }
804  has_order_a=TRUE;
805  p++;
806  }
807  R->block1[p]=R->N; /* only dp,Dp,wp,Wp; will be discarded for lp*/
808  switch(r->order[p])
809  {
810  case ringorder_dp:
811  case ringorder_Dp:
812  break;
813  case ringorder_wp:
814  case ringorder_Wp:
815  if (freeAlgebra_weights(r,R,p,d))
816  {
817  WerrorS("weights must be positive");
818  return NULL;
819  }
820  break;
821  case ringorder_lp:
822  case ringorder_rp:
823  {
824  if(has_order_a)
825  {
826  WerrorS("ordering (a(..),lp/rp not implemented for Letterplace rings");
827  return NULL;
828  }
829  int ** wvhdl=(int**)omAlloc0((r->N+3)*sizeof(int*));
830  rRingOrder_t* ord=(rRingOrder_t*)omAlloc0((r->N+3)*sizeof(rRingOrder_t));
831  int* blk0=(int*)omAlloc0((r->N+3)*sizeof(int));
832  int* blk1=(int*)omAlloc0((r->N+3)*sizeof(int));
833  omFree(R->wvhdl); R->wvhdl=wvhdl;
834  omFree(R->order); R->order=ord;
835  omFree(R->block0); R->block0=blk0;
836  omFree(R->block1); R->block1=blk1;
837  for(int i=0;i<r->N;i++)
838  {
839  ord[i+p]=ringorder_a;
840  //Print("entry:%d->a\n",i+p);
841  blk0[i+p]=1;
842  blk1[i+p]=R->N;
843  wvhdl[i+p]=(int*)omAlloc0(R->N*sizeof(int));
844  for(int j=0;j<d;j++)
845  {
846  assume(j*r->N+i<R->N);
847  if (r->order[p]==ringorder_lp)
848  wvhdl[i+p][j*r->N+i]=1;
849  else
850  wvhdl[i+p][(j+1)*r->N-i-1]=1;
851  }
852  }
853  ord[r->N+p]=r->order[p]; /* lp or rp */
854  //Print("entry:%d->lp\n",r->N+p);
855  blk0[r->N+p]=1;
856  blk1[r->N+p]=R->N;
857  // copy component order
858  if (p==1) ord[0]=r->order[0];
859  else if (p==0) ord[r->N+1]=r->order[1];
860  else
861  { // should never happen:
862  WerrorS("ordering not implemented for Letterplace rings");
863  return NULL;
864  }
865  //if (p==1) PrintS("entry:0 ->c/C\n");
866  //else if (p==0) Print("entry:%d ->c/C\n",r->N+1);
867  break;
868  }
869  default: WerrorS("ordering not implemented for Letterplace rings");
870  return NULL;
871  }
872  // create R->names
873  char **names=(char**)omAlloc(R->N*sizeof(char*));
874  for(int b=0;b<d;b++)
875  {
876  for(int i=r->N-1;i>=0;i--)
877  names[b*r->N+i]=omStrDup(r->names[i]);
878  }
879  for(int i=r->N-1;i>=0;i--) omFree(R->names[i]);
880  omFree(R->names);
881  R->names=names;
882 
883  rComplete(R,TRUE);
884  return R;
885 }
int BOOLEAN
Definition: auxiliary.h:87
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
int p
Definition: cfModGcd.cc:4019
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define assume(x)
Definition: mod2.h:390
#define omStrDup(s)
Definition: omAllocDecl.h:263
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omFree(addr)
Definition: omAllocDecl.h:261
#define omAlloc0(size)
Definition: omAllocDecl.h:211
#define NULL
Definition: omList.c:12
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
Definition: ring.cc:3398
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1365
rRingOrder_t
order stuff
Definition: ring.h:68
@ ringorder_lp
Definition: ring.h:77
@ ringorder_a
Definition: ring.h:70
@ ringorder_C
Definition: ring.h:73
@ ringorder_Dp
Definition: ring.h:80
@ ringorder_dp
Definition: ring.h:78
@ ringorder_c
Definition: ring.h:72
@ ringorder_rp
Definition: ring.h:79
@ ringorder_Wp
Definition: ring.h:82
@ ringorder_wp
Definition: ring.h:81
static BOOLEAN freeAlgebra_weights(const ring old_ring, ring new_ring, int p, int d)
substitute weights from orderings a,wp,Wp by d copies of it at position p
Definition: shiftop.cc:766
#define R
Definition: sirandom.c:27

◆ freeAlgebra_weights()

static BOOLEAN freeAlgebra_weights ( const ring  old_ring,
ring  new_ring,
int  p,
int  d 
)
static

substitute weights from orderings a,wp,Wp by d copies of it at position p

Definition at line 766 of file shiftop.cc.

767 {
768  omFree(new_ring->wvhdl[p]);
769  int *w=(int*)omAlloc(new_ring->N*sizeof(int));
770  for(int b=0;b<d;b++)
771  {
772  for(int i=old_ring->N-1;i>=0;i--)
773  {
774  if (old_ring->wvhdl[p][i]<-0) return TRUE;
775  w[b*old_ring->N+i]=old_ring->wvhdl[p][i];
776  }
777  }
778  new_ring->wvhdl[p]=w;
779  new_ring->block1[p]=new_ring->N;
780  return FALSE;
781 }
const CanonicalForm & w
Definition: facAbsFact.cc:55

◆ id_IsInV()

int id_IsInV ( ideal  I,
const ring  r 
)

Definition at line 611 of file shiftop.cc.

612 {
613  int i;
614  int s = IDELEMS(I)-1;
615  for(i = 0; i <= s; i++)
616  {
617  if ( !p_IsInV(I->m[i], r) )
618  {
619  return(0);
620  }
621  }
622  return(1);
623 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
int p_IsInV(poly p, const ring r)
Definition: shiftop.cc:626
#define IDELEMS(i)
Definition: simpleideals.h:23

◆ k_SplitFrame()

void k_SplitFrame ( poly &  m1,
poly &  m2,
int  at,
const ring  r 
)

Definition at line 593 of file shiftop.cc.

594 {
595  int lV = r->isLPring;
596 
597  number m1Coeff = pGetCoeff(m1);
598 
599  int hole = lV * at;
600  m2 = p_GetExp_k_n(m1, 1, hole, r);
601  m1 = p_GetExp_k_n(m1, hole, r->N, r);
602 
603  p_mLPunshift(m2, r);
604  p_SetCoeff(m1, m1Coeff, r);
605 
606  assume(p_FirstVblock(m1,r) <= 1);
607  assume(p_FirstVblock(m2,r) <= 1);
608 }
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:44
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:411
static poly p_GetExp_k_n(poly p, int l, int k, const ring r)
Definition: p_polys.h:1311
int p_FirstVblock(poly p, const ring r)
Definition: shiftop.cc:451

◆ LPExpVString()

char* LPExpVString ( int *  expV,
ring  ri 
)

Definition at line 573 of file shiftop.cc.

574 {
575  StringSetS("");
576  for (int i = 0; i <= ri->N; ++i)
577  {
578  StringAppend("%d", expV[i]);
579  if (i == 0)
580  {
581  StringAppendS("| ");
582  }
583  if (i % ri->isLPring == 0 && i != ri->N)
584  {
585  StringAppendS(" ");
586  }
587  }
588  return StringEndS();
589 }
#define StringAppend
Definition: emacs.cc:79
void StringSetS(const char *st)
Definition: reporter.cc:128
void StringAppendS(const char *st)
Definition: reporter.cc:107
char * StringEndS()
Definition: reporter.cc:151

◆ p_FirstVblock()

int p_FirstVblock ( poly  p,
const ring  r 
)

Definition at line 451 of file shiftop.cc.

452 {
453  if (p == NULL) {
454  return 0;
455  }
456 
457  poly q = p;
458  int ans = p_mFirstVblock(q, r);
459  while (q!=NULL)
460  {
461  int ansnew = p_mFirstVblock(q, r);
462  if (ansnew > 0) { // don't count constants
463  ans = si_min(ans,ansnew);
464  }
465  pIter(q);
466  }
467  /* do not need to delete q */
468  return(ans);
469 }
static int si_min(const int a, const int b)
Definition: auxiliary.h:141
#define pIter(p)
Definition: monomials.h:37
int p_mFirstVblock(poly p, const ring ri)
Definition: shiftop.cc:473

◆ p_IsInV()

int p_IsInV ( poly  p,
const ring  r 
)

Definition at line 626 of file shiftop.cc.

627 {
628  poly q = p;
629  while (q!=NULL)
630  {
631  if ( !p_mIsInV(q, r) )
632  {
633  return(0);
634  }
635  q = pNext(q);
636  }
637  return(1);
638 }
#define pNext(p)
Definition: monomials.h:36
int p_mIsInV(poly p, const ring r)
Definition: shiftop.cc:644

◆ p_LastVblock()

int p_LastVblock ( poly  p,
const ring  r 
)

Definition at line 401 of file shiftop.cc.

402 {
403  poly q = p;
404  int ans = 0;
405  while (q!=NULL)
406  {
407  int ansnew = p_mLastVblock(q, r);
408  ans = si_max(ans,ansnew);
409  pIter(q);
410  }
411  return(ans);
412 }
static int si_max(const int a, const int b)
Definition: auxiliary.h:140
int p_mLastVblock(poly p, const ring ri)
Definition: shiftop.cc:416

◆ p_LPDivisibleBy()

BOOLEAN p_LPDivisibleBy ( poly  a,
poly  b,
const ring  r 
)

Definition at line 696 of file shiftop.cc.

697 {
699  pIfThen1(a!=NULL, p_LmCheckPolyRing1(a, r));
700 
701  if (b == NULL) return TRUE;
702  if (a != NULL && (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r)))
703  return _p_LPLmDivisibleByNoComp(a,b,r);
704  return FALSE;
705 }
#define p_GetComp(p, r)
Definition: monomials.h:64
#define pIfThen1(cond, check)
Definition: monomials.h:179
#define p_LmCheckPolyRing1(p, r)
Definition: monomials.h:177
BOOLEAN _p_LPLmDivisibleByNoComp(poly a, poly b, const ring r)
Definition: shiftop.cc:716

◆ p_LPExpVappend()

void p_LPExpVappend ( int *  m1ExpV,
int *  m2ExpV,
int  m1Length,
int  m2Length,
const ring  ri 
)

Definition at line 506 of file shiftop.cc.

506  {
507 #ifdef SHIFT_MULT_DEBUG
508  PrintLn(); PrintS("Append");
509  PrintLn(); WriteLPExpV(m1ExpV, ri);
510  PrintLn(); WriteLPExpV(m2ExpV, ri);
511 #endif
512  int last = m1Length + m2Length;
513  if (last > ri->N)
514  {
515  Werror("degree bound of Letterplace ring is %d, but at least %d is needed for this multiplication", ri->N/ri->isLPring, last/ri->isLPring);
516  last = ri->N;
517  }
518  for (int i = 1 + m1Length; i < 1 + last; ++i)
519  {
520  assume(m2ExpV[i - m1Length] <= 1);
521  m1ExpV[i] = m2ExpV[i - m1Length];
522  }
523 
524  assume(m1ExpV[0] == 0 || m2ExpV[0] == 0); // one component should be zero (otherwise this doesn't make any sense)
525  m1ExpV[0] += m2ExpV[0]; // as in the commutative variant (they use MemAdd)
526 #ifdef SHIFT_MULT_DEBUG
527  PrintLn(); WriteLPExpV(m1ExpV, ri);
528 #endif
529 }
STATIC_VAR poly last
Definition: hdegree.cc:1076
void PrintS(const char *s)
Definition: reporter.cc:284
void PrintLn()
Definition: reporter.cc:310
void Werror(const char *fmt,...)
Definition: reporter.cc:189
void WriteLPExpV(int *expV, ring ri)
Definition: shiftop.cc:566

◆ p_LPExpVprepend()

void p_LPExpVprepend ( int *  m1ExpV,
int *  m2ExpV,
int  m1Length,
int  m2Length,
const ring  ri 
)

Definition at line 532 of file shiftop.cc.

533 {
534 #ifdef SHIFT_MULT_DEBUG
535  PrintLn(); PrintS("Prepend");
536  PrintLn(); WriteLPExpV(m1ExpV, ri);
537  PrintLn(); WriteLPExpV(m2ExpV, ri);
538 #endif
539  int last = m1Length + m2Length;
540  if (last > ri->N)
541  {
542  Werror("degree bound of Letterplace ring is %d, but at least %d is needed for this multiplication", ri->N/ri->isLPring, last/ri->isLPring);
543  last = ri->N;
544  }
545 
546  // shift m1 by m2Length
547  for (int i = last; i >= 1 + m2Length; --i)
548  {
549  m1ExpV[i] = m1ExpV[i - m2Length];
550  }
551 
552  // write m2 to m1
553  for (int i = 1; i < 1 + m2Length; ++i)
554  {
555  assume(m2ExpV[i] <= 1);
556  m1ExpV[i] = m2ExpV[i];
557  }
558 
559  assume(m1ExpV[0] == 0 || m2ExpV[0] == 0); // one component should be zero (otherwise this doesn't make any sense)
560  m1ExpV[0] += m2ExpV[0]; // as in the commutative variant (they use MemAdd)
561 #ifdef SHIFT_MULT_DEBUG
562  PrintLn(); WriteLPExpV(m1ExpV, ri);
563 #endif
564 }

◆ p_LPLmDivisibleBy()

BOOLEAN p_LPLmDivisibleBy ( poly  a,
poly  b,
const ring  r 
)

Definition at line 707 of file shiftop.cc.

708 {
709  p_LmCheckPolyRing1(b, r);
710  pIfThen1(a != NULL, p_LmCheckPolyRing1(b, r));
711  if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
712  return _p_LPLmDivisibleByNoComp(a, b, r);
713  return FALSE;
714 }

◆ p_LPshift()

void p_LPshift ( poly  p,
int  sh,
const ring  ri 
)

Definition at line 387 of file shiftop.cc.

388 {
389  if (sh == 0) return;
390 
391  while (p!=NULL)
392  {
393  p_mLPshift(p, sh, ri);
394  pIter(p);
395  }
396 }
void p_mLPshift(poly m, int sh, const ring ri)
Definition: shiftop.cc:357

◆ p_LPunshift()

void p_LPunshift ( poly  p,
const ring  ri 
)

Definition at line 348 of file shiftop.cc.

349 {
350  while (p!=NULL)
351  {
352  p_mLPunshift(p, ri);
353  pIter(p);
354  }
355 }

◆ p_LPVarAt()

poly p_LPVarAt ( poly  p,
int  pos,
const ring  r 
)

Definition at line 751 of file shiftop.cc.

752 {
753  if (p == NULL || pos < 1 || pos > (r->N / r->isLPring)) return NULL;
754  poly v = p_One(r);
755  for (int i = (pos-1) * r->isLPring + 1; i <= pos * r->isLPring; i++) {
756  if (p_GetExp(p, i, r)) {
757  p_SetExp(v, i - (pos-1) * r->isLPring, 1, r);
758  return v;
759  }
760  }
761  return v;
762 }
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
poly p_One(const ring r)
Definition: p_polys.cc:1303
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition: p_polys.h:487

◆ p_mFirstVblock() [1/2]

int p_mFirstVblock ( poly  p,
const ring  ri 
)

Definition at line 473 of file shiftop.cc.

474 {
475  if (p == NULL || p_LmIsConstantComp(p,ri))
476  {
477  return(0);
478  }
479 
480  int *e=(int *)omAlloc((ri->N+1)*sizeof(int));
481  p_GetExpV(p,e,ri);
482  int b = p_mFirstVblock(p, e, ri);
483  omFreeSize((ADDRESS) e, (ri->N+1)*sizeof(int));
484  return b;
485 }
void * ADDRESS
Definition: auxiliary.h:135
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1459

◆ p_mFirstVblock() [2/2]

int p_mFirstVblock ( poly  p,
int *  expV,
const ring  ri 
)

Definition at line 489 of file shiftop.cc.

490 {
491  if (p == NULL || p_LmIsConstantComp(p,ri))
492  {
493  return(0);
494  }
495 
496  int lV = ri->isLPring;
497  int j,b;
498  j = 1;
499  while ( (!expV[j]) && (j<=ri->N-1) ) j++;
500  assume(j <= ri->N);
501  b = (int)(j+lV-1)/lV; /* the number of the block, 1<= b <= r->N */
502  return b;
503 }

◆ p_mIsInV()

int p_mIsInV ( poly  p,
const ring  r 
)

Definition at line 644 of file shiftop.cc.

645 {
646  int lV = r->isLPring;
647  /* investigate only the leading monomial of p in currRing */
648  if ( p_Totaldegree(p, r)==0 ) return(1);
649  /* returns 1 iff p is in V */
650  /* that is in each block up to a certain one there is only one nonzero exponent */
651  /* lV = the length of V = the number of orig vars */
652  int *e = (int *)omAlloc((r->N+1)*sizeof(int));
653  int b = (int)((r->N+lV-1)/lV); /* the number of blocks */
654  //int b = (int)(currRing->N)/lV;
655  int *B = (int *)omAlloc0((b+1)*sizeof(int)); /* the num of elements in a block */
656  p_GetExpV(p,e,r);
657  int i,j;
658  for (j=1; j<=b; j++)
659  {
660  /* we go through all the vars */
661  /* by blocks in lV vars */
662  for (i=(j-1)*lV + 1; i<= j*lV; i++)
663  {
664  if (e[i]) B[j] = B[j]+1;
665  }
666  }
667  // j = b;
668  // while ( (!B[j]) && (j>=1)) j--;
669  for (j=b; j>=1; j--)
670  {
671  if (B[j]!=0) break;
672  }
673  /* do not need e anymore */
674  omFreeSize((ADDRESS) e, (r->N+1)*sizeof(int));
675 
676  if (j==0) goto ret_true;
677 // {
678 // /* it is a zero exp vector, which is in V */
679 // freeT(B, b);
680 // return(1);
681 // }
682  /* now B[j] != 0 and we test place-squarefreeness */
683  for (; j>=1; j--)
684  {
685  if (B[j]!=1)
686  {
687  omFreeSize((ADDRESS) B, (b+1)*sizeof(int));
688  return(0);
689  }
690  }
691  ret_true:
692  omFreeSize((ADDRESS) B, (b+1)*sizeof(int));
693  return(1);
694 }
b *CanonicalForm B
Definition: facBivar.cc:52
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1446

◆ p_mLastVblock() [1/2]

int p_mLastVblock ( poly  p,
const ring  ri 
)

Definition at line 416 of file shiftop.cc.

417 {
418  if (p == NULL || p_LmIsConstantComp(p,ri))
419  {
420  return(0);
421  }
422 
423  int *e=(int *)omAlloc((ri->N+1)*sizeof(int));
424  p_GetExpV(p,e,ri);
425  int b = p_mLastVblock(p, e, ri);
426  omFreeSize((ADDRESS) e, (ri->N+1)*sizeof(int));
427  return b;
428 }

◆ p_mLastVblock() [2/2]

int p_mLastVblock ( poly  p,
int *  expV,
const ring  ri 
)

Definition at line 432 of file shiftop.cc.

433 {
434  if (p == NULL || p_LmIsConstantComp(p,ri))
435  {
436  return(0);
437  }
438 
439  int lV = ri->isLPring;
440  int j,b;
441  j = ri->N;
442  while ( (!expV[j]) && (j>=1) ) j--;
443  assume(j>0);
444  b = (int)((j+lV-1)/lV); /* the number of the block, >=1 */
445  return b;
446 }

◆ p_mLPshift()

void p_mLPshift ( poly  m,
int  sh,
const ring  ri 
)

Definition at line 357 of file shiftop.cc.

358 {
359  if (sh == 0 || m == NULL || p_LmIsConstantComp(m,ri)) return;
360 
361  int lV = ri->isLPring;
362 
363  assume(p_mFirstVblock(m,ri) + sh >= 1);
364  assume(p_mLastVblock(m,ri) + sh <= ri->N/lV);
365 
366  int *e=(int *)omAlloc((ri->N+1)*sizeof(int));
367  int *s=(int *)omAlloc0((ri->N+1)*sizeof(int));
368  p_GetExpV(m,e,ri);
369 
370  if (p_mLastVblock(m, e, ri) + sh > ri->N/lV)
371  {
372  Werror("degree bound of Letterplace ring is %d, but at least %d is needed for this shift", ri->N/lV, p_mLastVblock(m, e, ri) + sh);
373  }
374  for (int i = ri->N - sh*lV; i > 0; i--)
375  {
376  assume(e[i]<=1);
377  if (e[i]==1)
378  {
379  s[i + (sh*lV)] = e[i]; /* actually 1 */
380  }
381  }
382  p_SetExpV(m,s,ri);
383  omFreeSize((ADDRESS) e, (ri->N+1)*sizeof(int));
384  omFreeSize((ADDRESS) s, (ri->N+1)*sizeof(int));
385 }
int m
Definition: cfEzgcd.cc:121
static void p_SetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1474

◆ p_mLPunshift()

void p_mLPunshift ( poly  m,
const ring  ri 
)

Definition at line 322 of file shiftop.cc.

323 {
324  if (m == NULL || p_LmIsConstantComp(m,ri)) return;
325 
326  int lV = ri->isLPring;
327 
328  int shift = p_mFirstVblock(m, ri) - 1;
329 
330  if (shift == 0) return;
331 
332  int *e=(int *)omAlloc((ri->N+1)*sizeof(int));
333  int *s=(int *)omAlloc0((ri->N+1)*sizeof(int));
334  p_GetExpV(m, e, ri);
335 
336  int expVoffset = shift*lV;
337  for (int i = 1 + expVoffset; i <= ri->N; i++)
338  {
339  assume(e[i] <= 1);
340  s[i - expVoffset] = e[i];
341  }
342  p_SetExpV(m,s,ri);
343  omFreeSize((ADDRESS) e, (ri->N+1)*sizeof(int));
344  omFreeSize((ADDRESS) s, (ri->N+1)*sizeof(int));
345 }

◆ shift_p_Minus_mm_Mult_qq()

poly shift_p_Minus_mm_Mult_qq ( poly  p,
poly  m,
poly  q,
int &  Shorter,
const poly  spNoether,
const ring  ri 
)

Definition at line 268 of file shiftop.cc.

268  {
269 #ifdef SHIFT_MULT_DEBUG
270  PrintLn(); PrintS("shift_p_Minus_mm_Mult_qq: "); p_wrp(p, ri, ri); PrintS(" - "); p_wrp(m, ri, ri); PrintS(" * "); p_wrp(q, ri, ri);
271 #endif
272 
273  Shorter = pLength(p) + pLength(q);
274 
275  poly qq = p_Add_q(p, shift_pp_mm_Mult(q, p_Neg(p_Copy(m, ri), ri), ri), ri);
276 
277 #ifdef SHIFT_MULT_DEBUG
278  PrintLn(); PrintS("shift_p_Minus_mm_Mult_qq result: "); p_wrp(qq, ri, ri); PrintLn();
279 #endif
280  Shorter -= pLength(qq);
281  return qq;
282 }
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1046
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:895
static unsigned pLength(poly a)
Definition: p_polys.h:191
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:373
poly shift_pp_mm_Mult(poly p, const poly m, const ring ri)
Definition: shiftop.cc:144

◆ shift_p_mm_Mult()

poly shift_p_mm_Mult ( poly  p,
const poly  m,
const ring  ri 
)

Definition at line 211 of file shiftop.cc.

212 {
213 #ifdef SHIFT_MULT_DEBUG
214  PrintLn(); PrintS("shift_p_mm_Mult: "); p_wrp(m, ri, ri); PrintS(" * ("); p_wrp(p, ri, ri); PrintS(")");
215 #endif
216 
217  p_Test(p, ri);
218  p_LmTest(m, ri);
219  pAssume(m != NULL);
220  assume(p!=NULL);
221 
222  int lV = ri->isLPring;
223  poly _m = m; // temp hack because m is const
224 #ifdef SHIFT_MULT_COMPAT_MODE
225  _m = p_Copy(_m, ri);
226  p_mLPunshift(_m, ri);
227  p_LPunshift(p, ri);
228 #else
229  assume(p_mFirstVblock(_m, ri) <= 1);
230  assume(p_FirstVblock(p, ri) <= 1); // TODO check that each block is <=1
231 #endif
232  // at this point _m and p are shifted to 1
233 
234  poly q = p; // we use p for iterating and q for the result
235  number mCoeff = pGetCoeff(_m);
236  number pCoeff;
237  pAssume(!n_IsZero(mCoeff, ri->cf));
238 
239  int *mExpV = (int *) omAlloc((ri->N+1)*sizeof(int));
240  p_GetExpV(_m,mExpV,ri);
241  int mLength = p_mLastVblock(_m, mExpV, ri) * lV;
242  int *pExpV = (int *) omAlloc((ri->N+1)*sizeof(int));
243  while (p != NULL)
244  {
245  pCoeff = pGetCoeff(p);
246  pSetCoeff0(p, n_Mult(mCoeff, pCoeff, ri->cf));
247  n_Delete(&pCoeff, ri->cf); // delete the old coeff
248 
249  p_GetExpV(p,pExpV,ri);
250  p_LPExpVprepend(pExpV, mExpV, p_mLastVblock(p, pExpV, ri) * lV, mLength, ri);
251  p_SetExpV(p, pExpV, ri);
252 
253  pIter(p);
254  }
255  omFreeSize((ADDRESS) pExpV, (ri->N+1)*sizeof(int));
256  omFreeSize((ADDRESS) mExpV, (ri->N+1)*sizeof(int));
257 #ifdef SHIFT_MULT_COMPAT_MODE
258  p_Delete(&_m, ri); // in this case we copied _m before
259 #endif
260 #ifdef SHIFT_MULT_DEBUG
261  PrintLn(); PrintS("shift_p_mm_Mult result: "); p_wrp(q, ri, ri); PrintLn();
262 #endif
263  p_Test(q, ri);
264  return q;
265 }
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:636
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:464
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
#define pSetCoeff0(p, n)
Definition: monomials.h:59
#define pAssume(cond)
Definition: monomials.h:90
#define p_LmTest(p, r)
Definition: p_polys.h:163
#define p_Test(p, r)
Definition: p_polys.h:162
void p_LPExpVprepend(int *m1ExpV, int *m2ExpV, int m1Length, int m2Length, const ring ri)
Definition: shiftop.cc:532
void p_LPunshift(poly p, const ring ri)
Definition: shiftop.cc:348

◆ shift_p_Mult_mm()

poly shift_p_Mult_mm ( poly  p,
const poly  m,
const ring  ri 
)

Definition at line 88 of file shiftop.cc.

89 {
90 #ifdef SHIFT_MULT_DEBUG
91  PrintLn(); PrintS("shift_p_Mult_mm: ("); p_wrp(p, ri, ri); PrintS(") * "); p_wrp(m, ri, ri);
92 #endif
93 
94  p_Test(p, ri);
95  p_LmTest(m, ri);
96  pAssume(m != NULL);
97  assume(p!=NULL);
98 
99  int lV = ri->isLPring;
100  poly _m = m; // temp hack because m is const
101 #ifdef SHIFT_MULT_COMPAT_MODE
102  _m = p_Copy(_m, ri);
103  p_mLPunshift(_m, ri);
104  p_LPunshift(p, ri);
105 #else
106  assume(p_mFirstVblock(_m, ri) <= 1);
107  assume(p_FirstVblock(p, ri) <= 1); // TODO check that each block is <=1
108 #endif
109  // at this point _m and p are shifted to 1
110 
111  poly q = p; // we use p for iterating and q for the result
112  number mCoeff = pGetCoeff(_m);
113  number pCoeff;
114  pAssume(!n_IsZero(mCoeff, ri->cf));
115 
116  int *mExpV = (int *) omAlloc((ri->N+1)*sizeof(int));
117  p_GetExpV(_m,mExpV,ri);
118  int mLength = p_mLastVblock(_m, mExpV, ri) * lV;
119  int *pExpV = (int *) omAlloc((ri->N+1)*sizeof(int));
120  while (p != NULL)
121  {
122  pCoeff = pGetCoeff(p);
123  pSetCoeff0(p, n_Mult(mCoeff, pCoeff, ri->cf));
124  n_Delete(&pCoeff, ri->cf); // delete the old coeff
125 
126  p_GetExpV(p,pExpV,ri);
127  p_LPExpVappend(pExpV, mExpV, p_mLastVblock(p, pExpV, ri) * lV, mLength, ri);
128  p_SetExpV(p, pExpV, ri);
129 
130  pIter(p);
131  }
132  omFreeSize((ADDRESS) pExpV, (ri->N+1)*sizeof(int));
133  omFreeSize((ADDRESS) mExpV, (ri->N+1)*sizeof(int));
134 #ifdef SHIFT_MULT_COMPAT_MODE
135  p_Delete(&_m, ri); // in this case we copied _m before
136 #endif
137 #ifdef SHIFT_MULT_DEBUG
138  PrintLn(); PrintS("shift_p_Mult_mm result: "); p_wrp(q, ri, ri); PrintLn();
139 #endif
140  p_Test(q, ri);
141  return q;
142 }
void p_LPExpVappend(int *m1ExpV, int *m2ExpV, int m1Length, int m2Length, const ring ri)
Definition: shiftop.cc:506

◆ shift_pp_mm_Mult()

poly shift_pp_mm_Mult ( poly  p,
const poly  m,
const ring  ri 
)

Definition at line 144 of file shiftop.cc.

145 {
146 #ifdef SHIFT_MULT_DEBUG
147  PrintLn(); PrintS("shift_pp_mm_Mult: "); p_wrp(m, ri, ri); PrintS(" * ("); p_wrp(p, ri, ri); PrintS(")");
148 #endif
149 
150  p_Test(p, ri);
151  p_LmTest(m, ri);
152  if (p == NULL)
153  {
154  return NULL;
155  }
156 
157  int lV = ri->isLPring;
158  poly _m = m; // temp hack because m is const
159 #ifdef SHIFT_MULT_COMPAT_MODE
160  _m = p_Copy(_m, ri);
161  p_mLPunshift(_m, ri);
162  p = p_Copy(p, ri);
163  poly pCopyHead = p; // used to delete p later
164  p_LPunshift(p, ri);
165 #else
166  assume(p_mFirstVblock(_m, ri) <= 1);
167  assume(p_FirstVblock(p, ri) <= 1); // TODO check that each block is <=1
168 #endif
169  // at this point _m and p are shifted to 1
170 
171  spolyrec rp;
172  poly q = &rp; // we use p for iterating and q for the result
173  number mCoeff = pGetCoeff(_m);
174  omBin bin = ri->PolyBin;
175  pAssume(!n_IsZero(mCoeff, ri->cf));
176  pAssume1(p_GetComp(m, ri) == 0 || p_MaxComp(p, ri) == 0);
177 
178  int *mExpV = (int *) omAlloc((ri->N+1)*sizeof(int));
179  p_GetExpV(_m,mExpV,ri);
180  int mLength = p_mLastVblock(_m, mExpV, ri) * lV;
181  int *pExpV = (int *) omAlloc((ri->N+1)*sizeof(int));
182  do
183  {
184  p_AllocBin(pNext(q), bin, ri);
185  pIter(q);
186  pSetCoeff0(q, n_Mult(mCoeff, pGetCoeff(p), ri->cf));
187 
188  p_GetExpV(p, pExpV, ri);
189  p_LPExpVprepend(pExpV, mExpV, p_mLastVblock(p, pExpV, ri) * lV, mLength, ri);
190  p_MemCopy_LengthGeneral(q->exp, p->exp, ri->ExpL_Size); // otherwise q is not initialized correctly
191  p_SetExpV(q, pExpV, ri);
192 
193  pIter(p);
194  }
195  while (p != NULL);
196  omFreeSize((ADDRESS) pExpV, (ri->N+1)*sizeof(int));
197  omFreeSize((ADDRESS) mExpV, (ri->N+1)*sizeof(int));
198  pNext(q) = NULL;
199 #ifdef SHIFT_MULT_COMPAT_MODE
200  p_Delete(&_m, ri); // in this case we copied _m before
201  p_Delete(&pCopyHead, ri); // in this case we copied p before
202 #endif
203 #ifdef SHIFT_MULT_DEBUG
204  PrintLn(); PrintS("shift_pp_mm_Mult result: "); p_wrp(pNext(&rp), ri, ri); PrintLn();
205 #endif
206  p_Test(pNext(&rp), ri);
207  return pNext(&rp);
208 }
#define pAssume1(cond)
Definition: monomials.h:171
#define p_AllocBin(p, bin, r)
Definition: monomials.h:248
omBin_t * omBin
Definition: omStructs.h:12
#define p_MemCopy_LengthGeneral(d, s, length)
Definition: p_MemCopy.h:79
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
Definition: p_polys.h:291

◆ shift_pp_Mult_Coeff_mm_DivSelect_STUB()

poly shift_pp_Mult_Coeff_mm_DivSelect_STUB ( poly  p,
const poly  m,
int &  shorter,
const ring  r 
)

Definition at line 314 of file shiftop.cc.

314  {
315  PrintLn(); WarnS("pp_Mult_Coeff_mm_DivSelect is not supported yet by Letterplace. This might lead to unexpected behavior.");
316  return NULL;
317 }
#define WarnS
Definition: emacs.cc:78

◆ shift_pp_Mult_Coeff_mm_DivSelectMult_STUB()

poly shift_pp_Mult_Coeff_mm_DivSelectMult_STUB ( poly  p,
const poly  m,
const poly  a,
const poly  b,
int &  shorter,
const ring  r 
)

Definition at line 309 of file shiftop.cc.

309  {
310  PrintLn(); WarnS("pp_Mult_Coeff_mm_DivSelectMult is not supported yet by Letterplace. This might lead to unexpected behavior.");
311  return NULL;
312 }

◆ shift_pp_Mult_mm()

poly shift_pp_Mult_mm ( poly  p,
const poly  m,
const ring  ri 
)

Definition at line 21 of file shiftop.cc.

22 {
23 #ifdef SHIFT_MULT_DEBUG
24  PrintLn(); PrintS("shift_pp_Mult_mm: ("); p_wrp(p, ri, ri); PrintS(") * "); p_wrp(m, ri, ri);
25 #endif
26 
27  p_Test(p, ri);
28  p_LmTest(m, ri);
29  if (p == NULL)
30  {
31  return NULL;
32  }
33 
34  int lV = ri->isLPring;
35  poly _m = m; // temp hack because m is const
36 #ifdef SHIFT_MULT_COMPAT_MODE
37  _m = p_Copy(_m, ri);
38  p_mLPunshift(_m, ri);
39  p = p_Copy(p, ri);
40  poly pCopyHead = p; // used to delete p later
41  p_LPunshift(p, ri);
42 #else
43  assume(p_mFirstVblock(_m, ri) <= 1);
44  assume(p_FirstVblock(p, ri) <= 1); // TODO check that each block is <=1
45 #endif
46  // at this point _m and p are shifted to 1
47 
48  spolyrec rp;
49  poly q = &rp; // we use p for iterating and q for the result
50  number mCoeff = pGetCoeff(_m);
51  omBin bin = ri->PolyBin;
52  pAssume(!n_IsZero(mCoeff, ri->cf));
53  pAssume1(p_GetComp(m, ri) == 0 || p_MaxComp(p, ri) == 0);
54 
55  int *mExpV = (int *) omAlloc((ri->N+1)*sizeof(int));
56  p_GetExpV(_m,mExpV,ri);
57  int mLength = p_mLastVblock(_m, mExpV, ri) * lV;
58  int *pExpV = (int *) omAlloc((ri->N+1)*sizeof(int));
59  do
60  {
61  p_AllocBin(pNext(q), bin, ri);
62  pIter(q);
63  pSetCoeff0(q, n_Mult(mCoeff, pGetCoeff(p), ri->cf));
64 
65  p_GetExpV(p, pExpV, ri);
66  p_LPExpVappend(pExpV, mExpV, p_mLastVblock(p, pExpV, ri) * lV, mLength, ri);
67  p_MemCopy_LengthGeneral(q->exp, p->exp, ri->ExpL_Size); // otherwise q is not initialized correctly
68  p_SetExpV(q, pExpV, ri);
69 
70  pIter(p);
71  }
72  while (p != NULL);
73  omFreeSize((ADDRESS) pExpV, (ri->N+1)*sizeof(int));
74  omFreeSize((ADDRESS) mExpV, (ri->N+1)*sizeof(int));
75  pNext(q) = NULL;
76 #ifdef SHIFT_MULT_COMPAT_MODE
77  p_Delete(&_m, ri); // in this case we copied _m before
78  p_Delete(&pCopyHead, ri); // in this case we copied p before
79 #endif
80 #ifdef SHIFT_MULT_DEBUG
81  PrintLn(); PrintS("shift_pp_Mult_mm result: "); p_wrp(pNext(&rp), ri, ri); PrintLn();
82 #endif
83  p_Test(pNext(&rp), ri);
84  return pNext(&rp);
85 }

◆ shift_pp_Mult_mm_Noether_STUB()

poly shift_pp_Mult_mm_Noether_STUB ( poly  p,
const poly  m,
const poly  spNoether,
int &  ll,
const ring  ri 
)

Definition at line 285 of file shiftop.cc.

285  {
286  PrintLn(); WarnS("pp_Mult_mm_Noether is not supported yet by Letterplace. Ignoring spNoether and using pp_Mult_mm. This might lead to unexpected behavior.");
287 
288  int pLen = 0;
289  if (ll >= 0)
290  {
291  pLen = pLength(p);
292  }
293 
294  p = shift_pp_Mult_mm(p, m, ri);
295 
296  if (ll >= 0)
297  {
298  ll = pLen - pLength(p);
299  }
300  else
301  {
302  ll = pLength(p);
303  }
304 
305  return p;
306 }
poly shift_pp_Mult_mm(poly p, const poly m, const ring ri)
Definition: shiftop.cc:21

◆ WriteLPExpV()

void WriteLPExpV ( int *  expV,
ring  ri 
)

Definition at line 566 of file shiftop.cc.

567 {
568  char *s = LPExpVString(expV, ri);
569  PrintS(s);
570  omFree(s);
571 }
char * LPExpVString(int *expV, ring ri)
Definition: shiftop.cc:573