40#define BITS_PER_LONG 8*SIZEOF_LONG
111 r->names = (
char **)
omAlloc0(
N *
sizeof(
char *));
119 r->wvhdl = (
int **)
omAlloc0((ord_size+1) *
sizeof(
int *));
125 if (bitmask!=0) r->wanted_maxExp=bitmask;
137 return rDefault(
cf,
N,n,ord_size,ord,block0,block1,wvhdl);
144 int *block0 = (
int *)
omAlloc0(2 *
sizeof(
int));
145 int *block1 = (
int *)
omAlloc0(2 *
sizeof(
int));
180 WerrorS(
"weights only for orderings wp,ws,Wp,Ws,a,M");
189 int sz = (int)
sqrt((
double)(order->
length()-2));
190 if ((sz*sz)!=(order->
length()-2))
192 WerrorS(
"Matrix order is not a square matrix");
195 while ((
i<sz) && (typ==1))
198 while ((
j<sz) && ((*order)[
j*sz+
i+2]==0))
j++;
202 WerrorS(
"Matrix order not complete");
204 else if ((*order)[
j*sz+
i+2]<0)
217 for (
int i=0;
i<
N;
i++)
219 if (names[
i]==
NULL)
return -1;
220 if (strcmp(n,names[
i]) == 0)
return (
int)
i;
236 int nblocks=rBlocks(r);
249 PrintS(
"// coefficients: ");
257 const BOOLEAN bSaveShortOut = rShortOut(
R);
R->ShortOut = rShortOut(r) & rCanShortOut(
R);
261 R->ShortOut = bSaveShortOut;
265 if (C->is_field)
PrintS(
" considered as a field\n");
266 else PrintS(
" considered as a non-field\n");
306 Print(
"// number of vars : %d",r->N);
309 nblocks=rBlocks(r)-1;
311 for (
int l=0, nlen=0 ;
l<nblocks;
l++)
314 Print(
"\n// block %3d : ",
l+1);
321 assume( r->block0[
l] == r->block1[
l] );
322 const int s = r->block0[
l];
330 Print(
" syz_comp: %d",r->block0[
l]);
342 for (
i = r->block0[
l]-1;
i<r->block1[
l];
i++)
344 nlen = strlen(r->names[
i]);
349 if (r->wvhdl[
l]!=
NULL)
361 Warn(
"should not have wvhdl entry at pos. %d",
l);
364 int bl=r->block1[
l]-r->block0[
l]+1;
366 j<(r->block1[
l]-r->block0[
l]+1)*(r->block1[
l]-r->block0[
l]+1);
369 PrintS(
"\n// : weights ");
370 for (
i = 0;
i<=r->block1[
l]-r->block0[
l];
i++)
382 Print(
" %*d" ,nlen,r->wvhdl[
l][
i+
j]);
388 int m=r->wvhdl[
l][bl];
389 Print(
"\n// : %d module weights ",
m);
391 for(;
i<=
m;
i++)
Print(
" %*d" ,nlen,r->wvhdl[
l][
i]);
398 PrintS(
"\n// noncommutative relations:");
404 for (
i = 1;
i<r->N;
i++)
406 for (
j =
i+1;
j<=r->N;
j++)
411 Print(
"\n// %s%s=",r->names[
j-1],r->names[
i-1]);
421 Print(
"\n// noncommutative type:%d", (
int)ncRingType(r));
422 Print(
"\n// is skew constant:%d",r->GetNC()->IsSkewConstant);
425 Print(
"\n// alternating variables: [%d, %d]", scaFirstAltVar(r), scaLastAltVar(r));
427 PrintS(
"\n// quotient of sca by ideal");
440 Print(
"\n// letterplace ring (block size %d, ncgen count %d)",r->isLPring, r->LPncGenCount);
445 PrintS(
"\n// quotient ring from ideal");
458 if (r ==
NULL)
return;
462 if (r->ppNoether!=
NULL) p_Delete(&(r->ppNoether),r);
463 if( r->qideal !=
NULL )
471 if (rIsPluralRing(r))
478 if (r->order !=
NULL)
489 if (r->wvhdl[
j]!=
NULL)
502 for (
i=0;
i<r->N;
i++)
521 if (order==0)
Werror(
"wrong ring order `%s`",ordername);
531 for (nblocks=0; r->order[nblocks]; nblocks++);
550 if (r->wvhdl[
l]!=
NULL)
562 Warn(
"should not have wvhdl entry at pos. %d",
l);
570 j<(r->block1[
l]-r->block0[
l]+1)*(r->block1[
l]-r->block0[
l]+1);
577 for (
i = 0;
i<r->block1[
l]-r->block0[
l];
i++)
586 for (
i = 0;
i<r->block1[
l]-r->block0[
l];
i++)
596 if (
j+
i+1==(r->block1[
l]-r->block0[
l]+1)*(r->block1[
l]-r->block0[
l]+1))
607 assume( r->block0[
l] == r->block1[
l] );
608 const int s = r->block0[
l];
616 if (r->wanted_maxExp!=0)
618 long mm=r->wanted_maxExp;
635 for (
i=0;
i<r->N;
i++)
637 l+=strlen(r->names[
i])+1;
641 for (
i=0;
i<r->N-1;
i++)
643 strcat(
s,r->names[
i]);
646 strcat(
s,r->names[
i]);
658 char const *
const *
const params = rParameter(r);
663 for (
i=0;
i<rPar(r);
i++)
665 l+=strlen(params[
i])+1;
669 for (
i=0;
i<rPar(r)-1;
i++)
671 strcat(
s, params[
i]);
674 strcat(
s, params[
i]);
685 int len=strlen(ch)+strlen(var)+strlen(ord)+9;
687 snprintf(
res,len,
"(%s),(%s),(%s)",ch,var,ord);
719int rChar(ring r) {
return r->cf->ch; }
728 if (rIsPluralRing(r))
734 for(
int i=1;
i<r->N;
i++)
735 for(
int j=
i+1;
j<=r->N;
j++)
739 WarnS(
"Error initializing multiplication!");
759 memset(&tmpR,0,
sizeof(tmpR));
764 tmpR.
cf=nCopyCoeff(r1->cf);
768 if (getCoeffType(r1->cf)==
n_Zp)
770 if (getCoeffType(r2->cf)==
n_Q)
772 tmpR.
cf=nCopyCoeff(r1->cf);
779 tmpR.
cf=nCopyCoeff(r2->cf);
787 else if ((getCoeffType(r1->cf)==
n_Zn)||(getCoeffType(r1->cf)==
n_Znm))
789 if (getCoeffType(r2->cf)==
n_Q)
791 tmpR.
cf=nCopyCoeff(r1->cf);
794 && (mpz_cmp(r1->cf->modNumber,r2->cf->extRing->cf->modNumber)==0))
796 tmpR.
cf=nCopyCoeff(r2->cf);
804 else if (getCoeffType(r1->cf)==
n_R)
809 else if (getCoeffType(r1->cf)==
n_Q)
811 if (getCoeffType(r2->cf)==
n_Zp)
813 tmpR.
cf=nCopyCoeff(r2->cf);
817 tmpR.
cf=nCopyCoeff(r2->cf);
827 if (r1->cf->extRing->cf==r2->cf)
829 tmpR.
cf=nCopyCoeff(r1->cf);
831 else if (getCoeffType(r1->cf->extRing->cf)==
n_Zp && getCoeffType(r2->cf)==
n_Q)
833 tmpR.
cf=nCopyCoeff(r1->cf);
837 WerrorS (
"coeff sum of two extension fields not implemented");
843 WerrorS(
"coeff sum not yet implemented");
850 char **names=(
char **)
omAlloc0(
l*
sizeof(
char *));
855 for (
i=0;
i<r1->N;
i++)
859 if (*(r1->names[
i]) ==
'\0')
861 else if ((rParameter(r2)!=
NULL) && (strlen(r1->names[
i])==1))
865 for(
j=0;
j<rPar(r2);
j++)
867 if (strcmp(r1->names[
i],rParameter(r2)[
j])==0)
891 if (*(r2->names[
i]) ==
'\0')
893 else if ((rParameter(r1)!=
NULL) && (strlen(r2->names[
i])==1))
897 for(
j=0;
j<rPar(r1);
j++)
899 if (strcmp(r2->names[
i],rParameter(r1)[
j])==0)
914 if (strcmp(r1->names[
j],r2->names[
i])==0)
947 && !rIsPluralRing(r1) && !rIsPluralRing(r2)
957 tmpR.
block1[0] = rVar(r1)+rVar(r2);
959 tmpR.
wvhdl[0]=(
int*)
omAlloc0((rVar(r1)+rVar(r2) + 1)*
sizeof(
int));
960 for(
int i=0;
i<rVar(r1);
i++) tmpR.
wvhdl[0][
i]=1;
963 tmpR.
block1[1] = rVar(r1)+rVar(r2);
970 && !rIsPluralRing(r1) && !rIsPluralRing(r2)
983 if ((r2->block0[0]==1)
984 && (r2->block1[0]==rVar(r2))
990 tmpR.
order[1]=r2->order[0];
991 if (r2->wvhdl[0]!=
NULL)
996 int l=r2->block1[0]-r2->block0[0]+1;
1001 l+=r2->wvhdl[1][r2->block1[0]-r2->block0[0]+1]+1;
1004 memcpy(tmpR.
wvhdl[1],r2->wvhdl[0],
l*
sizeof(
int));
1016 tmpR.
block0[1]=rVar(r1)+1;
1017 tmpR.
block1[1]=rVar(r1)+rVar(r2);
1056 b=rBlocks(r1)+rBlocks(r2)-2;
1071 if (rb->wvhdl[
i]!=
NULL)
1072 WarnS(
"rSum: weights not implemented");
1078 for (
i=0;r1->order[
i]!=0;
i++)
1083 if (r1->wvhdl[
i]!=
NULL)
1088 int l=r1->block1[
i]-r1->block0[
i]+1;
1093 l+=r1->wvhdl[
i][r1->block1[
i]-r1->block0[
i]+1]+1;
1096 memcpy(tmpR.
wvhdl[
i],r1->wvhdl[
i],
l*
sizeof(
int));
1108 for (
i=0;r2->order[
i]!=0;
i++)
1114 tmpR.
block0[
j]=r2->block0[
i]+rVar(r1);
1115 tmpR.
block1[
j]=r2->block1[
i]+rVar(r1);
1116 if (r2->wvhdl[
i]!=
NULL)
1122 int l=r2->block1[
i]-r2->block0[
i]+1;
1127 l+=r2->wvhdl[
i][r2->block1[
i]-r2->block0[
i]+1]+1;
1130 memcpy(tmpR.
wvhdl[
j],r2->wvhdl[
i],
l*
sizeof(
int));
1137 if((r1->OrdSgn==-1)||(r2->OrdSgn==-1))
1141 else if ((
k==rVar(r1)) && (
k==rVar(r2)))
1157 if (r1->wvhdl[
i]!=
NULL)
1163 int l=r1->block1[
i]-r1->block0[
i]+1;
1168 l+=r1->wvhdl[
i][r1->block1[
i]-r1->block0[
i]+1]+1;
1171 memcpy(tmpR.
wvhdl[
i],r1->wvhdl[
i],
l*
sizeof(
int));
1182 Werror(
"variables must not overlap (# of vars: %d,%d -> %d)",rVar(r1),rVar(r2),
k);
1186 tmpR.
bitmask=si_max(r1->bitmask,r2->bitmask);
1188 memcpy(sum,&tmpR,
sizeof(
ip_sring));
1202 BOOLEAN R1_is_nc = rIsPluralRing(r1);
1203 BOOLEAN R2_is_nc = rIsPluralRing(r2);
1205 if ( (R1_is_nc) || (R2_is_nc))
1208 assume( rIsPluralRing(R1) );
1229 int *perm1 = (
int *)
omAlloc0((rVar(R1)+1)*
sizeof(
int));
1230 int *par_perm1 =
NULL;
1231 if (rPar(R1)!=0) par_perm1=(
int *)
omAlloc0((rPar(R1)+1)*
sizeof(
int));
1233 int *perm2 = (
int *)
omAlloc0((rVar(R2)+1)*
sizeof(
int));
1234 int *par_perm2 =
NULL;
1235 if (rPar(R2)!=0) par_perm2=(
int *)
omAlloc0((rPar(R2)+1)*
sizeof(
int));
1237 maFindPerm(R1->names, rVar(R1), rParameter(R1), rPar(R1),
1238 sum->names, rVar(sum), rParameter(sum), rPar(sum),
1239 perm1, par_perm1, sum->cf->type);
1241 maFindPerm(R2->names, rVar(R2), rParameter(R2), rPar(R2),
1242 sum->names, rVar(sum), rParameter(sum), rPar(sum),
1243 perm2, par_perm2, sum->cf->type);
1246 matrix C1 = R1->GetNC()->C, C2 = R2->GetNC()->C;
1247 matrix D1 = R1->GetNC()->D, D2 = R2->GetNC()->D;
1251 int l = rVar(R1) + rVar(R2);
1256 for (
i = 1;
i <= rVar(R1);
i++)
1257 for (
j= rVar(R1)+1;
j <=
l;
j++)
1262 nMapFunc nMap1 = n_SetMap(R1->cf,sum->cf);
1265 for (
i=1;
i<= rVar(R1);
i++)
1266 for (
j=
i+1;
j<=rVar(R1);
j++)
1269 MATELEM(C,
i,
j) =
p_PermPoly(
MATELEM(C1,
i,
j), perm1, R1, sum, nMap1, par_perm1, rPar(R1));
1272 MATELEM(
D,
i,
j) =
p_PermPoly(
MATELEM(D1,
i,
j), perm1, R1, sum, nMap1, par_perm1, rPar(R1));
1279 nMapFunc nMap2 = n_SetMap(R2->cf,sum->cf);
1281 for (
i=1;
i<= rVar(R2);
i++)
1282 for (
j=
i+1;
j<=rVar(R2);
j++)
1285 MATELEM(C,rVar(R1)+
i,rVar(R1)+
j) =
p_PermPoly(
MATELEM(C2,
i,
j),perm2,R2,sum, nMap2,par_perm2,rPar(R2));
1288 MATELEM(
D,rVar(R1)+
i,rVar(R1)+
j) =
p_PermPoly(
MATELEM(D2,
i,
j),perm2,R2,sum, nMap2,par_perm2,rPar(R2));
1296 WarnS(
"Error initializing non-commutative multiplication!");
1305 Print(
"\nRefs: R1: %d, R2: %d\n", R1->GetNC()->ref, R2->GetNC()->ref);
1328 if (r1->qideal!=
NULL)
1339 int *perm1 = (
int *)
omAlloc0((rVar(r1)+1)*
sizeof(
int));
1340 int *par_perm1 =
NULL;
1341 if (rPar(r1)!=0) par_perm1=(
int *)
omAlloc0((rPar(r1)+1)*
sizeof(
int));
1342 maFindPerm(r1->names, rVar(r1), rParameter(r1), rPar(r1),
1343 sum->names, rVar(sum), rParameter(sum), rPar(sum),
1344 perm1, par_perm1, sum->cf->type);
1345 nMapFunc nMap1 = n_SetMap(r1->cf,sum->cf);
1348 for (
int for_i=0;for_i<
IDELEMS(r1->qideal);for_i++)
1350 r1->qideal->m[for_i], perm1,
1353 par_perm1, rPar(r1));
1358 if (r2->qideal!=
NULL)
1362 int *perm2 = (
int *)
omAlloc0((rVar(r2)+1)*
sizeof(
int));
1363 int *par_perm2 =
NULL;
1364 if (rPar(r2)!=0) par_perm2=(
int *)
omAlloc0((rPar(r2)+1)*
sizeof(
int));
1365 maFindPerm(r2->names, rVar(r2), rParameter(r2), rPar(r2),
1366 sum->names, rVar(sum), rParameter(sum), rPar(sum),
1367 perm2, par_perm2, sum->cf->type);
1368 nMapFunc nMap2 = n_SetMap(r2->cf,sum->cf);
1371 for (
int for_i=0;for_i<
IDELEMS(r2->qideal);for_i++)
1373 r2->qideal->m[for_i], perm2,
1376 par_perm2, rPar(r2));
1397 if( rIsPluralRing(sum) )
1408int rSum(ring r1, ring r2, ring &sum)
1434 res->options=r->options;
1443 res->cf=nCopyCoeff(r->cf);
1449 res->firstBlockEnds=r->firstBlockEnds;
1451 res->real_var_start=r->real_var_start;
1452 res->real_var_end=r->real_var_end;
1456 res->isLPring=r->isLPring;
1457 res->LPncGenCount=r->LPncGenCount;
1460 res->VectorOut=r->VectorOut;
1461 res->ShortOut=r->ShortOut;
1462 res->CanShortOut=r->CanShortOut;
1478 res->bitmask=r->bitmask;
1479 res->divmask=r->divmask;
1480 res->BitsPerExp = r->BitsPerExp;
1481 res->ExpPerLong = r->ExpPerLong;
1500 if (copy_ordering ==
TRUE)
1502 res->LexOrder=r->LexOrder;
1503 res->MixedOrder=r->MixedOrder;
1511 if (r->wvhdl[
j]!=
NULL)
1517 int l=r->block1[
j]-r->block0[
j]+1;
1522 l+=r->wvhdl[
j][r->block1[
j]-r->block0[
j]+1]+1;
1525 memcpy(
res->wvhdl[
j],r->wvhdl[
j],
l*
sizeof(
int));
1533 memcpy(
res->block0,r->block0,
i *
sizeof(
int));
1534 memcpy(
res->block1,r->block1,
i *
sizeof(
int));
1544 res->names = (
char **)
omAlloc0(rVar(r) *
sizeof(
char *));
1545 for (
i=0;
i<rVar(
res);
i++)
1549 if (r->qideal!=
NULL)
1578 res->options=r->options;
1587 res->cf=nCopyCoeff(r->cf);
1593 res->firstBlockEnds=r->firstBlockEnds;
1595 res->real_var_start=r->real_var_start;
1596 res->real_var_end=r->real_var_end;
1600 res->isLPring=r->isLPring;
1601 res->LPncGenCount=r->LPncGenCount;
1604 res->VectorOut=r->VectorOut;
1605 res->ShortOut=r->ShortOut;
1606 res->CanShortOut=r->CanShortOut;
1607 res->LexOrder=r->LexOrder;
1608 res->MixedOrder=r->MixedOrder;
1624 res->bitmask=r->bitmask;
1625 res->divmask=r->divmask;
1626 res->BitsPerExp = r->BitsPerExp;
1627 res->ExpPerLong = r->ExpPerLong;
1646 if (copy_ordering ==
TRUE)
1653 for (
j=0;
j<
i-1;
j++)
1655 if (r->wvhdl[
j]!=
NULL)
1661 int l=r->block1[
j]-r->block0[
j]+1;
1666 l+=r->wvhdl[
j][r->block1[
j]-r->block0[
j]+1]+1;
1669 memcpy(
res->wvhdl[
j+1],r->wvhdl[
j],
l*
sizeof(
int));
1677 memcpy(&(
res->block0[1]),r->block0,(
i-1) *
sizeof(
int));
1678 memcpy(&(
res->block1[1]),r->block1,(
i-1) *
sizeof(
int));
1690 int length=wv64->
rows();
1692 for(
j=length-1;
j>=0;
j--)
1696 res->wvhdl[0]=(
int *)
A;
1698 res->block1[0]=length;
1701 res->names = (
char **)
omAlloc0(rVar(r) *
sizeof(
char *));
1702 for (
i=0;
i<rVar(
res);
i++)
1706 if (r->qideal!=
NULL)
1712 WerrorS(
"internal error: rCopy0(Q,TRUE,FALSE)");
1717 WarnS(
"internal bad stuff: rCopy0(Q,TRUE,TRUE)");
1745 if (rIsPluralRing(r))
1754 if (r1 == r2)
return TRUE;
1756 if (r1->cf!=r2->cf)
return FALSE;
1757 if (rVar(r1)!=rVar(r2))
return FALSE;
1758 if (r1->bitmask!=r2->bitmask)
return FALSE;
1759 #ifdef HAVE_SHIFTBBA
1760 if (r1->isLPring!=r2->isLPring)
return FALSE;
1761 if (r1->LPncGenCount!=r2->LPncGenCount)
return FALSE;
1769 for (
i=0;
i<rVar(r1);
i++)
1771 if ((r1->names[
i] !=
NULL) && (r2->names[
i] !=
NULL))
1773 if (strcmp(r1->names[
i], r2->names[
i]))
return FALSE;
1775 else if ((r1->names[
i] !=
NULL) ^ (r2->names[
i] !=
NULL))
1783 if (r1->qideal !=
NULL)
1785 ideal id1 = r1->qideal, id2 = r2->qideal;
1799 else if (r2->qideal !=
NULL)
return FALSE;
1809 if (r1 == r2)
return TRUE;
1813 if ((r1->cf != r2->cf)
1814 || (rVar(r1) != rVar(r2))
1815 || (r1->OrdSgn != r2->OrdSgn))
1819 while (r1->order[
i] != 0)
1821 if (r2->order[
i] == 0)
return FALSE;
1822 if ((r1->order[
i] != r2->order[
i])
1823 || (r1->block0[
i] != r2->block0[
i])
1824 || (r1->block1[
i] != r2->block1[
i]))
1826 if (r1->wvhdl[
i] !=
NULL)
1828 if (r2->wvhdl[
i] ==
NULL)
1830 for (
j=0;
j<r1->block1[
i]-r1->block0[
i]+1;
j++)
1831 if (r2->wvhdl[
i][
j] != r1->wvhdl[
i][
j])
1837 if (r2->order[
i] != 0)
return FALSE;
1896 int blocks = rBlocks(r) - 1;
1898 if (blocks == 1)
return TRUE;
1907 if ((blocks -
s) > 2)
return FALSE;
1931 if ((r->block0[
s]!=1)||(r->block1[
s]!=r->N))
1940 for(
int i=0;
i<r->N;
i++)
1942 if(r->wvhdl[
s][
i]==0)
return TRUE;
1995 int blocks = rBlocks(r) - 1;
1997 if (blocks == 1)
return TRUE;
2006 if ((blocks -
s) > 3)
return FALSE;
2009 if ((blocks -
s) == 3)
2028 for (pos=0;pos<r->OrdSize;pos++)
2046 return ((rVar(r) > 1) &&
2052 ((r->order[1]!=0) &&
2060 return ((rVar(r) > 1) &&
2062 &&(r->block0[ord]==1)
2063 &&(r->block1[ord]==r->N));
2070 return ((rVar(r) > 1) &&
2072 &&(r->block0[ord]==1)
2073 &&(r->block1[ord]==r->N));
2080 return ((rVar(r) > 1) &&
2082 &&(r->block0[ord]==1)
2083 &&(r->block1[ord]==r->N));
2090 return ((rVar(r) > 1) &&
2109 if (r->N == 0)
return TRUE;
2111 if ((r->OrdSgn!=1) && (r->OrdSgn!= -1))
2123 for(
int j=0;
j<=
i;
j++)
2126 dError(
"wrong order in r->order");
2137 if (r->VarOffset ==
NULL)
2139 dReportError(
"Null ring VarOffset -- no rComplete (?) in n %s:%d", fn,
l);
2144 if ((r->OrdSize==0)!=(r->typ==
NULL))
2146 dReportError(
"mismatch OrdSize and typ-pointer in %s:%d");
2152 for(
i=0;
i<=r->N;
i++)
2156 for(
j=0;
j<r->OrdSize;
j++)
2160 const int p = r->typ[
j].data.isTemp.suffixpos;
2167 if(r->typ[
p].ord_typ !=
ro_is)
2168 dReportError(
"ordrec prefix %d is unmatched (suffix: %d is wrong!!!)",
j,
p);
2171 if(r->typ[
j].data.isTemp.pVarOffset[
i] != -1)
2177 else if (r->typ[
j].ord_typ ==
ro_is)
2180 if(r->typ[
j].data.is.pVarOffset[
i] != -1)
2188 if (r->typ[
j].ord_typ==
ro_cp)
2190 if(((
short)r->VarOffset[
i]) == r->typ[
j].data.cp.place)
2195 && (r->VarOffset[
i] == r->typ[
j].data.dp.place))
2201 tmp=r->VarOffset[
i] & 0xffffff;
2202 #if SIZEOF_LONG == 8
2203 if ((r->VarOffset[
i] >> 24) >63)
2205 if ((r->VarOffset[
i] >> 24) >31)
2207 dReportError(
"bit_start out of range:%d",r->VarOffset[
i] >> 24);
2208 if (
i > 0 && ((tmp<0) ||(tmp>r->ExpL_Size-1)))
2210 dReportError(
"varoffset out of range for var %d: %d",
i,tmp);
2215 for(
j=0;
j<r->OrdSize;
j++)
2217 if ((r->typ[
j].ord_typ==
ro_dp)
2218 || (r->typ[
j].ord_typ==
ro_wp)
2221 if (r->typ[
j].data.dp.start > r->typ[
j].data.dp.end)
2223 r->typ[
j].data.dp.start, r->typ[
j].data.dp.end);
2224 if ((r->typ[
j].data.dp.start < 1)
2225 || (r->typ[
j].data.dp.end > r->N))
2226 dReportError(
"in ordrec %d: start(%d)<1 or end(%d)>vars(%d)",
j,
2227 r->typ[
j].data.dp.start, r->typ[
j].data.dp.end,r->N);
2259static void rO_TDegree(
int &place,
int &bitplace,
int start,
int end,
2265 ord_struct.
data.dp.start=start;
2266 ord_struct.
data.dp.end=end;
2267 ord_struct.
data.dp.place=place;
2279 ord_struct.
data.dp.start=start;
2280 ord_struct.
data.dp.end=end;
2281 ord_struct.
data.dp.place=place;
2287static void rO_WDegree(
int &place,
int &bitplace,
int start,
int end,
2288 long *o,
sro_ord &ord_struct,
int *weights)
2291 while((start<end) && (weights[0]==0)) { start++; weights++; }
2292 while((start<end) && (weights[end-start]==0)) { end--; }
2295 for(
i=start;
i<=end;
i++)
2297 if(weights[
i-start]!=1)
2305 rO_TDegree(place,bitplace,start,end,o,ord_struct);
2310 ord_struct.
data.wp.start=start;
2311 ord_struct.
data.wp.end=end;
2312 ord_struct.
data.wp.place=place;
2313 ord_struct.
data.wp.weights=weights;
2317 for(
i=start;
i<=end;
i++)
2319 if(weights[
i-start]<0)
2328 long *o,
sro_ord &ord_struct,
int *weights)
2337 ord_struct.
data.am.start=start;
2338 ord_struct.
data.am.end=end;
2339 ord_struct.
data.am.place=place;
2340 ord_struct.
data.am.weights=weights;
2341 ord_struct.
data.am.weights_m = weights + (end-start+1);
2342 ord_struct.
data.am.len_gen=weights[end-start+1];
2343 assume( ord_struct.
data.am.weights_m[0] == ord_struct.
data.am.len_gen );
2356 ord_struct.
data.wp64.start=start;
2357 ord_struct.
data.wp64.end=end;
2358 ord_struct.
data.wp64.place=place;
2360 ord_struct.
data.wp64.weights64=weights;
2364 for(
int i=0;
i<
l;
i++) ord_struct.
data.wp64.weights64[
i]=weights[
i];
2374 long *o,
sro_ord &ord_struct,
int *weights)
2377 while((start<end) && (weights[0]==0)) { start++; weights++; }
2378 while((start<end) && (weights[end-start]==0)) { end--; }
2381 ord_struct.
data.wp.start=start;
2382 ord_struct.
data.wp.end=end;
2383 ord_struct.
data.wp.place=place;
2384 ord_struct.
data.wp.weights=weights;
2389 for(
i=start;
i<=end;
i++)
2391 if(weights[
i-start]<0)
2399static void rO_LexVars(
int &place,
int &bitplace,
int start,
int end,
2400 int &prev_ord,
long *o,
int *
v,
int bits,
int opt_var)
2405 if(prev_ord==-1)
rO_Align(place,bitplace);
2411 for(
k=start;;
k+=incr)
2416 v[
k]= place | (bitplace << 24);
2422 assume((opt_var == end+1) ||(opt_var == end-1));
2423 if((opt_var != end+1) &&(opt_var != end-1))
WarnS(
"hier-2");
2424 int save_bitplace=bitplace;
2428 bitplace=save_bitplace;
2432 v[opt_var]=place | (bitplace << 24);
2437 int &prev_ord,
long *o,
int *
v,
int bits,
int opt_var)
2442 if(prev_ord==1)
rO_Align(place,bitplace);
2448 for(
k=start;;
k+=incr)
2453 v[
k]=place | (bitplace << 24);
2460 assume((opt_var == end+1) ||(opt_var == end-1));
2461 if((opt_var != end+1) &&(opt_var != end-1))
WarnS(
"hier-1");
2462 int save_bitplace=bitplace;
2466 bitplace=save_bitplace;
2470 v[opt_var]=place | (bitplace << 24);
2481 ord_struct.
data.syzcomp.place=place;
2482 ord_struct.
data.syzcomp.Components=
NULL;
2483 ord_struct.
data.syzcomp.ShiftedComponents=
NULL;
2490static void rO_Syz(
int &place,
int &bitplace,
int &prev_ord,
2491 int syz_comp,
long *o,
sro_ord &ord_struct)
2498 ord_struct.
data.syz.place=place;
2499 ord_struct.
data.syz.limit=syz_comp;
2501 ord_struct.
data.syz.syz_index = (
int*)
omAlloc0((syz_comp+1)*
sizeof(
int));
2503 ord_struct.
data.syz.syz_index =
NULL;
2504 ord_struct.
data.syz.curr_index = 1;
2517 long *o,
int N,
int *
v,
sro_ord &ord_struct)
2524 ord_struct.
data.isTemp.start = place;
2528 ord_struct.
data.isTemp.pVarOffset = (
int *)
omAlloc((
N+1)*
sizeof(
int));
2529 memcpy(ord_struct.
data.isTemp.pVarOffset,
v,(
N+1)*
sizeof(
int));
2531 ord_struct.
data.isTemp.suffixpos = -1;
2539static void rO_ISSuffix(
int &place,
int &bitplace,
int &prev_ord,
long *o,
2544 int typ_j = typ_i - 1;
2547 if( tmp_typ[typ_j].ord_typ ==
ro_isTemp)
2560 const int start = tmp_typ[typ_j].
data.isTemp.start;
2561 int *pVarOffset = tmp_typ[typ_j].
data.isTemp.pVarOffset;
2572 tmp_typ[typ_j].
data.isTemp.suffixpos = typ_i;
2579 for(
int i = 0;
i <=
N;
i++ )
2582 if(
v[
i] != pVarOffset[
i] )
2584 pVarOffset[
i] =
v[
i];
2586 assume( pVarOffset[
i] != -1 );
2592 if( pVarOffset[0] != -1 )
2593 pVarOffset[0] &= 0x0fff;
2595 sro_ord &ord_struct = tmp_typ[typ_j];
2599 ord_struct.
data.is.start = start;
2600 ord_struct.
data.is.end = place;
2601 ord_struct.
data.is.pVarOffset = pVarOffset;
2623 v[0] = place | (bitplace << 24);
2634 bits=16; bitmask=0xffff;
2636 else if (bitmask <= 1L)
2638 bits=1; bitmask = 1L;
2640 else if (bitmask <= 3L)
2642 bits=2; bitmask = 3L;
2644 else if (bitmask <= 7L)
2648 else if (bitmask <= 0xfL)
2650 bits=4; bitmask=0xfL;
2652 else if (bitmask <= 0x1fL)
2654 bits=5; bitmask=0x1fL;
2656 else if (bitmask <= 0x3fL)
2658 bits=6; bitmask=0x3fL;
2661 else if (bitmask <= 0x7fL)
2663 bits=7; bitmask=0x7fL;
2666 else if (bitmask <= 0xffL)
2668 bits=8; bitmask=0xffL;
2671 else if (bitmask <= 0x1ffL)
2673 bits=9; bitmask=0x1ffL;
2676 else if (bitmask <= 0x3ffL)
2678 bits=10; bitmask=0x3ffL;
2681 else if (bitmask <= 0xfffL)
2683 bits=12; bitmask=0xfff;
2686 else if (bitmask <= 0xffffL)
2688 bits=16; bitmask=0xffffL;
2691 else if (bitmask <= 0xfffffL)
2693 bits=20; bitmask=0xfffffL;
2695 else if (bitmask <= 0xffffffffL)
2697 bits=32; bitmask=0xffffffffL;
2699 else if (bitmask <= 0x7fffffffffffffffL)
2701 bits=63; bitmask=0x7fffffffffffffffL;
2705 bits=63; bitmask=0x7fffffffffffffffL;
2708 else if (bitmask <= 0x7fffffff)
2710 bits=31; bitmask=0x7fffffff;
2714 bits=31; bitmask=0x7fffffffL;
2735 unsigned long bitmask1 =
rGetExpSize(bitmask+1, bits1);
2737 if ((((
N+vars_per_long-1)/vars_per_long) ==
2738 ((
N+vars_per_long1-1)/vars_per_long1)))
2740 vars_per_long=vars_per_long1;
2760 unsigned long exp_limit)
2768 BOOLEAN need_other_ring = (exp_limit != r->bitmask);
2770 int iNeedInducedOrderingSetup = 0;
2772 int nblocks=rBlocks(r);
2774 int *block0=(
int*)
omAlloc0((nblocks+1)*
sizeof(
int));
2775 int *block1=(
int*)
omAlloc0((nblocks+1)*
sizeof(
int));
2776 int **wvhdl=(
int**)
omAlloc0((nblocks+1)*
sizeof(
int *));
2785 if (r->block0[
i]==r->block1[
i])
2810 Warn(
"Error: unhandled ordering in rModifyRing: ringorder_S = [%d]", r_ord);
2824 need_other_ring=
TRUE;
2825 try_omit_comp=
FALSE;
2826 copy_block_index=
FALSE;
2840 need_other_ring=
TRUE;
2842 omitted_degree =
TRUE;
2856 need_other_ring=
TRUE;
2858 omitted_degree =
TRUE;
2866 try_omit_comp =
FALSE;
2869 iNeedInducedOrderingSetup++;
2878 try_omit_comp =
FALSE;
2887 if (copy_block_index)
2889 block0[
j]=r->block0[
i];
2890 block1[
j]=r->block1[
i];
2891 wvhdl[
j]=r->wvhdl[
i];
2896 if(!need_other_ring)
2916 res->bitmask=exp_limit;
2917 res->wanted_maxExp=r->wanted_maxExp;
2924 if (r->pFDegOrig !=
res->pFDegOrig &&
2929 res->firstwv = r->firstwv;
2930 res->firstBlockEnds = r->firstBlockEnds;
2934 res->pLDeg = r->pLDegOrig;
2943 res->typ[0] = r->typ[0];
2945 if (r->typ[0].data.syz.limit > 0)
2947 res->typ[0].data.syz.syz_index
2948 = (
int*)
omAlloc((r->typ[0].data.syz.limit +1)*
sizeof(
int));
2949 memcpy(
res->typ[0].data.syz.syz_index, r->typ[0].data.syz.syz_index,
2950 (r->typ[0].data.syz.limit +1)*
sizeof(
int));
2954 if( iNeedInducedOrderingSetup > 0 )
2956 for(
j = 0,
i = 0; (
i < nblocks) && (iNeedInducedOrderingSetup > 0);
i++)
2963 r->typ[
i].data.is.limit,
2968 iNeedInducedOrderingSetup--;
2974 res->OrdSgn=r->OrdSgn;
2978 if (rIsPluralRing(r))
2983 WarnS(
"error in nc_rComplete");
2995 if( !
sca_Force(
res, scaFirstAltVar(r), scaLastAltVar(r)) )
2996 WarnS(
"error in sca_Force!");
3022 res->block1[0] = r->N;
3023 res->wvhdl[0] = weights;
3033 if (rIsPluralRing(r))
3038 WarnS(
"error in nc_rComplete");
3065 int nblocks=1+(ommit_comp!=0);
3067 int *block0=(
int*)
omAlloc0((nblocks+1)*
sizeof(
int));
3068 int *block1=(
int*)
omAlloc0((nblocks+1)*
sizeof(
int));
3069 int **wvhdl=(
int**)
omAlloc0((nblocks+1)*
sizeof(
int *));
3088 res->bitmask=exp_limit;
3089 res->wanted_maxExp=r->wanted_maxExp;
3095 if (rIsPluralRing(r))
3100 WarnS(
"error in nc_rComplete");
3116 return rModifyRing(r, ommit_degree, ommit_comp, exp_limit);
3145 r->CanShortOut=
FALSE;
3148 r->CanShortOut =
TRUE;
3150 if (rParameter(r)!=
NULL)
3152 for (
i=0;
i<rPar(r);
i++)
3154 if(strlen(rParameter(r)[
i])>1)
3156 r->CanShortOut=
FALSE;
3164 for (
i=(
N-1);
i>=0;
i--)
3166 if(r->names[
i] !=
NULL && strlen(r->names[
i])>1)
3168 r->CanShortOut=
FALSE;
3174 r->ShortOut = r->CanShortOut;
3176 assume( !( !r->CanShortOut && r->ShortOut ) );
3184 if(block1[
i]!=r->N) r->LexOrder=
TRUE;
3185 r->firstBlockEnds=block1[
i];
3186 r->firstwv = wvhdl[
i];
3195 for(
j=block1[
i]-block0[
i];
j>=0;
j--)
3197 if (r->firstwv[
j]==0) r->LexOrder=
TRUE;
3204 for(
j=block1[
i]-block0[
i];
j>=0;
j--)
3206 if (
w[
j]==0) r->LexOrder=
TRUE;
3213 if (r->pFDeg ==
p_Deg)
3220 else if (r->pFDeg == p_Totaldegree)
3234 r->pLDegOrig = r->pLDeg;
3248 if (r->order[
i]==0)
break;
3250 r->pFDeg = p_Totaldegree;
3258 int* block0 = r->block0;
3259 int* block1 = r->block1;
3260 int** wvhdl = r->wvhdl;
3269 r->LexOrder =
FALSE;
3270 r->pFDeg = p_Totaldegree;
3276 for(
int ii=block0[0];ii<=block1[0];ii++)
3277 if (wvhdl[0][ii-1]<0) { r->MixedOrder=2;
break;}
3279 for(
int ii=block0[0];ii<=block1[0];ii++)
3280 if (wvhdl[0][ii-1]==0) { r->LexOrder=
TRUE;
break;}
3281 if ((block0[0]==1)&&(block1[0]==r->N))
3292 r->firstwv = wvhdl[0];
3304 if (r->OrdSgn == -1) r->pLDeg =
pLDeg0c;
3312 r->pFDeg = p_Totaldegree;
3323 for(
int ii=block0[0];ii<=block1[0];ii++)
3325 if (wvhdl[0][ii-1]<0) { r->MixedOrder=2;
break;}
3327 if (r->MixedOrder==0)
3329 if ((block0[0]==1)&&(block1[0]==r->N))
3335 r->pFDeg = p_Totaldegree;
3337 r->firstBlockEnds=block1[0];
3338 r->firstwv = wvhdl[0];
3355 r->pFDeg = p_Totaldegree;
3357 r->firstBlockEnds=block1[1];
3358 if (wvhdl!=
NULL) r->firstwv = wvhdl[1];
3366 for(
int ii=block0[1];ii<=block1[1];ii++)
3367 if (wvhdl[1][ii-1]<0) { r->MixedOrder=2;
break;}
3368 if (r->MixedOrder==
FALSE)
3371 r->pFDeg = p_Totaldegree;
3401 if(r->MixedOrder==
FALSE)
3404 r->pFDeg = p_Totaldegree;
3416 r->pFDegOrig = r->pFDeg;
3431 for(
i=0;
i<r->OrdSize;
i++)
3434 ||(r->typ[
i].ord_typ==
ro_am))
3439 r->NegWeightL_Size=
l;
3440 r->NegWeightL_Offset=(
int *)
omAlloc(
l*
sizeof(
int));
3442 for(
i=0;
i<r->OrdSize;
i++)
3446 r->NegWeightL_Offset[
l]=r->typ[
i].data.wp.place;
3449 else if(r->typ[
i].ord_typ==
ro_am)
3451 r->NegWeightL_Offset[
l]=r->typ[
i].data.am.place;
3458 r->NegWeightL_Size = 0;
3459 r->NegWeightL_Offset =
NULL;
3471 if ( (r->cf->extRing!=
NULL)
3474 || (((
int)getCoeffType(r->cf))>16)
3481 if (r->LexOrder || r->OrdSgn == -1 || (r->cf->extRing!=
NULL))
3496 r->pLexOrder=r->LexOrder;
3504static inline int sign(
int x) {
return (
x > 0) - (
x < 0);}
3511 int vz=
sign(p_FDeg(
p,r));
3512 for(
i=2;
i<=rVar(r);
i++)
3514 p_SetExp(
p,
i-1,0,r);
3517 if (
sign(p_FDeg(
p,r))!=vz)
3529 if (r->VarOffset!=
NULL && force == 0)
return FALSE;
3534 r->bitmask=
rGetExpSize(r->wanted_maxExp,bits,r->N);
3535 r->BitsPerExp = bits;
3540 long *tmp_ordsgn=(
long *)
omAlloc0(3*(n+r->N)*
sizeof(
long));
3542 int *
v=(
int *)
omAlloc((r->N+1)*
sizeof(
int));
3543 for(
i=r->N;
i>=0 ;
i--)
3560 switch (r->order[
i])
3564 rO_WDegree(
j,j_bits,r->block0[
i],r->block1[
i],tmp_ordsgn,tmp_typ[typ_i],
3570 rO_WMDegree(
j,j_bits,r->block0[
i],r->block1[
i],tmp_ordsgn,tmp_typ[typ_i],
3577 tmp_typ[typ_i], (
int64 *)(r->wvhdl[
i]));
3584 r->ComponentOrder=1;
3590 r->ComponentOrder=-1;
3596 k=r->block1[
i]-r->block0[
i]+1;
3601 r->wvhdl[
i]+(r->block1[
i]-r->block0[
i]+1)*
l);
3608 rO_LexVars(
j, j_bits, r->block0[
i],r->block1[
i], prev_ordsgn,
3609 tmp_ordsgn,
v,bits, -1);
3614 tmp_ordsgn,
v, bits, -1);
3619 tmp_ordsgn,
v, bits, -1);
3623 rO_LexVars(
j, j_bits, r->block1[
i],r->block0[
i], prev_ordsgn,
3624 tmp_ordsgn,
v, bits, -1);
3628 if (r->block0[
i]==r->block1[
i])
3630 rO_LexVars(
j, j_bits, r->block0[
i],r->block0[
i], prev_ordsgn,
3631 tmp_ordsgn,
v, bits, -1);
3639 prev_ordsgn,tmp_ordsgn,
v,bits, r->block0[
i]);
3644 if (r->block0[
i]==r->block1[
i])
3646 rO_LexVars(
j, j_bits, r->block0[
i],r->block0[
i], prev_ordsgn,
3647 tmp_ordsgn,
v, bits, -1);
3654 rO_LexVars(
j, j_bits, r->block0[
i],r->block1[
i]-1, prev_ordsgn,
3655 tmp_ordsgn,
v, bits, r->block1[
i]);
3660 if (r->block0[
i]==r->block1[
i])
3662 rO_LexVars(
j, j_bits, r->block0[
i],r->block0[
i], prev_ordsgn,
3663 tmp_ordsgn,
v, bits, -1);
3670 rO_LexVars(
j, j_bits, r->block1[
i],r->block0[
i], prev_ordsgn,
3671 tmp_ordsgn,
v, bits, -1);
3676 if (r->block0[
i]==r->block1[
i])
3679 tmp_ordsgn,
v,bits, -1);
3687 prev_ordsgn,tmp_ordsgn,
v,bits, r->block0[
i]);
3692 if (r->block0[
i]==r->block1[
i])
3695 tmp_ordsgn,
v, bits, -1);
3702 rO_LexVars(
j, j_bits, r->block0[
i],r->block1[
i]-1, prev_ordsgn,
3703 tmp_ordsgn,
v, bits, r->block1[
i]);
3709 tmp_typ[typ_i], r->wvhdl[
i]);
3714 for(jj=r->block1[
i]-r->block0[
i];jj>=0; jj--)
3716 if (r->wvhdl[
i][jj]<=0) have_bad_weights=
TRUE;
3718 if (have_bad_weights)
3725 if (r->block1[
i]!=r->block0[
i])
3728 tmp_ordsgn,
v,bits, r->block0[
i]);
3734 tmp_typ[typ_i], r->wvhdl[
i]);
3739 for(jj=r->block1[
i]-r->block0[
i];jj>=0; jj--)
3741 if (r->wvhdl[
i][jj]<=0) have_bad_weights=
TRUE;
3743 if (have_bad_weights)
3750 if (r->block1[
i]!=r->block0[
i])
3752 rO_LexVars(
j, j_bits,r->block0[
i],r->block1[
i]-1, prev_ordsgn,
3753 tmp_ordsgn,
v, bits, r->block1[
i]);
3759 tmp_typ[typ_i], r->wvhdl[
i]);
3761 if (r->block1[
i]!=r->block0[
i])
3764 tmp_ordsgn,
v,bits, r->block0[
i]);
3770 tmp_typ[typ_i], r->wvhdl[
i]);
3772 if (r->block1[
i]!=r->block0[
i])
3774 rO_LexVars(
j, j_bits,r->block0[
i],r->block1[
i]-1, prev_ordsgn,
3775 tmp_ordsgn,
v, bits, r->block1[
i]);
3782 rO_Syzcomp(
j, j_bits,prev_ordsgn, tmp_ordsgn,tmp_typ[typ_i]);
3783 need_to_add_comp=
TRUE;
3784 r->ComponentOrder=-1;
3790 rO_Syz(
j, j_bits, prev_ordsgn, r->block0[
i], tmp_ordsgn, tmp_typ[typ_i]);
3791 need_to_add_comp=
TRUE;
3792 r->ComponentOrder=-1;
3798 assume( r->block0[
i] == r->block1[
i] );
3799 const int s = r->block0[
i];
3803 rO_ISPrefix(
j, j_bits, prev_ordsgn, tmp_ordsgn, r->N,
v, tmp_typ[typ_i++]);
3806 rO_ISSuffix(
j, j_bits, prev_ordsgn, tmp_ordsgn, r->N,
v, tmp_typ, typ_i,
s);
3807 need_to_add_comp=
FALSE;
3826 j_bits=j_bits0;
j=j0;
3831 if((need_to_add_comp) && (
v[0]== -1))
3845 for(
i=1 ;
i<=r->N ;
i++)
3872 r->ordsgn=(
long *)
omAlloc0(r->ExpL_Size*
sizeof(
long));
3874 for(
j=0;
j<r->CmpL_Size;
j++)
3876 r->ordsgn[
j] = tmp_ordsgn[
j];
3885 if (typ_i==0) r->typ=
NULL;
3889 memcpy(r->typ,tmp_typ,typ_i*
sizeof(
sro_ord));
3899 r->pCompIndex=(r->VarOffset[0] & 0xffff);
3902 if (
i==r->pCompIndex)
i++;
3911 if (
i==r->pCompIndex)
i++;
3940 r->pFDeg = p_Totaldegree;
3949 for(
int i=1;
i<=r->N;
i++)
3956 if ((r->block0[
j]<=
i)&&(r->block1[
j]>=
i))
3976 if(r->wvhdl[
j][
i-r->block0[
j]]<0)
3982 else if(r->wvhdl[
j][
i-r->block0[
j]]>0)
3993 if(r->wvhdl[
j][
i-r->block0[
j]]<0)
3999 else if(r->wvhdl[
j][
i-r->block0[
j]]>0)
4007 int add=r->block1[
j]-r->block0[
j]+1;
4012 if (r->wvhdl[
j][
i-r->block0[
j]]<0)
4018 else if(r->wvhdl[
j][
i-r->block0[
j]]>0)
4048 if (nonneg>0) r->MixedOrder=1;
4059 if (r ==
NULL)
return;
4060 if (r->VarOffset !=
NULL)
4062 if (r->OrdSize!=0 && r->typ !=
NULL)
4064 for(
int i = 0;
i < r->OrdSize;
i++)
4065 if( r->typ[
i].ord_typ ==
ro_is)
4069 if( r->typ[
i].data.is.pVarOffset !=
NULL )
4074 else if (r->typ[
i].ord_typ ==
ro_syz)
4076 if(r->typ[
i].data.syz.limit > 0)
4077 omFreeSize(r->typ[
i].data.syz.syz_index, ((r->typ[
i].data.syz.limit) +1)*
sizeof(
int));
4081 assume( r->typ[
i].data.syzcomp.ShiftedComponents ==
NULL );
4082 assume( r->typ[
i].data.syzcomp.Components ==
NULL );
4092 if (r->PolyBin !=
NULL)
4098 if (r->ordsgn !=
NULL && r->CmpL_Size != 0)
4103 if (r->p_Procs !=
NULL)
4108 omfreeSize(r->VarL_Offset, r->VarL_Size*
sizeof(
int));
4109 r->VarL_Offset=
NULL;
4111 if (r->NegWeightL_Offset!=
NULL)
4113 omFreeSize(r->NegWeightL_Offset, r->NegWeightL_Size*
sizeof(
int));
4114 r->NegWeightL_Offset=
NULL;
4121 int min = INT_MAX, min_j = -1;
4122 int* VarL_Number = (
int*)
omAlloc0(r->ExpL_Size*
sizeof(
int));
4127 for (
i=1;
i<=r->N;
i++)
4129 VarL_Number[r->VarOffset[
i] & 0xffffff]++;
4133 for (
i=0,
j=0;
i<r->ExpL_Size;
i++)
4135 if (VarL_Number[
i] != 0)
4137 if (min > VarL_Number[
i])
4139 min = VarL_Number[
i];
4148 r->VarL_Offset = (
int*)
omAlloc(r->VarL_Size*
sizeof(
int));
4149 r->VarL_LowIndex = 0;
4152 for (
i=0,
j=0;
i<r->ExpL_Size;
i++)
4154 if (VarL_Number[
i] != 0)
4156 r->VarL_Offset[
j] =
i;
4157 if (
j > 0 && r->VarL_Offset[
j-1] != r->VarL_Offset[
j] - 1)
4158 r->VarL_LowIndex = -1;
4162 if (r->VarL_LowIndex >= 0)
4163 r->VarL_LowIndex = r->VarL_Offset[0];
4167 j = r->VarL_Offset[min_j];
4168 r->VarL_Offset[min_j] = r->VarL_Offset[0];
4169 r->VarL_Offset[0] =
j;
4176 int* shifts = (
int*)
omAlloc(r->ExpL_Size*
sizeof(
int));
4179 for (
i=0;
i<r->ExpL_Size;
i++)
4183 for (
i=1;
i<=r->N;
i++)
4185 if (shifts[r->VarOffset[
i] & 0xffffff] > r->VarOffset[
i] >> 24)
4186 shifts[r->VarOffset[
i] & 0xffffff] = r->VarOffset[
i] >> 24;
4189 for (
i=1;
i<=r->N;
i++)
4191 if (shifts[r->VarOffset[
i] & 0xffffff] != 0)
4193 = (r->VarOffset[
i] & 0xffffff) |
4194 (((r->VarOffset[
i] >> 24) - shifts[r->VarOffset[
i] & 0xffffff]) << 24);
4202 unsigned long divmask = 1;
4207 divmask |= (((
unsigned long) 1) << (
unsigned long)
i);
4222 const char *TYP[]={
"ro_dp",
"ro_wp",
"ro_am",
"ro_wp64",
"ro_wp_neg",
"ro_cp",
4223 "ro_syzcomp",
"ro_syz",
"ro_isTemp",
"ro_is",
"ro_none"};
4226 Print(
"ExpL_Size:%d ",r->ExpL_Size);
4227 Print(
"CmpL_Size:%d ",r->CmpL_Size);
4228 Print(
"VarL_Size:%d\n",r->VarL_Size);
4229 Print(
"bitmask=0x%lx (expbound=%ld) \n",r->bitmask, r->bitmask);
4230 Print(
"divmask=%lx\n", r->divmask);
4231 Print(
"BitsPerExp=%d ExpPerLong=%d at L[%d]\n", r->BitsPerExp, r->ExpPerLong, r->VarL_Offset[0]);
4233 Print(
"VarL_LowIndex: %d\n", r->VarL_LowIndex);
4234 PrintS(
"VarL_Offset:\n");
4237 for(
j = 0;
j < r->VarL_Size;
j++)
4238 Print(
" VarL_Offset[%d]: %d ",
j, r->VarL_Offset[
j]);
4245 for(
j=0;
j<=r->N;
j++)
4246 Print(
" v%d at e-pos %d, bit %d\n",
4247 j,r->VarOffset[
j] & 0xffffff, r->VarOffset[
j] >>24);
4249 for(
j=0;
j<r->CmpL_Size;
j++)
4250 Print(
" ordsgn %ld at pos %d\n",r->ordsgn[
j],
j);
4251 Print(
"OrdSgn:%d\n",r->OrdSgn);
4253 for(
j=0;
j<r->OrdSize;
j++)
4255 Print(
" typ %s", TYP[r->typ[
j].ord_typ]);
4256 if (r->typ[
j].ord_typ==
ro_syz)
4258 const short place = r->typ[
j].data.syz.place;
4259 const int limit = r->typ[
j].data.syz.limit;
4260 const int curr_index = r->typ[
j].data.syz.curr_index;
4261 const int* syz_index = r->typ[
j].data.syz.syz_index;
4263 Print(
" limit %d (place: %d, curr_index: %d), syz_index: ", limit, place, curr_index);
4265 if( syz_index ==
NULL )
4270 for(
i=0;
i <= limit;
i++ )
4271 Print(
"%d ", syz_index[
i]);
4278 Print(
" start (level) %d, suffixpos: %d, VO: ",r->typ[
j].data.isTemp.start, r->typ[
j].data.isTemp.suffixpos);
4281 else if (r->typ[
j].ord_typ==
ro_is)
4283 Print(
" start %d, end: %d: ",r->typ[
j].data.is.start, r->typ[
j].data.is.end);
4287 Print(
" limit %d",r->typ[
j].data.is.limit);
4294 else if (r->typ[
j].ord_typ==
ro_am)
4296 Print(
" place %d",r->typ[
j].data.am.place);
4297 Print(
" start %d",r->typ[
j].data.am.start);
4298 Print(
" end %d",r->typ[
j].data.am.end);
4299 Print(
" len_gen %d",r->typ[
j].data.am.len_gen);
4302 for(
l=r->typ[
j].data.am.start;
l<=r->typ[
j].data.am.end;
l++)
4303 Print(
" %d",r->typ[
j].data.am.weights[
l-r->typ[
j].data.am.start]);
4304 l=r->typ[
j].data.am.end+1;
4305 int ll=r->typ[
j].data.am.weights[
l-r->typ[
j].data.am.start];
4307 for(
int lll=
l+1;lll<
l+ll+1;lll++)
4308 Print(
" %d",r->typ[
j].data.am.weights[lll-r->typ[
j].data.am.start]);
4312 Print(
" place %d",r->typ[
j].data.dp.place);
4316 Print(
" start %d",r->typ[
j].data.dp.start);
4317 Print(
" end %d",r->typ[
j].data.dp.end);
4318 if ((r->typ[
j].ord_typ==
ro_wp)
4322 for(
int l=r->typ[
j].data.wp.start;
l<=r->typ[
j].data.wp.end;
l++)
4323 Print(
" %d",r->typ[
j].data.wp.weights[
l-r->typ[
j].data.wp.start]);
4325 else if (r->typ[
j].ord_typ==
ro_wp64)
4329 for(
l=r->typ[
j].data.wp64.start;
l<=r->typ[
j].data.wp64.end;
l++)
4330 Print(
" %ld",(
long)(r->typ[
j].data.wp64.weights64+
l-r->typ[
j].data.wp64.start));
4336 Print(
"pOrdIndex:%d pCompIndex:%d\n", r->pOrdIndex, r->pCompIndex);
4337 Print(
"OrdSize:%d\n",r->OrdSize);
4338 PrintS(
"--------------------\n");
4339 for(
j=0;
j<r->ExpL_Size;
j++)
4343 Print(
"ordsgn %ld ", r->ordsgn[
j]);
4349 if( (r->VarOffset[
i] & 0xffffff) ==
j )
4350 {
Print(
"v%d at e[%d], bit %d; ",
i,r->VarOffset[
i] & 0xffffff,
4351 r->VarOffset[
i] >>24 ); }
4353 if( r->pCompIndex==
j )
PrintS(
"v0; ");
4354 for(
i=0;
i<r->OrdSize;
i++)
4356 if (r->typ[
i].data.dp.place ==
j)
4358 Print(
"ordrec:%s (start:%d, end:%d) ",TYP[r->typ[
i].ord_typ],
4359 r->typ[
i].data.dp.start, r->typ[
i].data.dp.end);
4363 if (
j==r->pOrdIndex)
4368 Print(
"LexOrder:%d, MixedOrder:%d\n",r->LexOrder, r->MixedOrder);
4370 Print(
"NegWeightL_Size: %d, NegWeightL_Offset: ", r->NegWeightL_Size);
4371 if (r->NegWeightL_Offset==
NULL)
PrintS(
" NULL");
4373 for(
j = 0;
j < r->NegWeightL_Size;
j++)
4374 Print(
" [%d]: %d ",
j, r->NegWeightL_Offset[
j]);
4385 Print(
"p_Spec : %s, %s, %s\n", field, length, ord);
4387 for (
i=0;
i<(int) (
sizeof(
p_Procs_s)/
sizeof(
void*));
i++)
4389 Print(
" %s,\n", ((
char**) &proc_names)[
i]);
4395#define pFDeg_CASE(A) if(r->pFDeg == A) PrintS( "" #A "" )
4401 Print(
"(%p)", r->pFDeg);
4404 Print(
"pLDeg : (%p)", r->pLDeg);
4416 else Print(
"%p\n",r->p_Setm);
4426 Print(
"\nexp[0..%d]\n",r->ExpL_Size-1);
4427 for(
i=0;
i<r->ExpL_Size;
i++)
4431 for(
i=1;
i<=r->N;
i++)
Print(
" v%d:%ld",
i,p_GetExp(
p,
i, r));
4435 if (
j==0) {
PrintS(
"...\n");
break; }
4444 Print(
"\nexp[0..%d]\n",
R->ExpL_Size - 1);
4445 for(
int i = 0;
i <
R->ExpL_Size;
i++)
4449 for(
int i = 1;
i <=
R->N;
i++)
Print(
" v%d:%5ld",
i, p_GetExp(
p,
i,
R));
4464 r->typ[1].data.syzcomp.Components = currComponents;
4472 *currComponents = r->typ[1].data.syzcomp.Components;
4482 r->typ[1].data.syzcomp.length = length;
4492 *length = r->typ[1].data.syzcomp.length;
4534 WarnS(
"rAssure_SyzComp: input ring has an IS-ordering!");
4545 int ** wvhdl =(
int **)
omAlloc0((
i+1)*
sizeof(
int**));
4548 res->order[
j]=r->order[
j-1];
4549 res->block0[
j]=r->block0[
j-1];
4550 res->block1[
j]=r->block1[
j-1];
4551 if (r->wvhdl[
j-1] !=
NULL)
4557 int l=r->block1[
j-1]-r->block0[
j-1]+1;
4562 l+=r->wvhdl[
j-1][r->block1[
j-1]-r->block0[
j-1]+1]+1;
4565 memcpy(wvhdl[
j],r->wvhdl[
j-1],
l*
sizeof(
int));
4578 if (rIsPluralRing(r))
4583 WarnS(
"error in nc_rComplete");
4587 assume(rIsPluralRing(r) == rIsPluralRing(
res));
4593 if (r->qideal!=
NULL)
4598 if( rIsPluralRing(
res) )
4611 assume(rIsPluralRing(
res) == rIsPluralRing(old_ring));
4612 assume(rIsSCA(
res) == rIsSCA(old_ring));
4613 assume(ncRingType(
res) == ncRingType(old_ring));
4623 pos=r->VarL_LowIndex;
4628 for(
int i=r->OrdSize-1;
i>=0;
i--)
4630 if ((r->typ[
i].ord_typ==
ro_dp)
4631 && (r->typ[
i].data.dp.start==1)
4632 && (r->typ[
i].data.dp.end==r->N))
4634 pos=r->typ[
i].data.dp.place;
4653 res->ExpL_Size=r->ExpL_Size+1;
4657 for(
j=0;
j<r->CmpL_Size;
j++)
4659 res->ordsgn[
j] = r->ordsgn[
j];
4661 res->OrdSize=r->OrdSize+1;
4666 memcpy(
res->typ,r->typ,r->OrdSize*
sizeof(
sro_ord));
4670 res->typ[
res->OrdSize-1].data.dp.start=1;
4671 res->typ[
res->OrdSize-1].data.dp.end=
res->N;
4672 res->typ[
res->OrdSize-1].data.dp.place=
res->ExpL_Size-1;
4673 pos=
res->ExpL_Size-1;
4684 if (rIsPluralRing(r))
4689 WarnS(
"error in nc_rComplete");
4695 if (r->qideal!=
NULL)
4699 if (rIsPluralRing(
res))
4709 assume(rIsPluralRing(
res) == rIsPluralRing(r));
4711 assume(ncRingType(
res) == ncRingType(r));
4725 if (r->order[
i] == 0)
4734 new_r->wvhdl=(
int **)
omAlloc0(
i *
sizeof(
int *));
4736 new_r->block0 = (
int *)
omAlloc0(
i *
sizeof(
int));
4737 new_r->block1 = (
int *)
omAlloc0(
i *
sizeof(
int));
4739 memcpy(new_r->block0,r->block0,(
i-1) *
sizeof(
int));
4740 memcpy(new_r->block1,r->block1,(
i-1) *
sizeof(
int));
4741 for (
int j=0;
j<=last_block;
j++)
4743 if (r->wvhdl[
j]!=
NULL)
4746 new_r->wvhdl[
j] = (
int*)
omMemDup(r->wvhdl[
j]);
4749 int l=r->block1[
j]-r->block0[
j]+1;
4754 l+=r->wvhdl[
j][r->block1[
j]-r->block0[
j]+1]+1;
4756 new_r->wvhdl[
j]=(
int*)
omalloc(
l*
sizeof(
int));
4757 memcpy(new_r->wvhdl[
j],r->wvhdl[
j],
l*
sizeof(
int));
4771 if (rIsPluralRing(r))
4776 WarnS(
"error in nc_rComplete");
4780 assume(rIsPluralRing(r) == rIsPluralRing(new_r));
4788 int last_block = rBlocks(r) - 2;
4795 for (
i=0;
i< last_block;
i++)
4806 for (
i=c_pos+1;
i<=last_block;
i++)
4808 new_r->order[
i-1] = new_r->order[
i];
4809 new_r->block0[
i-1] = new_r->block0[
i];
4810 new_r->block1[
i-1] = new_r->block1[
i];
4811 new_r->wvhdl[
i-1] = new_r->wvhdl[
i];
4813 new_r->order[last_block] = r->order[c_pos];
4814 new_r->block0[last_block] = r->block0[c_pos];
4815 new_r->block1[last_block] = r->block1[c_pos];
4816 new_r->wvhdl[last_block] = r->wvhdl[c_pos];
4822 if (rIsPluralRing(r))
4827 WarnS(
"error in nc_rComplete");
4831 assume(rIsPluralRing(r) == rIsPluralRing(new_r));
4852 if (new_r_1 != new_r && new_r_1 != old_r)
rDelete(new_r_1);
4856 if (rIsPluralRing(old_r))
4861 WarnS(
"error in nc_rComplete");
4868 if (old_r->qideal !=
NULL)
4870 new_r->qideal =
idrCopyR(old_r->qideal, old_r, new_r);
4874 if( rIsPluralRing(old_r) )
4878 WarnS(
"error in nc_SetupQuotient");
4885 assume(rIsPluralRing(new_r) == rIsPluralRing(old_r));
4886 assume(rIsSCA(new_r) == rIsSCA(old_r));
4887 assume(ncRingType(new_r) == ncRingType(old_r));
4898 int r_blocks = rBlocks(r);
4903 if ((r_blocks == 3) &&
4904 (r->order[0] == b1) &&
4905 (r->order[1] == b2) &&
4918 res->block1[1] = r->N;
4923 res->block1[0] = r->N;
4928 if (rIsPluralRing(r))
4933 WarnS(
"error in nc_rComplete");
4944 int r_blocks = rBlocks(r);
4946 if ((r_blocks == 3) &&
4952 for(
int i=0;
i<r->N;
i++)
4954 if ((*
w)[
i]!=r->wvhdl[0][
i]) { ok=
FALSE;
break;}
4966 res->block1[1] = r->N;
4967 res->wvhdl[0]=(
int*)
omAlloc(r->N*
sizeof(
int));
4968 for(
int i=0;
i<r->N;
i++)
4970 r->wvhdl[0][
i]=(*w)[
i];
4975 if (rIsPluralRing(r))
4980 WarnS(
"error in nc_rComplete");
4993 Print(
"rAssure_InducedSchreyerOrdering(r, complete = %d, sgn = %d): r: \n", complete,
sgn);
5010 int ** wvhdl =(
int **)
omAlloc0((n+2)*
sizeof(
int**));
5018 res->block0[
j] =
res->block1[
j] = 0;
5022 for(
int i = 0; (
i <= n) && (r->order[
i] != 0);
i++,
j++)
5024 res->order [
j] = r->order [
i];
5025 res->block0[
j] = r->block0[
i];
5026 res->block1[
j] = r->block1[
i];
5028 if (r->wvhdl[
i] !=
NULL)
5034 int l=(r->block1[
i]-r->block0[
i]+1);
5039 l+=r->wvhdl[
i][r->block1[
i]-r->block0[
i]+1]+1;
5042 memcpy(wvhdl[
j],r->wvhdl[
i],
l*
sizeof(
int));
5069 if (rIsPluralRing(r))
5074 WarnS(
"error in nc_rComplete");
5078 assume(rIsPluralRing(r) == rIsPluralRing(
res));
5086 if (r->qideal!=
NULL)
5093 if( rIsPluralRing(
res) )
5105 assume(rIsPluralRing(
res) == rIsPluralRing(old_ring));
5106 assume(rIsSCA(
res) == rIsSCA(old_ring));
5107 assume(ncRingType(
res) == ncRingType(old_ring));
5148 Print(
"rIsIS(p: %d)\nF:",
p);
5159 for(
int pos = 0; pos < r->OrdSize; pos++ )
5160 if( r->typ[pos].ord_typ ==
ro_is)
5182 dReportError(
"Error: WRONG USE of rSetISReference: wrong ring! (typ == NULL)");
5191 dReportError(
"Error: WRONG USE of rSetISReference: specified ordering block was not found!!!" );
5196 if(
i != r->typ[pos].data.is.limit )
5197 Print(
"Changing record on pos: %d\nOld limit: %d --->> New Limit: %d\n", pos, r->typ[pos].data.is.limit,
i);
5200 const ideal FF =
idrHeadR(F, r, r);
5203 if( r->typ[pos].data.is.F !=
NULL)
5206 PrintS(
"Deleting old reference set F... \n");
5209 r->typ[pos].data.is.F =
NULL;
5214 r->typ[pos].data.is.F = FF;
5216 r->typ[pos].data.is.limit =
i;
5240 if ((r->typ!=
NULL) && (r->typ[0].ord_typ==
ro_syz))
5242 r->block0[0]=r->block1[0] =
k;
5243 if(
k == r->typ[0].data.syz.limit )
5247 if (r->typ[0].data.syz.limit == 0)
5249 r->typ[0].data.syz.syz_index = (
int*)
omAlloc0((
k+1)*
sizeof(
int));
5250 r->typ[0].data.syz.syz_index[0] = 0;
5251 r->typ[0].data.syz.curr_index = 1;
5255 r->typ[0].data.syz.syz_index = (
int*)
5257 (r->typ[0].data.syz.limit+1)*
sizeof(
int),
5260 for (
i=r->typ[0].data.syz.limit + 1;
i<=
k;
i++)
5262 r->typ[0].data.syz.syz_index[
i] =
5263 r->typ[0].data.syz.curr_index;
5265 if(
k < r->typ[0].data.syz.limit)
5268 Warn(
"rSetSyzComp called with smaller limit (%d) as before (%d)",
k, r->typ[0].data.syz.limit);
5270 r->typ[0].data.syz.curr_index = 1 + r->typ[0].data.syz.syz_index[
k];
5274 r->typ[0].data.syz.limit =
k;
5275 r->typ[0].data.syz.curr_index++;
5284 Warn(
"rSetSyzComp(%d) in an IS ring! Be careful!",
k);
5289 r->block0[0] = r->block1[0] =
k;
5304 if ((r->typ!=
NULL) && (r->typ[0].ord_typ==
ro_syz) &&
5305 r->typ[0].data.syz.limit > 0 &&
i > 0)
5309 for (
j=0;
j<r->typ[0].data.syz.limit;
j++)
5311 if (r->typ[0].data.syz.syz_index[
j] ==
i &&
5312 r->typ[0].data.syz.syz_index[
j+1] !=
i)
5314 assume(r->typ[0].data.syz.syz_index[
j+1] ==
i+1);
5318 return r->typ[0].data.syz.limit;
5323 WarnS(
"rGetMaxSyzComp: order c");
5332 int lb = rBlocks(r) - 2;
5338 if ((r->order[0]==
ringorder_dp) &&(r->block0[0]==1) &&(r->block1[0]==r->N))
5341 && ((r->order[1]==
ringorder_dp) &&(r->block0[1]==1) &&(r->block1[1]==r->N)))
5348 if ((r->order[0]==
ringorder_Dp) &&(r->block0[0]==1) &&(r->block1[0]==r->N))
5351 && ((r->order[1]==
ringorder_Dp) &&(r->block0[1]==1) &&(r->block1[1]==r->N)))
5358 if ((r->order[0]==
ringorder_lp) &&(r->block0[0]==1) &&(r->block1[0]==r->N))
5361 && ((r->order[1]==
ringorder_lp) &&(r->block0[1]==1) &&(r->block1[1]==r->N)))
5371 while((r->typ[
i].ord_typ!=
ro_wp64) && (r->typ[
i].ord_typ>0))
i++;
5373 return r->typ[
i].data.wp64.weights64;
5381 memcpy(r->typ[0].data.wp64.weights64,wv,r->N*
sizeof(
int64));
5392 for(
int k=
size;
k>pos;
k--) r->wvhdl[
k]=r->wvhdl[
k-1];
5398static int rReallocM1(ring r,
int size,
int pos)
5404 for(
int k=pos+1;
k<
size;
k++) r->wvhdl[
k]=r->wvhdl[
k+1];
5414 for(
int j=0;
j<=i2;
j++)
5422#define rOppVar(R,I) (rVar(R)+1-I)
5440 if (src->qideal !=
NULL)
5447 int i2 = (rVar(r)-1)/2;
5448 for(
i=i2;
i>=0;
i--)
5454 p = r->names[rVar(r)-1-
i];
5455 r->names[rVar(r)-1-
i] = r->names[
i];
5471 for (
i=rVar(r)-1;
i>=0;
i--)
5473 char *
p=r->names[
i];
5474 if(isupper(*
p)) *
p = tolower(*
p);
5475 else *
p = toupper(*
p);
5523 if ( ! rIsLPRing(src) )
5526 for(
i=0; src->order[
i]!=0;
i++)
5528 switch (src->order[
i])
5533 r->order[
j]=src->order[
i];
5537 r->block0[
j]=
rOppVar(r, src->block1[
i]);
5538 r->block1[
j]=
rOppVar(r, src->block0[
i]);
5542 r->block0[
j]=
rOppVar(r, src->block1[
i]);
5543 r->block1[
j]=
rOppVar(r, src->block0[
i]);
5549 r->block0[
j]=
rOppVar(r, src->block1[
i]);
5550 r->block1[
j]=
rOppVar(r, src->block0[
i]);
5551 r->wvhdl[
j]=(
int*)
omAlloc((r->block1[
j]-r->block0[
j]+1)*
sizeof(
int));
5552 for(
int k=r->block0[
j];
k<=r->block1[
j];
k++)
5553 r->wvhdl[
j][
k-r->block0[
j]]=1;
5556 r->block0[
j]=
rOppVar(r, src->block1[
i]);
5557 r->block1[
j]=
rOppVar(r, src->block0[
i]);
5565 r->block0[
j]=
rOppVar(r, src->block1[
i]);
5566 r->block1[
j]=
rOppVar(r, src->block0[
i]);
5567 r->wvhdl[
j]=(
int*)
omAlloc((r->block1[
j]-r->block0[
j]+1)*
sizeof(
int));
5568 for(
int k=r->block0[
j];
k<=r->block1[
j];
k++)
5569 r->wvhdl[
j][
k-r->block0[
j]]=1;
5572 r->block0[
j]=
rOppVar(r, src->block1[
i]);
5573 r->block1[
j]=
rOppVar(r, src->block0[
i]);
5581 r->block0[
j]=
rOppVar(r, src->block1[
i]);
5582 r->block1[
j]=
rOppVar(r, src->block0[
i]);
5583 r->wvhdl[
j]=r->wvhdl[
j+1]; r->wvhdl[
j+1]=
NULL;
5587 r->block0[
j]=
rOppVar(r, src->block1[
i]);
5588 r->block1[
j]=
rOppVar(r, src->block0[
i]);
5596 r->block0[
j]=
rOppVar(r, src->block1[
i]);
5597 r->block1[
j]=
rOppVar(r, src->block0[
i]);
5598 r->wvhdl[
j]=r->wvhdl[
j+1]; r->wvhdl[
j+1]=
NULL;
5602 r->block0[
j]=
rOppVar(r, src->block1[
i]);
5603 r->block1[
j]=
rOppVar(r, src->block0[
i]);
5610 r->block0[
j]=
rOppVar(r, src->block1[
i]);
5611 r->block1[
j]=
rOppVar(r, src->block0[
i]);
5612 int n=r->block1[
j]-r->block0[
j];
5614 for (
int nn=0; nn<=n; nn++)
5623 r->block0[
j]=
rOppVar(r, src->block1[
i]);
5624 r->block1[
j]=
rOppVar(r, src->block0[
i]);
5669 for(
i=0; src->order[
i]!=0;
i++)
5671 switch (src->order[
i])
5676 r->order[
j]=src->order[
i];
5680 r->block0[
j]=
rOppVar(r, src->block1[
i]);
5681 r->block1[
j]=
rOppVar(r, src->block0[
i]);
5685 r->block0[
j]=
rOppVar(r, src->block1[
i]);
5686 r->block1[
j]=
rOppVar(r, src->block0[
i]);
5691 r->block0[
j]=
rOppVar(r, src->block1[
i]);
5692 r->block1[
j]=
rOppVar(r, src->block0[
i]);
5698 r->block0[
j]=
rOppVar(r, src->block1[
i]);
5699 r->block1[
j]=
rOppVar(r, src->block0[
i]);
5740 if (rIsPluralRing(src))
5744 int *perm = (
int *)
omAlloc0((rVar(r)+1)*
sizeof(
int));
5745 int *par_perm =
NULL;
5746 nMapFunc nMap = n_SetMap(src->cf,r->cf);
5748 for(
i=1;
i<=r->N;
i++)
5756 for (
i=1;
i< rVar(r);
i++)
5758 for (
j=
i+1;
j<=rVar(r);
j++)
5764 MATELEM(C,nj,ni) =
p_PermPoly(
MATELEM(src->GetNC()->C,
i,
j),perm,src,r, nMap,par_perm,rPar(src));
5767 MATELEM(
D,nj,ni) =
p_PermPoly(
MATELEM(src->GetNC()->D,
i,
j),perm,src,r, nMap,par_perm,rPar(src));
5775 WarnS(
"Error initializing non-commutative multiplication!");
5783 assume( r->GetNC()->IsSkewConstant == src->GetNC()->IsSkewConstant);
5790 if (src->qideal !=
NULL)
5793 r->qideal =
idOppose(src, src->qideal, r);
5795 r->qideal =
id_Copy(src->qideal, r);
5799 if( rIsPluralRing(r) )
5811 if( rIsPluralRing(r) )
5812 assume( ncRingType(r) == ncRingType(src) );
5825 int stat =
rSum(
R, Ropp, Renv);
5827 WarnS(
"Error in rEnvelope at rSum");
5843 assume(!rIsPluralRing(dest));
5845 if (!rIsPluralRing(src))
5850 const int N = dest->N;
5859 const ring srcBase = src;
5861 assume( n_SetMap(srcBase->cf,dest->cf) == n_SetMap(dest->cf,dest->cf) );
5866 matrix C0 = src->GetNC()->C;
5867 matrix D0 = src->GetNC()->D;
5870 for (
int i = 1;
i <
N;
i++)
5872 for (
int j =
i + 1;
j <=
N;
j++)
5875 const poly
p =
p_NSet(n, dest);
5906 assume(rIsPluralRing(dest));
5914 p_SetExp(
p, varIndex, 1, r);
5937 Werror(
"n_IsParam: IsParam is not to be used for (coeff_type = %d)",getCoeffType(C));
5946 WerrorS(
"only for rings with an ordering of one block");
5963 WerrorS(
"ordering must be dp,Dp,lp,rp,ds,Ds or ls");
5966 for(
int i=r->N-1;
i>=0;
i--)
5968 if (strcmp(r->names[
i],
v)==0)
5970 Werror(
"duplicate variable name >>%s<<",
v);
5976 #ifdef HAVE_SHIFTBBA
5979 R->isLPring=r->isLPring+1;
5980 R->N=((r->N)/r->isLPring)+r->N;
5984 for(
int b=0;
b<((r->N)/r->isLPring);
b++)
5987 for(
int i=
R->isLPring-1;
i>0;
i--)
5988 names[
i+
b*
R->isLPring]=
R->names[
i-1+
b*r->isLPring];
5993 for(
int b=0;
b<((r->N)/r->isLPring);
b++)
5996 for(
int i=
R->isLPring-2;
i>=0;
i--)
5997 names[
i+
b*
R->isLPring]=
R->names[
i+
b*r->isLPring];
6009 for(
int i=
R->N-1;
i>0;
i--) names[
i]=
R->names[
i-1];
6014 for(
int i=
R->N-2;
i>=0;
i--) names[
i]=
R->names[
i];
6028 WerrorS(
"only for rings with an ordering of one block");
6045 WerrorS(
"ordering must be dp,Dp,lp,rp,ds,Ds or ls");
6052 if (strcmp(
R->names[
i],
v)==0)
6056 for(
int j=
i;
j<
R->N;
j++)
R->names[
j]=
R->names[
j+1];
int sgn(const Rational &a)
int naIsParam(number m, const coeffs cf)
if m == var(i)/1 => return i,
const CanonicalForm CFMap CFMap & N
Coefficient rings, fields and other domains suitable for Singular polynomials.
static FORCE_INLINE void n_CoeffWrite(const coeffs r, BOOLEAN details=TRUE)
output the coeff description
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
@ n_R
single prescision (6,6) real numbers
@ n_polyExt
used to represent polys as coefficients
@ n_Q
rational (GMP) numbers
@ n_Znm
only used if HAVE_RINGS is defined
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
@ n_Zn
only used if HAVE_RINGS is defined
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
static FORCE_INLINE char * nCoeffString(const coeffs cf)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar.
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
number(*) nMapFunc(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
void nKillChar(coeffs r)
undo all initialisations
const CanonicalForm int s
const Variable & v
< [in] a sqrfree bivariate poly
void WerrorS(const char *s)
ideal id_Copy(ideal h1, const ring r)
copy an ideal
ideal idOppose(ring Rop_src, ideal I, const ring Rop_dst)
opposes a module I from Rop to currRing(dst)
bool nc_rCopy(ring res, const ring r, bool bSetupQuotient)
bool nc_SetupQuotient(ring rGR, const ring rG=NULL, bool bCopy=false)
BOOLEAN nc_CallPlural(matrix cc, matrix dd, poly cn, poly dn, ring r, bool bSetupQuotient, bool bCopyInput, bool bBeQuiet, ring curr, bool dummy_ring=false)
returns TRUE if there were errors analyze inputs, check them for consistency detects nc_type,...
void nc_rKill(ring r)
complete destructor
#define UPMATELEM(i, j, nVar)
bool sca_Force(ring rGR, int b, int e)
void maFindPerm(char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch)
void mp_Delete(matrix *a, const ring r)
matrix mpNew(int r, int c)
create a r x c zero-matrix
void iiWriteMatrix(matrix im, const char *n, int dim, const ring r, int spaces)
set spaces to zero by default
#define MATELEM(mat, i, j)
1-based access to matrix
STATIC_VAR unsigned add[]
int dReportError(const char *fmt,...)
gmp_float sqrt(const gmp_float &a)
The main handler for Singular numbers which are suitable for Singular polynomials.
#define omFreeSize(addr, size)
#define omCheckAddr(addr)
#define omReallocSize(addr, o_size, size)
#define omCheckAddrSize(addr, size)
#define omFreeBin(addr, bin)
#define omcheckAddrSize(addr, size)
#define omfreeSize(addr, size)
#define omGetSpecBin(size)
#define omUnGetSpecBin(bin_ptr)
void p_ProcsSet(ring r, p_Procs_s *p_Procs)
void p_Debug_GetProcNames(const ring r, p_Procs_s *p_Procs)
void p_Debug_GetSpecNames(const ring r, const char *&field, const char *&length, const char *&ord)
void p_Setm_WFirstTotalDegree(poly p, const ring r)
long pLDegb(poly p, int *l, const ring r)
long pLDeg1_Totaldegree(poly p, int *l, const ring r)
long p_WFirstTotalDegree(poly p, const ring r)
long pLDeg1_WFirstTotalDegree(poly p, int *l, const ring r)
long pLDeg1c_WFirstTotalDegree(poly p, int *l, const ring r)
void p_Setm_Dummy(poly p, const ring r)
void p_Setm_TotalDegree(poly p, const ring r)
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
long pLDeg1c_Deg(poly p, int *l, const ring r)
long pLDeg1(poly p, int *l, const ring r)
poly p_PermPoly(poly p, const int *perm, const ring oldRing, const ring dst, nMapFunc nMap, const int *par_perm, int OldPar, BOOLEAN use_mult)
long pLDeg1_Deg(poly p, int *l, const ring r)
long p_WTotaldegree(poly p, const ring r)
p_SetmProc p_GetSetmProc(const ring r)
void p_Setm_General(poly p, const ring r)
long pLDeg1c(poly p, int *l, const ring r)
long pLDeg1c_Totaldegree(poly p, int *l, const ring r)
long pLDeg0c(poly p, int *l, const ring r)
long pLDeg0(poly p, int *l, const ring r)
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
long p_Deg(poly a, const ring r)
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
void p_Write(poly p, ring lmRing, ring tailRing)
void p_Write0(poly p, ring lmRing, ring tailRing)
poly prCopyR(poly p, ring src_r, ring dest_r)
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
ideal idrCopyR_NoSort(ideal id, ring src_r, ring dest_r)
ideal idrHeadR(ideal id, ring r, ring dest_r)
Copy leading terms of id[i] via prHeeadR into dest_r.
void StringSetS(const char *st)
void StringAppendS(const char *st)
void PrintS(const char *s)
void Werror(const char *fmt,...)
static void rSetNegWeight(ring r)
BOOLEAN rOrd_SetCompRequiresSetm(const ring r)
return TRUE if p_SetComp requires p_Setm
static void rO_ISSuffix(int &place, int &bitplace, int &prev_ord, long *o, int N, int *v, sro_ord *tmp_typ, int &typ_i, int sgn)
int rSum(ring r1, ring r2, ring &sum)
ring rAssure_TDeg(ring r, int &pos)
void rWrite(ring r, BOOLEAN details)
ring rAssure_InducedSchreyerOrdering(const ring r, BOOLEAN complete, int sgn)
static ring rAssure_Global(rRingOrder_t b1, rRingOrder_t b2, const ring r)
BOOLEAN rOrder_is_WeightedOrdering(rRingOrder_t order)
void rGetSComps(int **currComponents, long **currShiftedComponents, int *length, ring r)
BOOLEAN rRing_ord_pure_Dp(const ring r)
static void rNChangeSComps(int *currComponents, long *currShiftedComponents, ring r)
ring rModifyRing_Wp(ring r, int *weights)
construct Wp, C ring
BOOLEAN rOrder_is_DegOrdering(const rRingOrder_t order)
BOOLEAN rHasSimpleOrderAA(ring r)
void rSetWeightVec(ring r, int64 *wv)
BOOLEAN rHasBlockOrder(const ring r)
static void rSetOption(ring r)
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...
int r_IsRingVar(const char *n, char **names, int N)
int rGetISPos(const int p, const ring r)
Finds p^th IS ordering, and returns its position in r->typ[] returns -1 if something went wrong!...
static void rNGetSComps(int **currComponents, long **currShiftedComponents, ring r)
static void rO_WDegree64(int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct, int64 *weights)
BOOLEAN rHasSimpleLexOrder(const ring r)
returns TRUE, if simple lp or ls ordering
void p_SetGlobals(const ring r, BOOLEAN complete)
set all properties of a new ring - also called by rComplete
ring rAssure_SyzComp(const ring r, BOOLEAN complete)
BOOLEAN nc_rComplete(const ring src, ring dest, bool bSetupQuotient)
void p_DebugPrint(poly p, const ring r)
void rKillModifiedRing(ring r)
BOOLEAN rRing_ord_pure_dp(const ring r)
static void rSetVarL(ring r)
set r->VarL_Size, r->VarL_Offset, r->VarL_LowIndex
static void rO_LexVars(int &place, int &bitplace, int start, int end, int &prev_ord, long *o, int *v, int bits, int opt_var)
const char * rSimpleOrdStr(int ord)
ring rAssure_Wp_C(const ring r, intvec *w)
BOOLEAN rOrd_is_MixedDegree_Ordering(ring r)
static void rDBChangeSComps(int *currComponents, long *currShiftedComponents, int length, ring r)
ring rAssure_c_dp(const ring r)
static void rSetOutParams(ring r)
static void rSetDegStuff(ring r)
static void rDBGetSComps(int **currComponents, long **currShiftedComponents, int *length, ring r)
rOrderType_t rGetOrderType(ring r)
int rTypeOfMatrixOrder(const intvec *order)
ring nc_rCreateNCcomm_rCopy(ring r)
static void rOppWeight(int *w, int l)
static void rO_WDegree_neg(int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct, int *weights)
void rKillModified_Wp_Ring(ring r)
ring rMinusVar(const ring r, char *v)
undo rPlusVar
BOOLEAN rRing_has_CompLastBlock(const ring r)
ring rAssure_Dp_C(const ring r)
ring rCopy0AndAddA(const ring r, int64vec *wv64, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
static void rO_Syzcomp(int &place, int &bitplace, int &prev_ord, long *o, sro_ord &ord_struct)
BOOLEAN rOrd_is_Totaldegree_Ordering(const ring r)
ring rModifyRing(ring r, BOOLEAN omit_degree, BOOLEAN try_omit_comp, unsigned long exp_limit)
ring rAssure_SyzOrder(const ring r, BOOLEAN complete)
static void rO_TDegree(int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct)
ring rAssure_C_dp(const ring r)
BOOLEAN rHasSimpleOrder(const ring r)
int rGetMaxSyzComp(int i, const ring r)
return the max-comonent wchich has syzIndex i Assume: i<= syzIndex_limit
BOOLEAN rSetISReference(const ring r, const ideal F, const int i, const int p)
Changes r by setting induced ordering parameters: limit and reference leading terms F belong to r,...
ring rAssure_HasComp(const ring r)
BOOLEAN rOrd_is_Ds(const ring r)
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
static void rO_WMDegree(int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct, int *weights)
static void rO_Syz(int &place, int &bitplace, int &prev_ord, int syz_comp, long *o, sro_ord &ord_struct)
BOOLEAN rHas_c_Ordering(const ring r)
static int rRealloc1(ring r, int size, int pos)
static unsigned long rGetExpSize(unsigned long bitmask, int &bits)
void rDebugPrint(const ring r)
static void rCheckOrdSgn(ring r, int i)
BOOLEAN rRing_ord_pure_lp(const ring r)
poly rGetVar(const int varIndex, const ring r)
BOOLEAN rOrd_is_dp(const ring r)
ring rModifyRing_Simple(ring r, BOOLEAN ommit_degree, BOOLEAN ommit_comp, unsigned long exp_limit, BOOLEAN &simple)
void rChangeSComps(int *currComponents, long *currShiftedComponents, int length, ring r)
static void m_DebugPrint(const poly p, const ring R)
debug-print monomial poly/vector p, assuming that it lives in the ring R
static unsigned long rGetDivMask(int bits)
get r->divmask depending on bits per exponent
BOOLEAN rSamePolyRep(ring r1, ring r2)
returns TRUE, if r1 and r2 represents the monomials in the same way FALSE, otherwise this is an analo...
ring rAssure_SyzComp_CompLastBlock(const ring r)
makes sure that c/C ordering is last ordering and SyzIndex is first
char * rCharStr(const ring r)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar.
static void rOptimizeLDeg(ring r)
BOOLEAN rCheckIV(const intvec *iv)
rRingOrder_t rOrderName(char *ordername)
void rDelete(ring r)
unconditionally deletes fields in r
ring rDefault(const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl, unsigned long bitmask)
static void rRightAdjustVarOffset(ring r)
right-adjust r->VarOffset
ring rPlusVar(const ring r, char *v, int left)
K[x],"y" -> K[x,y] resp. K[y,x].
ring rAssure_CompLastBlock(ring r, BOOLEAN complete)
makes sure that c/C ordering is last ordering
static void rO_ISPrefix(int &place, int &bitplace, int &prev_ord, long *o, int N, int *v, sro_ord &ord_struct)
static void rO_Align(int &place, int &bitplace)
ring rAssure_dp_S(const ring r)
BOOLEAN rOrd_is_ds(const ring r)
static void rO_TDegree_neg(int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct)
static void rSetFirstWv(ring r, int i, rRingOrder_t *order, int *block0, int *block1, int **wvhdl)
BOOLEAN rEqual(ring r1, ring r2, BOOLEAN qr)
returns TRUE, if r1 equals r2 FALSE, otherwise Equality is determined componentwise,...
int rSumInternal(ring r1, ring r2, ring &sum, BOOLEAN vartest, BOOLEAN dp_dp)
returns -1 for not compatible, 1 for compatible (and sum) dp_dp:0: block ordering,...
void rSetSyzComp(int k, const ring r)
static const char *const ringorder_name[]
static void rO_WDegree(int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct, int *weights)
BOOLEAN rOrd_is_WeightedDegree_Ordering(const ring r)
int n_IsParam(const number m, const ring r)
TODO: rewrite somehow...
int64 * rGetWeightVec(const ring r)
static void rO_LexVars_neg(int &place, int &bitplace, int start, int end, int &prev_ord, long *o, int *v, int bits, int opt_var)
ring rAssure_dp_C(const ring r)
BOOLEAN rDBTest(ring r, const char *fn, const int l)
struct p_Procs_s p_Procs_s
@ ringorder_a64
for int64 weights
@ ringorder_aa
for idElimination, like a, except pFDeg, pWeigths ignore it
@ ringorder_is
opposite of ls
@ ringorder_IS
Induced (Schreyer) ordering.
union sro_ord::@006200034235045362245112336324125006204215012002 data
@ rOrderType_CompExp
simple ordering, component has priority
@ rOrderType_Exp
simple ordering, exponent vector has priority component is compatible with exp-vector order
@ rOrderType_General
non-simple ordering as specified by currRing
@ rOrderType_ExpComp
simple ordering, exponent vector has priority component not compatible with exp-vector order
#define rField_is_Ring(R)
ideal SCAQuotient(const ring r)
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
void idShow(const ideal id, const ring lmRing, const ring tailRing, const int debugPrint)
ideal id_SimpleAdd(ideal h1, ideal h2, const ring R)
concat the lists h1 and h2 without zeros
EXTERN_VAR omBin char_ptr_bin
EXTERN_VAR long * currShiftedComponents
int ntIsParam(number m, const coeffs cf)
if m == var(i)/1 => return i,