My Project
Macros | Functions
shiftop.h File Reference
#include "misc/auxiliary.h"
#include "monomials/ring.h"

Go to the source code of this file.

Macros

#define pLPunshift(p, sh)   p_LPunshift(p, currRing)
 
#define pmLPunshift(p, sh)   p_mLPunshift(p, currRing)
 
#define pLPshift(p, sh)   p_LPshift(p, sh, currRing)
 
#define pmLPshift(p, sh)   p_mLPshift(p, sh, currRing)
 
#define pLastVblock(p)   p_LastVblock(p,currRing)
 
#define pmLastVblock(p)   p_mLastVblock(p,currRing)
 
#define pFirstVblock(p)   p_FirstVblock(p,currRing)
 
#define pmFirstVblock(p)   p_mFirstVblock(p,currRing)
 
#define kSplitFrame(m1, m2, at)   k_SplitFrame(m1, m2, at, currRing)
 
#define idIsInV(I)   id_IsInV(I, currRing)
 
#define pIsInV(p)   p_IsInV(p, currRing)
 
#define pmIsInV(p)   p_mIsInV(p, currRing)
 
#define pLPDivisibleBy(a, b)   p_LPLmDivisibleBy(a, b, currRing)
 
#define pLPLmDivisibleBy(a, b)   p_LPLmDivisibleBy(a, b, currRing)
 
#define pGetNCGen(p)   p_GetNCGen(p, currRing)
 
#define pLPSubst(p, n, e)   p_LPSubst(p, n, e, r)
 
#define pmLPSubst(m, n, e)   p_LPSubst(m, n, e, r)
 

Functions

poly shift_pp_Mult_mm (poly p, const poly m, const ring r)
 
poly shift_p_Mult_mm (poly p, const poly m, const ring r)
 
poly shift_pp_mm_Mult (poly p, const poly m, const ring r)
 
poly shift_p_mm_Mult (poly p, const poly m, const ring r)
 
poly shift_p_Minus_mm_Mult_qq (poly p, poly m, poly q, int &Shorter, const poly spNoether, const ring r)
 
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 p, int sh, const ring r)
 
void p_LPshift (poly p, int sh, const ring r)
 
int p_LastVblock (poly p, const ring r)
 
int p_mLastVblock (poly p, const ring r)
 
int p_mLastVblock (poly p, int *expV, const ring r)
 
int p_FirstVblock (poly p, const ring r)
 
int p_mFirstVblock (poly p, const ring r)
 
int p_mFirstVblock (poly p, int *expV, const ring r)
 
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)
 
BOOLEAN p_LPDivisibleBy (ideal I, poly p, ring r)
 
BOOLEAN _p_mLPNCGenValid (poly p, const ring r)
 
BOOLEAN _p_mLPNCGenValid (int *mExpV, const ring r)
 
poly p_LPVarAt (poly p, int pos, const ring r)
 
int p_GetNCGen (poly p, const ring r)
 
poly p_LPSubst (poly p, int n, poly e, const ring r)
 
poly p_mLPSubst (poly m, int n, poly e, const ring r)
 
ring freeAlgebra (ring r, int d, int LPncGenCount=0)
 create the letterplace ring corresponding to r up to degree d More...
 

Macro Definition Documentation

◆ idIsInV

#define idIsInV (   I)    id_IsInV(I, currRing)

Definition at line 49 of file shiftop.h.

◆ kSplitFrame

#define kSplitFrame (   m1,
  m2,
  at 
)    k_SplitFrame(m1, m2, at, currRing)

Definition at line 44 of file shiftop.h.

◆ pFirstVblock

#define pFirstVblock (   p)    p_FirstVblock(p,currRing)

Definition at line 34 of file shiftop.h.

◆ pGetNCGen

#define pGetNCGen (   p)    p_GetNCGen(p, currRing)

Definition at line 65 of file shiftop.h.

◆ pIsInV

#define pIsInV (   p)    p_IsInV(p, currRing)

Definition at line 50 of file shiftop.h.

◆ pLastVblock

#define pLastVblock (   p)    p_LastVblock(p,currRing)

Definition at line 32 of file shiftop.h.

◆ pLPDivisibleBy

#define pLPDivisibleBy (   a,
  b 
)    p_LPLmDivisibleBy(a, b, currRing)

Definition at line 57 of file shiftop.h.

◆ pLPLmDivisibleBy

#define pLPLmDivisibleBy (   a,
  b 
)    p_LPLmDivisibleBy(a, b, currRing)

Definition at line 58 of file shiftop.h.

◆ pLPshift

#define pLPshift (   p,
  sh 
)    p_LPshift(p, sh, currRing)

Definition at line 23 of file shiftop.h.

◆ pLPSubst

#define pLPSubst (   p,
  n,
 
)    p_LPSubst(p, n, e, r)

Definition at line 68 of file shiftop.h.

◆ pLPunshift

#define pLPunshift (   p,
  sh 
)    p_LPunshift(p, currRing)

Definition at line 21 of file shiftop.h.

◆ pmFirstVblock

#define pmFirstVblock (   p)    p_mFirstVblock(p,currRing)

Definition at line 35 of file shiftop.h.

◆ pmIsInV

#define pmIsInV (   p)    p_mIsInV(p, currRing)

Definition at line 51 of file shiftop.h.

◆ pmLastVblock

#define pmLastVblock (   p)    p_mLastVblock(p,currRing)

Definition at line 33 of file shiftop.h.

◆ pmLPshift

#define pmLPshift (   p,
  sh 
)    p_mLPshift(p, sh, currRing)

Definition at line 24 of file shiftop.h.

◆ pmLPSubst

#define pmLPSubst (   m,
  n,
 
)    p_LPSubst(m, n, e, r)

Definition at line 69 of file shiftop.h.

◆ pmLPunshift

#define pmLPunshift (   p,
  sh 
)    p_mLPunshift(p, currRing)

Definition at line 22 of file shiftop.h.

Function Documentation

◆ _p_LPLmDivisibleByNoComp()

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

Definition at line 794 of file shiftop.cc.

795 {
796 #ifdef SHIFT_MULT_COMPAT_MODE
797  a = p_Head0(a, r);
798  p_mLPunshift(a, r);
799  b = p_Head0(b, r);
800  p_mLPunshift(b, r);
801 #endif
802  int aLastVblock = p_mLastVblock(a, r);
803  int bLastVblock = p_mLastVblock(b, r);
804  for (int i = 0; i <= bLastVblock - aLastVblock; i++)
805  {
806  bool divisible = true;
807  for (int j = 1; j <= aLastVblock * r->isLPring; j++)
808  {
809  if (p_GetExp(a, j, r) > p_GetExp(b, j + (i * r->isLPring), r))
810  {
811  divisible = false;
812  break;
813  }
814  }
815  if (divisible)
816  {
817  #ifdef SHIFT_MULT_COMPAT_MODE
818  p_LmDelete0(a, r);
819  p_LmDelete0(b, r);
820  #endif
821  return TRUE;
822  }
823  }
824 #ifdef SHIFT_MULT_COMPAT_MODE
825  p_LmDelete0(a, r);
826  p_LmDelete0(b, r);
827 #endif
828  return FALSE;
829 }
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
int i
Definition: cfEzgcd.cc:132
CanonicalForm b
Definition: cfModGcd.cc:4103
int j
Definition: facHensel.cc:110
poly p_Head0(const poly p, const ring r)
like p_Head, but allow NULL coeff
Definition: p_polys.cc:5030
static void p_LmDelete0(poly p, const ring r)
Definition: p_polys.h:717
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:469
int p_mLastVblock(poly p, const ring ri)
Definition: shiftop.cc:419
void p_mLPunshift(poly m, const ring ri)
Definition: shiftop.cc:325

◆ _p_mLPNCGenValid() [1/2]

BOOLEAN _p_mLPNCGenValid ( int *  mExpV,
const ring  r 
)

Definition at line 631 of file shiftop.cc.

632 {
633  BOOLEAN hasNCGen = FALSE;
634  int lV = r->isLPring;
635  int degbound = r->N/lV;
636  int ncGenCount = r->LPncGenCount;
637  for (int i = 1; i <= degbound; i++)
638  {
639  for (int j = i*lV; j > (i*lV - ncGenCount); j--)
640  {
641  if (mExpV[j])
642  {
643  if (hasNCGen)
644  {
645  return FALSE;
646  }
647  hasNCGen = TRUE;
648  }
649  }
650  }
651  return TRUE;
652 }
int BOOLEAN
Definition: auxiliary.h:87
#define degbound(p)
Definition: tgb.cc:153

◆ _p_mLPNCGenValid() [2/2]

BOOLEAN _p_mLPNCGenValid ( poly  p,
const ring  r 
)

Definition at line 621 of file shiftop.cc.

