My Project
Loading...
Searching...
No Matches
old.gring.cc File Reference
#include "misc/auxiliary.h"
#include "nc.h"
#include "sca.h"
#include "gb_hack.h"
#include "polys/monomials/ring.h"
#include "coeffs/numbers.h"
#include "misc/options.h"
#include "polys/monomials/p_polys.h"
#include "polys/simpleideals.h"
#include "polys/matpol.h"
#include "polys/kbuckets.h"
#include "polys/sbuckets.h"
#include "polys/prCopy.h"
#include "polys/operations/p_Mult_q.h"
#include "summator.h"
#include "ncSAMult.h"
#include "ncSAFormula.h"

Go to the source code of this file.

Macros

#define MYTEST   0
 
#define OUTPUT   0
 
#define PLURAL_INTERNAL_DECLARATIONS
 
#define freeT(A, v)
 
#define freeN(A, k)
 

Functions

static poly NF_Proc_Dummy (ideal, ideal, poly, int, int, const ring)
 
static ideal BBA_Proc_Dummy (const ideal, const ideal, const intvec *, const bigintmat *, kStrategy, const ring)
 
poly nc_p_CopyGet (poly a, const ring r)
 
poly nc_p_CopyPut (poly a, const ring r)
 
poly nc_p_Bracket_qq (poly p, const poly q, const ring r)
 returns [p,q], destroys p
 
int & getNCExtensions ()
 
int setNCExtensions (int iMask)
 
bool ncExtensions (int iMask)
 
poly gnc_pp_Mult_mm (const poly p, const poly m, const ring r, poly &last)
 
poly gnc_p_Mult_mm (poly p, const poly m, const ring r)
 
poly gnc_p_mm_Mult (poly m, const poly p, const ring r)
 
poly gnc_pp_mm_Mult (const poly p, const poly m, const ring r)
 
poly gnc_CreateSpolyOld (const poly p1, const poly p2, const ring r)
 
poly gnc_ReduceSpolyOld (const poly p1, poly p2, const ring r)
 
poly gnc_CreateSpolyNew (const poly p1, const poly p2, const ring r)
 
poly gnc_ReduceSpolyNew (const poly p1, poly p2, const ring r)
 
static void gnc_kBucketPolyRedNew (kBucket_pt b, poly p, number *c, BOOLEAN)
 
static void gnc_kBucketPolyRed_ZNew (kBucket_pt b, poly p, number *c, BOOLEAN reduce)
 
void gnc_kBucketPolyRedOld (kBucket_pt b, poly p, number *c)
 
void gnc_kBucketPolyRed_ZOld (kBucket_pt b, poly p, number *c)
 
void nc_CleanUp (nc_struct *p)
 
void nc_rCleanUp (ring r)
 
poly nc_p_Minus_mm_Mult_qq (poly p, const poly m, const poly q, int &shorter, const poly, const ring r)
 for p_Minus_mm_Mult_qq in pInline2.h
 
poly nc_p_Plus_mm_Mult_qq (poly p, const poly m, const poly q, int &lp, const int, const ring r)
 
poly _gnc_p_Mult_q (poly p, poly q, const int copy, const ring r)
 
poly _nc_p_Mult_q (poly pPolyP, poly pPolyQ, const ring rRing)
 general NC-multiplication with destruction
 
poly _nc_pp_Mult_qq (const poly pPolyP, const poly pPolyQ, const ring rRing)
 general NC-multiplication without destruction
 
poly gnc_mm_Mult_nn (int *F, int *G, const ring r)
 
poly gnc_mm_Mult_uu (int *F, int jG, int bG, const ring r)
 
poly gnc_uu_Mult_ww (int i, int a, int j, int b, const ring r)
 
poly gnc_p_Mult_mm_Common (poly p, const poly m, int side, const ring r)
 
poly gnc_pp_Mult_mm (const poly p, const poly m, const ring r)
 
poly gnc_uu_Mult_ww_vert (int i, int a, int j, int b, const ring r)
 
static poly gnc_uu_Mult_ww_formula (int i, int a, int j, int b, const ring r)
 
poly gnc_uu_Mult_ww_horvert (int i, int a, int j, int b, const ring r)
 
poly nc_CreateShortSpoly (poly p1, poly p2, const ring r)
 
void nc_PolyPolyRedOld (poly &b, poly p, number *c, const ring r)
 
void nc_PolyPolyRedNew (poly &b, poly p, number *c, const ring r)
 
void nc_PolyPolyRed (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
 
matrix nc_PrintMat (int a, int b, ring r, int metric)
 returns matrix with the info on noncomm multiplication
 
void nc_CleanUp (ring r)
 
void nc_rKill (ring r)
 complete destructor
 
BOOLEAN nc_CheckSubalgebra (poly PolyVar, ring r)
 
BOOLEAN gnc_CheckOrdCondition (matrix D, ring r)
 
BOOLEAN gnc_InitMultiplication (ring r, bool bSetupQuotient=false)
 
BOOLEAN nc_CallPlural (matrix CCC, matrix DDD, poly CCN, poly DDN, ring r, bool bSetupQuotient, bool bCopyInput, bool bBeQuiet, ring curr, bool dummy_ring)
 returns TRUE if there were errors analyze inputs, check them for consistency detects nc_type, DO NOT initialize multiplication but call for it at the end checks the ordering condition and evtl. NDC NOTE: all the data belong to the curr, we change r which may be the same ring, and must have the same representation!
 
bool nc_rCopy (ring res, const ring r, bool bSetupQuotient)
 
static void gnc_p_ProcsSet (ring rGR, p_Procs_s *p_Procs)
 
void nc_p_ProcsSet (ring rGR, p_Procs_s *p_Procs)
 
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
 
ring nc_rCreateNCcomm (ring r)
 
poly p_CopyEmbed (poly p, ring srcRing, int shift, int, ring dstRing)
 
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 pOppose (ring Rop, poly p, const ring dst)
 opposes a vector p from Rop to currRing (dst!)
 
ideal idOppose (ring Rop, ideal I, const ring dst)
 opposes a module I from Rop to currRing(dst)
 
bool nc_SetupQuotient (ring rGR, const ring rG, bool bCopy)
 

Variables

VAR NF_Proc nc_NF =NF_Proc_Dummy
 
VAR BBA_Proc gnc_gr_bba =BBA_Proc_Dummy
 
VAR BBA_Proc gnc_gr_mora =BBA_Proc_Dummy
 
VAR BBA_Proc sca_bba =BBA_Proc_Dummy
 
VAR BBA_Proc sca_mora =BBA_Proc_Dummy
 
VAR BBA_Proc sca_gr_bba =BBA_Proc_Dummy
 
VAR int iNCExtensions = SCAMASK | NOFORMULAMASK
 

Macro Definition Documentation

◆ freeN

#define freeN ( A,
k )
Value:
omFreeSize((ADDRESS)A,k*sizeof(number))
void * ADDRESS
Definition auxiliary.h:120
int k
Definition cfEzgcd.cc:99
#define omFreeSize(addr, size)
#define A
Definition sirandom.c:24

Definition at line 102 of file old.gring.cc.

◆ freeT

#define freeT ( A,
v )
Value:
omFreeSize((ADDRESS)A,(v+1)*sizeof(int))
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39

Definition at line 101 of file old.gring.cc.

◆ MYTEST

#define MYTEST   0

Definition at line 11 of file old.gring.cc.

◆ OUTPUT

#define OUTPUT   0

Definition at line 12 of file old.gring.cc.

◆ PLURAL_INTERNAL_DECLARATIONS

#define PLURAL_INTERNAL_DECLARATIONS

Definition at line 26 of file old.gring.cc.

Function Documentation

◆ _gnc_p_Mult_q()

poly _gnc_p_Mult_q ( poly p,
poly q,
const int copy,
const ring r )

Definition at line 190 of file old.gring.cc.

192{
193 poly res=NULL;
194 poly qq,pp;
195 if (copy)
196 {
197 qq=p_Copy(q,r);
198 pp=p_Copy(p,r);
199 }
200 else
201 {
202 qq=q;
203 pp=p;
204 }
205 while (qq!=NULL)
206 {
207 res=p_Add_q(res, pp_Mult_mm(pp, qq, r), r); // p_Head(qq, r)?
208 qq=p_LmDeleteAndNext(qq,r);
209 }
210 p_Delete(&pp,r);
211 return(res);
212}
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition cf_gcd.cc:676
int p
Definition cfModGcd.cc:4086
CanonicalForm res
Definition facAbsFact.cc:60
CFArray copy(const CFList &list)
write elements of list into an array
#define NULL
Definition omList.c:12
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:938
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1033
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition p_polys.h:757
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848

◆ _nc_p_Mult_q()

poly _nc_p_Mult_q ( poly pPolyP,
poly pPolyQ,
const ring rRing )

general NC-multiplication with destruction

Definition at line 215 of file old.gring.cc.

