Changeset 512a2b in git for Singular/polys.h


Ignore:
Timestamp:
Sep 18, 2000, 11:19:39 AM (24 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
d1655e92ca71fb37d1b57af88efdff5b65b8988b
Parents:
f3398d316400fe1ee1677fc397cacb80566ac664
Message:
p_polys.h


git-svn-id: file:///usr/local/Singular/svn/trunk@4606 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/polys.h

    rf3398d r512a2b  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: polys.h,v 1.37 2000-09-14 13:04:40 obachman Exp $ */
     6/* $Id: polys.h,v 1.38 2000-09-18 09:19:30 obachman Exp $ */
    77/*
    8 * ABSTRACT - all basic methods to manipulate polynomials
     8* ABSTRACT - all basic methods to manipulate polynomials of the
     9             currRing
    910*/
    1011
    11 #include "structs.h"
    12 #include "polys-impl.h"
    13 /***************************************************************
     12#include "p_polys.h"
     13/*
    1414 Some general remarks:
    1515 We divide poly operations into roughly 4 categories:
     
    3737          - debugging if PDEBUG >= 0
    3838
    39  You can set PDEBUG on a per-file basis, before including "mod2.h"
     39 You can set PDEBUG on a per-file basis, before including "mod2.h" like
     40   #define PDEBUG 2
     41   #include "mod2.h"
    4042 However, PDEBUG will only be in effect, if !NDEBUG.
    4143
     
    4446 just macros to the respective p_*(..,currRing).
    4547
    46  ***************************************************************/
     48*/
    4749
    4850/***************************************************************
     
    5254 *
    5355 ***************************************************************/
    54 // next
    55 #define pNext(p)            _pNext(p)
    56 #define pIter(p)            _pIter(p)
    57 
    58 // coeff
    59 #define pGetCoeff(p)        _pGetCoeff(p)
    6056// deletes old coeff before setting the new one
    6157#define pSetCoeff(p,n)      p_SetCoeff(p,n,currRing)
    62 #define pSetCoeff0(p,n)     _pSetCoeff0(p,n)
    63 #define p_GetCoeff(p,r)     _pGetCoeff(p)
    64 #define p_SetCoeff0(p,n,r)  _pSetCoeff0(p,n)
    65 PINLINE2 number p_SetCoeff(poly p, number n, ring r);
    6658
    6759// Order
    6860#define pGetOrder(p)        p_GetOrder(p, currRing)
    69 PINLINE2 Order_t p_GetOrder(poly p, ring r);
    7061// don't use this
    7162#define pSetOrder(p, o)     p_SetOrder(p, o, currRing)
    72 PINLINE2 Order_t p_SetOrder(poly p, long order, ring r);
    7363
    7464// Component
     
    7969#define pAddComp(p,v)       p_AddComp(p,v,currRing)
    8070#define pSubComp(p,v)       p_SubComp(p,v,currRing)
    81 #define p_GetComp(p, r)     _p_GetComp(p, r)
    82 PINLINE2 unsigned long p_SetComp(poly p, unsigned long c, ring r);
    83 PINLINE2 unsigned long p_IncrComp(poly p, ring r);
    84 PINLINE2 unsigned long p_DecrComp(poly p, ring r);
    85 PINLINE2 unsigned long p_AddComp(poly p, unsigned long v, ring r);
    86 PINLINE2 unsigned long p_SubComp(poly p, unsigned long v, ring r);
    8771
    8872// Exponent
     
    9478#define pSubExp(p,i,v)      p_SubExp(p,i,v, currRing)
    9579#define pMultExp(p,i,v)     p_MultExp(p,i,v, currRing)
    96 PINLINE2 Exponent_t p_GetExp(poly p, int v, ring r);
    97 PINLINE2 Exponent_t p_SetExp(poly p, int v, int e, ring r);
    98 PINLINE2 Exponent_t p_IncrExp(poly p, int v, ring r);
    99 PINLINE2 Exponent_t p_DecrExp(poly p, int v, ring r);
    100 PINLINE2 Exponent_t p_AddExp(poly p, int v, Exponent_t ee, ring r);
    101 PINLINE2 Exponent_t p_SubExp(poly p, int v, Exponent_t ee, ring r);
    102 PINLINE2 Exponent_t p_MultExp(poly p, int v, Exponent_t ee, ring r);
    103 
    104 // Gets Difference and sum of ith Exponent of m1, m2
    105 #define pGetExpSum(m1, m2, i)  p_GetExpSum(p1, p2, i, currRing)
    106 #define pGetExpDiff(p1, p2, i) p_GetExpDiff(p1, p2, i, currRing)
     80#define pGetExpSum(p1, p2, i)    p_GetExpSum(p1, p2, i, currRing)
     81#define pGetExpDiff(p1, p2, i)   p_GetExpDiff(p1, p2, i, currRing)
    10782
    10883/***************************************************************
    10984 *
    11085 * Allocation/Initalization/Deletion
    111  * except for pDelete1 and pHead, all polys must be != NULL
     86 * except for pDeleteLm and pHead, all polys must be != NULL
     87 *
    11288 ***************************************************************/
    11389// allocates the space for a new monomial -- no initialization !!!
    11490#define pNew()          p_New(currRing)
    11591// allocates a new monomial and initializes everything to 0
    116 PINLINE1 poly pInit();
    117 // like pInit, except that expvector is initialized to that of p, p must be != NULL
    118 PINLINE1 poly pInit(poly p);
    119 // returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
     92#define pInit()         p_Init(currRing)
     93// like pInit, except that expvector is initialized to that of p,
     94// p must be != NULL
     95#define pLmInit(p)  p_LmInit(p, currRing)
     96// returns newly allocated copy of Lm(p), coef is copied, next=NULL,
     97// p might be NULL
    12098#define pHead(p)        p_Head(p, currRing)
    121 // if *p_ptr != NULL, delete *p_ptr->coef, *p_ptr, and set *p_ptr to pNext(*p_ptr)
    122 #define pDelete1(p_ptr) p_Delete1(p_ptr, currRing)
     99// if *p_ptr != NULL, delete p_ptr->coef, *p_ptr, and set *p_ptr to
     100// pNext(*p_ptr)
     101static inline void pDeleteLm(poly *p) {p_DeleteLm(p, currRing);}
     102// if (p!=NULL) delete p-coef and p
     103static inline void pDeleteLm(poly p)  {p_DeleteLm(p, currRing);}
    123104// frees the space of the monomial m, assumes m != NULL
    124105// coef is not freed, m is not advanced
    125 #define pFree(m)        p_Free(m, currRing)
     106static inline void pLmFree(poly p)    {p_LmFree(p, currRing);}
     107// like pLmFree, but advances p
     108static inline void pLmFree(poly *p)   {p_LmFree(p, currRing);}
    126109// assumes p != NULL, deletes p, returns pNext(p)
    127 #define pFreeAndNext(p) p_FreeAndNext(p, currRing)
     110#define pLmFreeAndNext(p) p_LmFreeAndNext(p, currRing)
    128111// assume p != NULL, deletes Lm(p)->coef and Lm(p)
    129112#define pLmDelete(p)    p_LmDelete(p, currRing)
    130113// like pLmDelete, returns pNext(p)
    131114#define pLmDeleteAndNext(p) p_LmDeleteAndNext(p, currRing)
    132 
    133 PINLINE2 poly p_New(ring r);
    134 PINLINE1 poly p_Init(ring r);
    135 PINLINE1 poly p_Init(poly p, ring r);
    136 PINLINE1 poly p_Head(poly p, ring r);
    137 PINLINE2 void p_Delete1(poly *p, ring r);
    138 PINLINE2 void p_Free(poly p, ring r);
    139 PINLINE2 poly p_LmFreeAndNext(poly p, ring r);
    140 PINLINE2 void p_LmDelete(poly p, ring r);
    141 PINLINE2 poly p_LmDeleteAndNext(poly p, ring r);
    142115// used by iparith.cc
    143116extern poly pHeadProc(poly p);
     
    148121 *
    149122 ***************************************************************/
    150 // ExpVextor(d_p) = ExpVector(s_p)
    151 PINLINE1 void p_ExpVectorCopy(poly d_p, poly s_p, ring r);
    152 // ExpVector(p1) += ExpVector(p2)
    153 PINLINE1 void p_ExpVectorAdd(poly p1, poly p2, ring r);
    154 // ExpVector(p1) -= ExpVector(p2)
    155 PINLINE1 void p_ExpVectorSub(poly p1, poly p2, ring r);
    156 // ExpVector(pr) = ExpVector(p1) + ExpVector(p2)
    157 PINLINE1 void p_ExpVectorSum(poly pr, poly p1, poly p2, ring r);
    158 // ExpVector(pr) = ExpVector(p1) + ExpVector(p2)
    159 PINLINE1 void p_ExpVectorDiff(poly pr, poly p1, poly p2, ring r);
    160 // returns TRUE if ExpVector(p1) == ExpVector(p2), FALSE, otherwise
    161 PINLINE1 BOOLEAN p_ExpVectorEqual(poly p1, poly p2, ring r);
    162 // returns sum of all exponents
    163 PINLINE1 unsigned long p_ExpVectorQuerSum(poly p, ring r);
    164123
    165124#define pExpVectorCopy(d_p, s_p)    p_ExpVectorCopy(d_p, s_p, currRing)
     
    170129#define pExpVectorEqual(p1, p2)     p_ExpVectorEqual(p1, p2, currRing)
    171130#define pExpVectorQuerSum(p)        p_ExpVectorQuerSum(p, currRing)
    172 #define pEqual(p1, p2)              pExpVectorEqual(p1, p2)
    173 
    174 // Gets a copy of (resp. sets) the exponent vector, where e is assumed
    175 // to point to (pVariables+1)*sizeof(Exponent_t) memory. Exponents are
     131
     132// Gets a copy of (resp. set) the exponent vector, where e is assumed
     133// to point to (r->N +1)*sizeof(Exponent_t) memory. Exponents are
    176134// filled in as follows: comp, e_1, .., e_n
    177135#define pGetExpV(p, e)      p_GetExpV(p, e, currRing)
    178136#define pSetExpV(p, e)      p_SetExpV(p, e, currRing)
    179 PINLINE1 void p_GetExpV(poly p, Exponent_t *ev, ring r);
    180 PINLINE1 void p_SetExpV(poly p, Exponent_t *ev, ring r);
    181 
    182 
    183 
    184 /***************************************************************
    185  *
    186  * Operations on Lm: assumes polys != NULL
     137
     138/***************************************************************
     139 *
     140 * Comparisons: they are all done without regarding coeffs
    187141 *
    188142 ***************************************************************/
     
    193147#define pLmCmpAction(p,q, actionE, actionG, actionS)  \
    194148  _p_LmCmpAction(p,q,currRing, actionE, actionG,actionS)
    195 PINLINE1 int p_LmCmp(poly p, poly q, ring r);
    196 #define p_LmCmpAction(p, q, r, actionE, actionG, actionS) \
    197   _p_LmCmpAction(p, q, r, actionE, actionG, actionS)
    198 
    199 // returns 1 if Lm(p)=Lm(q) -- including comparison of coeff
    200 PINLINE1 BOOLEAN p_LmEqual(poly p, poly q, ring r);
    201 #define pLmEqual(p,q)       p_LmEqual(p,q,currRing)
     149
     150#define pLmEqual(p1, p2)     pExpVectorEqual(p1, p2)
    202151
    203152// pCmp: args may be NULL
    204153// returns: (p2==NULL ? 1 : (p1 == NULL ? -1 : p_LmCmp(p1, p2)))
    205154#define pCmp(p1, p2)    p_Cmp(p1, p2, currRing)
    206 PINLINE2 int p_Cmp(poly p1, poly p2, ring r);
    207155
    208156 
     
    214162 ***************************************************************/
    215163// returns TRUE, if leading monom of a divides leading monom of b
    216 // i.e., if there exists a expvector c > 0, s.t. b = a + c; assumes b != NULL
     164// i.e., if there exists a expvector c > 0, s.t. b = a + c;
    217165#define pDivisibleBy(a, b)  p_DivisibleBy(a,b,currRing)
    218 // like pDivisibleBy, except that it is assumed that a!=NULL
    219 #define pDivisibleBy1(a,b)  p_DivisibleBy1(a,b,currRing)
    220 // like pDivisibleBy1, does not check components
    221 #define pDivisibleBy2(a, b) p_DivisibleBy2(a,b,currRing)
     166// like pDivisibleBy, except that it is assumed that a!=NULL, b!=NULL
     167#define pLmDivisibleBy(a,b)  p_LmDivisibleBy(a,b,currRing)
     168// like pLmDivisibleBy, does not check components
     169#define pLmDivisibleByNoComp(a, b) p_LmDivisibleByNoComp(a,b,currRing)
    222170// Divisibility tests based on Short Exponent vectors
    223171// sev_a     == pGetShortExpVector(a)
    224172// not_sev_b == ~ pGetShortExpVector(b)
    225 PINLINE1 BOOLEAN p_DivisibleBy(poly a, poly b, ring r);
    226 PINLINE1 BOOLEAN p_DivisibleBy1(poly a, poly b, ring r);
    227 PINLINE1 BOOLEAN p_DivisibleBy2(poly a, poly b, ring r);
     173#define pLmShortDivisibleBy(a, sev_a, b, not_sev_b) \
     174  p_LmShortDivisibleBy(a, sev_a, b, not_sev_b, currRing)
    228175// returns the "Short Exponent Vector" -- used to speed up divisibility
    229176// tests (see polys-impl.cc )
    230177#define pGetShortExpVector(a)   p_GetShortExpVector(a, currRing)
    231 #define pShortDivisibleBy(a, sev_a, b, not_sev_b) \
    232   p_ShortDivisibleBy(a, sev_a, b, not_sev_b, currRing)
    233 unsigned long p_GetShortExpVector(poly a, ring r);
    234 PINLINE1 BOOLEAN p_ShortDivisibleBy(poly a, unsigned long sev_a,
    235                                     poly b, unsigned long not_sev_b, ring r);
    236178
    237179/***************************************************************
     
    242184// return a copy of the poly
    243185#define pCopy(p) p_Copy(p, currRing)
    244 // returns a copy of p
    245 PINLINE2 poly p_Copy(poly p, const ring r);
    246 // returns a copy of p with Lm(p) from lmRing and Tail(p) from tailRing
    247 PINLINE2 poly p_Copy(poly p, const ring lmRing, const ring tailRing);
    248 // deletes *p, and sets *p to NULL
    249 PINLINE2 void p_Delete(poly *p, const ring r);
    250186#define pDelete(p_ptr)  p_Delete(p_ptr, currRing)
    251 
    252187
    253188/***************************************************************
     
    261196 *
    262197 ***************************************************************/
    263 // returns -p, p is destroyed
    264 PINLINE2 poly p_Neg(poly p, const ring r);
    265 
    266 // returns p*n, p is const (i.e. copied)
    267 PINLINE2 poly pp_Mult_nn(poly p, number n, const ring r);
    268 // returns p*n, destroys p
    269 PINLINE2 poly p_Mult_nn(poly p, number n, const ring r);
    270 
    271 // returns p*m, does neither destroy p nor m
    272 PINLINE2 poly pp_Mult_mm(poly p, poly m, const ring r);
    273 // returns p*m, destroys p, const: m
    274 PINLINE2 poly p_Mult_mm(poly p, poly m, const ring r);
    275 
    276 // returns p+q, destroys p and q
    277 PINLINE2 poly p_Add_q(poly p, poly q, const ring r);
    278 // like p_Add_q, except that if lp == pLength(lp) lq == pLength(lq)
    279 // then lp == pLength(p+q)
    280 PINLINE2 poly p_Add_q(poly p, poly q, int &lp, int lq, const ring r);
    281 
    282 // return p - m*q, destroys p; const: q,m
    283 PINLINE2 poly p_Minus_mm_Mult_qq(poly p, poly m, poly q, const ring r);
    284 // like p_Minus_mm_Mult_qq, except that if lp == pLength(lp) lq == pLength(lq)
    285 // then lp == pLength(p -m*q)
    286 PINLINE2 poly p_Minus_mm_Mult_qq(poly p, poly m, poly q, int &lp, int lq,
    287                                  poly spNoether, const ring r);
    288 // returns p + m*q destroys p, const: q, m
    289 PINLINE2 poly p_Plus_mm_Mult_qq(poly p, poly m, poly q, const ring r);
    290 
    291 // returns p*q, destroys p and q
    292 PINLINE2 poly p_Mult_q(poly p, poly q, const ring r);
    293 // returns p*q, does neither destroy p nor q
    294 PINLINE2 poly pp_Mult_qq(poly p, poly q, const ring r);
    295 
    296198#define pNeg(p)                     p_Neg(p, currRing)
    297199#define ppMult_nn(p, n)             pp_Mult_nn(p, n, currRing)
     
    342244/*-----------the ordering of monomials:-------------*/
    343245#define pSetm(p)    p_Setm(p, currRing)
    344 extern void p_Setm(poly p, ring r);
    345246// TODO:
    346247#define pSetmComp   pSetm
    347 #define p_SetmComp  p_Setm
    348248
    349249extern pLDegProc pLDeg;
     
    379279poly      pDiffOp(poly a, poly b,BOOLEAN multiply);
    380280
    381 int       pLength(poly a);
    382281int       pMaxComp(poly p);
    383282int       pMinComp(poly p, ring r=currRing);
     
    385284int       pWeight(int c);
    386285#define   pSetCompP(a,i)    p_SetCompP(a, i, currRing)
    387 PINLINE0   void p_SetCompP(poly a, int i, ring r);
    388 PINLINE0   void p_SetCompP(poly a, int i, ring lmRing, ring tailRing);
    389286
    390287
     
    463360
    464361/*-----------specials for spoly-computations--------------*/
    465 int     pDivComp(poly p, poly q);
    466362BOOLEAN pCompareChain (poly p,poly p1,poly p2,poly lcm);
    467363BOOLEAN pEqualPolys(poly p1,poly p2);
    468364BOOLEAN pComparePolys(poly p1,poly p2);
    469365
    470 /*-----------Misc stuff-----------------------------------*/
    471 // reverses the monomials of p
    472 PINLINE0 poly pReverse(poly p);
    473366
    474367
     
    479372 ***************************************************************/
    480373#ifdef PDEBUG
    481 // Returns TRUE if m is monom of p, FALSE otherwise
    482 BOOLEAN pIsMonomOf(poly p, poly m);
    483 // Returns TRUE if p and q have common monoms
    484 BOOLEAN pHaveCommonMonoms(poly p, poly q);
    485 
    486 // p_Check* routines return TRUE if everything is ok,
    487 // else, they report error message and return false
    488 
    489 // check if poly p is from ring r
    490 BOOLEAN p_CheckIsFromRing(poly p, ring r);
    491 // check if p != NULL, r != NULL and initialized && p is from r
    492 BOOLEAN p_CheckPolyRing(poly p, ring r);
    493 // check if r != NULL and initialized
    494 BOOLEAN p_CheckRing(ring r);
    495 // only do check if cond
    496 #define pIfThen(cond, check) do {if (cond) {check;}} while (0)
    497 
    498 BOOLEAN _p_Test(poly p, ring r, int level);
    499 BOOLEAN _p_LmTest(poly p, ring r, int level);
    500 BOOLEAN _pp_Test(poly p, ring lmRing, ring tailRing, int level);
    501 
    502374#define pTest(p)        _p_Test(p, currRing, PDEBUG)
    503 #define p_Test(p,r)     _p_Test(p, r, PDEBUG)
    504375#define pLmTest(p)      _p_LmTest(p, currRing, PDEBUG)
    505 #define p_LmTest(p,r)   _p_LmTest(p, r, PDEBUG)
    506 #define pp_Test(p, lmRing, tailRing)    _pp_Test(p, lmRing, tailRing, PDEBUG)
    507376
    508377#else // ! PDEBUG
    509378
    510 
    511 #define pIsMonomOf(p, q)        (TRUE)
    512 #define pHaveCommonMonoms(p, q) (TRUE)
    513 #define p_CheckIsFromRing(p,r)  ((void)0)
    514 #define p_CheckPolyRing(p,r)    ((void)0)
    515 #define p_CheckRing(r)          ((void)0)
    516 #define P_CheckIf(cond, check)  ((void)0)
    517 
    518379#define pTest(p)        ((void)0)
    519 #define p_Test(p,r)     ((void)0)
    520380#define pLmTest(p)      ((void)0)
    521 #define p_LmTest(p,r)   ((void)0)
    522 #define pp_Test(p, lmRing, tailRing) ((void)0)
    523 
    524381#endif
    525382
    526383#endif // POLYS_H
    527384
    528 #include "pInline2.h"
    529 #include "pInline1.h"
Note: See TracChangeset for help on using the changeset viewer.