622 {
623  if (p == NULL) return TRUE;
624  int *e=(int *)omAlloc((r->N+1)*sizeof(int));
625  p_GetExpV(p,e,r);
626  int b = _p_mLPNCGenValid(e, r);
627  omFreeSize((ADDRESS) e, (r->N+1)*sizeof(int));
628  return b;
629 }
void * ADDRESS
Definition: auxiliary.h:119
int p
Definition: cfModGcd.cc:4078
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define NULL
Definition: omList.c:12
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1492
BOOLEAN _p_mLPNCGenValid(poly p, const ring r)
Definition: shiftop.cc:621

◆ freeAlgebra()

ring freeAlgebra ( ring  r,
int  d,
int  LPncGenCount = 0 
)

create the letterplace ring corresponding to r up to degree d

Definition at line 940 of file shiftop.cc.

941 {
942  if (ncGenCount) r = rCopy0(r);
943  char *varname=(char *)omAlloc(20);
944  for (int i = 1; i <= ncGenCount; i++)
945  {
946  sprintf(varname, "ncgen(%d)", i);
947  ring save = r;
948  r = rPlusVar(r, varname, 0);
949  if (r==NULL)
950  {
951  omFreeSize(varname, 20);
952  return NULL; /* error in rPlusVar*/
953  }
954  rDelete(save);
955  }
956  omFreeSize(varname, 20);
957  ring R=rCopy0(r);
958  int p;
959  if((r->order[0]==ringorder_C)
960  ||(r->order[0]==ringorder_c))
961  p=1;
962  else
963  p=0;
964  // create R->N
965  R->N=r->N*d;
966  if (ncGenCount>0)
967  R->wanted_maxExp=7; /* Tst/Manual/letterplace_liftstd.tst*/
968  else
969  R->wanted_maxExp=3;
970  R->isLPring=r->N;
971  R->LPncGenCount=ncGenCount;
972  // create R->order
973  BOOLEAN has_order_a=FALSE;
974  while (r->order[p]==ringorder_a)
975  {
976  if (freeAlgebra_weights(r,R,p,d))
977  {
978  WerrorS("weights must be positive");
979  return NULL;
980  }
981  has_order_a=TRUE;
982  p++;
983  }
984  R->block1[p]=R->N; /* only dp,Dp,wp,Wp; will be discarded for lp*/
985  switch(r->order[p])
986  {
987  case ringorder_dp:
988  case ringorder_Dp:
989  break;
990  case ringorder_wp:
991  case ringorder_Wp:
992  if (freeAlgebra_weights(r,R,p,d))
993  {
994  WerrorS("weights must be positive");
995  return NULL;
996  }
997  break;
998  case ringorder_lp:
999  case ringorder_rp:
1000  {
1001  if(has_order_a)
1002  {
1003  WerrorS("ordering (a(..),lp/rp not implemented for Letterplace rings");
1004  return NULL;
1005  }
1006  int ** wvhdl=(int**)omAlloc0((r->N+3)*sizeof(int*));
1007  rRingOrder_t* ord=(rRingOrder_t*)omAlloc0((r->N+3)*sizeof(rRingOrder_t));
1008  int* blk0=(int*)omAlloc0((r->N+3)*sizeof(int));
1009  int* blk1=(int*)omAlloc0((r->N+3)*sizeof(int));
1010  omFree(R->wvhdl); R->wvhdl=wvhdl;
1011  omFree(R->order); R->order=ord;
1012  omFree(R->block0); R->block0=blk0;
1013  omFree(R->block1); R->block1=blk1;
1014  for(int i=0;i<r->N;i++)
1015  {
1016  ord[i+p]=ringorder_a;
1017  //Print("entry:%d->a\n",i+p);
1018  blk0[i+p]=1;
1019  blk1[i+p]=R->N;
1020  wvhdl[i+p]=(int*)omAlloc0(R->N*sizeof(int));
1021  for(int j=0;j<d;j++)
1022  {
1023  assume(j*r->N+i<R->N);
1024  if (r->order[p]==ringorder_lp)
1025  wvhdl[i+p][j*r->N+i]=1;
1026  else
1027  wvhdl[i+p][(j+1)*r->N-i-1]=1;
1028  }
1029  }
1030  ord[r->N+p]=r->order[p]; /* lp or rp */
1031  //Print("entry:%d->lp\n",r->N+p);
1032  blk0[r->N+p]=1;
1033  blk1[r->N+p]=R->N;
1034  // copy component order
1035  if (p==1) ord[0]=r->order[0];
1036  else if (p==0) ord[r->N+1]=r->order[1];
1037  else
1038  { // should never happen:
1039  WerrorS("ordering not implemented for Letterplace rings");
1040  return NULL;
1041  }
1042  //if (p==1) PrintS("entry:0 ->c/C\n");
1043  //else if (p==0) Print("entry:%d ->c/C\n",r->N+1);
1044  break;
1045  }
1046  default: WerrorS("ordering not implemented for Letterplace rings");
1047  return NULL;
1048  }
1049  // create R->names
1050  char **names=(char**)omAlloc(R->N*sizeof(char*));
1051  for(int b=0;b<d;b++)
1052  {
1053  for(int i=r->N-1;i>=0;i--)
1054  names[b*r->N+i]=omStrDup(r->names[i]);
1055  }
1056  for(int i=r->N-1;i>=0;i--) omFree(R->names[i]);
1057  omFree(R->names);
1058  R->names=names;
1059 
1060  if (ncGenCount) rDelete(r);
1061  rComplete(R,TRUE);
1062  return R;
1063 }
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define assume(x)
Definition: mod2.h:387
#define omStrDup(s)
Definition: omAllocDecl.h:263
#define omFree(addr)
Definition: omAllocDecl.h:261
#define omAlloc0(size)
Definition: omAllocDecl.h:211
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:3395
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1363
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:449
ring rPlusVar(const ring r, char *v, int left)
K[x],"y" -> K[x,y] resp. K[y,x].
Definition: ring.cc:5779
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:923
#define R
Definition: sirandom.c:27

◆ id_IsInV()

int id_IsInV ( ideal  I,
const ring  r 
)

Definition at line 676 of file shiftop.cc.

677 {
678  int i;
679  int s = IDELEMS(I)-1;
680  for(i = 0; i <= s; i++)
681  {
682  if ( !p_IsInV(I->m[i], r) )
683  {
684  return(0);
685  }
686  }
687  return(1);
688 }
const CanonicalForm int s
Definition: facAbsFact.cc:51
int p_IsInV(poly p, const ring r)
Definition: shiftop.cc:691
#define IDELEMS(i)
Definition: simpleideals.h:23

◆ k_SplitFrame()

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

Definition at line 598 of file shiftop.cc.

599 {
600  assume(at >= 1);
601  assume(at <= r->N/r->isLPring);
602  int lV = r->isLPring;
603  int split = (lV * (at - 1));
604 
605  m2 = p_GetExp_k_n(m1, 1, split, r);
606  p_SetComp(m2, 0, r); // important, otherwise both m1 and m2 have a component set, this leads to problems later
607  p_Setm(m2, r); // p_mLPunshift also implicitly calls p_Setm(), but just for the case this changes in future.
608  p_mLPunshift(m2, r);
609 
610  m1 = p_Head0(m1, r);
611  for(int i = split + 1; i <= r->N; i++)
612  {
613  p_SetExp(m1, i, 0, r);
614  }
615  p_Setm(m1, r);
616 
617  assume(p_FirstVblock(m1,r) <= 1);
618  assume(p_FirstVblock(m2,r) <= 1);
619 }
static CFList split(const CanonicalForm &F, const int m, const Variable &x)
Definition: facMul.cc:3469
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:488
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:247
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
static poly p_GetExp_k_n(poly p, int l, int k, const ring r)
Definition: p_polys.h:1344
int p_FirstVblock(poly p, const ring r)
Definition: shiftop.cc:454

◆ LPExpVString()

char* LPExpVString ( int *  expV,
ring  ri 
)

Definition at line 578 of file shiftop.cc.

579 {
580  StringSetS("");
581  for (int i = 0; i <= ri->N; ++i)
582  {
583  StringAppend("%d", expV[i]);
584  if (i == 0)
585  {
586  StringAppendS("| ");
587  }
588  if (i % ri->isLPring == 0 && i != ri->N)
589  {
590  StringAppendS(" ");
591  }
592  }
593  return StringEndS();
594 }
#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 454 of file shiftop.cc.

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

◆ p_GetNCGen()

int p_GetNCGen ( poly  p,
const ring  r 
)

Definition at line 654 of file shiftop.cc.

655 {
656  if (p == NULL) return 0;
658 
659  int lV = r->isLPring;
660  int degbound = r->N/lV;
661  int ncGenCount = r->LPncGenCount;
662  for (int i = 1; i <= degbound; i++)
663  {
664  for (int j = i*lV; j > (i*lV - ncGenCount); j--)
665  {
666  if (p_GetExp(p, j, r))
667  {
668  return j - i*lV + ncGenCount;
669  }
670  }
671  }
672  return 0;
673 }

◆ p_IsInV()

int p_IsInV ( poly  p,
const ring  r 
)

Definition at line 691 of file shiftop.cc.

