26# define PLURAL_INTERNAL_DECLARATIONS
101#define freeT(A,v) omFreeSize((ADDRESS)A,(v+1)*sizeof(int))
102#define freeN(A,k) omFreeSize((ADDRESS)A,k*sizeof(number))
151 const poly,
const ring r)
153 poly mc = p_Neg( p_Copy(
m, r), r );
157 int org_p=pLength(
p);
158 int org_q=pLength(q);
160 p = p_Add_q(
p, mmc, r);
162 shorter = pLength(
p)-org_p-org_q;
169 const int,
const ring r)
179poly gnc_p_Minus_mm_Mult_qq_ign(poly
p,
const poly
m, poly q,
int & d1, poly d2,
const ring r, poly &d3)
184 return gnc_p_Minus_mm_Mult_qq(
p,
m, q, d1,
i, t, r);
207 res=p_Add_q(
res, pp_Mult_mm(
pp, qq, r), r);
208 qq=p_LmDeleteAndNext(qq,r);
217 assume( rIsNCRing(rRing) );
237 for( ; pPolyQ!=
NULL; pPolyQ = p_LmDeleteAndNext( pPolyQ, rRing ) )
238 sum += pp_Mult_mm( pPolyP, pPolyQ, rRing);
240 p_Delete( &pPolyP, rRing );
244 for( ; pPolyP!=
NULL; pPolyP = p_LmDeleteAndNext( pPolyP, rRing ) )
247 p_Delete( &pPolyQ, rRing );
256 assume( rIsNCRing(rRing) );
276 for( poly q = pPolyQ; q !=
NULL; q =
pNext(q) )
277 sum += pp_Mult_mm(pPolyP, q, rRing);
316 int *P=(
int *)
omAlloc0((rN+1)*
sizeof(
int));
317 int *
M=(
int *)
omAlloc0((rN+1)*
sizeof(
int));
359 if (side==1)
s=
"gnc_p_Mult_mm";
360 else s=
"gnc_p_mm_Mult";
361 Print(
"%s: exponent mismatch %d and %d\n",
s,expP,expM);
368 cOut=n_Mult(cP,cM,r->cf);
378 n_Delete(&cOut,r->cf);
379 p_SetCompP(
v,expOut,r);
423 int *F=(
int *)
omAlloc0((rN+1)*
sizeof(
int));
424 int *
G=(
int *)
omAlloc0((rN+1)*
sizeof(
int));
426 memcpy(F, F0,(rN+1)*
sizeof(
int));
428 memcpy(
G, G0,(rN+1)*
sizeof(
int));
434 while ((F[iF]==0)&&(iF>=1)) iF--;
445 while ((
G[jG]==0)&&(jG<rN)) jG++;
447 while ((
G[iG]==0)&&(iG>1)) iG--;
454 {
for(
int ii=rN;ii>0;ii--) F[ii]+=
G[ii]; }
462 number cff=n_Init(1,r->cf);
468 if (r->GetNC()->IsSkewConstant==1)
471 for(
j=jG;
j<=iG;
j++)
476 for(
i=
j+1;
i<=iF;
i++)
478 cpower = cpower + F[
i];
480 cpower = cpower*
G[
j];
481 tpower = tpower + cpower;
484 cff = n_Copy(pGetCoeff(
MATELEM(r->GetNC()->COM,1,2)),r->cf);
485 n_Power(cff,tpower,&tmp_num, r->cf);
486 n_Delete(&cff,r->cf);
491 number totcff=n_Init(1,r->cf);
492 for(
j=jG;
j<=iG;
j++)
497 for(
i=
j+1;
i<=iF;
i++)
502 cff = n_Copy(pGetCoeff(
MATELEM(r->GetNC()->COM,
j,
i)),r->cf);
503 n_Power(cff,cpower,&tmp_num, r->cf);
504 cff = n_Mult(totcff,tmp_num, r->cf);
505 n_Delete(&totcff, r->cf);
506 n_Delete(&tmp_num, r->cf);
507 totcff = n_Copy(cff,r->cf);
508 n_Delete(&cff,r->cf);
515 {
for(
int ii=rN;ii>0;ii--) F[ii]+=
G[ii]; }
518 p_SetCoeff(out,cff,r);
537 int *Prv=(
int *)
omAlloc0((rN+1)*
sizeof(
int));
538 int *Nxt=(
int *)
omAlloc0((rN+1)*
sizeof(
int));
541 int cnt=0;
int cnf=0;
546 Prv[
i]=F[
i]; Nxt[
i]=0;
550 if (cnf==0)
freeT(Prv,rN);
552 for (
i=jG+1;
i<=rN;
i++)
576 number *c=(number *)
omAlloc0((rN+1)*
sizeof(number));
577 c[0]=n_Init(1,r->cf);
581 int *U=(
int *)
omAlloc0((rN+1)*
sizeof(
int));
583 for (
i=jG;
i<=rN;
i++) U[
i]=Nxt[
i]+
G[
i];
598 c[cnt]=n_Mult(c[cnt-1],pGetCoeff(
w),r->cf);
633 out=p_Add_q(out,Rout,r);
653 p_SetCoeff(Rout,c[cnt-1],r);
654 out=p_Add_q(out,Rout,r);
661 p_SetExpV(Rout,Prv,r);
683 while ((F[iF]==0)&&(iF>0)) iF-- ;
688 p_SetExp(out,jG,bG,r);
694 while ((F[jF]==0)&&(jF<=rN)) jF++;
745 int *Prv=(
int*)
omAlloc0((rN+1)*
sizeof(
int));
746 int *Nxt=(
int*)
omAlloc0((rN+1)*
sizeof(
int));
747 int *lF=(
int *)
omAlloc0((rN+1)*
sizeof(
int));
749 int cnt=0;
int cnf=0;
753 Prv[
i]=F[
i]; Nxt[
i]=0;
762 for (
i=jG+1;
i<=rN;
i++)
765 if (cnf!=0) { Prv[
i]=0;}
784 p_SetExpV(Rout,Prv,r);
812 number *c=(number *)
omAlloc0((cnt+2)*
sizeof(number));
813 c[cnt+1]=n_Init(1,r->cf);
818 int *U=(
int *)
omAlloc0((rN+1)*
sizeof(
int));
822 memcpy(U, Nxt,(rN+1)*
sizeof(
int));
842 c[cnt]=n_Copy(pGetCoeff(
w),r->cf);
887 num=n_Mult(c[cnt+1],c[cnt],r->cf);
888 n_Delete(&c[cnt],r->cf);
891 out=p_Add_q(out,Rout,r);
909 p_SetCoeff(Rout,c[cnt+1],r);
911 out=p_Add_q(out,Rout,r);
922 p_SetExpV(Rout,Prv,r);
937 matrix cMT=r->GetNC()->MT[cMTindex];
939 poly
x=
p_One(r);p_SetExp(
x,
j,1,r);p_Setm(
x,r);
941 poly
y=
p_One(r);p_SetExp(
y,
i,1,r);p_Setm(
y,r);
959 cMT=r->GetNC()->MT[cMTindex];
981 cMT=r->GetNC()->MT[cMTindex];
1015 if( FormulaMultiplier !=
NULL )
1016 PairType = FormulaMultiplier->
GetPair(
j,
i);
1050 p_SetExp(out,
i,a,r);
1051 p_AddExp(out,
j,
b,r);
1060 p_SetExp(out,
i,a,r);
1061 p_AddExp(out,
j,
b,r);
1063 if (n_IsOne(pGetCoeff(
MATELEM(r->GetNC()->COM,
j,
i)),r->cf))
1069 number tmp_number=pGetCoeff(
MATELEM(r->GetNC()->COM,
j,
i));
1070 n_Power(tmp_number,a*
b,&tmp_number, r->cf);
1071 p_SetCoeff(out,tmp_number,r);
1083 if( FormulaMultiplier !=
NULL )
1084 PairType = FormulaMultiplier->
GetPair(
j,
i);
1097 int cMTsize=r->GetNC()->MTsize[vik];
1099 newcMTsize=si_max(a,
b);
1101 if (newcMTsize<=cMTsize)
1104 if (out !=
NULL)
return (out);
1107 if (newcMTsize > cMTsize)
1109 int inM=(((newcMTsize+6)/7)*7);
1110 assume (inM>=newcMTsize);
1115 for (
k=1;
k<=cMTsize;
k++)
1117 for (
m=1;
m<=cMTsize;
m++)
1133 r->GetNC()->MTsize[
UPMATELEM(
j,
i,rN)] = newcMTsize;
1152 poly
x=
p_One(r);p_SetExp(
x,
j,1,r);p_Setm(
x,r);
1153 poly
y=
p_One(r);p_SetExp(
y,
i,1,r);p_Setm(
y,r);
1167 while ( (
MATELEM(cMT,1,toXY)==
NULL) && (toXY>=2)) toXY--;
1168 for (
m=toXY+1;
m<=
b;
m++)
1181 WarnS(
"Error: a=1; MATELEM!=0");
1185 return(p_Copy(
MATELEM(cMT,1,
b),r));
1191 while ( (
MATELEM(cMT,toYX,1)==
NULL) && (toYX>=2)) toYX--;
1192 for (
m=toYX+1;
m<=a;
m++)
1205 WarnS(
"Error: b=1, MATELEM!=0");
1209 return(p_Copy(
MATELEM(cMT,a,1),r));
1215 int dXY=0;
int dYX=0;
1218 int toX=a-1;
int toY=
b-1;
1225 while ( (
MATELEM(cMT,1,toXY)==
NULL) && (toXY>=1)) toXY--;
1231 while ( (
MATELEM(cMT,a,toY)==
NULL) && (toY>=1)) toY--;
1234 while ( (
MATELEM(cMT,toYX,1)==
NULL) && (toYX>=1)) toYX--;
1245 for (
m=toXY+1;
m<=
b;
m++)
1258 WarnS(
"dYX>=dXY,toXY; MATELEM==0");
1265 for (
k=toX+1;
k<=a;
k++)
1278 WarnS(
"dYX>=dXY,toX; MATELEM==0");
1290 for (
m=toYX+1;
m<=a;
m++)
1303 WarnS(
"dYX<dXY,toYX; MATELEM==0");
1310 for (
k=toY+1;
k<=
b;
k++)
1323 WarnS(
"dYX<dXY,toY; MATELEM==0");
1345 assume(p_LmDivisibleBy(p1, p2, r));
1352 dReportError(
"nc_ReduceSpolyOld: different components");
1357 p_ExpVectorDiff(
m,p2,p1,r);
1367 number cG = n_SubringGcd(C, cF, r->cf);
1368 if ( !n_IsOne(cG,r->cf) )
1370 cF = n_Div(cF, cG, r->cf); n_Normalize(cF, r->cf);
1371 C = n_Div(C, cG, r->cf); n_Normalize(C, r->cf);
1375 cF = n_Copy(cF, r->cf);
1376 C = n_Copy(C, r->cf);
1378 n_Delete(&cG,r->cf);
1381 N = p_Add_q(
N, out, r);
1384 if (!n_IsMOne(cF,r->cf))
1386 cF = n_InpNeg(cF,r->cf);
1390 out = p_Add_q(p2,
N,r);
1394 n_Delete(&cF,r->cf);
1401 assume(p_LmDivisibleBy(p1, p2, r));
1406 if ((lCompP1!=lCompP2) && (lCompP1!=0) && (lCompP2!=0))
1409 WerrorS(
"gnc_ReduceSpolyNew: different non-zero components!");
1415 p_ExpVectorDiff(
m, p2, p1, r);
1428 number cG = n_SubringGcd(C, cF, r->cf);
1430 if (!n_IsOne(cG, r->cf))
1432 cF = n_Div(cF, cG, r->cf); n_Normalize(cF, r->cf);
1433 C = n_Div(C, cG, r->cf); n_Normalize(C, r->cf);
1437 cF = n_Copy(cF, r->cf);
1438 C = n_Copy(C, r->cf);
1440 n_Delete(&cG,r->cf);
1449 N = p_Add_q(
N, out, r);
1452 if (!n_IsMOne(cF,r->cf))
1454 cF = n_InpNeg(cF,r->cf);
1458 n_Delete(&cF,r->cf);
1460 out = p_Add_q(p2,
N,r);
1478 dReportError(
"gnc_CreateSpolyOld : different components!");
1489 pL =
p_Lcm(p1,p2,r);
1494 p_ExpVectorDiff(m1,pL,p1,r);
1500 p_ExpVectorDiff(m2,pL,p2,r);
1513 number C = n_SubringGcd(C1,C2,r->cf);
1514 if (!n_IsOne(C,r->cf))
1516 C1=n_Div(C1,C, r->cf);n_Normalize(C1,r->cf);
1517 C2=n_Div(C2,C, r->cf);n_Normalize(C2,r->cf);
1521 C1=n_Copy(C1, r->cf);
1522 C2=n_Copy(C2, r->cf);
1526 p_SetCoeff(m1,C2,r);
1527 if (n_IsMOne(C1,r->cf))
1529 M2=p_Add_q(M1,M2,r);
1533 C1=n_InpNeg(C1,r->cf);
1535 M2=p_Add_q(M1,M2,r);
1536 p_SetCoeff(m2,C1,r);
1539 poly tmp=p_Copy(p1,r);
1540 tmp=p_LmDeleteAndNext(tmp,r);
1543 tmp=p_LmDeleteAndNext(tmp,r);
1544 M2=p_Add_q(M2,M1,r);
1546 M2=p_Add_q(M2,M1,r);
1572 if ((lCompP1!=lCompP2) && (lCompP1!=0) && (lCompP2!=0))
1575 WerrorS(
"gnc_CreateSpolyNew: different non-zero components!");
1591 poly pL =
p_Lcm(p1,p2,r);
1598 p_ExpVectorDiff(m1, pL, p1, r);
1607 p_ExpVectorDiff(m2, pL, p2, r);
1629 WarnS(
"gnc_CreateSpolyNew: wrong monomials!");
1685 WerrorS(
"ERROR in nc_CreateSpoly: result of multiplication is Zero!\n");
1694 number C = n_SubringGcd(C1, C2, r->cf);
1696 if (!n_IsOne(C, r->cf))
1698 C1=n_Div(C1, C, r->cf);n_Normalize(C1,r->cf);
1699 C2=n_Div(C2, C, r->cf);n_Normalize(C2,r->cf);
1703 C1=n_Copy(C1,r->cf);
1704 C2=n_Copy(C2,r->cf);
1709 C1=n_InpNeg(C1,r->cf);
1738 M2=p_Add_q(M1,M2,r);
1753 p_SetCoeff(m1,C2,r);
1754 p_SetCoeff(m2,C1,r);
1778 M2=p_Add_q(M2,M1,r);
1807 M2 = p_Add_q(M2,M1,r);
1840void gnc_ReduceSpolyTail(poly p1, poly q, poly q2, poly spNoether,
const ring r)
1842 poly a1=p_Head(p1,r);
1846 p_ExpVectorDiff(
m,
Q,p1,r);
1857 number MinusOne=n_Init(-1,r->cf);
1858 if (!n_Equal(cQ,MinusOne,r->cf))
1868 n_Delete(&cQ,r->cf);
1869 n_Delete(&MinusOne,r->cf);
1889 if ((lCompP1!=lCompP2) && (lCompP1!=0) && (lCompP2!=0))
1892 WerrorS(
"nc_CreateShortSpoly: wrong module components!");
1900 if ( rIsRatGRing(r))
1903 m =
p_LcmRat(p1, p2, si_max(lCompP1, lCompP2), r);
1917 const ring r =
b->bucket_ring;
1920 if (c!=
NULL) *c=n_Init(1, r->cf);
1930 number n=pGetCoeff(
pp);
1932 if (!n_IsMOne(n, r->cf))
1934 nn=n_InpNeg(n_Invers(n, r->cf), r->cf);
1936 n_Delete(&nn, r->cf);
1938 n_Delete(&n, r->cf);
1950 const ring r =
b->bucket_ring;
1968 if (c!=
NULL) *c=n_Init(1, r->cf);
1982 p_ExpVectorDiff(
m, pLmB,
p, r);
1996 const number n = pGetCoeff(
pp);
1998 if (!n_IsMOne(n, r->cf) )
2001 number nn=n_InpNeg(n_Invers(n, r->cf), r->cf);
2002 number t = n_Mult(nn,pGetCoeff(pLmB), r->cf);
2003 n_Delete(&nn, r->cf);
2005 n_Delete(&t, r->cf);
2012 int l = pLength(
pp);
2031 const ring r =
b->bucket_ring;
2040 if(p_IsConstant(
m,r))
2054 n_Delete(&c2, r->cf);
2058 if (c!=
NULL) *c=ctmp;
2059 else n_Delete(&ctmp, r->cf);
2065 const ring r =
b->bucket_ring;
2075 if(p_IsConstant(
m,r))
2089 ctmp=n_Init(1,r->cf);
2095 n_Delete(&c2, r->cf);
2099 if (c!=
NULL) *c=ctmp;
2100 else n_Delete(&ctmp, r->cf);
2109 if (c!=
NULL) *c=n_Init(1, r->cf);
2111 p_ExpVectorDiff(
m,p_Head(
b, r),
p, r);
2120 number n=pGetCoeff(
pp);
2122 if (!n_IsMOne(n, r->cf))
2124 nn=n_InpNeg(n_Invers(n, r->cf), r->cf);
2125 n =n_Mult(nn,pGetCoeff(
b), r->cf);
2126 n_Delete(&nn, r->cf);
2128 n_Delete(&n, r->cf);
2147 PrintS(
"nc_PolyPolyRedNew(");
2156 if (c!=
NULL) *c=n_Init(1, r->cf);
2167 p_ExpVectorDiff(
m,
b,
p, r);
2194 b = p_LmDeleteAndNext(
b, r);
2196 if( !p_DivisibleBy(
p,
b, r) )
2211 if(
b ==
NULL)
return;
2216 const number n = pGetCoeff(
pp);
2220 if (!n_IsMOne(n, r->cf))
2222 nn=n_InpNeg(n_Invers(n, r->cf), r->cf);
2223 number t = n_Mult(nn, pGetCoeff(
b), r->cf);
2224 n_Delete(&nn, r->cf);
2226 n_Delete(&t, r->cf);
2255 if (!rIsPluralRing(r))
return(
NULL);
2277 coef = n_Mult(pGetCoeff(
p),pGetCoeff(
Q), r->cf);
2281 n_Delete(&coef, r->cf);
2285 p=p_LmDeleteAndNext(
p, r);
2294 if (p_LmIsConstant(m1, r) || p_LmIsConstant(m1, r))
return(
NULL);
2295 if (p_LmCmp(m1,m2, r)==0)
return(
NULL);
2297 int *M1=(
int *)
omAlloc0((rN+1)*
sizeof(
int));
2298 int *M2=(
int *)
omAlloc0((rN+1)*
sizeof(
int));
2299 int *aPREFIX=(
int *)
omAlloc0((rN+1)*
sizeof(
int));
2300 int *aSUFFIX=(
int *)
omAlloc0((rN+1)*
sizeof(
int));
2301 p_GetExpV(m1,M1, r);
2302 p_GetExpV(m2,M2, r);
2322 if (
i<
j) {nMax=
j; nMin=
i;}
else {nMax=
i; nMin=
j;}
2323 if ( (
i==
j) || ((
MATELEM(r->GetNC()->COM,nMin,nMax)!=
NULL) && n_IsOne(pGetCoeff(
MATELEM(r->GetNC()->C,nMin,nMax)), r->cf) ))
2329 if (n_IsOne(pGetCoeff(bres), r->cf))
2331 bres=p_LmDeleteAndNext(bres, r);
2335 nTmp=n_Sub(pGetCoeff(bres),n_Init(1, r->cf), r->cf);
2336 p_SetCoeff(bres,nTmp, r);
2341 if (
i>
j) bres=p_Neg(bres, r);
2346 memcpy(aSUFFIX, M1,(rN+1)*
sizeof(
int));
2347 memcpy(aPREFIX, M1,(rN+1)*
sizeof(
int));
2348 for (
k=1;
k<=
j;
k++) aSUFFIX[
k]=0;
2349 for (
k=
j;
k<=rN;
k++) aPREFIX[
k]=0;
2354 p_SetExpV(prefix,aPREFIX, r);
2356 p_SetExpV(suffix,aSUFFIX, r);
2358 if (!p_LmIsConstant(prefix, r)) bres =
gnc_p_mm_Mult(bres, prefix, r);
2359 if (!p_LmIsConstant(suffix, r)) bres =
gnc_p_Mult_mm(bres, suffix, r);
2360 ares=p_Add_q(ares, bres, r);
2363 p_Delete(&prefix, r);
2364 p_Delete(&suffix, r);
2371 memcpy(aSUFFIX, M2,(rN+1)*
sizeof(
int));
2372 memcpy(aPREFIX, M2,(rN+1)*
sizeof(
int));
2373 for (
k=1;
k<=
i;
k++) aSUFFIX[
k]=0;
2374 for (
k=
i;
k<=rN;
k++) aPREFIX[
k]=0;
2379 p_SetExpV(prefix,aPREFIX, r);
2381 p_SetExpV(suffix,aSUFFIX, r);
2384 if (!p_LmIsConstant(prefix, r)) bres =
gnc_p_mm_Mult(bres, prefix, r);
2385 if (!p_LmIsConstant(suffix, r)) bres =
gnc_p_Mult_mm(bres, suffix, r);
2386 res=p_Add_q(
res, bres, r);
2387 p_Delete(&prefix, r);
2388 p_Delete(&suffix, r);
2405 if ( (a==
b) || !rIsPluralRing(r) )
return(
NULL);
2408 if (a>
b) {
j=
b;
i=a;}
2434 for(t=1;t<=
size;t++)
2443 length = pLength(
p);
2453 totdeg=totdeg+
p_Deg(
p,r);
2456 number ntd = n_Init(totdeg, r->cf);
2457 number nln = n_Init(length, r->cf);
2458 number nres= n_Div(ntd,nln, r->cf);
2459 n_Delete(&ntd, r->cf);
2460 n_Delete(&nln, r->cf);
2486 if( r->GetNC()->GetGlobalMultiplier() !=
NULL )
2488 delete r->GetNC()->GetGlobalMultiplier();
2489 r->GetNC()->GetGlobalMultiplier() =
NULL;
2492 if( r->GetNC()->GetFormulaPowerMultiplier() !=
NULL )
2494 delete r->GetNC()->GetFormulaPowerMultiplier();
2495 r->GetNC()->GetFormulaPowerMultiplier() =
NULL;
2505 for(
j=
i+1;
j<=rN;
j++)
2510 int mat_size=rN*(rN-1)/2;
2511 mat_size=si_max(1,mat_size);
2514 id_Delete((ideal *)&(r->GetNC()->COM),r);
2519 if( rIsSCA(r) && (r->GetNC()->SCAQuotient() !=
NULL) )
2521 id_Delete(&r->GetNC()->SCAQuotient(), r);
2549 return(p_Copy(a,r));
2571 return(p_Copy(a,r));
2587 int *ExpVar=(
int*)
omAlloc0((rN+1)*
sizeof(
int));
2588 int *ExpTmp=(
int*)
omAlloc0((rN+1)*
sizeof(
int));
2589 p_GetExpV(PolyVar, ExpVar, r);
2590 int i;
int j;
int k;
2593 for (
i=1;
i<rN;
i++)
2597 for (
j=
i+1;
j<=rN;
j++)
2604 p_GetExpV(
test, ExpTmp, r);
2610 if (ExpVar[
k]!=0) OK=0;
2651 for(
i=1;
i<r->N;
i++)
2653 for(
j=
i+1;
j<=r->N;
j++)
2662 if (p_LmCmp(q,
p,r) != 1)
2664 Werror(
"Bad ordering at %d,%d\n",
i,
j);
2695 bool bSetupQuotient,
bool bCopyInput,
bool bBeQuiet,
2696 ring curr,
bool dummy_ring )
2701 if( !bSetupQuotient)
2713 PrintS(
"nc_CallPlural(), Input data, CCC: \n");
2718 PrintS(
"nc_CallPlural(), Input data, DDD: \n");
2731 if( (!bBeQuiet) && (r->GetNC() !=
NULL) )
2732 WarnS(
"going to redefine the algebra structure");
2736 matrix C;
bool bCnew =
false;
2744 bool IsSkewConstant =
false, tmpIsSkewConstant;
2758 Werror(
"Square %d x %d matrix expected", r->N, r->N);
2762 if (( CCC !=
NULL) && (CC ==
NULL)) CC = CCC;
2763 if (( CCN !=
NULL) && (CN ==
NULL)) CN = CCN;
2774 Werror(
"Square %d x %d matrix expected",r->N,r->N);
2779 if (( DDD !=
NULL) && (DD ==
NULL)) DD = DDD;
2780 if (( DDN !=
NULL) && (DN ==
NULL)) DN = DDN;
2786 if (!p_IsConstant(CN,curr))
2788 WerrorS(
"Incorrect input : non-constants are not allowed as coefficients (first argument)");
2791 assume(p_IsConstant(CN,curr));
2794 if (n_IsZero(nN, curr->cf))
2796 WerrorS(
"Incorrect input : zero coefficients are not allowed");
2800 if (n_IsOne(nN, curr->cf))
2805 IsSkewConstant =
true;
2807 C =
mpNew(r->N,r->N);
2810 for(
i=1;
i<r->N;
i++)
2811 for(
j=
i+1;
j<=r->N;
j++)
2819 else if ( (CN ==
NULL) && (CC !=
NULL) )
2824 pN = n_Init(0,curr->cf);
2829 if (!pN_set) n_Delete(&pN,curr->cf);
2834 tmpIsSkewConstant =
true;
2836 for(
i=1;
i<r->N;
i++)
2837 for(
j=
i+1;
j<=r->N;
j++)
2843 if (!p_IsConstant(
MATELEM(CC,
i,
j),curr))
2845 Werror(
"Incorrect input : non-constants are not allowed as coefficients (first argument at [%d, %d])",
i,
j);
2855 WerrorS(
"Incorrect input : matrix of coefficients contains zeros in the upper triangle");
2859 if (!n_Equal(pN, qN, curr->cf)) tmpIsSkewConstant =
false;
2874 IsSkewConstant = tmpIsSkewConstant;
2876 if ( tmpIsSkewConstant && n_IsOne(pN, curr->cf) )
2880 if (!pN_set) n_Delete(&pN,curr->cf);
2886 D =
mpNew(r->N,r->N); bDnew =
true;
2896 for(
i=1;
i<r->N;
i++)
2897 for(
j=
i+1;
j<=r->N;
j++)
2907 for(
int i = 1; (
i < r->N) &&
b;
i++)
2908 for(
int j =
i+1; (
j <= r->N) &&
b;
j++)
2939 PrintS(
"nc_CallPlural(), Computed data, C: \n");
2942 PrintS(
"nc_CallPlural(), Computed data, D: \n");
2945 Print(
"\nTemporary: type = %d, IsSkewConstant = %d\n", nctype, IsSkewConstant);
2955 WerrorS(
"Matrix of polynomials violates the ordering condition");
2964 ncRingType(nc_new, nctype);
2972 if (r->GetNC() !=
NULL)
2975 WarnS(
"Changing the NC-structure of an existing NC-ring!!!");
2980 r->GetNC() = nc_new;
2993 WarnS(
"Error occurred while coping/setuping the NC structure!");
3020 int mat_size=r->N*(r->N-1)/2;
3021 mat_size=si_max(1,mat_size);
3023 r->GetNC()->MTsize = (
int *)
omAlloc0(mat_size*
sizeof(
int));
3024 id_Test((ideal)r->GetNC()->C, r);
3031 for(
i=1;
i<r->N;
i++)
3033 for(
j=
i+1;
j<=r->N;
j++)
3047 r->GetNC()->MTsize[
UPMATELEM(
i,
j,r->N)] = DefMTsize;
3053 p_SetCoeff(
p,n_Copy(pGetCoeff(
MATELEM(r->GetNC()->C,
i,
j)),r->cf),r);
3076 r->GetNC()->IsSkewConstant = 0;
3080 r->GetNC()->COM=
COM;
3100 p_Procs->p_Mult_mm = rGR->p_Procs->p_Mult_mm =
gnc_p_Mult_mm;
3125 if (rHasLocalOrMixedOrdering(rGR))
3147 p_Procs->p_Minus_mm_Mult_qq =
NULL;
3150 r->GetNC()->mmMultP() = gnc_mm_Mult_p;
3151 r->GetNC()->mmMultPP() = gnc_mm_Mult_pp;
3153 r->GetNC()->SPoly() = gnc_CreateSpoly;
3154 r->GetNC()->ReduceSPoly() = gnc_ReduceSpoly;
3163 assume(rIsPluralRing(rGR));
3188 int *PRE = (
int *)
omAlloc0((rN+1)*
sizeof(
int));
3189 int *SUF = (
int *)
omAlloc0((rN+1)*
sizeof(
int));
3198 p_GetExpV(
p, PRE, r);
3199 pow = PRE[n]; PRE[n]=0;
3203 for (
i=n+1;
i<=rN;
i++)
3211 p_SetExpV(pre,PRE, r);
3216 p_SetExpV(suf,SUF, r);
3218 res = p_Mult_mm(
res,suf, r);
3220 p_SetComp(
res,PRE[0], r);
3226 p = p_LmDeleteAndNext(
p, r);
3227 out = p_Add_q(out,
res, r);
3238 if (rIsPluralRing(r))
return r;
3245 for(
int i=1;
i<rr->N;
i++)
3246 for(
int j=
i+1;
j<=rr->N;
j++)
3250 WarnS(
"Error initializing multiplication!");
3262 if (dstRing == srcRing)
3264 return(p_Copy(
p,dstRing));
3266 nMapFunc nMap=n_SetMap(srcRing->cf, dstRing->cf);
3274 int *perm = (
int *)
omAlloc0((rVar(srcRing)+1)*
sizeof(
int));
3275 int *par_perm = (
int *)
omAlloc0((rPar(srcRing)+1)*
sizeof(
int));
3283 if ((shift<0) || (shift > rVar(srcRing)))
3285 WerrorS(
"bad shifts in p_CopyEmbed");
3288 for (
i=1;
i<= srcRing->N;
i++)
3292 q =
p_PermPoly(
p,perm,srcRing, dstRing, nMap,par_perm, rPar(srcRing));
3300 int diagnose =
TRUE;
3301 nMapFunc nMap = n_SetMap(rCandidate->cf, rBase->cf);
3308 if (rBase->N != rCandidate->N) diagnose =
FALSE;
3310 if ( rIsPluralRing(rBase) != rIsPluralRing(rCandidate) ) diagnose =
FALSE;
3327 if ( Rop == dst )
return(p_Copy(
p, dst));
3333 WarnS(
"an opposite ring should be used");
3337 nMapFunc nMap = n_SetMap(Rop->cf, dst->cf);
3344 int *perm=(
int *)
omAlloc0((Rop->N+1)*
sizeof(
int));
3345 if (!p_IsConstant(
p, Rop))
3349 for(
i=1;
i<=Rop->N;
i++)
3351 perm[
i] = Rop->N+1-
i;
3366 if ( Rop == dst )
return id_Copy(I, dst);
3371 WarnS(
"an opposite ring should be used");
3375 ideal idOp =
idInit(I->ncols, I->rank);
3376 for (
i=0;
i< (I->ncols)*(I->nrows);
i++)
3387 if( rGR->qideal ==
NULL )
3403 assume(rIsPluralRing(rGR) == rIsPluralRing(rG));
3405 assume(rIsSCA(rGR) == rIsSCA(rG));
3406 assume(ncRingType(rGR) == ncRingType(rG));
Rational pow(const Rational &a, int e)
void * cast_A_to_vptr(A a)
const CanonicalForm CFMap CFMap & N
CPolynomialSummator: unifies bucket and polynomial summation as the later is broken in buckets :(.
number(*) nMapFunc(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
const CanonicalForm int s
const CanonicalForm int const CFList const Variable & y
const Variable & v
< [in] a sqrfree bivariate poly
CFArray copy(const CFList &list)
write elements of list into an array
void WerrorS(const char *s)
EXTERN_VAR BBA_Proc gnc_gr_bba
EXTERN_VAR BBA_Proc gnc_gr_mora
EXTERN_VAR BBA_Proc sca_gr_bba
EXTERN_VAR BBA_Proc sca_mora
EXTERN_VAR BBA_Proc sca_bba
ideal id_Copy(ideal h1, const ring r)
copy an ideal
BOOLEAN kbTest(kBucket_pt bucket)
Tests.
number kBucketPolyRed(kBucket_pt bucket, poly p1, int l1, poly spNoether)
void kBucket_Add_q(kBucket_pt bucket, poly q, int *l)
Add to Bucket a poly ,i.e. Bpoly == q+Bpoly.
void kBucketPolyRedNF(kBucket_pt bucket, poly p1, int l1, poly spNoether)
const poly kBucketGetLm(kBucket_pt bucket)
static poly nc_mm_Mult_pp(const poly m, const poly p, const ring r)
ideal idOppose(ring Rop_src, ideal I, const ring Rop_dst)
opposes a module I from Rop to currRing(dst)
void nc_p_ProcsSet(ring rGR, p_Procs_s *p_Procs)
poly pOppose(ring Rop_src, poly p, const ring Rop_dst)
opposes a vector p from Rop to currRing (dst!)
void nc_PolyPolyRed(poly &b, poly p, number *c, const ring r)
poly nc_pSubst(poly p, int n, poly e, const ring r)
substitute the n-th variable by e in p destroy p e is not a constant
poly nc_CreateShortSpoly(poly p1, poly p2, const ring r)
bool nc_rCopy(ring res, const ring r, bool bSetupQuotient)
bool ncExtensions(int iMask)
bool nc_SetupQuotient(ring rGR, const ring rG=NULL, bool bCopy=false)
static poly nc_mm_Mult_p(const poly m, poly p, const ring r)
int setNCExtensions(int iMask)
BOOLEAN rIsLikeOpposite(ring rBase, ring rCandidate)
checks whether rings rBase and rCandidate could be opposite to each other returns TRUE if it is so
poly nc_p_Plus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp, const int, const ring r)
BOOLEAN nc_CheckSubalgebra(poly PolyVar, ring r)
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,...
poly nc_p_Bracket_qq(poly p, const poly q, const ring r)
returns [p,q], destroys p
poly _nc_pp_Mult_qq(const poly p, const poly q, const ring r)
general NC-multiplication without destruction
poly _nc_p_Mult_q(poly p, poly q, const ring r)
general NC-multiplication with destruction
void nc_rKill(ring r)
complete destructor
#define UPMATELEM(i, j, nVar)
poly nc_p_Minus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp, const poly, const ring r)
for p_Minus_mm_Mult_qq in pInline2.h
matrix nc_PrintMat(int a, int b, ring r, int metric)
returns matrix with the info on noncomm multiplication
void sca_p_ProcsSet(ring rGR, p_Procs_s *p_Procs)
bool sca_SetupQuotient(ring rGR, ring rG, bool bCopy)
void mp_Delete(matrix *a, const ring r)
matrix mpNew(int r, int c)
create a r x c zero-matrix
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
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
int dReportError(const char *fmt,...)
gmp_float log(const gmp_float &a)
BOOLEAN ncInitSpecialPairMultiplication(ring r)
static void gnc_kBucketPolyRed_ZNew(kBucket_pt b, poly p, number *c, BOOLEAN reduce)
static poly gnc_uu_Mult_ww_formula(int i, int a, int j, int b, const ring r)
poly gnc_ReduceSpolyOld(const poly p1, poly p2, const ring r)
ring nc_rCreateNCcomm(ring r)
poly gnc_CreateSpolyNew(const poly p1, const poly p2, const ring r)
static poly NF_Proc_Dummy(ideal, ideal, poly, int, int, const ring)
void nc_PolyPolyRedNew(poly &b, poly p, number *c, const ring r)
poly gnc_uu_Mult_ww_horvert(int i, int a, int j, int b, const ring r)
poly gnc_pp_mm_Mult(const poly p, const poly m, const ring r)
poly gnc_p_Mult_mm(poly p, const poly m, const ring r)
poly gnc_uu_Mult_ww(int i, int a, int j, int b, const ring r)
poly p_CopyEmbed(poly p, ring srcRing, int shift, int, ring dstRing)
poly gnc_ReduceSpolyNew(const poly p1, poly p2, const ring r)
poly nc_p_CopyGet(poly a, const ring r)
static void gnc_p_ProcsSet(ring rGR, p_Procs_s *p_Procs)
poly gnc_CreateSpolyOld(const poly p1, const poly p2, const ring r)
BOOLEAN gnc_InitMultiplication(ring r, bool bSetupQuotient=false)
void gnc_kBucketPolyRed_ZOld(kBucket_pt b, poly p, number *c)
void nc_CleanUp(nc_struct *p)
poly _gnc_p_Mult_q(poly p, poly q, const int copy, const ring r)
void gnc_kBucketPolyRedOld(kBucket_pt b, poly p, number *c)
BOOLEAN gnc_CheckOrdCondition(matrix D, ring r)
poly nc_p_CopyPut(poly a, const ring r)
poly gnc_uu_Mult_ww_vert(int i, int a, int j, int b, const ring r)
poly gnc_p_mm_Mult(poly m, const poly p, const ring r)
poly gnc_p_Mult_mm_Common(poly p, const poly m, int side, const ring r)
void nc_PolyPolyRedOld(poly &b, poly p, number *c, const ring r)
poly nc_mm_Bracket_nn(poly m1, poly m2, const ring r)
returns [m1,m2] for two monoms, destroys nothing without coeffs
static ideal BBA_Proc_Dummy(const ideal, const ideal, const intvec *, const bigintmat *, kStrategy, const ring)
static void gnc_kBucketPolyRedNew(kBucket_pt b, poly p, number *c, BOOLEAN)
poly gnc_mm_Mult_uu(int *F, int jG, int bG, const ring r)
poly gnc_mm_Mult_nn(int *F, int *G, const ring r)
poly gnc_pp_Mult_mm(const poly p, const poly m, const ring r, poly &last)
#define omFreeSize(addr, size)
#define TEST_OPT_NOT_BUCKETS
BOOLEAN pqLength(poly p, poly q, int &lp, int &lq, const int min)
return TRUE and lp == pLength(p), lq == pLength(q), if min(pLength(p), pLength(q)) >= min FALSE if mi...
#define MIN_LENGTH_BUCKET
STATIC_VAR p_Procs_s * _p_procs
void p_Cleardenom_n(poly ph, const ring r, number &c)
BOOLEAN p_ComparePolys(poly p1, poly p2, const ring r)
returns TRUE if p1 is a skalar multiple of p2 assume p1 != NULL and p2 != NULL
BOOLEAN p_HasNotCF(poly p1, poly p2, const ring r)
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
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)
poly p_Power(poly p, int i, const ring r)
poly p_Cleardenom(poly p, const ring r)
poly p_LcmRat(const poly a, const poly b, const long lCompM, 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)
void p_Lcm(const poly a, const poly b, poly m, const ring r)
void p_Write(poly p, ring lmRing, ring tailRing)
void p_Write0(poly p, ring lmRing, ring tailRing)
#define __p_Mult_nn(p, n, r)
poly prCopyR_NoSort(poly p, ring src_r, ring dest_r)
void PrintS(const char *s)
void Werror(const char *fmt,...)
void p_DebugPrint(poly p, const ring r)
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...
struct p_Procs_s p_Procs_s
ideal(*) BBA_Proc(const ideal, const ideal, const intvec *, const bigintmat *, kStrategy strat, const ring)
poly(*) NF_Proc(ideal, ideal, poly, int, int, const ring _currRing)
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix