My Project
Loading...
Searching...
No Matches
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, const ring ri)
 
poly shift_pp_Mult_mm_Noether_STUB (poly p, const poly m, const poly, int &ll, const ring ri)
 
poly shift_pp_Mult_Coeff_mm_DivSelectMult_STUB (poly, const poly, const poly, const poly, int &, const ring)
 
poly shift_pp_Mult_Coeff_mm_DivSelect_STUB (poly, const poly, int &, const ring)
 
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)
 
BOOLEAN _p_mLPNCGenValid (poly p, const ring r)
 
BOOLEAN _p_mLPNCGenValid (int *mExpV, const ring r)
 
int p_GetNCGen (poly p, 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)
 
poly p_LPVarAt (poly p, int pos, const ring r)
 
poly p_mLPSubst (poly m, int n, poly e, const ring r)
 
poly p_LPSubst (poly p, int n, poly e, 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, int ncGenCount)
 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 796 of file shiftop.cc.

797{
798#ifdef SHIFT_MULT_COMPAT_MODE
799 a = p_Head0(a, r);
800 p_mLPunshift(a, r);
801 b = p_Head0(b, r);
802 p_mLPunshift(b, r);
803#endif
804 int aLastVblock = p_mLastVblock(a, r);
805 int bLastVblock = p_mLastVblock(b, r);
806 for (int i = 0; i <= bLastVblock - aLastVblock; i++)
807 {
808 bool divisible = true;
809 for (int j = 1; j <= aLastVblock * r->isLPring; j++)
810 {
811 if (p_GetExp(a, j, r) > p_GetExp(b, j + (i * r->isLPring), r))
812 {
813 divisible = false;
814 break;
815 }
816 }
817 if (divisible)
818 {
819 #ifdef SHIFT_MULT_COMPAT_MODE
820 p_LmDelete0(a, r);
821 p_LmDelete0(b, r);
822 #endif
823 return TRUE;
824 }
825 }
826#ifdef SHIFT_MULT_COMPAT_MODE
827 p_LmDelete0(a, r);
828 p_LmDelete0(b, r);
829#endif
830 return FALSE;
831}
#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:4939
static void p_LmDelete0(poly p, const ring r)
Definition: p_polys.h:731
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:467
int p_mLastVblock(poly p, const ring ri)
Definition: shiftop.cc:421
void p_mLPunshift(poly m, const ring ri)
Definition: shiftop.cc:327

◆ _p_mLPNCGenValid() [1/2]

BOOLEAN _p_mLPNCGenValid ( int *  mExpV,
const ring  r 
)

Definition at line 633 of file shiftop.cc.

634{
635 BOOLEAN hasNCGen = FALSE;
636 int lV = r->isLPring;
637 int degbound = r->N/lV;
638 int ncGenCount = r->LPncGenCount;
639 for (int i = 1; i <= degbound; i++)
640 {
641 for (int j = i*lV; j > (i*lV - ncGenCount); j--)
642 {
643 if (mExpV[j])
644 {
645 if (hasNCGen)
646 {
647 return FALSE;
648 }
649 hasNCGen = TRUE;
650 }
651 }
652 }
653 return TRUE;
654}
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 623 of file shiftop.cc.

624{
625 if (p == NULL) return TRUE;
626 int *e=(int *)omAlloc((r->N+1)*sizeof(int));
627 p_GetExpV(p,e,r);
628 int b = _p_mLPNCGenValid(e, r);
629 omFreeSize((ADDRESS) e, (r->N+1)*sizeof(int));
630 return b;
631}
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:1518
BOOLEAN _p_mLPNCGenValid(poly p, const ring r)
Definition: shiftop.cc:623

◆ freeAlgebra()

ring freeAlgebra ( ring  r,
int  d,
int  ncGenCount 
)

create the letterplace ring corresponding to r up to degree d

Definition at line 942 of file shiftop.cc.

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

926{
927 omFree(new_ring->wvhdl[p]);
928 int *w=(int*)omAlloc(new_ring->N*sizeof(int));
929 for(int b=0;b<d;b++)
930 {
931 for(int i=old_ring->N-1;i>=0;i--)
932 {
933 if (old_ring->wvhdl[p][i]<-0) return TRUE;
934 w[b*old_ring->N+i]=old_ring->wvhdl[p][i];
935 }
936 }
937 new_ring->wvhdl[p]=w;
938 new_ring->block1[p]=new_ring->N;
939 return FALSE;
940}
const CanonicalForm & w
Definition: facAbsFact.cc:51

◆ id_IsInV()

int id_IsInV ( ideal  I,
const ring  r 
)

Definition at line 678 of file shiftop.cc.

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

◆ k_SplitFrame()

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

Definition at line 600 of file shiftop.cc.

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

◆ LPExpVString()

char * LPExpVString ( int *  expV,
ring  ri 
)

Definition at line 580 of file shiftop.cc.

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

457{
458 if (p == NULL) {
459 return 0;
460 }
461
462 poly q = p;
463 int ans = p_mFirstVblock(q, r);
464 while (q!=NULL)
465 {
466 int ansnew = p_mFirstVblock(q, r);
467 if (ansnew > 0) { // don't count constants
468 ans = si_min(ans,ansnew);
469 }
470 pIter(q);
471 }
472 /* do not need to delete q */
473 return(ans);
474}
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:478