692 {
693  poly q = p;
694  while (q!=NULL)
695  {
696  if ( !p_mIsInV(q, r) )
697  {
698  return(0);
699  }
700  q = pNext(q);
701  }
702  return(1);
703 }
#define pNext(p)
Definition: monomials.h:36
int p_mIsInV(poly p, const ring r)
Definition: shiftop.cc:709

◆ p_LastVblock()

int p_LastVblock ( poly  p,
const ring  r 
)

Definition at line 404 of file shiftop.cc.

405 {
406  poly q = p;
407  int ans = 0;
408  while (q!=NULL)
409  {
410  int ansnew = p_mLastVblock(q, r);
411  ans = si_max(ans,ansnew);
412  pIter(q);
413  }
414  return(ans);
415 }
static int si_max(const int a, const int b)
Definition: auxiliary.h:124

◆ p_LPDivisibleBy() [1/2]

BOOLEAN p_LPDivisibleBy ( ideal  I,
poly  p,
ring  r 
)

Definition at line 831 of file shiftop.cc.

832 {
833  for(int i = 0; i < IDELEMS(I); i++)
834  {
835  if (p_LPDivisibleBy(I->m[i], p, r))
836  {
837  return TRUE;
838  }
839  }
840  return FALSE;
841 }
BOOLEAN p_LPDivisibleBy(poly a, poly b, const ring r)
Definition: shiftop.cc:774

◆ p_LPDivisibleBy() [2/2]

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

Definition at line 774 of file shiftop.cc.

775 {
777  pIfThen1(a!=NULL, p_LmCheckPolyRing1(a, r));
778 
779  if (b == NULL) return TRUE;
780  if (a != NULL && (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r)))
781  return _p_LPLmDivisibleByNoComp(a,b,r);
782  return FALSE;
783 }
#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:794

◆ p_LPExpVappend()

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

Definition at line 509 of file shiftop.cc.

509  {
510 #ifdef SHIFT_MULT_DEBUG
511  PrintLn(); PrintS("Append");
512  PrintLn(); WriteLPExpV(m1ExpV, ri);
513  PrintLn(); WriteLPExpV(m2ExpV, ri);
514 #endif
515  int last = m1Length + m2Length;
516  if (last > ri->N)
517  {
518  Werror("degree bound of Letterplace ring is %d, but at least %d is needed for this multiplication", ri->N/ri->isLPring, last/ri->isLPring);
519  last = ri->N;
520  }
521  for (int i = 1 + m1Length; i < 1 + last; ++i)
522  {
523  assume(m2ExpV[i - m1Length] <= 1);
524  m1ExpV[i] = m2ExpV[i - m1Length];
525  }
526 
527  assume(m1ExpV[0] == 0 || m2ExpV[0] == 0); // one component should be zero (otherwise this doesn't make any sense)
528  m1ExpV[0] += m2ExpV[0]; // as in the commutative variant (they use MemAdd)
529 #ifdef SHIFT_MULT_DEBUG
530  PrintLn(); WriteLPExpV(m1ExpV, ri);
531 #endif
532  assume(_p_mLPNCGenValid(m1ExpV, ri));
533 }
STATIC_VAR poly last
Definition: hdegree.cc:1151
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:571

◆ p_LPExpVprepend()

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

Definition at line 536 of file shiftop.cc.

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

◆ p_LPLmDivisibleBy()

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

Definition at line 785 of file shiftop.cc.

786 {
787  p_LmCheckPolyRing1(b, r);
788  pIfThen1(a != NULL, p_LmCheckPolyRing1(b, r));
789  if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
790  return _p_LPLmDivisibleByNoComp(a, b, r);
791  return FALSE;
792 }

◆ p_LPshift()

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

Definition at line 390 of file shiftop.cc.

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

◆ p_LPSubst()

poly p_LPSubst ( poly  p,
int  n,
poly  e,
const ring  r 
)

Definition at line 910 of file shiftop.cc.

911 {
912  poly res = NULL;
913  while (p!=NULL)
914  {
915  res = p_Add_q(res, p_mLPSubst(p, n, e, r), r);
916  pIter(p);
917  }
918  return res;
919 }
CanonicalForm res
Definition: facAbsFact.cc:60
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:908
poly p_mLPSubst(poly m, int n, poly e, const ring r)
Definition: shiftop.cc:861

◆ p_LPunshift()

void p_LPunshift ( poly  p,
const ring  ri 
)

Definition at line 351 of file shiftop.cc.

352 {
353  while (p!=NULL)
354  {
355  p_mLPunshift(p, ri);
356  pIter(p);
357  }
358 }

◆ p_LPVarAt()

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

Definition at line 843 of file shiftop.cc.

844 {
845  if (p == NULL || pos < 1 || pos > (r->N / r->isLPring)) return NULL;
846  poly v = p_One(r);
847  for (int i = (pos-1) * r->isLPring + 1; i <= pos * r->isLPring; i++) {
848  if (p_GetExp(p, i, r)) {
849  p_SetExp(v, i - (pos-1) * r->isLPring, 1, r);
850  return v;
851  }
852  }
853  return v;
854 }
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
poly p_One(const ring r)
Definition: p_polys.cc:1309

◆ p_mFirstVblock() [1/2]

int p_mFirstVblock ( poly  p,
const ring  r 
)

Definition at line 476 of file shiftop.cc.

477 {
478  if (p == NULL || p_LmIsConstantComp(p,ri))
479  {
480  return(0);
481  }
482 
483  int *e=(int *)omAlloc((ri->N+1)*sizeof(int));
484  p_GetExpV(p,e,ri);
485  int b = p_mFirstVblock(p, e, ri);
486  omFreeSize((ADDRESS) e, (ri->N+1)*sizeof(int));
487  return b;
488 }
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition: p_polys.h:978

◆ p_mFirstVblock() [2/2]

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

Definition at line 492 of file shiftop.cc.

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

◆ p_mIsInV()

int p_mIsInV ( poly  p,
const ring  r 
)

Definition at line 709 of file shiftop.cc.

710 {
711  int lV = r->isLPring;
712  /* investigate only the leading monomial of p in currRing */
713  if ( p_Totaldegree(p, r)==0 ) return(1);
714  /* returns 1 iff p is in V */
715  /* that is in each block up to a certain one there is only one nonzero exponent */
716  /* lV = the length of V = the number of orig vars */
717  int *e = (int *)omAlloc((r->N+1)*sizeof(int));
718  int b = (int)((r->N+lV-1)/lV); /* the number of blocks */
719  //int b = (int)(currRing->N)/lV;
720  int *B = (int *)omAlloc0((b+1)*sizeof(int)); /* the num of elements in a block */
721  p_GetExpV(p,e,r);
722  int i,j;
723  for (j=1; j<=b; j++)
724  {
725  /* we go through all the vars */
726  /* by blocks in lV vars */
727  for (i=(j-1)*lV + 1; i<= j*lV; i++)
728  {
729  if (e[i]) B[j] = B[j]+1;
730  }
731  }
732  // j = b;
733  // while ( (!B[j]) && (j>=1)) j--;
734  for (j=b; j>=1; j--)
735  {
736  if (B[j]!=0) break;
737  }
738 
739  if (j==0)
740  {
741  omFreeSize((ADDRESS) e, (r->N+1)*sizeof(int));
742  omFreeSize((ADDRESS) B, (b+1)*sizeof(int));
743  return 1;
744  }
745 
746  if (!_p_mLPNCGenValid(e, r))
747  {
748  omFreeSize((ADDRESS) e, (r->N+1)*sizeof(int));
749  omFreeSize((ADDRESS) B, (b+1)*sizeof(int));
750  return 0;
751  }
752 
753  omFreeSize((ADDRESS) e, (r->N+1)*sizeof(int));
754 
755 // {
756 // /* it is a zero exp vector, which is in V */
757 // freeT(B, b);
758 // return(1);
759 // }
760  /* now B[j] != 0 and we test place-squarefreeness */
761  for (; j>=1; j--)
762  {
763  if (B[j]!=1)
764  {
765  omFreeSize((ADDRESS) B, (b+1)*sizeof(int));
766  return 0;
767  }
768  }
769 
770  omFreeSize((ADDRESS) B, (b+1)*sizeof(int));
771  return 1;
772 }
b *CanonicalForm B
Definition: facBivar.cc:52
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1479

◆ p_mLastVblock() [1/2]

int p_mLastVblock ( poly  p,
const ring  r 
)

Definition at line 419 of file shiftop.cc.

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

◆ p_mLastVblock() [2/2]

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

Definition at line 435 of file shiftop.cc.

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

◆ p_mLPshift()

void p_mLPshift ( poly  p,
int  sh,
const ring  r 
)

Definition at line 360 of file shiftop.cc.

361 {
362  if (sh == 0 || m == NULL || p_LmIsConstantComp(m,ri)) return;
363 
364  int lV = ri->isLPring;
365 
366  assume(p_mFirstVblock(m,ri) + sh >= 1);
367  assume(p_mLastVblock(m,ri) + sh <= ri->N/lV);
368 
369  int *e=(int *)omAlloc((ri->N+1)*sizeof(int));
370  int *s=(int *)omAlloc0((ri->N+1)*sizeof(int));
371  p_GetExpV(m,e,ri);
372 
373  if (p_mLastVblock(m, e, ri) + sh > ri->N/lV)
374  {
375  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);
376  }
377  for (int i = ri->N - sh*lV; i > 0; i--)
378  {
379  assume(e[i]<=1);
380  if (e[i]==1)
381  {
382  s[i + (sh*lV)] = e[i]; /* actually 1 */
383  }
384  }
385  p_SetExpV(m,s,ri);
386  omFreeSize((ADDRESS) e, (ri->N+1)*sizeof(int));
387  omFreeSize((ADDRESS) s, (ri->N+1)*sizeof(int));
388 }
int m
Definition: cfEzgcd.cc:128
static void p_SetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1516

◆ p_mLPSubst()

poly p_mLPSubst ( poly  m,
int  n,
poly  e,
const ring  r 
)

Definition at line 861 of file shiftop.cc.

862 {
863  assume(p_GetComp(e, r) == 0);
864  if (m == NULL) return NULL;
865 
866  int lV = r->isLPring;
867  int degbound = r->N/lV;
868 
869  poly result = p_One(r);
870  poly remaining = p_Head(m, r);
871  p_SetComp(result, p_GetComp(remaining, r), r);
872  p_SetComp(remaining, 0, r);
873  for (int i = 0; i < degbound; i++)
874  {
875  int var = n + lV*i;
876  if (p_GetExp(remaining, var, r)) {
877  if (e == NULL) {
878  p_Delete(&result, r);
879  result = NULL;
880  break;
881  }
882  int startOfBlock = 1 + lV*i;
883  int endOfBlock = lV*(i+1);
884 
885  poly left = p_GetExp_k_n(remaining, startOfBlock, r->N, r);
886  p_SetCoeff(left, n_Copy(p_GetCoeff(remaining, r), r->cf), r);
887  p_mLPunshift(left, r);
888 
889  poly right = p_GetExp_k_n(remaining, 1, endOfBlock, r);
890  p_Delete(&remaining, r);
891  remaining = right;
892 
893  left = p_Mult_q(left, p_Copy(e, r), r);
894  result = p_Mult_q(result, left, r);
895  }
896  }
897  if (result == NULL) {
898  return NULL;
899  } else {
900  p_mLPunshift(remaining, r);
901  return p_Mult_q(result, remaining, r);
902  }
903 }
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:451
return result
Definition: facAbsBiFact.cc:75
#define p_GetCoeff(p, r)
Definition: monomials.h:50
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1086
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:412
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
Definition: p_polys.h:832
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:873
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:818

◆ p_mLPunshift()

void p_mLPunshift ( poly  m,
const ring  ri 
)

Definition at line 325 of file shiftop.cc.

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

◆ 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  r 
)

Definition at line 269 of file shiftop.cc.

269  {
270 #ifdef SHIFT_MULT_DEBUG
271  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);
272 #endif
273 
274  Shorter = pLength(p) + pLength(q);
275 
276  poly tmp = p_Neg(p_Copy(m, ri), ri);
277  poly qq = p_Add_q(p, shift_pp_mm_Mult(q, tmp, ri), ri);
278  p_Delete(&tmp,ri);
279 
280 #ifdef SHIFT_MULT_DEBUG
281  PrintLn(); PrintS("shift_p_Minus_mm_Mult_qq result: "); p_wrp(qq, ri, ri); PrintLn();
282 #endif
283  Shorter -= pLength(qq);
284  return qq;
285 }
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1079
static unsigned pLength(poly a)
Definition: p_polys.h:191
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:145

◆ shift_p_mm_Mult()

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

Definition at line 212 of file shiftop.cc.

213 {
214 #ifdef SHIFT_MULT_DEBUG
215  PrintLn(); PrintS("shift_p_mm_Mult: "); p_wrp(m, ri, ri); PrintS(" * ("); p_wrp(p, ri, ri); PrintS(")");
216 #endif
217 
218  p_Test(p, ri);
219  p_LmTest(m, ri);
220  pAssume(m != NULL);
221  assume(p!=NULL);
222 
223  int lV = ri->isLPring;
224  poly _m = m; // temp hack because m is const
225 #ifdef SHIFT_MULT_COMPAT_MODE
226  _m = p_Copy(_m, ri);
227  p_mLPunshift(_m, ri);
228  p_LPunshift(p, ri);
229 #else
230  assume(p_mFirstVblock(_m, ri) <= 1);
231  assume(p_FirstVblock(p, ri) <= 1); // TODO check that each block is <=1
232 #endif
233  // at this point _m and p are shifted to 1
234 
235  poly q = p; // we use p for iterating and q for the result
236  number mCoeff = pGetCoeff(_m);
237  number pCoeff;
238  pAssume(!n_IsZero(mCoeff, ri->cf));
239 
240  int *mExpV = (int *) omAlloc((ri->N+1)*sizeof(int));
241  p_GetExpV(_m,mExpV,ri);
242  int mLength = p_mLastVblock(_m, mExpV, ri) * lV;
243  int *pExpV = (int *) omAlloc((ri->N+1)*sizeof(int));
244  while (p != NULL)
245  {
246  pCoeff = pGetCoeff(p);
247  pSetCoeff0(p, n_Mult(mCoeff, pCoeff, ri->cf));
248  n_Delete(&pCoeff, ri->cf); // delete the old coeff
249 
250  p_GetExpV(p,pExpV,ri);
251  p_LPExpVprepend(pExpV, mExpV, p_mLastVblock(p, pExpV, ri) * lV, mLength, ri);
252  p_SetExpV(p, pExpV, ri);
253 
254  pIter(p);
255  }
256  omFreeSize((ADDRESS) pExpV, (ri->N+1)*sizeof(int));
257  omFreeSize((ADDRESS) mExpV, (ri->N+1)*sizeof(int));
258 #ifdef SHIFT_MULT_COMPAT_MODE
259  p_Delete(&_m, ri); // in this case we copied _m before
260 #endif
261 #ifdef SHIFT_MULT_DEBUG
262  PrintLn(); PrintS("shift_p_mm_Mult result: "); p_wrp(q, ri, ri); PrintLn();
263 #endif
264  p_Test(q, ri);
265  return q;
266 }
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
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
#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:536
void p_LPunshift(poly p, const ring ri)
Definition: shiftop.cc:351

◆ shift_p_Mult_mm()

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

Definition at line 89 of file shiftop.cc.

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

◆ shift_pp_mm_Mult()

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

Definition at line 145 of file shiftop.cc.

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

◆ 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 317 of file shiftop.cc.

317  {
318  PrintLn(); WarnS("pp_Mult_Coeff_mm_DivSelect is not supported yet by Letterplace. This might lead to unexpected behavior.");
319  return NULL;
320 }
#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 312 of file shiftop.cc.

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

◆ shift_pp_Mult_mm()

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

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  pNext(q)=NULL;
64  pSetCoeff0(q, n_Mult(mCoeff, pGetCoeff(p), ri->cf));
65 
66  p_GetExpV(p, pExpV, ri);
67  p_LPExpVappend(pExpV, mExpV, p_mLastVblock(p, pExpV, ri) * lV, mLength, ri);
68  p_MemCopy_LengthGeneral(q->exp, p->exp, ri->ExpL_Size); // otherwise q is not initialized correctly
69  p_SetExpV(q, pExpV, ri);
70 
71  pIter(p);
72  }
73  while (p != NULL);
74  omFreeSize((ADDRESS) pExpV, (ri->N+1)*sizeof(int));
75  omFreeSize((ADDRESS) mExpV, (ri->N+1)*sizeof(int));
76  pNext(q) = NULL;
77 #ifdef SHIFT_MULT_COMPAT_MODE
78  p_Delete(&_m, ri); // in this case we copied _m before
79  p_Delete(&pCopyHead, ri); // in this case we copied p before
80 #endif
81 #ifdef SHIFT_MULT_DEBUG
82  PrintLn(); PrintS("shift_pp_Mult_mm result: "); p_wrp(pNext(&rp), ri, ri); PrintLn();
83 #endif
84  p_Test(pNext(&rp), ri);
85  return pNext(&rp);
86 }

◆ 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 288 of file shiftop.cc.

288  {
289  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.");
290 
291  int pLen = 0;
292  if (ll >= 0)
293  {
294  pLen = pLength(p);
295  }
296 
297  p = shift_pp_Mult_mm(p, m, ri);
298 
299  if (ll >= 0)
300  {
301  ll = pLen - pLength(p);
302  }
303  else
304  {
305  ll = pLength(p);
306  }
307 
308  return p;
309 }
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 571 of file shiftop.cc.

572 {
573  char *s = LPExpVString(expV, ri);
574  PrintS(s);
575  omFree(s);
576 }
char * LPExpVString(int *expV, ring ri)
Definition: shiftop.cc:578