216{
217 assume( rIsNCRing(rRing) );
218#ifdef PDEBUG
219 p_Test(pPolyP, rRing);
220 p_Test(pPolyQ, rRing);
221#endif
222#ifdef RDEBUG
223 rTest(rRing);
224#endif
225
226 int lp, lq;
227
228 pqLength(pPolyP, pPolyQ, lp, lq, MIN_LENGTH_BUCKET);
229
230 bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (si_max(lp, lq) < MIN_LENGTH_BUCKET); // ???
231
232 CPolynomialSummator sum(rRing, bUsePolynomial);
233
234 if (lq <= lp) // ?
235 {
236 // always length(q) times "p * q[j]"
237 for( ; pPolyQ!=NULL; pPolyQ = p_LmDeleteAndNext( pPolyQ, rRing ) )
238 sum += pp_Mult_mm( pPolyP, pPolyQ, rRing);
239
240 p_Delete( &pPolyP, rRing );
241 } else
242 {
243 // always length(p) times "p[i] * q"
244 for( ; pPolyP!=NULL; pPolyP = p_LmDeleteAndNext( pPolyP, rRing ) )
245 sum += nc_mm_Mult_pp( pPolyP, pPolyQ, rRing);
246
247 p_Delete( &pPolyQ, rRing );
248 }
249
250 return(sum);
251}
static int si_max(const int a, const int b)
Definition auxiliary.h:125
CPolynomialSummator: unifies bucket and polynomial summation as the later is broken in buckets :(.
Definition summator.h:21
static poly nc_mm_Mult_pp(const poly m, const poly p, const ring r)
Definition nc.h:224
#define assume(x)
Definition mod2.h:389
Definition lq.h:40
#define TEST_OPT_NOT_BUCKETS
Definition options.h:107
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...
Definition p_Mult_q.cc:31
#define MIN_LENGTH_BUCKET
Definition p_Mult_q.h:21
#define p_Test(p, r)
Definition p_polys.h:161
static BOOLEAN rIsNCRing(const ring r)
Definition ring.h:427
#define rTest(r)
Definition ring.h:794

◆ _nc_pp_Mult_qq()

poly _nc_pp_Mult_qq ( const poly pPolyP,
const poly pPolyQ,
const ring rRing )

general NC-multiplication without destruction

Definition at line 254 of file old.gring.cc.

255{
256 assume( rIsNCRing(rRing) );
257#ifdef PDEBUG
258 p_Test(pPolyP, rRing);
259 p_Test(pPolyQ, rRing);
260#endif
261#ifdef RDEBUG
262 rTest(rRing);
263#endif
264
265 int lp, lq;
266
267 pqLength(pPolyP, pPolyQ, lp, lq, MIN_LENGTH_BUCKET);
268
269 bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (si_max(lp, lq) < MIN_LENGTH_BUCKET); // ???
270
271 CPolynomialSummator sum(rRing, bUsePolynomial);
272
273 if (lq <= lp) // ?
274 {
275 // always length(q) times "p * q[j]"
276 for( poly q = pPolyQ; q !=NULL; q = pNext(q) )
277 sum += pp_Mult_mm(pPolyP, q, rRing);
278 } else
279 {
280 // always length(p) times "p[i] * q"
281 for( poly p = pPolyP; p !=NULL; p = pNext(p) )
282 sum += nc_mm_Mult_pp( p, pPolyQ, rRing);
283 }
284
285 return(sum);
286}
#define pNext(p)
Definition monomials.h:36

◆ BBA_Proc_Dummy()

static ideal BBA_Proc_Dummy ( const ideal ,
const ideal ,
const intvec * ,
const bigintmat * ,
kStrategy ,
const ring  )
static

Definition at line 61 of file old.gring.cc.

62{ WerrorS("nc_NF not defined"); return NULL; }
void WerrorS(const char *s)
Definition feFopen.cc:24

◆ getNCExtensions()

int & getNCExtensions ( )

Definition at line 82 of file old.gring.cc.

83{
84 return (iNCExtensions);
85}
VAR int iNCExtensions
Definition old.gring.cc:80

◆ gnc_CheckOrdCondition()

BOOLEAN gnc_CheckOrdCondition ( matrix D,
ring r )

Definition at line 2637 of file old.gring.cc.

2638{
2639 /* analyze D: an upper triangular matrix of polys */
2640 /* check the ordering condition for D */
2641// ring save = currRing;
2642// int WeChangeRing = 0;
2643// if (r != currRing)
2644// {
2645// rChangeCurrRing(r);
2646// WeChangeRing = 1;
2647// }
2648 poly p,q;
2649 int i,j;
2650 int report = 0;
2651 for(i=1; i<r->N; i++)
2652 {
2653 for(j=i+1; j<=r->N; j++)
2654 {
2655 p = nc_p_CopyGet(MATELEM(D,i,j),r);
2656 if ( p != NULL)
2657 {
2658 q = p_One(r);
2659 p_SetExp(q,i,1,r);
2660 p_SetExp(q,j,1,r);
2661 p_Setm(q,r);
2662 if (p_LmCmp(q,p,r) != 1) /* i.e. lm(p)==xy < lm(q)==D_ij */
2663 {
2664 Werror("Bad ordering at %d,%d\n",i,j);
2665#if 0 /*Singularg should not differ from Singular except in error case*/
2666 p_Write(p,r);
2667 p_Write(q,r);
2668#endif
2669 report = 1;
2670 }
2671 p_Delete(&q,r);
2672 p_Delete(&p,r);
2673 p = NULL;
2674 }
2675 }
2676 }
2677// if ( WeChangeRing )
2678// rChangeCurrRing(save);
2679 return(report);
2680}
int i
Definition cfEzgcd.cc:132
int j
Definition facHensel.cc:110
#define D(A)
Definition gentable.cc:128
#define MATELEM(mat, i, j)
1-based access to matrix
Definition matpol.h:29
void report(const char *fmt, const char *name)
Definition shared.cc:661
poly nc_p_CopyGet(poly a, const ring r)
poly p_One(const ring r)
Definition p_polys.cc:1314
void p_Write(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:342
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:490
static void p_Setm(poly p, const ring r)
Definition p_polys.h:235
static int p_LmCmp(poly p, poly q, const ring r)
Definition p_polys.h:1596
void Werror(const char *fmt,...)
Definition reporter.cc:189

◆ gnc_CreateSpolyNew()

poly gnc_CreateSpolyNew ( const poly p1,
const poly p2,
const ring r )

Definition at line 1558 of file old.gring.cc.

1559{
1560#ifdef PDEBUG
1561 p_Test(p1, r);
1562 p_Test(p2, r);
1563#if MYTEST
1564 PrintS("p1: "); p_Write(p1, r);
1565 PrintS("p2: "); p_Write(p2, r);
1566#endif
1567#endif
1568
1569 const long lCompP1 = p_GetComp(p1,r);
1570 const long lCompP2 = p_GetComp(p2,r);
1571
1572 if ((lCompP1!=lCompP2) && (lCompP1!=0) && (lCompP2!=0))
1573 {
1574#ifdef PDEBUG
1575 WerrorS("gnc_CreateSpolyNew: different non-zero components!");
1576 assume(0);
1577#endif
1578 return(NULL);
1579 }
1580
1581// if ((r->GetNC()->type==nc_lie) && pHasNotCF(p1,p2)) /* prod crit */
1582// {
1583// return(nc_p_Bracket_qq(pCopy(p2),p1));
1584// }
1585
1586// poly pL=p_One( r);
1587
1588 poly m1=p_One( r);
1589 poly m2=p_One( r);
1590
1591 poly pL = p_Lcm(p1,p2,r); // pL = lcm( lm(p1), lm(p2) )
1592
1593
1594#ifdef PDEBUG
1595// p_Test(pL,r);
1596#endif
1597
1598 p_ExpVectorDiff(m1, pL, p1, r); // m1 = pL / lm(p1)
1599 //p_SetComp(m1,0,r);
1600 //p_Setm(m1,r);
1601
1602#ifdef PDEBUG
1603 p_Test(m1,r);
1604#endif
1605// assume(p_GetComp(m1,r) == 0);
1606
1607 p_ExpVectorDiff(m2, pL, p2, r); // m2 = pL / lm(p2)
1608
1609 //p_SetComp(m2,0,r);
1610 //p_Setm(m2,r);
1611#ifdef PDEBUG
1612 p_Test(m2,r);
1613#endif
1614
1615#ifdef PDEBUG
1616#if MYTEST
1617 PrintS("m1: "); pWrite(m1);
1618 PrintS("m2: "); pWrite(m2);
1619#endif
1620#endif
1621
1622
1623// assume(p_GetComp(m2,r) == 0);
1624
1625#ifdef PDEBUG
1626#if 0
1627 if( (p_GetComp(m2,r) != 0) || (p_GetComp(m1,r) != 0) )
1628 {
1629 WarnS("gnc_CreateSpolyNew: wrong monomials!");
1630
1631
1632#ifdef RDEBUG
1633 PrintS("m1 = "); p_Write(m1, r);
1634 p_DebugPrint(m1, r);
1635
1636 PrintS("m2 = "); p_Write(m2, r);
1637 p_DebugPrint(m2, r);
1638
1639 PrintS("p1 = "); p_Write(p1, r);
1640 p_DebugPrint(p1, r);
1641
1642 PrintS("p2 = "); p_Write(p2, r);
1643 p_DebugPrint(p2, r);
1644
1645 PrintS("pL = "); p_Write(pL, r);
1646 p_DebugPrint(pL, r);
1647#endif
1648
1649 }
1650
1651#endif
1652#endif
1653
1654 p_LmFree(&pL,r);
1655
1656 /* zero exponents !? */
1657 poly M1 = nc_mm_Mult_p(m1,p_Head(p1,r),r); // M1 = m1 * lt(p1)
1658 poly M2 = nc_mm_Mult_p(m2,p_Head(p2,r),r); // M2 = m2 * lt(p2)
1659
1660#ifdef PDEBUG
1661 p_Test(M1,r);
1662 p_Test(M2,r);
1663
1664#if MYTEST
1665 PrintS("M1: "); pWrite(M1);
1666 PrintS("M2: "); pWrite(M2);
1667#endif
1668#endif
1669
1670 if(M1 == NULL || M2 == NULL)
1671 {
1672#ifdef PDEBUG
1673 PrintS("\np1 = ");
1674 p_Write(p1, r);
1675
1676 PrintS("m1 = ");
1677 p_Write(m1, r);
1678
1679 PrintS("p2 = ");
1680 p_Write(p2, r);
1681
1682 PrintS("m2 = ");
1683 p_Write(m2, r);
1684
1685 WerrorS("ERROR in nc_CreateSpoly: result of multiplication is Zero!\n");
1686#endif
1687 return(NULL);
1688 }
1689
1690 number C1 = p_GetCoeff(M1,r); // C1 = lc(M1)
1691 number C2 = p_GetCoeff(M2,r); // C2 = lc(M2)
1692
1693 /* GCD stuff */
1694 number C = n_SubringGcd(C1, C2, r->cf); // C = gcd(C1, C2)
1695
1696 if (!n_IsOne(C, r->cf)) // if C != 1
1697 {
1698 C1=n_Div(C1, C, r->cf);n_Normalize(C1,r->cf); // C1 = C1 / C
1699 C2=n_Div(C2, C, r->cf);n_Normalize(C2,r->cf); // C2 = C2 / C
1700 }
1701 else
1702 {
1703 C1=n_Copy(C1,r->cf);
1704 C2=n_Copy(C2,r->cf);
1705 }
1706
1707 n_Delete(&C,r->cf); // destroy the number C
1708
1709 C1=n_InpNeg(C1,r->cf);
1710
1711// number MinusOne=n_Init(-1,r);
1712// if (n_Equal(C1,MinusOne,r)) // lc(M1) / gcd( lc(M1), lc(M2)) == -1 ????
1713// {
1714// M2=p_Add_q(M1,M2,r); // ?????
1715// }
1716// else
1717// {
1718 M1=__p_Mult_nn(M1,C2,r); // M1 = (C2*lc(p1)) * (lcm(lm(p1),lm(p2)) / lm(p1)) * lm(p1)
1719
1720#ifdef PDEBUG
1721 p_Test(M1,r);
1722#endif
1723
1724 M2=__p_Mult_nn(M2,C1,r); // M2 =(-C1*lc(p2)) * (lcm(lm(p1),lm(p2)) / lm(p2)) * lm(p2)
1725
1726
1727
1728#ifdef PDEBUG
1729 p_Test(M2,r);
1730
1731#if MYTEST
1732 PrintS("M1: "); pWrite(M1);
1733 PrintS("M2: "); pWrite(M2);
1734#endif
1735#endif
1736
1737
1738 M2=p_Add_q(M1,M2,r); // M1 is killed, M2 = spoly(lt(p1), lt(p2)) = C2*M1 - C1*M2
1739
1740#ifdef PDEBUG
1741 p_Test(M2,r);
1742
1743#if MYTEST
1744 PrintS("M2: "); pWrite(M2);
1745#endif
1746
1747#endif
1748
1749// M2 == 0 for supercommutative algebras!
1750// }
1751// n_Delete(&MinusOne,r);
1752
1753 p_SetCoeff(m1,C2,r); // lc(m1) = C2!!!
1754 p_SetCoeff(m2,C1,r); // lc(m2) = C1!!!
1755
1756#ifdef PDEBUG
1757 p_Test(m1,r);
1758 p_Test(m2,r);
1759#endif
1760
1761// poly tmp = p_Copy(p1,r); // tmp = p1
1762// tmp=p_LmDeleteAndNext(tmp,r); // tmp = tail(p1)
1763//#ifdef PDEBUG
1764// p_Test(tmp,r);
1765//#endif
1766
1767 M1 = nc_mm_Mult_pp(m1, pNext(p1), r); // M1 = m1 * tail(p1), delete tmp // ???
1768
1769#ifdef PDEBUG
1770 p_Test(M1,r);
1771
1772#if MYTEST
1773 PrintS("M1: "); pWrite(M1);
1774#endif
1775
1776#endif
1777
1778 M2=p_Add_q(M2,M1,r); // M2 = spoly(lt(p1), lt(p2)) + m1 * tail(p1), delete M1
1779#ifdef PDEBUG
1780 M1=NULL;
1781 p_Test(M2,r);
1782
1783#if MYTEST
1784 PrintS("M2: "); pWrite(M2);
1785#endif
1786
1787#endif
1788
1789// tmp=p_Copy(p2,r); // tmp = p2
1790// tmp=p_LmDeleteAndNext(tmp,r); // tmp = tail(p2)
1791
1792//#ifdef PDEBUG
1793// p_Test(tmp,r);
1794//#endif
1795
1796 M1 = nc_mm_Mult_pp(m2, pNext(p2), r); // M1 = m2 * tail(p2), detele tmp
1797
1798#ifdef PDEBUG
1799 p_Test(M1,r);
1800
1801#if MYTEST
1802 PrintS("M1: "); pWrite(M1);
1803#endif
1804
1805#endif
1806
1807 M2 = p_Add_q(M2,M1,r); // M2 = spoly(lt(p1), lt(p2)) + m1 * tail(p1) + m2*tail(p2)
1808
1809#ifdef PDEBUG
1810 M1=NULL;
1811 p_Test(M2,r);
1812
1813#if MYTEST
1814 PrintS("M2: "); pWrite(M2);
1815#endif
1816
1817#endif
1818
1819 p_Delete(&m1,r); // => n_Delete(&C1,r);
1820 p_Delete(&m2,r); // => n_Delete(&C2,r);
1821
1822#ifdef PDEBUG
1823 p_Test(M2,r);
1824#endif
1825
1826 if (M2!=NULL) p_Cleardenom(M2,r);
1827
1828 return(M2);
1829}
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition coeffs.h:455
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition coeffs.h:558
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition coeffs.h:616
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:459
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition coeffs.h:667
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition coeffs.h:579
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition coeffs.h:472
#define WarnS
Definition emacs.cc:78
static poly nc_mm_Mult_p(const poly m, poly p, const ring r)
Definition nc.h:233
#define p_GetComp(p, r)
Definition monomials.h:64
#define p_GetCoeff(p, r)
Definition monomials.h:50
poly p_Cleardenom(poly p, const ring r)
Definition p_polys.cc:2849
void p_Lcm(const poly a, const poly b, poly m, const ring r)
Definition p_polys.cc:1659
static void p_ExpVectorDiff(poly pr, poly p1, poly p2, const ring r)
Definition p_polys.h:1490
static number p_SetCoeff(poly p, number n, ring r)
Definition p_polys.h:414
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
Definition p_polys.h:862
static void p_LmFree(poly p, ring)
Definition p_polys.h:685
#define __p_Mult_nn(p, n, r)
Definition p_polys.h:973
void pWrite(poly p)
Definition polys.h:309
void PrintS(const char *s)
Definition reporter.cc:284
void p_DebugPrint(poly p, const ring r)
Definition ring.cc:4419

◆ gnc_CreateSpolyOld()

poly gnc_CreateSpolyOld ( const poly p1,
const poly p2,
const ring r )

Definition at line 1471 of file old.gring.cc.

1472{
1473#ifdef PDEBUG
1474 if ((p_GetComp(p1,r)!=p_GetComp(p2,r))
1475 && (p_GetComp(p1,r)!=0)
1476 && (p_GetComp(p2,r)!=0))
1477 {
1478 dReportError("gnc_CreateSpolyOld : different components!");
1479 return(NULL);
1480 }
1481#endif
1482 if ((ncRingType(r)==nc_lie) && p_HasNotCF(p1,p2, r)) /* prod crit */
1483 {
1484 return(nc_p_Bracket_qq(p_Copy(p2, r),p1, r));
1485 }
1486 poly pL=p_One(r);
1487 poly m1=p_One(r);
1488 poly m2=p_One(r);
1489 pL = p_Lcm(p1,p2,r);
1490 p_Setm(pL,r);
1491#ifdef PDEBUG
1492 p_Test(pL,r);
1493#endif
1494 p_ExpVectorDiff(m1,pL,p1,r);
1495 //p_SetComp(m1,0,r);
1496 //p_Setm(m1,r);
1497#ifdef PDEBUG
1498 p_Test(m1,r);
1499#endif
1500 p_ExpVectorDiff(m2,pL,p2,r);
1501 //p_SetComp(m2,0,r);
1502 //p_Setm(m2,r);
1503#ifdef PDEBUG
1504 p_Test(m2,r);
1505#endif
1506 p_Delete(&pL,r);
1507 /* zero exponents ! */
1508 poly M1 = nc_mm_Mult_p(m1,p_Head(p1,r),r);
1509 number C1 = p_GetCoeff(M1,r);
1510 poly M2 = nc_mm_Mult_p(m2,p_Head(p2,r),r);
1511 number C2 = p_GetCoeff(M2,r);
1512 /* GCD stuff */
1513 number C = n_SubringGcd(C1,C2,r->cf);
1514 if (!n_IsOne(C,r->cf))
1515 {
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);
1518 }
1519 else
1520 {
1521 C1=n_Copy(C1, r->cf);
1522 C2=n_Copy(C2, r->cf);
1523 }
1524 n_Delete(&C,r->cf);
1525 M1=__p_Mult_nn(M1,C2,r);
1526 p_SetCoeff(m1,C2,r);
1527 if (n_IsMOne(C1,r->cf))
1528 {
1529 M2=p_Add_q(M1,M2,r);
1530 }
1531 else
1532 {
1533 C1=n_InpNeg(C1,r->cf);
1534 M2=__p_Mult_nn(M2,C1,r);
1535 M2=p_Add_q(M1,M2,r);
1536 p_SetCoeff(m2,C1,r);
1537 }
1538 /* M1 is killed, M2=res = C2 M1 - C1 M2 */
1539 poly tmp=p_Copy(p1,r);
1540 tmp=p_LmDeleteAndNext(tmp,r);
1541 M1=nc_mm_Mult_p(m1,tmp,r);
1542 tmp=p_Copy(p2,r);
1543 tmp=p_LmDeleteAndNext(tmp,r);
1544 M2=p_Add_q(M2,M1,r);
1545 M1=nc_mm_Mult_p(m2,tmp,r);
1546 M2=p_Add_q(M2,M1,r);
1547 p_Delete(&m1,r);
1548 p_Delete(&m2,r);
1549 // n_Delete(&C1,r);
1550 // n_Delete(&C2,r);
1551#ifdef PDEBUG
1552 p_Test(M2,r);
1553#endif
1554 if (M2!=NULL) M2=p_Cleardenom(M2,r);
1555 return(M2);
1556}
static FORCE_INLINE BOOLEAN n_IsMOne(number n, const coeffs r)
TRUE iff 'n' represents the additive inverse of the one element, i.e. -1.
Definition coeffs.h:476
@ nc_lie
Definition nc.h:18
static nc_type & ncRingType(nc_struct *p)
Definition nc.h:159
int dReportError(const char *fmt,...)
Definition dError.cc:44
poly nc_p_Bracket_qq(poly p, const poly q, const ring r)
returns [p,q], destroys p
BOOLEAN p_HasNotCF(poly p1, poly p2, const ring r)
Definition p_polys.cc:1330

◆ gnc_InitMultiplication()

BOOLEAN gnc_InitMultiplication ( ring r,
bool bSetupQuotient = false )

Definition at line 3001 of file old.gring.cc.

3002{
3003 /* returns TRUE if there were errors */
3004 /* initialize the multiplication: */
3005 /* r->GetNC()->MTsize, r->GetNC()->MT, r->GetNC()->COM, */
3006 /* and r->GetNC()->IsSkewConstant for the skew case */
3007
3008// ring save = currRing;
3009// int WeChangeRing = 0;
3010
3011// if (currRing!=r)
3012// {
3013// rChangeCurrRing(r);
3014// WeChangeRing = 1;
3015// }
3016// assume( (currRing == r)
3017// && (currRing->GetNC()!=NULL) ); // otherwise we cannot work with all these matrices!
3018
3019 int i,j;
3020 int mat_size=r->N*(r->N-1)/2;
3021 mat_size=si_max(1,mat_size);
3022 r->GetNC()->MT = (matrix *)omAlloc0(mat_size*sizeof(matrix));
3023 r->GetNC()->MTsize = (int *)omAlloc0(mat_size*sizeof(int));
3024 id_Test((ideal)r->GetNC()->C, r);
3025 matrix COM = mp_Copy(r->GetNC()->C, r);
3026 poly p,q;
3027 short DefMTsize=7;
3028 int IsNonComm=0;
3029// bool tmpIsSkewConstant = false;
3030
3031 for(i=1; i<r->N; i++)
3032 {
3033 for(j=i+1; j<=r->N; j++)
3034 {
3035 if ( MATELEM(r->GetNC()->D,i,j) == NULL ) /* quasicommutative case */
3036 {
3037 /* 1x1 mult.matrix */
3038 r->GetNC()->MTsize[UPMATELEM(i,j,r->N)] = 1;
3039 r->GetNC()->MT[UPMATELEM(i,j,r->N)] = mpNew(1,1);
3040 }
3041 else /* pure noncommutative case */
3042 {
3043 /* TODO check the special multiplication properties */
3044 IsNonComm = 1;
3045 p_Delete(&(MATELEM(COM,i,j)),r);
3046 //MATELEM(COM,i,j) = NULL; // done by p_Delete
3047 r->GetNC()->MTsize[UPMATELEM(i,j,r->N)] = DefMTsize; /* default sizes */
3048 r->GetNC()->MT[UPMATELEM(i,j,r->N)] = mpNew(DefMTsize, DefMTsize);
3049 }
3050 /* set MT[i,j,1,1] to c_i_j*x_i*x_j + D_i_j */
3051 p = p_One(r);
3052 if (MATELEM(r->GetNC()->C,i,j)!=NULL)
3053 p_SetCoeff(p,n_Copy(pGetCoeff(MATELEM(r->GetNC()->C,i,j)),r->cf),r);
3054 p_SetExp(p,i,1,r);
3055 p_SetExp(p,j,1,r);
3056 p_Setm(p,r);
3057 p_Test(MATELEM(r->GetNC()->D,i,j),r);
3058 q = nc_p_CopyGet(MATELEM(r->GetNC()->D,i,j),r);
3059 p = p_Add_q(p,q,r);
3060 MATELEM(r->GetNC()->MT[UPMATELEM(i,j,r->N)],1,1) = nc_p_CopyPut(p,r);
3061 p_Delete(&p,r);
3062 // p = NULL;// done by p_Delete
3063 }
3064 }
3065 if (ncRingType(r)==nc_undef)
3066 {
3067 if (IsNonComm==1)
3068 {
3069 // assume(pN!=NULL);
3070 // if ((tmpIsSkewConstant==1) && (nIsOne(pGetCoeff(pN)))) r->GetNC()->type=nc_lie;
3071 // else r->GetNC()->type=nc_general;
3072 }
3073 if (IsNonComm==0)
3074 {
3075 ncRingType(r, nc_skew); // TODO: check whether it is commutative
3076 r->GetNC()->IsSkewConstant = 0; // true; //tmpIsSkewConstant; // BUG???
3077 } else
3078 assume( FALSE );
3079 }
3080 r->GetNC()->COM=COM;
3081
3082 nc_p_ProcsSet(r, r->p_Procs);
3083
3084 if(bSetupQuotient) // Test me!!!
3085 nc_SetupQuotient(r, NULL, false); // no copy!
3086
3087
3088// if (save != currRing)
3089// rChangeCurrRing(save);
3090
3091 return FALSE;
3092}
#define FALSE
Definition auxiliary.h:97
@ nc_skew
Definition nc.h:16
@ nc_undef
Definition nc.h:19
#define UPMATELEM(i, j, nVar)
Definition nc.h:36
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition matpol.cc:37
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
Definition matpol.cc:57
ip_smatrix * matrix
Definition matpol.h:43
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
void nc_p_ProcsSet(ring rGR, p_Procs_s *p_Procs)
bool nc_SetupQuotient(ring rGR, const ring rG, bool bCopy)
poly nc_p_CopyPut(poly a, const ring r)
#define omAlloc0(size)
#define id_Test(A, lR)
#define COM(f)
Definition transext.cc:69

◆ gnc_kBucketPolyRed_ZNew()

static void gnc_kBucketPolyRed_ZNew ( kBucket_pt b,
poly p,
number * c,
BOOLEAN reduce )
static

Definition at line 2063 of file old.gring.cc.

2064{
2065 const ring r = b->bucket_ring;
2066 // b is multiplied by a constant in this impl.
2067 number ctmp;
2068 poly m=p_One(r);
2070 //pSetm(m);
2071#ifdef PDEBUG
2072 p_Test(m, r);
2073#endif
2074
2075 if(p_IsConstant(m,r))
2076 {
2077 p_Delete(&m, r);
2078 ctmp = kBucketPolyRed(b,p,pLength(p),NULL);
2079 }
2080 else
2081 {
2082 poly pp = nc_mm_Mult_pp(m,p,r);
2083 number c2;
2084 p_Cleardenom_n(pp,r,c2);
2085 p_Delete(&m, r);
2086 if (reduce)
2087 {
2089 ctmp=n_Init(1,r->cf);
2090 }
2091 else
2092 ctmp = kBucketPolyRed(b,pp,pLength(pp),NULL);
2093 //cc=*c;
2094 //*c=nMult(*c,c2);
2095 n_Delete(&c2, r->cf);
2096 //nDelete(&cc);
2097 p_Delete(&pp, r);
2098 }
2099 if (c!=NULL) *c=ctmp;
2100 else n_Delete(&ctmp, r->cf);
2101}
CanonicalForm reduce(const CanonicalForm &f, const CanonicalForm &M)
polynomials in M.mvar() are considered coefficients M univariate monic polynomial the coefficients of...
Definition cf_ops.cc:660
int m
Definition cfEzgcd.cc:128
CanonicalForm b
Definition cfModGcd.cc:4111
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition coeffs.h:539
number kBucketPolyRed(kBucket_pt bucket, poly p1, int l1, poly spNoether)
Definition kbuckets.cc:1071
void kBucketPolyRedNF(kBucket_pt bucket, poly p1, int l1, poly spNoether)
Definition kbuckets.cc:1188
const poly kBucketGetLm(kBucket_pt bucket)
Definition kbuckets.cc:506
void p_Cleardenom_n(poly ph, const ring r, number &c)
Definition p_polys.cc:2958
static int pLength(poly a)
Definition p_polys.h:190
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition p_polys.h:1980

◆ gnc_kBucketPolyRed_ZOld()

void gnc_kBucketPolyRed_ZOld ( kBucket_pt b,
poly p,
number * c )

◆ gnc_kBucketPolyRedNew()

static void gnc_kBucketPolyRedNew ( kBucket_pt b,
poly p,
number * c,
BOOLEAN  )
static

Definition at line 1948 of file old.gring.cc.

1949{
1950 const ring r = b->bucket_ring;
1951#ifdef PDEBUG
1952// PrintS(">*");
1953#endif
1954
1955#ifdef KDEBUG
1956 if( !kbTest(b) ) WerrorS("nc_kBucketPolyRed: broken bucket!");
1957#endif
1958
1959#ifdef PDEBUG
1960 p_Test(p, r);
1961#if MYTEST
1962 PrintS("p: "); p_Write(p, r);
1963#endif
1964#endif
1965
1966 // b will not be multiplied by any constant in this impl.
1967 // ==> *c=1
1968 if (c!=NULL) *c=n_Init(1, r->cf);
1969 poly m = p_One(r);
1970 const poly pLmB = kBucketGetLm(b); // no new copy!
1971
1972 assume( pLmB != NULL );
1973
1974#ifdef PDEBUG
1975 p_Test(pLmB, r);
1976
1977#if MYTEST
1978 PrintS("pLmB: "); p_Write(pLmB, r);
1979#endif
1980#endif
1981
1982 p_ExpVectorDiff(m, pLmB, p, r);
1983 //pSetm(m);
1984
1985#ifdef PDEBUG
1986 p_Test(m, r);
1987#if MYTEST
1988 PrintS("m: "); p_Write(m, r);
1989#endif
1990#endif
1991
1992 poly pp = nc_mm_Mult_pp(m, p, r);
1993 p_Delete(&m, r);
1994
1995 assume( pp != NULL );
1996 const number n = pGetCoeff(pp); // bug!
1997
1998 if (!n_IsMOne(n, r->cf) ) // does this improve performance??!? also see below... // TODO: check later on.
1999 // if n == -1 => nn = 1 and -1/n
2000 {
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);
2004 pp = __p_Mult_nn(pp,t,r);
2005 n_Delete(&t, r->cf);
2006 }
2007 else
2008 {
2009 pp = __p_Mult_nn(pp,p_GetCoeff(pLmB, r), r);
2010 }
2011
2012 int l = pLength(pp);
2013
2014#ifdef PDEBUG
2015 p_Test(pp, r);
2016// PrintS("PP: "); pWrite(pp);
2017#endif
2018
2019 kBucket_Add_q(b,pp,&l);
2020
2021
2022#ifdef PDEBUG
2023// PrintS("*>");
2024#endif
2025}
int l
Definition cfEzgcd.cc:100
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:637
static FORCE_INLINE number n_Invers(number a, const coeffs r)
return the multiplicative inverse of 'a'; raise an error if 'a' is not invertible
Definition coeffs.h:565
BOOLEAN kbTest(kBucket_pt bucket)
Tests.
Definition kbuckets.cc:197
void kBucket_Add_q(kBucket_pt bucket, poly q, int *l)
Add to Bucket a poly ,i.e. Bpoly == q+Bpoly.
Definition kbuckets.cc:660