◆ p_GetNCGen()

int p_GetNCGen ( poly  p,
const ring  r 
)

Definition at line 656 of file shiftop.cc.

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

◆ p_IsInV()

int p_IsInV ( poly  p,
const ring  r 
)

Definition at line 693 of file shiftop.cc.

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

◆ p_LastVblock()

int p_LastVblock ( poly  p,
const ring  r 
)

Definition at line 406 of file shiftop.cc.

407{
408 poly q = p;
409 int ans = 0;
410 while (q!=NULL)
411 {
412 int ansnew = p_mLastVblock(q, r);
413 ans = si_max(ans,ansnew);
414 pIter(q);
415 }
416 return(ans);
417}
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 833 of file shiftop.cc.

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

◆ p_LPDivisibleBy() [2/2]

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

Definition at line 776 of file shiftop.cc.

777{
780
781 if (b == NULL) return TRUE;
782 if (a != NULL && (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r)))
783 return _p_LPLmDivisibleByNoComp(a,b,r);
784 return FALSE;
785}
#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:796

◆ p_LPExpVappend()

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

Definition at line 511 of file shiftop.cc.

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

◆ p_LPExpVprepend()

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

Definition at line 538 of file shiftop.cc.

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

◆ p_LPLmDivisibleBy()

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

Definition at line 787 of file shiftop.cc.

788{
791 if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
792 return _p_LPLmDivisibleByNoComp(a, b, r);
793 return FALSE;
794}

◆ p_LPshift()

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

Definition at line 392 of file shiftop.cc.

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

◆ p_LPSubst()

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

Definition at line 912 of file shiftop.cc.

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

◆ p_LPunshift()

void p_LPunshift ( poly  p,
const ring  ri 
)

Definition at line 353 of file shiftop.cc.

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

◆ p_LPVarAt()

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

Definition at line 845 of file shiftop.cc.

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

◆ p_mFirstVblock() [1/2]

int p_mFirstVblock ( poly  p,
const ring  ri 
)

Definition at line 478 of file shiftop.cc.

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

◆ p_mFirstVblock() [2/2]

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

Definition at line 494 of file shiftop.cc.

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

◆ p_mIsInV()

int p_mIsInV ( poly  p,
const ring  r 
)

Definition at line 711 of file shiftop.cc.

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

◆ p_mLastVblock() [1/2]

int p_mLastVblock ( poly  p,
const ring  ri 
)

Definition at line 421 of file shiftop.cc.

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

◆ p_mLastVblock() [2/2]

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

Definition at line 437 of file shiftop.cc.

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

◆ p_mLPshift()

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

Definition at line 362 of file shiftop.cc.

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

◆ p_mLPSubst()

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

Definition at line 863 of file shiftop.cc.

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

◆ p_mLPunshift()

void p_mLPunshift ( poly  m,
const ring  ri 
)

Definition at line 327 of file shiftop.cc.

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

◆ shift_p_Minus_mm_Mult_qq()

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

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:1105
static int pLength(poly a)
Definition: p_polys.h:188
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  ri 
)

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:633
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:461
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:452
#define pSetCoeff0(p, n)
Definition: monomials.h:59
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 pAssume(cond)
Definition: monomials.h:90
#define p_LmTest(p, r)
Definition: p_polys.h:160
#define p_Test(p, r)
Definition: p_polys.h:159
void p_LPExpVprepend(int *m1ExpV, int *m2ExpV, int m1Length, int m2Length, const ring ri)
Definition: shiftop.cc:538
void p_LPunshift(poly p, const ring ri)
Definition: shiftop.cc:353

◆ shift_p_Mult_mm()

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

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:511

◆ shift_pp_mm_Mult()

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

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:290

◆ shift_pp_Mult_Coeff_mm_DivSelect_STUB()

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

Definition at line 319 of file shiftop.cc.

319 {
320 WarnS("\n** pp_Mult_Coeff_mm_DivSelect is not supported yet by Letterplace. This might lead to unexpected behavior.");
321 return NULL;
322}
#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,
const  poly,
const  poly,
int &  shorter,
const  ring 
)

Definition at line 313 of file shiftop.cc.

314{
315 WarnS("\n** pp_Mult_Coeff_mm_DivSelectMult is not supported yet by Letterplace. This might lead to unexpected behavior.");
316 return NULL;
317}

◆ 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 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,
int &  ll,
const ring  ri 
)

Definition at line 288 of file shiftop.cc.

289{
290 WarnS("\n** pp_Mult_mm_Noether is not supported yet by Letterplace. Ignoring spNoether and using pp_Mult_mm. This might lead to unexpected behavior.");
291
292 int pLen = 0;
293 if (ll >= 0)
294 {
295 pLen = pLength(p);
296 }
297
298 p = shift_pp_Mult_mm(p, m, ri);
299
300 if (ll >= 0)
301 {
302 ll = pLen - pLength(p);
303 }
304 else
305 {
306 ll = pLength(p);
307 }
308
309 return p;
310}
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 573 of file shiftop.cc.

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