source: git/libpolys/polys/pInline0.h @ c462b55

spielwiese
Last change on this file since c462b55 was c462b55, checked in by Hans Schoenemann <hannes@…>, 13 years ago
p_MinComp, p_MaxComp
  • Property mode set to 100644
File size: 2.3 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/***************************************************************
5 *  File:    pInline.cc
6 *  Purpose: implementation of poly Level 0 functions
7 *  Author:  obachman (Olaf Bachmann)
8 *  Created: 8/00
9 *  Version: $Id$
10 *******************************************************************/
11#ifndef PINLINE0_H
12#define PINLINE0_H
13
14#if defined(DO_PINLINE0)
15#define PINLINE0 static inline
16#else
17#define PINLINE0
18#endif
19
20#include <polys/monomials/p_polys.h>
21#include <polys/monomials/ring.h>
22
23PINLINE0 void p_SetCompP(poly p, int i, ring r)
24{
25  if (p != NULL)
26  {
27#ifdef PDEBUG
28    poly q = p;
29    int l = 0;
30#endif
31
32    if (rOrd_SetCompRequiresSetm(r))
33    {
34      do
35      {
36        p_SetComp(p, i, r);
37        p_SetmComp(p, r);
38#ifdef PDEBUG
39        l++;
40#endif
41        pIter(p);
42      }
43      while (p != NULL);
44    }
45    else
46    {
47      do
48      {
49        p_SetComp(p, i, r);
50#ifdef PDEBUG
51        l++;
52#endif
53        pIter(p);
54      }
55      while(p != NULL);
56    }
57#ifdef PDEBUG
58    p_Test(q, r);
59    assume(l == pLength(q));
60#endif
61  }
62}
63
64PINLINE0 void p_SetCompP(poly p, int i, ring lmRing, ring tailRing)
65{
66  if (p != NULL)
67  {
68    p_SetComp(p, i, lmRing);
69    p_SetmComp(p, lmRing);
70    p_SetCompP(pNext(p), i, tailRing);
71  }
72}
73
74// returns minimal column number in the modul element a (or 0)
75BOOLEAN   p_IsConstantPoly(const poly p, const ring r)
76{
77  poly pp=p;
78  while(pp!=NULL)
79  {
80    if (! p_LmIsConstantComp(pp, r))
81      return FALSE;
82    pIter(pp);
83  }
84  return TRUE;
85}
86
87/***************************************************************
88 *
89 * poly things which are independent of ring
90 *
91 ***************************************************************/
92PINLINE0 poly pReverse(poly p)
93{
94  if (p == NULL || pNext(p) == NULL) return p;
95
96  poly q = pNext(p), // == pNext(p)
97    qn;
98  pNext(p) = NULL;
99  do
100  {
101    qn = pNext(q);
102    pNext(q) = p;
103    p = q;
104    q = qn;
105  }
106  while (qn != NULL);
107  return p;
108}
109
110
111/*2
112* returns the length of a (numbers of monomials)
113*/
114PINLINE0 int pLength(poly a)
115{
116  int l = 0;
117
118  while (a!=NULL)
119  {
120    pIter(a);
121    l++;
122  }
123  return l;
124}
125
126/*2
127* returns the length of a (numbers of monomials)
128* respect syzComp
129*/
130poly pLast(poly a, int &l);
131
132#endif // PINLINE_CC
133
Note: See TracBrowser for help on using the repository browser.