◆ gnc_kBucketPolyRedOld()

void gnc_kBucketPolyRedOld ( kBucket_pt b,
poly p,
number * c )

Definition at line 1915 of file old.gring.cc.

1916{
1917 const ring r = b->bucket_ring;
1918 // b will not be multiplied by any constant in this impl.
1919 // ==> *c=1
1920 if (c!=NULL) *c=n_Init(1, r->cf);
1921 poly m=p_One(r);
1923 //pSetm(m);
1924#ifdef PDEBUG
1925 p_Test(m, r);
1926#endif
1927 poly pp= nc_mm_Mult_pp(m,p, r);
1928 assume(pp!=NULL);
1929 p_Delete(&m, r);
1930 number n=pGetCoeff(pp);
1931 number nn;
1932 if (!n_IsMOne(n, r->cf))
1933 {
1934 nn=n_InpNeg(n_Invers(n, r->cf), r->cf);
1935 n= n_Mult(nn,pGetCoeff(kBucketGetLm(b)), r->cf);
1936 n_Delete(&nn, r->cf);
1937 pp=__p_Mult_nn(pp,n,r);
1938 n_Delete(&n, r->cf);
1939 }
1940 else
1941 {
1943 }
1944 int l=pLength(pp);
1945 kBucket_Add_q(b,pp,&l);
1946}

◆ gnc_mm_Mult_nn()

poly gnc_mm_Mult_nn ( int * F,
int * G,
const ring r )

Definition at line 415 of file old.gring.cc.

417{
418 poly out=NULL;
419 int i,j;
420 int iF,jG,iG;
421 int rN=r->N;
422
423 int *F=(int *)omAlloc0((rN+1)*sizeof(int));
424 int *G=(int *)omAlloc0((rN+1)*sizeof(int));
425
426 memcpy(F, F0,(rN+1)*sizeof(int));
427 // pExpVectorCopy(F,F0);
428 memcpy(G, G0,(rN+1)*sizeof(int));
429 // pExpVectorCopy(G,G0);
430 F[0]=0;
431 G[0]=0;
432
433 iF=rN;
434 while ((F[iF]==0)&&(iF>=1)) iF--; /* last exp_num of F */
435 if (iF==0) /* F0 is zero vector */
436 {
437 out=p_One(r);
438 p_SetExpV(out,G0,r);
439 p_Setm(out,r);
440 freeT(F,rN);
441 freeT(G,rN);
442 return(out);
443 }
444 jG=1;
445 while ((G[jG]==0)&&(jG<rN)) jG++; /* first exp_num of G */
446 iG=rN;
447 while ((G[iG]==0)&&(iG>1)) iG--; /* last exp_num of G */
448
449 out=p_One(r);
450
451 if (iF<=jG)
452 /* i.e. no mixed exp_num , MERGE case */
453 {
454 { for(int ii=rN;ii>0;ii--) F[ii]+=G[ii]; }
455 p_SetExpV(out,F,r);
456 p_Setm(out,r);
457 freeT(F,rN);
458 freeT(G,rN);
459 return(out);
460 }
461
462 number cff=n_Init(1,r->cf);
463 number tmp_num=NULL;
464 int cpower=0;
465
466 if (ncRingType(r)==nc_skew)
467 {
468 if (r->GetNC()->IsSkewConstant==1)
469 {
470 int tpower=0;
471 for(j=jG; j<=iG; j++)
472 {
473 if (G[j]!=0)
474 {
475 cpower = 0;
476 for(i=j+1; i<=iF; i++)
477 {
478 cpower = cpower + F[i];
479 }
480 cpower = cpower*G[j]; // bug! here may happen an arithmetic overflow!!!
481 tpower = tpower + cpower;
482 }
483 }
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);
487 cff = tmp_num;
488 }
489 else /* skew commutative with nonequal coeffs */
490 {
491 number totcff=n_Init(1,r->cf);
492 for(j=jG; j<=iG; j++)
493 {
494 if (G[j]!=0)
495 {
496 cpower = 0;
497 for(i=j+1; i<=iF; i++)
498 {
499 if (F[i]!=0)
500 {
501 cpower = F[i]*G[j]; // bug! overflow danger!!!
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);
509 }
510 } /* end 2nd for */
511 }
512 }
513 cff=totcff;
514 }
515 { for(int ii=rN;ii>0;ii--) F[ii]+=G[ii]; }
516 p_SetExpV(out,F,r);
517 p_Setm(out,r);
518 p_SetCoeff(out,cff,r);
519 freeT(F,rN);
520 freeT(G,rN);
521 return(out);
522 } /* end nc_skew */
523
524 /* now we have to destroy out! */
525 p_Delete(&out,r);
526
527 if (iG==jG)
528 /* g is univariate monomial */
529 {
530 /* if (ri->GetNC()->type==nc_skew) -- postpone to TU */
531 out = gnc_mm_Mult_uu(F,jG,G[jG],r);
532 freeT(F,rN);
533 freeT(G,rN);
534 return(out);
535 }
536
537 int *Prv=(int *)omAlloc0((rN+1)*sizeof(int));
538 int *Nxt=(int *)omAlloc0((rN+1)*sizeof(int));
539
540 int *log=(int *)omAlloc0((rN+1)*sizeof(int));
541 int cnt=0; int cnf=0;
542
543 /* splitting F wrt jG */
544 for (i=1;i<=jG;i++)
545 {
546 Prv[i]=F[i]; Nxt[i]=0; /* mult at the very end */
547 if (F[i]!=0) cnf++;
548 }
549
550 if (cnf==0) freeT(Prv,rN);
551
552 for (i=jG+1;i<=rN;i++)
553 {
554 Nxt[i]=F[i];
555 /* if (cnf!=0) Prv[i]=0; */
556 if (F[i]!=0)
557 {
558 cnt++;
559 } /* effective part for F */
560 }
561 freeT(F,rN);
562 cnt=0;
563
564 for (i=1;i<=rN;i++)
565 {
566 if (G[i]!=0)
567 {
568 cnt++;
569 log[cnt]=i;
570 } /* lG for G */
571 }
572
573/* ---------------------- A C T I O N ------------------------ */
574 poly D=NULL;
575 poly Rout=NULL;
576 number *c=(number *)omAlloc0((rN+1)*sizeof(number));
577 c[0]=n_Init(1,r->cf);
578
579 int *Op=Nxt;
580 int *On=G;
581 int *U=(int *)omAlloc0((rN+1)*sizeof(int));
582
583 for (i=jG;i<=rN;i++) U[i]=Nxt[i]+G[i]; /* make leadterm */
584 Nxt=NULL;
585 G=NULL;
586 cnt=1;
587 int t=0;
588 poly w=NULL;
589 poly Pn=p_One(r);
590 p_SetExpV(Pn,On,r);
591 p_Setm(Pn,r);
592
593 while (On[iG]!=0)
594 {
595 t=log[cnt];
596
597 w=gnc_mm_Mult_uu(Op,t,On[t],r);
598 c[cnt]=n_Mult(c[cnt-1],pGetCoeff(w),r->cf);
599 D = pNext(w); /* getting coef and rest D */
600 p_LmDelete(&w,r);
601 w=NULL;
602
603 Op[t] += On[t]; /* update exp_vectors */
604 On[t] = 0;
605
606 if (t!=iG) /* not the last step */
607 {
608 p_SetExpV(Pn,On,r);
609 p_Setm(Pn,r);
610#ifdef PDEBUG
611 p_Test(Pn,r);
612#endif
613
614// if (pNext(D)==0)
615// is D a monomial? could be postponed higher
616// {
617// Rout=nc_mm_Mult_nn(D,Pn,r);
618// }
619// else
620// {
621 Rout=gnc_p_Mult_mm(D,Pn,r);
622// }
623 }
624 else
625 {
626 Rout=D;
627 D=NULL;
628 }
629
630 if (Rout!=NULL)
631 {
632 Rout=__p_Mult_nn(Rout,c[cnt-1],r); /* Rest is ready */
633 out=p_Add_q(out,Rout,r);
634 Rout=NULL;
635 }
636 cnt++;
637 }
638 freeT(On,rN);
639 freeT(Op,rN);
640 p_Delete(&Pn,r);
641 omFreeSize((ADDRESS)log,(rN+1)*sizeof(int));
642
643 /* leadterm and Prv-part */
644
645 Rout=p_One(r);
646 /* U is lead.monomial */
647 U[0]=0;
648 p_SetExpV(Rout,U,r);
649 p_Setm(Rout,r); /* use again this name Rout */
650#ifdef PDEBUG
651 p_Test(Rout,r);
652#endif
653 p_SetCoeff(Rout,c[cnt-1],r);
654 out=p_Add_q(out,Rout,r);
655 freeT(U,rN);
656 freeN(c,rN+1);
657 if (cnf!=0) /* Prv is non-zero vector */
658 {
659 Rout=p_One(r);
660 Prv[0]=0;
661 p_SetExpV(Rout,Prv,r);
662 p_Setm(Rout,r);
663#ifdef PDEBUG
664 p_Test(Rout,r);
665#endif
666 out=gnc_p_mm_Mult(out,Rout,r); /* getting the final result */
667 freeT(Prv,rN);
668 p_Delete(&Rout,r);
669 }
670 return (out);
671}
void On(int sw)
switches
static FORCE_INLINE void n_Power(number a, int b, number *res, const coeffs r)
fill res with the power a^b
Definition coeffs.h:633
const CanonicalForm & w
Definition facAbsFact.cc:51
STATIC_VAR TreeM * G
Definition janet.cc:31
gmp_float log(const gmp_float &a)
#define freeN(A, k)
Definition old.gring.cc:102
poly gnc_p_Mult_mm(poly p, const poly m, const ring r)
Definition old.gring.cc:397
#define freeT(A, v)
Definition old.gring.cc:101
poly gnc_p_mm_Mult(poly m, const poly p, const ring r)
Definition old.gring.cc:403
poly gnc_mm_Mult_uu(int *F, int jG, int bG, const ring r)
Definition old.gring.cc:674
static void p_LmDelete(poly p, const ring r)
Definition p_polys.h:725
static void p_SetExpV(poly p, int *ev, const ring r)
Definition p_polys.h:1560

◆ gnc_mm_Mult_uu()

poly gnc_mm_Mult_uu ( int * F,
int jG,
int bG,
const ring r )

Definition at line 674 of file old.gring.cc.

676{
677 poly out=NULL;
678 int i;
679 number num=NULL;
680
681 int rN=r->N;
682 int iF=r->N;
683 while ((F[iF]==0)&&(iF>0)) iF-- ; /* last exponent_num of F */
684
685 if (iF==0) /* F==zero vector in other words */
686 {
687 out=p_One(r);
688 p_SetExp(out,jG,bG,r);
689 p_Setm(out,r);
690 return(out);
691 }
692
693 int jF=1;
694 while ((F[jF]==0)&&(jF<=rN)) jF++; /* first exp of F */
695
696 if (iF<=jG) /* i.e. no mixed exp_num */
697 {
698 out=p_One(r);
699 F[jG]=F[jG]+bG;
700 p_SetExpV(out,F,r);
701 p_Setm(out,r);
702 return(out);
703 }
704
705 if (iF==jF) /* uni times uni */
706 {
707 out=gnc_uu_Mult_ww(iF,F[iF],jG,bG,r);
708 return(out);
709 }
710
711 /* Now: F is mono with >=2 exponents, jG<iF */
712 /* check the quasi-commutative case */
713// matrix LCOM=r->GetNC()->COM;
714// number rescoef=n_Init(1,r);
715// number tmpcoef=n_Init(1,r);
716// int tmpint;
717// i=iF;
718// while (i>=jG+1)
719// /* all the non-zero exponents */
720// {
721// if (MATELEM(LCOM,jG,i)!=NULL)
722// {
723// tmpcoef=pGetCoeff(MATELEM(LCOM,jG,i));
724// tmpint=(int)F[i];
725// nPower(tmpcoef,F[i],&tmpcoef);
726// rescoef=nMult(rescoef,tmpcoef);
727// i--;
728// }
729// else
730// {
731// if (F[i]!=0) break;
732// }
733// }
734// if (iF==i)
735// /* no action took place*/
736// {
737
738// }
739// else /* power the result up to bG */
740// {
741// nPower(rescoef,bG,&rescoef);
742// /* + cleanup, post-processing */
743// }
744
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));
748
749 int cnt=0; int cnf=0;
750 /* splitting F wrt jG */
751 for (i=1;i<=jG;i++) /* mult at the very end */
752 {
753 Prv[i]=F[i]; Nxt[i]=0;
754 if (F[i]!=0) cnf++;
755 }
756
757 if (cnf==0)
758 {
759 freeT(Prv,rN); Prv = NULL;
760 }
761
762 for (i=jG+1;i<=rN;i++)
763 {
764 Nxt[i]=F[i];
765 if (cnf!=0) { Prv[i]=0;}
766 if (F[i]!=0)
767 {
768 cnt++;
769 lF[cnt]=i;
770 } /* eff_part,lF_for_F */
771 }
772
773 if (cnt==1) /* Nxt consists of 1 nonzero el-t only */
774 {
775 int q=lF[1];
776 poly Rout=p_One(r);
777 out=gnc_uu_Mult_ww(q,Nxt[q],jG,bG,r);
778
779 freeT(Nxt,rN); Nxt = NULL;
780
781 if (cnf!=0)
782 {
783 Prv[0]=0;
784 p_SetExpV(Rout,Prv,r);
785 p_Setm(Rout,r);
786
787#ifdef PDEBUG
788 p_Test(Rout,r);
789#endif
790
791 freeT(Prv,rN);
792 Prv = NULL;
793
794 out=gnc_p_mm_Mult(out,Rout,r); /* getting the final result */
795 }
796
797 freeT(lF,rN);
798 lF = NULL;
799
800 p_Delete(&Rout,r);
801
802 assume(Nxt == NULL);
803 assume(lF == NULL);
804 assume(Prv == NULL);
805
806 return (out);
807 }
808/* -------------------- MAIN ACTION --------------------- */
809
810 poly D=NULL;
811 poly Rout=NULL;
812 number *c=(number *)omAlloc0((cnt+2)*sizeof(number));
813 c[cnt+1]=n_Init(1,r->cf);
814 i=cnt+2; /* later in freeN */
815 int *Op=Nxt;
816
817 int *On=(int *)omAlloc0((rN+1)*sizeof(int));
818 int *U=(int *)omAlloc0((rN+1)*sizeof(int));
819
820
821 // pExpVectorCopy(U,Nxt);
822 memcpy(U, Nxt,(rN+1)*sizeof(int));
823 U[jG] = U[jG] + bG;
824
825 /* Op=Nxt and initial On=(0); */
826 Nxt=NULL;
827
828 poly Pp;
829 poly Pn;
830 int t=0;
831 int first=lF[1];
832 int nlast=lF[cnt];
833 int kk=0;
834 /* cnt--; */
835 /* now lF[cnt] should be <=iF-1 */
836
837 while (Op[first]!=0)
838 {
839 t=lF[cnt]; /* cnt as it was computed */
840
841 poly w=gnc_uu_Mult_ww(t,Op[t],jG,bG,r);
842 c[cnt]=n_Copy(pGetCoeff(w),r->cf);
843 D = pNext(w); /* getting coef and rest D */
844 p_LmDelete(&w,r);
845 w=NULL;
846
847 Op[t]= 0;
848 Pp=p_One(r);
849 p_SetExpV(Pp,Op,r);
850 p_Setm(Pp,r);
851
852 if (t<nlast)
853 {
854 kk=lF[cnt+1];
855 On[kk]=F[kk];
856
857 Pn=p_One(r);
858 p_SetExpV(Pn,On,r);
859 p_Setm(Pn,r);
860
861 if (t!=first) /* typical expr */
862 {
863 w=gnc_p_Mult_mm(D,Pn,r);
864 Rout=gnc_p_mm_Mult(w,Pp,r);
865 w=NULL;
866 }
867 else /* last step */
868 {
869 On[t]=0;
870 p_SetExpV(Pn,On,r);
871 p_Setm(Pn,r);
872 Rout=gnc_p_Mult_mm(D,Pn,r);
873 }
874#ifdef PDEBUG
875 p_Test(Pp,r);
876#endif
877 p_Delete(&Pn,r);
878 }
879 else /* first step */
880 {
881 Rout=gnc_p_mm_Mult(D,Pp,r);
882 }
883#ifdef PDEBUG
884 p_Test(Pp,r);
885#endif
886 p_Delete(&Pp,r);
887 num=n_Mult(c[cnt+1],c[cnt],r->cf);
888 n_Delete(&c[cnt],r->cf);
889 c[cnt]=num;
890 Rout=__p_Mult_nn(Rout,c[cnt+1],r); /* Rest is ready */
891 out=p_Add_q(out,Rout,r);
892 Pp=NULL;
893 cnt--;
894 }
895 /* only to feel safe:*/
896 Pn=Pp=NULL;
897 freeT(On,rN);
898 freeT(Op,rN);
899
900/* leadterm and Prv-part with coef 1 */
901/* U[0]=exp; */
902/* U[jG]=U[jG]+bG; */
903/* make leadterm */
904/* ??????????? we have done it already :-0 */
905
906 Rout=p_One(r);
907 p_SetExpV(Rout,U,r);
908 p_Setm(Rout,r); /* use again this name */
909 p_SetCoeff(Rout,c[cnt+1],r); /* last computed coef */
910
911 out=p_Add_q(out,Rout,r);
912
913 Rout=NULL;
914
915 freeT(U, rN);
916 freeN(c, i);
917 freeT(lF, rN);
918
919 if (cnf!=0)
920 {
921 Rout=p_One(r);
922 p_SetExpV(Rout,Prv,r);
923 p_Setm(Rout,r);
924 freeT(Prv, rN);
925 out=gnc_p_mm_Mult(out,Rout,r); /* getting the final result */
926 p_Delete(&Rout,r);
927 }
928
929 return (out);
930}
CanonicalForm num(const CanonicalForm &f)
poly gnc_uu_Mult_ww(int i, int a, int j, int b, const ring r)

◆ gnc_p_mm_Mult()

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

Definition at line 403 of file old.gring.cc.

404{
405 return( gnc_p_Mult_mm_Common(p, m, 0, r) );
406}
poly gnc_p_Mult_mm_Common(poly p, const poly m, int side, const ring r)
Definition old.gring.cc:301

◆ gnc_p_Mult_mm()

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

Definition at line 397 of file old.gring.cc.

398{
399 return( gnc_p_Mult_mm_Common(p, m, 1, r) );
400}

◆ gnc_p_Mult_mm_Common()

poly gnc_p_Mult_mm_Common ( poly p,
const poly m,
int side,
const ring r )

Definition at line 301 of file old.gring.cc.

304{
305 if ((p==NULL) || (m==NULL)) return NULL;
306 /* if (pNext(p)==NULL) return(nc_mm_Mult_nn(p,pCopy(m),r)); */
307 /* excluded - the cycle will do it anyway - OK. */
308 if (p_IsConstant(m,r)) return(__p_Mult_nn(p,p_GetCoeff(m,r),r));
309
310#ifdef PDEBUG
311 p_Test(p,r);
312 p_Test(m,r);
313#endif
314 poly v=NULL;
315 int rN=r->N;
316 int *P=(int *)omAlloc0((rN+1)*sizeof(int));
317 int *M=(int *)omAlloc0((rN+1)*sizeof(int));
318 /* coefficients: */
319 number cP,cM,cOut;
320 p_GetExpV(m, M, r);
321 cM=p_GetCoeff(m,r);
322 /* components:*/
323 const int expM=p_GetComp(m,r);
324 int expP=0;
325 int expOut=0;
326 /* bucket constraints: */
327 int UseBuckets=1;
328 if (pLength(p)< MIN_LENGTH_BUCKET || TEST_OPT_NOT_BUCKETS) UseBuckets=0;
329
330 CPolynomialSummator sum(r, UseBuckets == 0);
331
332 while (p!=NULL)
333 {
334#ifdef PDEBUG
335 p_Test(p,r);
336#endif
337 expP=p_GetComp(p,r);
338 if (expP==0)
339 {
340 expOut=expM;
341 }
342 else
343 {
344 if (expM==0)
345 {
346 expOut=expP;
347#ifdef PDEBUG
348// if (side)
349// {
350// PrintS("gnc_p_Mult_mm: Multiplication in the left module from the right");
351// }
352#endif
353 }
354 else
355 {
356 /* REPORT_ERROR */
357#ifdef PDEBUG
358 const char* s;
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);
362#endif
363 expOut=0;
364 }
365 }
366 p_GetExpV(p,P,r);
367 cP=pGetCoeff(p);
368 cOut=n_Mult(cP,cM,r->cf);
369 if (side==1)
370 {
371 v = gnc_mm_Mult_nn(P, M, r);
372 }
373 else
374 {
375 v = gnc_mm_Mult_nn(M, P, r);
376 }
377 v = __p_Mult_nn(v,cOut,r);
378 n_Delete(&cOut,r->cf);
379 p_SetCompP(v,expOut,r);
380
381 sum += v;
382
383 p_LmDelete(&p,r);
384 }
385 freeT(P,rN);
386 freeT(M,rN);
387
388 return(sum);
389}
#define Print
Definition emacs.cc:80
const CanonicalForm int s
Definition facAbsFact.cc:51
poly gnc_mm_Mult_nn(int *F, int *G, const ring r)
Definition old.gring.cc:415
static void p_SetCompP(poly p, int i, ring r)
Definition p_polys.h:256
static void p_GetExpV(poly p, int *ev, const ring r)
Definition p_polys.h:1536
#define M
Definition sirandom.c:25

◆ gnc_p_ProcsSet()

static void gnc_p_ProcsSet ( ring rGR,
p_Procs_s * p_Procs )
inlinestatic

Definition at line 3097 of file old.gring.cc.

3098{
3099 // "commutative"
3100 p_Procs->p_Mult_mm = rGR->p_Procs->p_Mult_mm = gnc_p_Mult_mm;
3101 p_Procs->pp_Mult_mm = rGR->p_Procs->pp_Mult_mm = gnc_pp_Mult_mm;
3102 p_Procs->p_Minus_mm_Mult_qq = rGR->p_Procs->p_Minus_mm_Mult_qq = nc_p_Minus_mm_Mult_qq;
3103
3104 // non-commutaitve multiplication by monomial from the left
3105 p_Procs->p_mm_Mult = gnc_p_mm_Mult;
3106 p_Procs->pp_mm_Mult = gnc_pp_mm_Mult;
3107
3108#if 0
3109 // Previous Plural's implementation...
3110 rGR->GetNC()->p_Procs.SPoly = gnc_CreateSpolyOld;
3111 rGR->GetNC()->p_Procs.ReduceSPoly = gnc_ReduceSpolyOld;
3112
3113 rGR->GetNC()->p_Procs.BucketPolyRed = gnc_kBucketPolyRedOld;
3114 rGR->GetNC()->p_Procs.BucketPolyRed_Z= gnc_kBucketPolyRed_ZOld;
3115#else
3116 // A bit cleaned up and somewhat rewritten functions...
3117 rGR->GetNC()->p_Procs.SPoly = gnc_CreateSpolyNew;
3118 rGR->GetNC()->p_Procs.ReduceSPoly = gnc_ReduceSpolyNew;
3119
3120 rGR->GetNC()->p_Procs.BucketPolyRed_NF= gnc_kBucketPolyRedNew;
3121 rGR->GetNC()->p_Procs.BucketPolyRed_Z= gnc_kBucketPolyRed_ZNew;
3122#endif
3123
3124 // warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object?
3125 if (rHasLocalOrMixedOrdering(rGR))
3126 rGR->GetNC()->p_Procs.GB = cast_A_to_vptr(gnc_gr_mora);
3127 else
3128 rGR->GetNC()->p_Procs.GB = cast_A_to_vptr(gnc_gr_bba);
3129
3130/////////// rGR->GetNC()->p_Procs.GB = gnc_gr_bba; // bba even for local case!
3131// old /// r->GetNC()->GB() = gnc_gr_bba;
3132// rGR->GetNC()->p_Procs.GlobalGB = gnc_gr_bba;
3133// rGR->GetNC()->p_Procs.LocalGB = gnc_gr_mora;
3134// const ring save = currRing; if( save != r ) rChangeCurrRing(r);
3135// ideal res = gnc_gr_bba(F, Q, w, hilb, strat/*, r*/);
3136// if( save != r ) rChangeCurrRing(save); return (res);
3137
3138
3139#if 0
3140 // Old Stuff
3141 p_Procs->p_Mult_mm = gnc_p_Mult_mm;
3142 _p_procs->p_Mult_mm = gnc_p_Mult_mm;
3143
3144 p_Procs->pp_Mult_mm = gnc_pp_Mult_mm;
3145 _p_procs->pp_Mult_mm = gnc_pp_Mult_mm;
3146
3147 p_Procs->p_Minus_mm_Mult_qq = NULL; // gnc_p_Minus_mm_Mult_qq_ign;
3148 _p_procs->p_Minus_mm_Mult_qq= NULL; // gnc_p_Minus_mm_Mult_qq_ign;
3149
3150 r->GetNC()->mmMultP() = gnc_mm_Mult_p;
3151 r->GetNC()->mmMultPP() = gnc_mm_Mult_pp;
3152
3153 r->GetNC()->SPoly() = gnc_CreateSpoly;
3154 r->GetNC()->ReduceSPoly() = gnc_ReduceSpoly;
3155
3156#endif
3157}
void * cast_A_to_vptr(A a)
Definition auxiliary.h:386
EXTERN_VAR BBA_Proc gnc_gr_bba
Definition gb_hack.h:10
EXTERN_VAR BBA_Proc gnc_gr_mora
Definition gb_hack.h:10
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
Definition old.gring.cc:150
static void gnc_kBucketPolyRed_ZNew(kBucket_pt b, poly p, number *c, BOOLEAN reduce)
poly gnc_ReduceSpolyOld(const poly p1, poly p2, const ring r)
poly gnc_CreateSpolyNew(const poly p1, const poly p2, const ring r)
poly gnc_pp_mm_Mult(const poly p, const poly m, const ring r)
Definition old.gring.cc:408
poly gnc_ReduceSpolyNew(const poly p1, poly p2, const ring r)
poly gnc_CreateSpolyOld(const poly p1, const poly p2, const ring r)
void gnc_kBucketPolyRed_ZOld(kBucket_pt b, poly p, number *c)
void gnc_kBucketPolyRedOld(kBucket_pt b, poly p, number *c)
static void gnc_kBucketPolyRedNew(kBucket_pt b, poly p, number *c, BOOLEAN)
poly gnc_pp_Mult_mm(const poly p, const poly m, const ring r, poly &last)
STATIC_VAR p_Procs_s * _p_procs
static BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition ring.h:769

◆ gnc_pp_mm_Mult()

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

Definition at line 408 of file old.gring.cc.

409{
410 return( gnc_p_Mult_mm_Common(p_Copy(p,r), m, 0, r) );
411}

◆ gnc_pp_Mult_mm() [1/2]

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

Definition at line 392 of file old.gring.cc.

393{
394 return( gnc_p_Mult_mm_Common(p_Copy(p,r), m, 1, r) );
395}

◆ gnc_pp_Mult_mm() [2/2]

poly gnc_pp_Mult_mm ( const poly p,
const poly m,
const ring r,
poly & last )

◆ gnc_ReduceSpolyNew()

poly gnc_ReduceSpolyNew ( const poly p1,
poly p2,
const ring r )

Definition at line 1399 of file old.gring.cc.

1400{
1401 assume(p_LmDivisibleBy(p1, p2, r));
1402
1403 const long lCompP1 = p_GetComp(p1,r);
1404 const long lCompP2 = p_GetComp(p2,r);
1405
1406 if ((lCompP1!=lCompP2) && (lCompP1!=0) && (lCompP2!=0))
1407 {
1408#ifdef PDEBUG
1409 WerrorS("gnc_ReduceSpolyNew: different non-zero components!");
1410#endif
1411 return(NULL);
1412 }
1413
1414 poly m = p_One(r);
1415 p_ExpVectorDiff(m, p2, p1, r);
1416 //p_Setm(m,r);
1417#ifdef PDEBUG
1418 p_Test(m,r);
1419#endif
1420
1421 /* pSetComp(m,r)=0? */
1422 poly N = nc_mm_Mult_p(m, p_Head(p1,r), r);
1423
1424 number C = p_GetCoeff(N, r);
1425 number cF = p_GetCoeff(p2, r);
1426
1427 /* GCD stuff */
1428 number cG = n_SubringGcd(C, cF, r->cf);
1429
1430 if (!n_IsOne(cG, r->cf))
1431 {
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);
1434 }
1435 else
1436 {
1437 cF = n_Copy(cF, r->cf);
1438 C = n_Copy(C, r->cf);
1439 }
1440 n_Delete(&cG,r->cf);
1441
1442 p2 = __p_Mult_nn(p2, C, r); // p2 !!!
1443 p_Test(p2,r);
1444 n_Delete(&C,r->cf);
1445
1446 poly out = nc_mm_Mult_pp(m, pNext(p1), r);
1447 p_Delete(&m,r);
1448
1449 N = p_Add_q(N, out, r);
1450 p_Test(N,r);
1451
1452 if (!n_IsMOne(cF,r->cf)) // ???
1453 {
1454 cF = n_InpNeg(cF,r->cf);
1455 N = __p_Mult_nn(N, cF, r);
1456 p_Test(N,r);
1457 }
1458 n_Delete(&cF,r->cf);
1459
1460 out = p_Add_q(p2,N,r); // delete N, p2
1461 p_Test(out,r);
1462 if ( out!=NULL ) p_Cleardenom(out,r);
1463 return(out);
1464}
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition p_polys.h:1907

◆ gnc_ReduceSpolyOld()

poly gnc_ReduceSpolyOld ( const poly p1,
poly p2,
const ring r )

Definition at line 1343 of file old.gring.cc.

1344{
1345 assume(p_LmDivisibleBy(p1, p2, r));
1346
1347#ifdef PDEBUG
1348 if (p_GetComp(p1,r)!=p_GetComp(p2,r)
1349 && (p_GetComp(p1,r)!=0)
1350 && (p_GetComp(p2,r)!=0))
1351 {
1352 dReportError("nc_ReduceSpolyOld: different components");
1353 return(NULL);
1354 }
1355#endif
1356 poly m = p_One(r);
1357 p_ExpVectorDiff(m,p2,p1,r);
1358 //p_Setm(m,r);
1359#ifdef PDEBUG
1360 p_Test(m,r);
1361#endif
1362 /* pSetComp(m,r)=0? */
1363 poly N = nc_mm_Mult_p(m, p_Head(p1,r), r);
1364 number C = p_GetCoeff(N, r);
1365 number cF = p_GetCoeff(p2, r);
1366 /* GCD stuff */
1367 number cG = n_SubringGcd(C, cF, r->cf);
1368 if ( !n_IsOne(cG,r->cf) )
1369 {
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);
1372 }
1373 else
1374 {
1375 cF = n_Copy(cF, r->cf);
1376 C = n_Copy(C, r->cf);
1377 }
1378 n_Delete(&cG,r->cf);
1379 p2 = __p_Mult_nn(p2, C, r);
1380 poly out = nc_mm_Mult_pp(m, pNext(p1), r);
1381 N = p_Add_q(N, out, r);
1382 p_Test(p2,r);
1383 p_Test(N,r);
1384 if (!n_IsMOne(cF,r->cf))
1385 {
1386 cF = n_InpNeg(cF,r->cf);
1387 N = __p_Mult_nn(N, cF, r);
1388 p_Test(N,r);
1389 }
1390 out = p_Add_q(p2,N,r);
1391 p_Test(out,r);
1392 if ( out!=NULL ) p_Cleardenom(out,r);
1393 p_Delete(&m,r);
1394 n_Delete(&cF,r->cf);
1395 n_Delete(&C,r->cf);
1396 return(out);
1397}

◆ gnc_uu_Mult_ww()

poly gnc_uu_Mult_ww ( int i,
int a,
int j,
int b,
const ring r )

Definition at line 1040 of file old.gring.cc.

1043{
1044 /* Check zero exceptions, (q-)commutativity and is there something to do? */
1045 assume(a!=0);
1046 assume(b!=0);
1047 poly out=p_One(r);
1048 if (i<=j)
1049 {
1050 p_SetExp(out,i,a,r);
1051 p_AddExp(out,j,b,r);
1052 p_Setm(out,r);
1053 return(out);
1054 }/* zero exceptions and usual case */
1055 /* if ((a==0)||(b==0)||(i<=j)) return(out); */
1056
1057 if (MATELEM(r->GetNC()->COM,j,i)!=NULL)
1058 /* commutative or quasicommutative case */
1059 {
1060 p_SetExp(out,i,a,r);
1061 p_AddExp(out,j,b,r);
1062 p_Setm(out,r);
1063 if (n_IsOne(pGetCoeff(MATELEM(r->GetNC()->COM,j,i)),r->cf)) /* commutative case */
1064 {
1065 return(out);
1066 }
1067 else
1068 {
1069 number tmp_number=pGetCoeff(MATELEM(r->GetNC()->COM,j,i)); /* quasicommutative case */
1070 n_Power(tmp_number,a*b,&tmp_number, r->cf); // BUG! ;-(
1071 p_SetCoeff(out,tmp_number,r);
1072 return(out);
1073 }
1074 }/* end_of commutative or quasicommutative case */
1075 p_Delete(&out,r);
1076
1077
1078 if(ncExtensions(NOCACHEMASK) && !ncExtensions(NOFORMULAMASK)) // don't use cache whenever possible!
1079 { // without cache!?
1080 CFormulaPowerMultiplier* FormulaMultiplier = GetFormulaPowerMultiplier(r);
1082
1083 if( FormulaMultiplier != NULL )
1084 PairType = FormulaMultiplier->GetPair(j, i);
1085
1086 if( PairType != _ncSA_notImplemented )
1087 // // return FormulaMultiplier->Multiply(j, i, b, a);
1088 return CFormulaPowerMultiplier::Multiply( PairType, j, i, b, a, r);
1089 }
1090
1091
1092 /* we are here if i>j and variables do not commute or quasicommute */
1093 /* in fact, now a>=1 and b>=1; and j<i */
1094 /* now check whether the polynomial is already computed */
1095 int rN=r->N;
1096 int vik = UPMATELEM(j,i,rN);
1097 int cMTsize=r->GetNC()->MTsize[vik];
1098 int newcMTsize=0;
1099 newcMTsize=si_max(a,b);
1100
1101 if (newcMTsize<=cMTsize)
1102 {
1103 out = nc_p_CopyGet(MATELEM(r->GetNC()->MT[vik],a,b),r);
1104 if (out !=NULL) return (out);
1105 }
1106 int k,m;
1107 if (newcMTsize > cMTsize)
1108 {
1109 int inM=(((newcMTsize+6)/7)*7);
1110 assume (inM>=newcMTsize);
1111 newcMTsize = inM;
1112 // matrix tmp = (matrix)omAlloc0(inM*inM*sizeof(poly));
1113 matrix tmp = mpNew(newcMTsize,newcMTsize);
1114
1115 for (k=1;k<=cMTsize;k++)
1116 {
1117 for (m=1;m<=cMTsize;m++)
1118 {
1119 out = MATELEM(r->GetNC()->MT[UPMATELEM(j,i,rN)],k,m);
1120 if ( out != NULL )
1121 {
1122 MATELEM(tmp,k,m) = out;/*MATELEM(r->GetNC()->MT[UPMATELEM(j,i,rN)],k,m)*/
1123 // omCheckAddr(tmp->m);
1124 MATELEM(r->GetNC()->MT[UPMATELEM(j,i,rN)],k,m)=NULL;
1125 // omCheckAddr(r->GetNC()->MT[UPMATELEM(j,i,rN)]->m);
1126 out=NULL;
1127 }
1128 }
1129 }
1130 id_Delete((ideal *)&(r->GetNC()->MT[UPMATELEM(j,i,rN)]),r);
1131 r->GetNC()->MT[UPMATELEM(j,i,rN)] = tmp;
1132 tmp=NULL;
1133 r->GetNC()->MTsize[UPMATELEM(j,i,rN)] = newcMTsize;
1134 }
1135 /* The update of multiplication matrix is finished */
1136
1137
1138 return gnc_uu_Mult_ww_formula(i, a, j, b, r);
1139
1140 out = gnc_uu_Mult_ww_vert(i, a, j, b, r);
1141 // out = nc_uu_Mult_ww_horvert(i, a, j, b, r);
1142 return(out);
1143}
Enum_ncSAType GetPair(int i, int j) const
Definition ncSAFormula.h:44
static poly Multiply(Enum_ncSAType type, const int i, const int j, const int n, const int m, const ring r)
const int NOCACHEMASK
Definition nc.h:336
const int NOFORMULAMASK
Definition nc.h:335
static CFormulaPowerMultiplier * GetFormulaPowerMultiplier(const ring r)
Definition ncSAFormula.h:93
Enum_ncSAType
Definition ncSAFormula.h:16
@ _ncSA_notImplemented
Definition ncSAFormula.h:17
static poly gnc_uu_Mult_ww_formula(int i, int a, int j, int b, const ring r)
bool ncExtensions(int iMask)
Definition old.gring.cc:94
poly gnc_uu_Mult_ww_vert(int i, int a, int j, int b, const ring r)
Definition old.gring.cc:932
static long p_AddExp(poly p, int v, long ee, ring r)
Definition p_polys.h:608
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix

◆ gnc_uu_Mult_ww_formula()

static poly gnc_uu_Mult_ww_formula ( int i,
int a,
int j,
int b,
const ring r )
inlinestatic

Definition at line 1007 of file old.gring.cc.

1008{
1010 return gnc_uu_Mult_ww_vert(i, a, j, b, r);
1011
1012 CFormulaPowerMultiplier* FormulaMultiplier = GetFormulaPowerMultiplier(r);
1014
1015 if( FormulaMultiplier != NULL )
1016 PairType = FormulaMultiplier->GetPair(j, i);
1017
1018
1019 if( PairType == _ncSA_notImplemented )
1020 return gnc_uu_Mult_ww_vert(i, a, j, b, r);
1021
1022
1023 // return FormulaMultiplier->Multiply(j, i, b, a);
1024 poly t = CFormulaPowerMultiplier::Multiply( PairType, j, i, b, a, r);
1025
1026 int rN=r->N;
1027 matrix cMT = r->GetNC()->MT[UPMATELEM(j,i,rN)]; /* cMT=current MT */
1028
1029
1030 MATELEM(cMT, a, b) = nc_p_CopyPut(t,r);
1031
1032 // t=MATELEM(cMT,a,b);
1033// t= nc_p_CopyGet(MATELEM(cMT,a,b),r);
1034 // return(p_Copy(t,r));
1035 /* since the last computed element was cMT[a,b] */
1036 return(t);
1037}

◆ gnc_uu_Mult_ww_horvert()

poly gnc_uu_Mult_ww_horvert ( int i,
int a,
int j,
int b,
const ring r )

Definition at line 1145 of file old.gring.cc.

1147{
1148 int k,m;
1149 int rN=r->N;
1150 matrix cMT=r->GetNC()->MT[UPMATELEM(j,i,rN)]; /* cMT=current MT */
1151
1152 poly x=p_One(r);p_SetExp(x,j,1,r);p_Setm(x,r);/* var(j); */
1153 poly y=p_One(r);p_SetExp(y,i,1,r);p_Setm(y,r); /*var(i); for convenience */
1154#ifdef PDEBUG
1155 p_Test(x,r);
1156 p_Test(y,r);
1157#endif
1158
1159 poly t=NULL;
1160
1161 int toXY;
1162 int toYX;
1163
1164 if (a==1) /* y*x^b, b>=2 */
1165 {
1166 toXY=b-1;
1167 while ( (MATELEM(cMT,1,toXY)==NULL) && (toXY>=2)) toXY--;
1168 for (m=toXY+1;m<=b;m++)
1169 {
1170 t=MATELEM(cMT,1,m);
1171 if (t==NULL) /* remove after debug */
1172 {
1173 t = p_Copy(MATELEM(cMT,1,m-1),r);
1174 t = gnc_p_Mult_mm(t,x,r);
1175 MATELEM(cMT,1,m) = t;
1176 /* omCheckAddr(cMT->m); */
1177 }
1178 else
1179 {
1180 /* Error, should never get there */
1181 WarnS("Error: a=1; MATELEM!=0");
1182 }
1183 t=NULL;
1184 }
1185 return(p_Copy(MATELEM(cMT,1,b),r));
1186 }
1187
1188 if (b==1) /* y^a*x, a>=2 */
1189 {
1190 toYX=a-1;
1191 while ( (MATELEM(cMT,toYX,1)==NULL) && (toYX>=2)) toYX--;
1192 for (m=toYX+1;m<=a;m++)
1193 {
1194 t=MATELEM(cMT,m,1);
1195 if (t==NULL) /* remove after debug */
1196 {
1197 t = p_Copy(MATELEM(cMT,m-1,1),r);
1198 t = gnc_p_mm_Mult(t,y,r);
1199 MATELEM(cMT,m,1) = t;
1200 /* omCheckAddr(cMT->m); */
1201 }
1202 else
1203 {
1204 /* Error, should never get there */
1205 WarnS("Error: b=1, MATELEM!=0");
1206 }
1207 t=NULL;
1208 }
1209 return(p_Copy(MATELEM(cMT,a,1),r));
1210 }
1211
1212/* ------------ Main Cycles ----------------------------*/
1213 /* a>1, b>1 */
1214
1215 int dXY=0; int dYX=0;
1216 /* dXY = distance for computing x-mult, then y-mult */
1217 /* dYX = distance for computing y-mult, then x-mult */
1218 int toX=a-1; int toY=b-1; /* toX = to axe X, toY = to axe Y */
1219 toXY=b-1; toYX=a-1;
1220 /* if toX==0, toXY = dist. to computed y * x^toXY */
1221 /* if toY==0, toYX = dist. to computed y^toYX * x */
1222 while ( (MATELEM(cMT,toX,b)==NULL) && (toX>=1)) toX--;
1223 if (toX==0) /* the whole column is not computed yet */
1224 {
1225 while ( (MATELEM(cMT,1,toXY)==NULL) && (toXY>=1)) toXY--;
1226 /* toXY >=1 */
1227 dXY=b-1-toXY;
1228 }
1229 dXY=dXY+a-toX; /* the distance to nearest computed y^toX x^b */
1230
1231 while ( (MATELEM(cMT,a,toY)==NULL) && (toY>=1)) toY--;
1232 if (toY==0) /* the whole row is not computed yet */
1233 {
1234 while ( (MATELEM(cMT,toYX,1)==NULL) && (toYX>=1)) toYX--;
1235 /* toYX >=1 */
1236 dYX=a-1-toYX;
1237 }
1238 dYX=dYX+b-toY; /* the distance to nearest computed y^a x^toY */
1239
1240 if (dYX>=dXY)
1241 {
1242 /* first x, then y */
1243 if (toX==0) /* start with the row*/
1244 {
1245 for (m=toXY+1;m<=b;m++)
1246 {
1247 t=MATELEM(cMT,1,m);
1248 if (t==NULL) /* remove after debug */
1249 {
1250 t = p_Copy(MATELEM(cMT,1,m-1),r);
1251 t = gnc_p_Mult_mm(t,x,r);
1252 MATELEM(cMT,1,m) = t;
1253 /* omCheckAddr(cMT->m); */
1254 }
1255 else
1256 {
1257 /* Error, should never get there */
1258 WarnS("dYX>=dXY,toXY; MATELEM==0");
1259 }
1260 t=NULL;
1261 }
1262 toX=1; /* y*x^b is computed */
1263 }
1264 /* Now toX>=1 */
1265 for (k=toX+1;k<=a;k++)
1266 {
1267 t=MATELEM(cMT,k,b);
1268 if (t==NULL) /* remove after debug */
1269 {
1270 t = p_Copy(MATELEM(cMT,k-1,b),r);
1271 t = gnc_p_mm_Mult(t,y,r);
1272 MATELEM(cMT,k,b) = t;
1273 /* omCheckAddr(cMT->m); */
1274 }
1275 else
1276 {
1277 /* Error, should never get there */
1278 WarnS("dYX>=dXY,toX; MATELEM==0");
1279 }
1280 t=NULL;
1281 }
1282 } /* endif (dYX>=dXY) */
1283
1284
1285 if (dYX<dXY)
1286 {
1287 /* first y, then x */
1288 if (toY==0) /* start with the column*/
1289 {
1290 for (m=toYX+1;m<=a;m++)
1291 {
1292 t=MATELEM(cMT,m,1);
1293 if (t==NULL) /* remove after debug */
1294 {
1295 t = p_Copy(MATELEM(cMT,m-1,1),r);
1296 t = gnc_p_mm_Mult(t,y,r);
1297 MATELEM(cMT,m,1) = t;
1298 /* omCheckAddr(cMT->m); */
1299 }
1300 else
1301 {
1302 /* Error, should never get there */
1303 WarnS("dYX<dXY,toYX; MATELEM==0");
1304 }
1305 t=NULL;
1306 }
1307 toY=1; /* y^a*x is computed */
1308 }
1309 /* Now toY>=1 */
1310 for (k=toY+1;k<=b;k++)
1311 {
1312 t=MATELEM(cMT,a,k);
1313 if (t==NULL) /* remove after debug */
1314 {
1315 t = p_Copy(MATELEM(cMT,a,k-1),r);
1316 t = gnc_p_Mult_mm(t,x,r);
1317 MATELEM(cMT,a,k) = t;
1318 /* omCheckAddr(cMT->m); */
1319 }
1320 else
1321 {
1322 /* Error, should never get there */
1323 WarnS("dYX<dXY,toY; MATELEM==0");
1324 }
1325 t=NULL;
1326 }
1327 } /* endif (dYX<dXY) */
1328
1329 p_Delete(&x,r);
1330 p_Delete(&y,r);
1331 t=p_Copy(MATELEM(cMT,a,b),r);
1332 return(t); /* since the last computed element was cMT[a,b] */
1333}
Variable x
Definition cfModGcd.cc:4090
const CanonicalForm int const CFList const Variable & y
Definition facAbsFact.cc:53

◆ gnc_uu_Mult_ww_vert()

poly gnc_uu_Mult_ww_vert ( int i,
int a,
int j,
int b,
const ring r )

Definition at line 932 of file old.gring.cc.

933{
934 int k,m;
935 int rN=r->N;
936 const int cMTindex = UPMATELEM(j,i,rN);
937 matrix cMT=r->GetNC()->MT[cMTindex]; /* cMT=current MT */
938
939 poly x=p_One(r);p_SetExp(x,j,1,r);p_Setm(x,r);
940/* var(j); */
941 poly y=p_One(r);p_SetExp(y,i,1,r);p_Setm(y,r);
942/*var(i); for convenience */
943#ifdef PDEBUG
944 p_Test(x,r);
945 p_Test(y,r);
946#endif
947 poly t=NULL;
948/* ------------ Main Cycles ----------------------------*/
949
950 for (k=2;k<=a;k++)
951 {
952 t = MATELEM(cMT,k,1);
953
954 if (t==NULL) /* not computed yet */
955 {
956 t = nc_p_CopyGet(MATELEM(cMT,k-1,1),r);
957 // t=p_Copy(MATELEM(cMT,k-1,1),r);
958 t = gnc_p_mm_Mult(t,y,r);
959 cMT=r->GetNC()->MT[cMTindex]; // since multiplication can change the MT table...
960 assume( t != NULL );
961#ifdef PDEBUG
962 p_Test(t,r);
963#endif
964 MATELEM(cMT,k,1) = nc_p_CopyPut(t,r);
965 // omCheckAddr(cMT->m);
966 p_Delete(&t,r);
967 }
968 t=NULL;
969 }
970
971 for (m=2;m<=b;m++)
972 {
973 t = MATELEM(cMT,a,m);
974 // t=MATELEM(cMT,a,m);
975 if (t==NULL) //not computed yet
976 {
977 t = nc_p_CopyGet(MATELEM(cMT,a,m-1),r);
978 assume( t != NULL );
979 // t=p_Copy(MATELEM(cMT,a,m-1),r);
980 t = gnc_p_Mult_mm(t,x,r);
981 cMT=r->GetNC()->MT[cMTindex]; // since multiplication can change the MT table...
982#ifdef PDEBUG
983 p_Test(t,r);
984#endif
985 MATELEM(cMT,a,m) = nc_p_CopyPut(t,r);
986 // MATELEM(cMT,a,m) = t;
987 // omCheckAddr(cMT->m);
988 p_Delete(&t,r);
989 }
990 t=NULL;
991 }
992 p_Delete(&x,r);
993 p_Delete(&y,r);
994 t=MATELEM(cMT,a,b);
995 assume( t != NULL );
996
997 t= nc_p_CopyGet(t,r);
998#ifdef PDEBUG
999 p_Test(t,r);
1000#endif
1001 // return(p_Copy(t,r));
1002 /* since the last computed element was cMT[a,b] */
1003 return(t);
1004}

◆ idOppose()

ideal idOppose ( ring Rop,
ideal I,
const ring dst )

opposes a module I from Rop to currRing(dst)

Definition at line 3363 of file old.gring.cc.

3364{
3365 /* the simplest case:*/
3366 if ( Rop == dst ) return id_Copy(I, dst);
3367
3368 /* check Rop == rOpposite(currRing) */
3369 if (!rIsLikeOpposite(dst, Rop))
3370 {
3371 WarnS("an opposite ring should be used");
3372 return NULL;
3373 }
3374 int i;
3375 ideal idOp = idInit(I->ncols, I->rank);
3376 for (i=0; i< (I->ncols)*(I->nrows); i++)
3377 {
3378 idOp->m[i] = pOppose(Rop,I->m[i], dst);
3379 }
3380 id_Test(idOp, dst);
3381 return idOp;
3382}
ideal id_Copy(ideal h1, const ring r)
copy an ideal
poly pOppose(ring Rop, poly p, const ring dst)
opposes a vector p from Rop to currRing (dst!)
BOOLEAN rIsLikeOpposite(ring rBase, ring rCandidate)
checks whether rings rBase and rCandidate could be opposite to each other returns TRUE if it is so
ideal idInit(int idsize, int rank)
initialise an ideal / module

◆ nc_CallPlural()

BOOLEAN nc_CallPlural ( matrix CCC,
matrix DDD,
poly CCN,
poly DDN,
ring r,
bool bSetupQuotient,
bool bCopyInput,
bool bBeQuiet,
ring curr,
bool dummy_ring )

returns TRUE if there were errors analyze inputs, check them for consistency detects nc_type, DO NOT initialize multiplication but call for it at the end checks the ordering condition and evtl. NDC NOTE: all the data belong to the curr, we change r which may be the same ring, and must have the same representation!

Definition at line 2692 of file old.gring.cc.

2697{
2698 assume( r != NULL );
2699 assume( curr != NULL );
2700
2701 if( !bSetupQuotient)
2702 assume( (r->qideal == NULL) ); // The basering must NOT be a qring!??
2703
2704 assume( rSamePolyRep(r, curr) || bCopyInput ); // wrong assumption?
2705
2706 // there must be:
2707 assume( (CCC != NULL) != (CCN != NULL) ); // exactly one data about coeffs (C).
2708 assume( !((DDD != NULL) && (DDN != NULL)) ); // at most one data about tails (D).
2709
2710#if OUTPUT
2711 if( CCC != NULL )
2712 {
2713 PrintS("nc_CallPlural(), Input data, CCC: \n");
2714 iiWriteMatrix(CCC, "C", 2, curr, 4);
2715 }
2716 if( DDD != NULL )
2717 {
2718 PrintS("nc_CallPlural(), Input data, DDD: \n");
2719 iiWriteMatrix(DDD, "D", 2, curr, 4);
2720 }
2721#endif
2722
2723
2724#ifndef SING_NDEBUG
2725 if (CCC!=NULL) id_Test((ideal)CCC, curr);
2726 if (DDD!=NULL) id_Test((ideal)DDD, curr);
2727 p_Test(CCN, curr);
2728 p_Test(DDN, curr);
2729#endif
2730
2731 if( (!bBeQuiet) && (r->GetNC() != NULL) )
2732 WarnS("going to redefine the algebra structure");
2733
2734 matrix CC = NULL;
2735 poly CN = NULL;
2736 matrix C; bool bCnew = false;
2737
2738 matrix DD = NULL;
2739 poly DN = NULL;
2740 matrix D; bool bDnew = false;
2741
2742 number nN, pN, qN;
2743
2744 bool IsSkewConstant = false, tmpIsSkewConstant;
2745 int i, j;
2746
2747 nc_type nctype = nc_undef;
2748
2749 //////////////////////////////////////////////////////////////////
2750 // check the correctness of arguments, without any real changes!!!
2751
2752
2753
2754 // check C
2755 {
2756 if ((CCC != NULL) && ( (MATCOLS(CCC)!=r->N) || (MATROWS(CCC)!=r->N) ))
2757 {
2758 Werror("Square %d x %d matrix expected", r->N, r->N);
2759 return TRUE;
2760 }
2761 }
2762 if (( CCC != NULL) && (CC == NULL)) CC = CCC; // mp_Copy(CCC, ?); // bug!?
2763 if (( CCN != NULL) && (CN == NULL)) CN = CCN;
2764
2765 // check D
2766 if ((DDD != NULL) && ( (MATCOLS(DDD)==1) || MATROWS(DDD)==1 ) )
2767 {
2768 DN = MATELEM(DDD,1,1);
2769 }
2770 else
2771 {
2772 if ((DDD != NULL) && ( (MATCOLS(DDD)!=r->N) || (MATROWS(DDD)!=r->N) ))
2773 {
2774 Werror("Square %d x %d matrix expected",r->N,r->N);
2775 return TRUE;
2776 }
2777 }
2778
2779 if (( DDD != NULL) && (DD == NULL)) DD = DDD; // mp_Copy(DDD, ?); // ???
2780 if (( DDN != NULL) && (DN == NULL)) DN = DDN;
2781
2782 // further checks and some analysis:
2783 // all data in 'curr'!
2784 if (CN != NULL) /* create matrix C = CN * Id */
2785 {
2786 if (!p_IsConstant(CN,curr))
2787 {
2788 WerrorS("Incorrect input : non-constants are not allowed as coefficients (first argument)");
2789 return TRUE;
2790 }
2791 assume(p_IsConstant(CN,curr));
2792
2793 nN = pGetCoeff(CN);
2794 if (n_IsZero(nN, curr->cf))
2795 {
2796 WerrorS("Incorrect input : zero coefficients are not allowed");
2797 return TRUE;
2798 }
2799
2800 if (n_IsOne(nN, curr->cf))
2801 nctype = nc_lie;
2802 else
2803 nctype = nc_general;
2804
2805 IsSkewConstant = true;
2806
2807 C = mpNew(r->N,r->N); // ring independent!
2808 bCnew = true;
2809
2810 for(i=1; i<r->N; i++)
2811 for(j=i+1; j<=r->N; j++)
2812 MATELEM(C,i,j) = prCopyR_NoSort(CN, curr, r); // nc_p_CopyPut(CN, r); // copy CN from curr into r
2813
2814#ifndef SING_NDEBUG
2815 id_Test((ideal)C, r);
2816#endif
2817
2818 }
2819 else if ( (CN == NULL) && (CC != NULL) ) /* copy matrix C */
2820 {
2821 /* analyze C */
2822
2823 BOOLEAN pN_set=FALSE;
2824 pN = n_Init(0,curr->cf);
2825
2826 if( r->N > 1 )
2827 if ( MATELEM(CC,1,2) != NULL )
2828 {
2829 if (!pN_set) n_Delete(&pN,curr->cf); // free initial nInit(0)
2830 pN = p_GetCoeff(MATELEM(CC,1,2), curr);
2831 pN_set=TRUE;
2832 }
2833
2834 tmpIsSkewConstant = true;
2835
2836 for(i=1; i<r->N; i++)
2837 for(j=i+1; j<=r->N; j++)
2838 {
2839 if (MATELEM(CC,i,j) == NULL)
2840 qN = NULL;
2841 else
2842 {
2843 if (!p_IsConstant(MATELEM(CC,i,j),curr))
2844 {
2845 Werror("Incorrect input : non-constants are not allowed as coefficients (first argument at [%d, %d])", i, j);
2846 return TRUE;
2847 }
2848 assume(p_IsConstant(MATELEM(CC,i,j),curr));
2849 qN = p_GetCoeff(MATELEM(CC,i,j),curr);
2850 }
2851
2852 if ( qN == NULL ) /* check the consistency: Cij!=0 */
2853 // find also illegal pN
2854 {
2855 WerrorS("Incorrect input : matrix of coefficients contains zeros in the upper triangle");
2856 return TRUE;
2857 }
2858
2859 if (!n_Equal(pN, qN, curr->cf)) tmpIsSkewConstant = false;
2860 }
2861
2862 if( bCopyInput )
2863 {
2864 C = mp_Copy(CC, curr, r); // Copy C into r!!!???
2865#ifndef SING_NDEBUG
2866 id_Test((ideal)C, r);
2867#endif
2868 bCnew = true;
2869 }
2870 else
2871
2872 C = CC;
2873
2874 IsSkewConstant = tmpIsSkewConstant;
2875
2876 if ( tmpIsSkewConstant && n_IsOne(pN, curr->cf) )
2877 nctype = nc_lie;
2878 else
2879 nctype = nc_general;
2880 if (!pN_set) n_Delete(&pN,curr->cf); // free initial nInit(0)
2881 }
2882
2883 /* initialition of the matrix D */
2884 if ( DD == NULL ) /* we treat DN only (it could also be NULL) */
2885 {
2886 D = mpNew(r->N,r->N); bDnew = true;
2887
2888 if (DN == NULL)
2889 {
2890 if ( (nctype == nc_lie) || (nctype == nc_undef) )
2891 nctype = nc_comm; /* it was nc_skew earlier */
2892 else /* nc_general, nc_skew */
2893 nctype = nc_skew;
2894 }
2895 else /* DN != NULL */
2896 for(i=1; i<r->N; i++)
2897 for(j=i+1; j<=r->N; j++)
2898 MATELEM(D,i,j) = prCopyR_NoSort(DN, curr, r); // project DN into r->GetNC()->basering!
2899#ifndef SING_NDEBUG
2900 id_Test((ideal)D, r);
2901#endif
2902 }
2903 else /* DD != NULL */
2904 {
2905 bool b = true; // DD == null ?
2906
2907 for(int i = 1; (i < r->N) && b; i++)
2908 for(int j = i+1; (j <= r->N) && b; j++)
2909 if (MATELEM(DD, i, j) != NULL)
2910 {
2911 b = false;
2912 break;
2913 }
2914
2915 if (b) // D == NULL!!!
2916 {
2917 if ( (nctype == nc_lie) || (nctype == nc_undef) )
2918 nctype = nc_comm; /* it was nc_skew earlier */
2919 else /* nc_general, nc_skew */
2920 nctype = nc_skew;
2921 }
2922
2923 if( bCopyInput )
2924 {
2925 D = mp_Copy(DD, curr, r); // Copy DD into r!!!
2926#ifndef SING_NDEBUG
2927 id_Test((ideal)D, r);
2928#endif
2929 bDnew = true;
2930 }
2931 else
2932 D = DD;
2933 }
2934
2935 assume( C != NULL );
2936 assume( D != NULL );
2937
2938#if OUTPUT
2939 PrintS("nc_CallPlural(), Computed data, C: \n");
2940 iiWriteMatrix(C, "C", 2, r, 4);
2941
2942 PrintS("nc_CallPlural(), Computed data, D: \n");
2943 iiWriteMatrix(D, "D", 2, r, 4);
2944
2945 Print("\nTemporary: type = %d, IsSkewConstant = %d\n", nctype, IsSkewConstant);
2946#endif
2947
2948
2949 // check the ordering condition for D (both matrix and poly cases):
2950 if ( gnc_CheckOrdCondition(D, r) )
2951 {
2952 if( bCnew ) mp_Delete( &C, r );
2953 if( bDnew ) mp_Delete( &D, r );
2954
2955 WerrorS("Matrix of polynomials violates the ordering condition");
2956 return TRUE;
2957 }
2958
2959 // okay now we are ready for this!!!
2960
2961 // create new non-commutative structure
2962 nc_struct *nc_new = (nc_struct *)omAlloc0(sizeof(nc_struct));
2963
2964 ncRingType(nc_new, nctype);
2965
2966 nc_new->C = C; // if C and D were given by matrices at the beginning they are in r
2967 nc_new->D = D; // otherwise they should be in r->GetNC()->basering(polynomial * Id_{N})
2968
2969 nc_new->IsSkewConstant = (IsSkewConstant?1:0);
2970
2971 // Setup new NC structure!!!
2972 if (r->GetNC() != NULL)
2973 {
2974#ifndef SING_NDEBUG
2975 WarnS("Changing the NC-structure of an existing NC-ring!!!");
2976#endif
2977 nc_rKill(r);
2978 }
2979
2980 r->GetNC() = nc_new;
2981
2982 r->ext_ref=NULL;
2983
2984 return gnc_InitMultiplication(r, bSetupQuotient);
2985}
int BOOLEAN
Definition auxiliary.h:88
#define TRUE
Definition auxiliary.h:101
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:468
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
Definition coeffs.h:464
nc_type
Definition nc.h:13
@ nc_general
Definition nc.h:15
@ nc_comm
Definition nc.h:17
void mp_Delete(matrix *a, const ring r)
Definition matpol.cc:874
void iiWriteMatrix(matrix im, const char *n, int dim, const ring r, int spaces)
set spaces to zero by default
Definition matpol.cc:828
#define MATROWS(i)
Definition matpol.h:26
#define MATCOLS(i)
Definition matpol.h:27
BOOLEAN gnc_InitMultiplication(ring r, bool bSetupQuotient=false)
BOOLEAN gnc_CheckOrdCondition(matrix D, ring r)
void nc_rKill(ring r)
complete destructor
poly prCopyR_NoSort(poly p, ring src_r, ring dest_r)
Definition prCopy.cc:77
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...
Definition ring.cc:1804
Definition nc.h:68
matrix C
Definition nc.h:75
int IsSkewConstant
Definition nc.h:85
matrix D
Definition nc.h:76

◆ nc_CheckSubalgebra()

BOOLEAN nc_CheckSubalgebra ( poly PolyVar,
ring r )

Definition at line 2578 of file old.gring.cc.

2579{
2580// ring save = currRing;
2581// int WeChangeRing = 0;
2582// if (currRing != r)
2583// rChangeCurrRing(r);
2584// WeChangeRing = 1;
2585// }
2586 int rN=r->N;
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;
2591 poly test=NULL;
2592 int OK=1;
2593 for (i=1; i<rN; i++)
2594 {
2595 if (ExpVar[i]==0) /* i.e. not in PolyVar */
2596 {
2597 for (j=i+1; j<=rN; j++)
2598 {
2599 if (ExpVar[j]==0)
2600 {
2601 test = MATELEM(r->GetNC()->D,i,j);
2602 while (test!=NULL)
2603 {
2604 p_GetExpV(test, ExpTmp, r);
2605 OK=1;
2606 for (k=1;k<=rN;k++)
2607 {
2608 if (ExpTmp[k]!=0)
2609 {
2610 if (ExpVar[k]!=0) OK=0;
2611 }
2612 }
2613 if (!OK)
2614 {
2615// if ( WeChangeRing )
2616// rChangeCurrRing(save);
2617 return(TRUE);
2618 }
2619 pIter(test);
2620 }
2621 }
2622 }
2623 }
2624 }
2625 freeT(ExpVar,rN);
2626 freeT(ExpTmp,rN);
2627// if ( WeChangeRing )
2628// rChangeCurrRing(save);
2629 return(FALSE);
2630}
CanonicalForm test
Definition cfModGcd.cc:4104
#define pIter(p)
Definition monomials.h:37

◆ nc_CleanUp() [1/2]

void nc_CleanUp ( nc_struct * p)
inline

Definition at line 2469 of file old.gring.cc.

2470{
2471 assume(p != NULL);
2472 omFreeSize((ADDRESS)p,sizeof(nc_struct));
2473}

◆ nc_CleanUp() [2/2]

void nc_CleanUp ( ring r)
inline

Definition at line 2475 of file old.gring.cc.

2476{
2477 /* small CleanUp of r->GetNC() */
2478 assume(r != NULL);
2479 nc_CleanUp(r->GetNC());
2480 r->GetNC() = NULL;
2481}
void nc_CleanUp(nc_struct *p)

◆ nc_CreateShortSpoly()

poly nc_CreateShortSpoly ( poly p1,
poly p2,
const ring r )

Definition at line 1879 of file old.gring.cc.

1880{
1881#ifdef PDEBUG
1882 p_Test(p1, r);
1883 p_Test(p2, r);
1884#endif
1885
1886 const long lCompP1 = p_GetComp(p1,r);
1887 const long lCompP2 = p_GetComp(p2,r);
1888
1889 if ((lCompP1!=lCompP2) && (lCompP1!=0) && (lCompP2!=0))
1890 {
1891#ifdef PDEBUG
1892 WerrorS("nc_CreateShortSpoly: wrong module components!"); // !!!!
1893#endif
1894 return(NULL);
1895 }
1896
1897 poly m;
1898
1899#ifdef HAVE_RATGRING
1900 if ( rIsRatGRing(r))
1901 {
1902 /* rational version */
1903 m = p_LcmRat(p1, p2, si_max(lCompP1, lCompP2), r);
1904 } else
1905#endif
1906 {
1907 m = p_Lcm(p1, p2, r);
1908 }
1909
1910 pSetCoeff0(m,NULL);
1911
1912 return(m);
1913}
#define pSetCoeff0(p, n)
Definition monomials.h:59
poly p_LcmRat(const poly a, const poly b, const long lCompM, const ring r)
Definition p_polys.cc:1681
static BOOLEAN rIsRatGRing(const ring r)
Definition ring.h:433

◆ nc_mm_Bracket_nn()

poly nc_mm_Bracket_nn ( poly m1,
poly m2,
const ring r )

returns [m1,m2] for two monoms, destroys nothing without coeffs

Definition at line 2292 of file old.gring.cc.

2293{
2294 if (p_LmIsConstant(m1, r) || p_LmIsConstant(m1, r)) return(NULL);
2295 if (p_LmCmp(m1,m2, r)==0) return(NULL);
2296 int rN=r->N;
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);
2303 poly res=NULL;
2304 poly ares=NULL;
2305 poly bres=NULL;
2306 poly prefix=NULL;
2307 poly suffix=NULL;
2308 int nMin,nMax;
2309 number nTmp=NULL;
2310 int i,j,k;
2311 for (i=1;i<=rN;i++)
2312 {
2313 if (M2[i]!=0)
2314 {
2315 ares=NULL;
2316 for (j=1;j<=rN;j++)
2317 {
2318 if (M1[j]!=0)
2319 {
2320 bres=NULL;
2321 /* compute [ x_j^M1[j],x_i^M2[i] ] */
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) )) /* not (the same exp. or commuting exps)*/
2324 { bres=NULL; }
2325 else
2326 {
2327 if (i<j) { bres=gnc_uu_Mult_ww(j,M1[j],i,M2[i], r); }
2328 else bres=gnc_uu_Mult_ww(i,M2[i],j,M1[j], r);
2329 if (n_IsOne(pGetCoeff(bres), r->cf))
2330 {
2331 bres=p_LmDeleteAndNext(bres, r);
2332 }
2333 else
2334 {
2335 nTmp=n_Sub(pGetCoeff(bres),n_Init(1, r->cf), r->cf);
2336 p_SetCoeff(bres,nTmp, r); /* only lc ! */
2337 }
2338#ifdef PDEBUG
2339 p_Test(bres, r);
2340#endif
2341 if (i>j) bres=p_Neg(bres, r);
2342 }
2343 if (bres!=NULL)
2344 {
2345 /* now mult (prefix, bres, suffix) */
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;
2350 aSUFFIX[0]=0;
2351 aPREFIX[0]=0;
2352 prefix=p_One(r);
2353 suffix=p_One(r);
2354 p_SetExpV(prefix,aPREFIX, r);
2355 p_Setm(prefix, r);
2356 p_SetExpV(suffix,aSUFFIX, r);
2357 p_Setm(suffix, 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);
2361 /* What to give free? */
2362 /* Do we have to free aPREFIX/aSUFFIX? it seems so */
2363 p_Delete(&prefix, r);
2364 p_Delete(&suffix, r);
2365 }
2366 }
2367 }
2368 if (ares!=NULL)
2369 {
2370 /* now mult (prefix, bres, suffix) */
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;
2375 aSUFFIX[0]=0;
2376 aPREFIX[0]=0;
2377 prefix=p_One(r);
2378 suffix=p_One(r);
2379 p_SetExpV(prefix,aPREFIX, r);
2380 p_Setm(prefix, r);
2381 p_SetExpV(suffix,aSUFFIX, r);
2382 p_Setm(suffix, r);
2383 bres=ares;
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);
2389 }
2390 }
2391 }
2392 freeT(M1, rN);
2393 freeT(M2, rN);
2394 freeT(aPREFIX, rN);
2395 freeT(aSUFFIX, rN);
2396#ifdef PDEBUG
2397 p_Test(res, r);
2398#endif
2399 return(res);
2400}
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
Definition coeffs.h:656
static poly p_Neg(poly p, const ring r)
Definition p_polys.h:1109
static BOOLEAN p_LmIsConstant(const poly p, const ring r)
Definition p_polys.h:1025

◆ nc_p_Bracket_qq()

poly nc_p_Bracket_qq ( poly p,
const poly q,
const ring r )

returns [p,q], destroys p

Definition at line 2251 of file old.gring.cc.

2252{
2253 assume(p != NULL && q!= NULL);
2254
2255 if (!rIsPluralRing(r)) return(NULL);
2256 if (p_ComparePolys(p,q, r)) return(NULL);
2257 /* Components !? */
2258 poly Q=NULL;
2259 number coef=NULL;
2260 poly pres=NULL;
2261 int UseBuckets=1;
2262 if (((pLength(p)< MIN_LENGTH_BUCKET/2) && (pLength(q)< MIN_LENGTH_BUCKET/2))
2264 UseBuckets=0;
2265
2266
2267 CPolynomialSummator sum(r, UseBuckets == 0);
2268
2269 while (p!=NULL)
2270 {
2271 Q=q;
2272 while(Q!=NULL)
2273 {
2274 pres=nc_mm_Bracket_nn(p,Q, r); /* since no coeffs are taken into account there */
2275 if (pres!=NULL)
2276 {
2277 coef = n_Mult(pGetCoeff(p),pGetCoeff(Q), r->cf);
2278 pres = __p_Mult_nn(pres,coef,r);
2279
2280 sum += pres;
2281 n_Delete(&coef, r->cf);
2282 }
2283 pIter(Q);
2284 }
2285 p=p_LmDeleteAndNext(p, r);
2286 }
2287 return(sum);
2288}
poly nc_mm_Bracket_nn(poly m1, poly m2, const ring r)
returns [m1,m2] for two monoms, destroys nothing without coeffs
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
Definition p_polys.cc:4685
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:406
#define Q
Definition sirandom.c:26

◆ nc_p_CopyGet()

poly nc_p_CopyGet ( poly a,
const ring r )

Definition at line 2536 of file old.gring.cc.

2537{
2538#ifndef PDEBUG
2539 p_Test(a, r);
2540#endif
2541
2542// if (r != currRing)
2543// {
2544//#ifdef PDEBUF
2545// WerrorS("nc_p_CopyGet call not in currRing");
2546//#endif
2547// return(NULL);
2548// }
2549 return(p_Copy(a,r));
2550}

◆ nc_p_CopyPut()

poly nc_p_CopyPut ( poly a,
const ring r )

Definition at line 2557 of file old.gring.cc.

2558{
2559#ifndef PDEBUG
2560 p_Test(a, r);
2561#endif
2562
2563// if (r != currRing)
2564// {
2565//#ifdef PDEBUF
2566// WerrorS("nc_p_CopyGet call not in currRing");
2567//#endif
2568// return(NULL);
2569// }
2570
2571 return(p_Copy(a,r));
2572}

◆ nc_p_Minus_mm_Mult_qq()

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

for p_Minus_mm_Mult_qq in pInline2.h

Definition at line 150 of file old.gring.cc.

152{
153 poly mc = p_Neg( p_Copy(m, r), r );
154 poly mmc = nc_mm_Mult_pp( mc, q, r );
155 p_Delete(&mc, r);
156
157 int org_p=pLength(p);
158 int org_q=pLength(q);
159
160 p = p_Add_q(p, mmc, r);
161
162 shorter = pLength(p)-org_p-org_q; // ring independent!
163
164 return(p);
165}

◆ nc_p_Plus_mm_Mult_qq()

poly nc_p_Plus_mm_Mult_qq ( poly p,
const poly m,
const poly q,
int & lp,
const int ,
const ring r )

Definition at line 168 of file old.gring.cc.

170{
171 p = p_Add_q(p, nc_mm_Mult_pp( m, q, r ), r);
172
173 lp = pLength(p);
174
175 return(p);
176}

◆ nc_p_ProcsSet()

void nc_p_ProcsSet ( ring rGR,
p_Procs_s * p_Procs )

Definition at line 3161 of file old.gring.cc.

3162{
3163 assume(rIsPluralRing(rGR));
3164 assume(p_Procs!=NULL);
3165
3166 gnc_p_ProcsSet(rGR, p_Procs);
3167
3168 if(rIsSCA(rGR) && ncExtensions(SCAMASK) )
3169 {
3170 sca_p_ProcsSet(rGR, p_Procs);
3171 }
3172
3175
3176 if(!rIsSCA(rGR) && !ncExtensions(NOFORMULAMASK))
3178
3179}
static bool rIsSCA(const ring r)
Definition nc.h:190
const int NOPLURALMASK
Definition nc.h:334
const int SCAMASK
Definition nc.h:320
void sca_p_ProcsSet(ring rGR, p_Procs_s *p_Procs)
Definition sca.cc:1223
bool ncInitSpecialPowersMultiplication(ring r)
BOOLEAN ncInitSpecialPairMultiplication(ring r)
Definition ncSAMult.cc:266
static void gnc_p_ProcsSet(ring rGR, p_Procs_s *p_Procs)

◆ nc_PolyPolyRed()

void nc_PolyPolyRed ( poly & b,
poly p,
number * c,
const ring r )

Definition at line 2238 of file old.gring.cc.

2239{
2240#if 0
2241 nc_PolyPolyRedOld(b, p, c, r);
2242#else
2243 nc_PolyPolyRedNew(b, p, c, r);
2244#endif
2245}
void nc_PolyPolyRedNew(poly &b, poly p, number *c, const ring r)
void nc_PolyPolyRedOld(poly &b, poly p, number *c, const ring r)

◆ nc_PolyPolyRedNew()

void nc_PolyPolyRedNew ( poly & b,
poly p,
number * c,
const ring r )
inline

Definition at line 2138 of file old.gring.cc.

2140{
2141#ifdef PDEBUG
2142 p_Test(b, r);
2143 p_Test(p, r);
2144#endif
2145
2146#if MYTEST
2147 PrintS("nc_PolyPolyRedNew(");
2148 p_Write0(b, r);
2149 PrintS(", ");
2150 p_Write0(p, r);
2151 PrintS(", *c): ");
2152#endif
2153
2154 // b will not by multiplied by any constant in this impl.
2155 // ==> *c=1
2156 if (c!=NULL) *c=n_Init(1, r->cf);
2157
2158 poly pp = NULL;
2159
2160 // there is a problem when p is a square(=>0!)
2161
2162 while((b != NULL) && (pp == NULL))
2163 {
2164
2165// poly pLmB = p_Head(b, r);
2166 poly m = p_One(r);
2167 p_ExpVectorDiff(m, b, p, r);
2168// pDelete(&pLmB);
2169 //pSetm(m);
2170
2171#ifdef PDEBUG
2172 p_Test(m, r);
2173 p_Test(b, r);
2174#endif
2175
2176 pp = nc_mm_Mult_pp(m, p, r);
2177
2178#if MYTEST
2179 PrintS("\n{b': ");
2180 p_Write0(b, r);
2181 PrintS(", m: ");
2182 p_Write0(m, r);
2183 PrintS(", pp: ");
2184 p_Write0(pp, r);
2185 PrintS(" }\n");
2186#endif
2187
2188 p_Delete(&m, r); // one m for all tries!
2189
2190// assume( pp != NULL );
2191
2192 if( pp == NULL )
2193 {
2194 b = p_LmDeleteAndNext(b, r);
2195
2196 if( !p_DivisibleBy(p, b, r) )
2197 return;
2198
2199 }
2200 }
2201
2202#if MYTEST
2203 PrintS("{b': ");
2204 p_Write0(b, r);
2205 PrintS(", pp: ");
2206 p_Write0(pp, r);
2207 PrintS(" }\n");
2208#endif
2209
2210
2211 if(b == NULL) return;
2212
2213
2214 assume(pp != NULL);
2215
2216 const number n = pGetCoeff(pp); // no new copy
2217
2218 number nn;
2219
2220 if (!n_IsMOne(n, r->cf)) // TODO: as above.
2221 {
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);
2225 pp=__p_Mult_nn(pp, t, r);
2226 n_Delete(&t, r->cf);
2227 }
2228 else
2229 {
2230 pp=__p_Mult_nn(pp, pGetCoeff(b), r);
2231 }
2232
2233
2234 b=p_Add_q(b,pp,r);
2235
2236}
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
Definition p_polys.h:1916
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:332

◆ nc_PolyPolyRedOld()

void nc_PolyPolyRedOld ( poly & b,
poly p,
number * c,
const ring r )
inline

Definition at line 2104 of file old.gring.cc.

2106{
2107 // b will not by multiplied by any constant in this impl.
2108 // ==> *c=1
2109 if (c!=NULL) *c=n_Init(1, r->cf);
2110 poly m=p_One(r);
2111 p_ExpVectorDiff(m,p_Head(b, r),p, r);
2112 //pSetm(m);
2113#ifdef PDEBUG
2114 p_Test(m, r);
2115#endif
2116 poly pp=nc_mm_Mult_pp(m,p,r);
2117 assume(pp!=NULL);
2118
2119 p_Delete(&m, r);
2120 number n=pGetCoeff(pp);
2121 number nn;
2122 if (!n_IsMOne(n, r->cf))
2123 {
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);
2127 pp=__p_Mult_nn(pp,n,r);
2128 n_Delete(&n, r->cf);
2129 }
2130 else
2131 {
2132 pp=__p_Mult_nn(pp,p_GetCoeff(b, r),r);
2133 }
2134 b=p_Add_q(b,pp,r);
2135}

◆ nc_PrintMat()

matrix nc_PrintMat ( int a,
int b,
ring r,
int metric )

returns matrix with the info on noncomm multiplication

Definition at line 2402 of file old.gring.cc.

2403{
2404
2405 if ( (a==b) || !rIsPluralRing(r) ) return(NULL);
2406 int i;
2407 int j;
2408 if (a>b) {j=b; i=a;}
2409 else {j=a; i=b;}
2410 /* i<j */
2411 int rN=r->N;
2412 int size=r->GetNC()->MTsize[UPMATELEM(i,j,rN)];
2413 matrix M = r->GetNC()->MT[UPMATELEM(i,j,rN)];
2414 /* return(M); */
2415/*
2416 int sizeofres;
2417 if (metric==0)
2418 {
2419 sizeofres=sizeof(int);
2420 }
2421 if (metric==1)
2422 {
2423 sizeofres=sizeof(number);
2424 }
2425*/
2427 int s;
2428 int t;
2429 int length;
2430 long totdeg;
2431 poly p;
2432 for(s=1;s<=size;s++)
2433 {
2434 for(t=1;t<=size;t++)
2435 {
2436 p=MATELEM(M,s,t);
2437 if (p==NULL)
2438 {
2439 MATELEM(res,s,t)=0;
2440 }
2441 else
2442 {
2443 length = pLength(p);
2444 if (metric==0) /* length */
2445 {
2446 MATELEM(res,s,t)= p_ISet(length,r);
2447 }
2448 else if (metric==1) /* sum of deg divided by the length */
2449 {
2450 totdeg=0;
2451 while (p!=NULL)
2452 {
2453 totdeg=totdeg+p_Deg(p,r);
2454 pIter(p);
2455 }
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);
2461 MATELEM(res,s,t)=p_NSet(nres,r);
2462 }
2463 }
2464 }
2465 }
2466 return(res);
2467}
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition cf_ops.cc:600
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition p_polys.cc:1298
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition p_polys.cc:1474
long p_Deg(poly a, const ring r)
Definition p_polys.cc:586

◆ nc_pSubst()

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

Definition at line 3185 of file old.gring.cc.

3186{
3187 int rN = r->N;
3188 int *PRE = (int *)omAlloc0((rN+1)*sizeof(int));
3189 int *SUF = (int *)omAlloc0((rN+1)*sizeof(int));
3190 int i,pow;
3191 number C;
3192 poly suf,pre;
3193 poly res = NULL;
3194 poly out = NULL;
3195 while ( p!= NULL )
3196 {
3197 C = p_GetCoeff(p, r);
3198 p_GetExpV(p, PRE, r); /* faster splitting? */
3199 pow = PRE[n]; PRE[n]=0;
3200 res = NULL;
3201 if (pow!=0)
3202 {
3203 for (i=n+1; i<=rN; i++)
3204 {
3205 SUF[i] = PRE[i];
3206 PRE[i] = 0;
3207 }
3208 res = p_Power(p_Copy(e, r),pow, r);
3209 /* multiply with prefix */
3210 pre = p_One(r);
3211 p_SetExpV(pre,PRE, r);
3212 p_Setm(pre, r);
3213 res = nc_mm_Mult_p(pre,res, r);
3214 /* multiply with suffix */
3215 suf = p_One(r);
3216 p_SetExpV(suf,SUF, r);
3217 p_Setm(suf, r);
3218 res = p_Mult_mm(res,suf, r);
3219 res = __p_Mult_nn(res,C, r);
3220 p_SetComp(res,PRE[0], r);
3221 }
3222 else /* pow==0 */
3223 {
3224 res = p_Head(p, r);
3225 }
3226 p = p_LmDeleteAndNext(p, r);
3227 out = p_Add_q(out,res, r);
3228 }
3229 freeT(PRE,rN);
3230 freeT(SUF,rN);
3231 return(out);
3232}
Rational pow(const Rational &a, int e)
Definition GMPrat.cc:411
poly p_Power(poly p, int i, const ring r)
Definition p_polys.cc:2201
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition p_polys.h:249
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1053

◆ nc_rCleanUp()

void nc_rCleanUp ( ring r)

◆ nc_rCopy()

bool nc_rCopy ( ring res,
const ring r,
bool bSetupQuotient )

Definition at line 2989 of file old.gring.cc.

2990{
2991 if (nc_CallPlural(r->GetNC()->C, r->GetNC()->D, NULL, NULL, res, bSetupQuotient, true, true, r))
2992 {
2993 WarnS("Error occurred while coping/setuping the NC structure!"); // No reaction!???
2994 return true; // error
2995 }
2996
2997 return false;
2998}
BOOLEAN nc_CallPlural(matrix CCC, matrix DDD, poly CCN, poly DDN, ring r, bool bSetupQuotient, bool bCopyInput, bool bBeQuiet, ring curr, bool dummy_ring)
returns TRUE if there were errors analyze inputs, check them for consistency detects nc_type,...

◆ nc_rCreateNCcomm()

ring nc_rCreateNCcomm ( ring r)

Definition at line 3236 of file old.gring.cc.

3237{
3238 if (rIsPluralRing(r)) return r;
3239
3240 ring rr = rCopy(r);
3241
3242 matrix C = mpNew(rr->N,rr->N); // ring-independent!?!
3243 matrix D = mpNew(rr->N,rr->N);
3244
3245 for(int i=1; i<rr->N; i++)
3246 for(int j=i+1; j<=rr->N; j++)
3247 MATELEM(C,i,j) = p_One(rr);
3248
3249 if (nc_CallPlural(C, D, NULL, NULL, rr, false, true, false, rr, TRUE)) // TODO: what about quotient ideal?
3250 WarnS("Error initializing multiplication!"); // No reaction!???
3251
3252 return rr;
3253}
ring rCopy(ring r)
Definition ring.cc:1736

◆ nc_rKill()

void nc_rKill ( ring r)

complete destructor

Definition at line 2483 of file old.gring.cc.

2485{
2486 if( r->GetNC()->GetGlobalMultiplier() != NULL )
2487 {
2488 delete r->GetNC()->GetGlobalMultiplier();
2489 r->GetNC()->GetGlobalMultiplier() = NULL;
2490 }
2491
2492 if( r->GetNC()->GetFormulaPowerMultiplier() != NULL )
2493 {
2494 delete r->GetNC()->GetFormulaPowerMultiplier();
2495 r->GetNC()->GetFormulaPowerMultiplier() = NULL;
2496 }
2497
2498
2499 int i,j;
2500 int rN=r->N;
2501 if ( rN > 1 )
2502 {
2503 for(i=1;i<rN;i++)
2504 {
2505 for(j=i+1;j<=rN;j++)
2506 {
2507 id_Delete((ideal *)&(r->GetNC()->MT[UPMATELEM(i,j,rN)]),r);
2508 }
2509 }
2510 int mat_size=rN*(rN-1)/2;
2511 mat_size=si_max(1,mat_size);
2512 omFreeSize((ADDRESS)r->GetNC()->MT,mat_size*sizeof(matrix));
2513 omFreeSize((ADDRESS)r->GetNC()->MTsize,mat_size*sizeof(int));
2514 id_Delete((ideal *)&(r->GetNC()->COM),r);
2515 }
2516 id_Delete((ideal *)&(r->GetNC()->C),r);
2517 id_Delete((ideal *)&(r->GetNC()->D),r);
2518
2519 if( rIsSCA(r) && (r->GetNC()->SCAQuotient() != NULL) )
2520 {
2521 id_Delete(&r->GetNC()->SCAQuotient(), r); // Custom SCA destructor!!!
2522 }
2523
2524
2525 nc_CleanUp(r);
2526}

◆ nc_SetupQuotient()

bool nc_SetupQuotient ( ring rGR,
const ring rG,
bool bCopy )

Definition at line 3385 of file old.gring.cc.

3386{
3387 if( rGR->qideal == NULL )
3388 return false; // no quotient = no work! done!? What about factors of SCA?
3389
3390 bool ret = true;
3391 // currently only super-commutative extension deals with factors.
3392
3393 if( ncExtensions(SCAMASK) )
3394 {
3395 bool sca_ret = sca_SetupQuotient(rGR, rG, bCopy);
3396
3397 if(sca_ret) // yes it was dealt with!
3398 ret = false;
3399 }
3400
3401 if( bCopy )
3402 {
3403 assume(rIsPluralRing(rGR) == rIsPluralRing(rG));
3404 assume((rGR->qideal==NULL) == (rG->qideal==NULL));
3405 assume(rIsSCA(rGR) == rIsSCA(rG));
3406 assume(ncRingType(rGR) == ncRingType(rG));
3407 }
3408
3409 return ret;
3410}
bool sca_SetupQuotient(ring rGR, ring rG, bool bCopy)
Definition sca.cc:911

◆ ncExtensions()

bool ncExtensions ( int iMask)

Definition at line 94 of file old.gring.cc.

95{
96 return ((getNCExtensions() & iMask) == iMask);
97}
int & getNCExtensions()
Definition old.gring.cc:82

◆ NF_Proc_Dummy()

static poly NF_Proc_Dummy ( ideal ,
ideal ,
poly ,
int ,
int ,
const ring  )
static

Definition at line 59 of file old.gring.cc.

60{ WerrorS("nc_NF not defined"); return NULL; }

◆ p_CopyEmbed()

poly p_CopyEmbed ( poly p,
ring srcRing,
int shift,
int ,
ring dstRing )

Definition at line 3260 of file old.gring.cc.

3261{
3262 if (dstRing == srcRing)
3263 {
3264 return(p_Copy(p,dstRing));
3265 }
3266 nMapFunc nMap=n_SetMap(srcRing->cf, dstRing->cf);
3267 poly q;
3268 // if ( nMap == nCopy)
3269 // {
3270 // q = prCopyR(p,srcRing);
3271 // }
3272 // else
3273 {
3274 int *perm = (int *)omAlloc0((rVar(srcRing)+1)*sizeof(int));
3275 int *par_perm = (int *)omAlloc0((rPar(srcRing)+1)*sizeof(int));
3276 // int *par_perm = (int *)omAlloc0((rPar(srcRing)+1)*sizeof(int));
3277 int i;
3278 // if (srcRing->P > 0)
3279 // {
3280 // for (i=0; i<srcRing->P; i++)
3281 // par_perm[i]=-i;
3282 // }
3283 if ((shift<0) || (shift > rVar(srcRing))) // ???
3284 {
3285 WerrorS("bad shifts in p_CopyEmbed");
3286 return(0);
3287 }
3288 for (i=1; i<= srcRing->N; i++)
3289 {
3290 perm[i] = shift+i;
3291 }
3292 q = p_PermPoly(p,perm,srcRing, dstRing, nMap,par_perm, rPar(srcRing));
3293 }
3294 return(q);
3295}
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition coeffs.h:701
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:80
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)
Definition p_polys.cc:4211
static int rPar(const ring r)
(r->cf->P)
Definition ring.h:605
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition ring.h:598

◆ pOppose()

poly pOppose ( ring Rop,
poly p,
const ring dst )

opposes a vector p from Rop to currRing (dst!)

Definition at line 3324 of file old.gring.cc.

3325{
3326 /* the simplest case:*/
3327 if ( Rop == dst ) return(p_Copy(p, dst));
3328 /* check Rop == rOpposite(currRing) */
3329
3330
3331 if ( !rIsLikeOpposite(dst, Rop) )
3332 {
3333 WarnS("an opposite ring should be used");
3334 return NULL;
3335 }
3336
3337 nMapFunc nMap = n_SetMap(Rop->cf, dst->cf); // reverse?
3338
3339 /* nMapFunc nMap = nSetMap(Rop);*/
3340 /* since we know that basefields coincide! */
3341
3342 // coincide???
3343
3344 int *perm=(int *)omAlloc0((Rop->N+1)*sizeof(int));
3345 if (!p_IsConstant(p, Rop))
3346 {
3347 /* we know perm exactly */
3348 int i;
3349 for(i=1; i<=Rop->N; i++)
3350 {
3351 perm[i] = Rop->N+1-i;
3352 }
3353 }
3354 poly res = p_PermPoly(p, perm, Rop, dst, nMap);
3355 omFreeSize((ADDRESS)perm,(Rop->N+1)*sizeof(int));
3356
3357 p_Test(res, dst);
3358
3359 return res;
3360}

◆ rIsLikeOpposite()

BOOLEAN rIsLikeOpposite ( ring rBase,
ring rCandidate )

checks whether rings rBase and rCandidate could be opposite to each other returns TRUE if it is so

Definition at line 3297 of file old.gring.cc.

3298{
3299 /* the same basefield */
3300 int diagnose = TRUE;
3301 nMapFunc nMap = n_SetMap(rCandidate->cf, rBase->cf); // reverse?
3302
3303////// if (nMap != nCopy) diagnose = FALSE;
3304 if (nMap == NULL) diagnose = FALSE;
3305
3306
3307 /* same number of variables */
3308 if (rBase->N != rCandidate->N) diagnose = FALSE;
3309 /* nc and comm ring */
3310 if ( rIsPluralRing(rBase) != rIsPluralRing(rCandidate) ) diagnose = FALSE;
3311 /* both are qrings */
3312 /* NO CHECK, since it is used in building opposite qring */
3313 /* if ( ((rBase->qideal != NULL) && (rCandidate->qideal == NULL)) */
3314 /* || ((rBase->qideal == NULL) && (rCandidate->qideal != NULL)) ) */
3315 /* diagnose = FALSE; */
3316 /* TODO: varnames are e->E etc */
3317 return diagnose;
3318}

◆ setNCExtensions()

int setNCExtensions ( int iMask)

Definition at line 87 of file old.gring.cc.

88{
89 const int iOld = getNCExtensions();
90 getNCExtensions() = iMask;
91 return (iOld);
92}

Variable Documentation

◆ gnc_gr_bba

Definition at line 67 of file old.gring.cc.

◆ gnc_gr_mora

VAR BBA_Proc gnc_gr_mora =BBA_Proc_Dummy

Definition at line 68 of file old.gring.cc.

◆ iNCExtensions

VAR int iNCExtensions = SCAMASK | NOFORMULAMASK

Definition at line 80 of file old.gring.cc.

◆ nc_NF

Definition at line 66 of file old.gring.cc.

◆ sca_bba

Definition at line 69 of file old.gring.cc.

◆ sca_gr_bba

Definition at line 71 of file old.gring.cc.

◆ sca_mora

Definition at line 70 of file old.gring.cc.