source: git/kernel/pInline0.h @ d51339

spielwiese
Last change on this file since d51339 was 35aab3, checked in by Hans Schönemann <hannes@…>, 20 years ago
This commit was generated by cvs2svn to compensate for changes in r6879, which included commits to RCS files with non-trunk default branches. git-svn-id: file:///usr/local/Singular/svn/trunk@6880 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.0 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: pInline0.h,v 1.1.1.1 2003-10-06 12:15:58 Singular Exp $
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 "p_polys.h"
21#include "ring.h"
22
23PINLINE0 int p_SetCompP(poly p, int i, ring r)
24{
25  if (p == NULL) return 0;
26
27#ifdef PDEBUG
28  poly q = p;
29#endif
30
31  int l = 0;
32
33  if (rOrd_SetCompRequiresSetm(r))
34  {
35    do
36    {
37      p_SetComp(p, i, r);
38      p_SetmComp(p, r);
39      l++;
40      pIter(p);
41    }
42    while (p != NULL);
43  }
44  else
45  {
46    do
47    {
48      p_SetComp(p, i, r);
49      l++;
50      pIter(p);
51    }
52    while(p != NULL);
53  }
54#ifdef PDEBUG
55  p_Test(q, r);
56  assume(l == pLength(q));
57#endif
58  return l;
59}
60
61PINLINE0 int p_SetCompP(poly p, int i, ring lmRing, ring tailRing)
62{
63  if (p != NULL)
64  {
65    p_SetComp(p, i, lmRing);
66    p_SetmComp(p, lmRing);
67    return p_SetCompP(pNext(p), i, tailRing) + 1;
68  }
69  else
70    return 0;
71}
72
73// returns minimal column number in the modul element a (or 0)
74PINLINE0 long p_MinComp(poly p, ring lmRing, ring tailRing)
75{
76  long result,i;
77
78  if(p==NULL) return 0;
79  result = p_GetComp(p,lmRing);
80  if (result != 0)
81  {
82    loop
83    {
84      pIter(p);
85      if(p==NULL) break;
86      i = p_GetComp(p,tailRing);
87      if (i<result) result = i;
88    }
89  }
90  return result;
91}
92
93// returns maximal column number in the modul element a (or 0)
94PINLINE0 long p_MaxComp(poly p, ring lmRing, ring tailRing)
95{
96  long result,i;
97
98  if(p==NULL) return 0;
99  result = p_GetComp(p, lmRing);
100  if (result != 0)
101  {
102    loop
103    {
104      pIter(p);
105      if(p==NULL) break;
106      i = p_GetComp(p, tailRing);
107      if (i>result) result = i;
108    }
109  }
110  return result;
111}
112
113BOOLEAN   p_IsConstantPoly(const poly p, const ring r)
114{
115  poly pp=p;
116  while(pp!=NULL)
117  {
118    if (! p_LmIsConstantComp(pp, r))
119      return FALSE;
120    pIter(pp);
121  }
122  return TRUE;
123}
124
125/***************************************************************
126 *
127 * poly things which are independent of ring
128 *
129 ***************************************************************/
130PINLINE0 poly pReverse(poly p)
131{
132  if (p == NULL || pNext(p) == NULL) return p;
133
134  poly q = pNext(p), // == pNext(p)
135    qn;
136  pNext(p) = NULL;
137  do
138  {
139    qn = pNext(q);
140    pNext(q) = p;
141    p = q;
142    q = qn;
143  }
144  while (qn != NULL);
145  return p;
146}
147
148
149/*2
150* returns the length of a (numbers of monomials)
151*/
152PINLINE0 int pLength(poly a)
153{
154  int l = 0;
155
156  while (a!=NULL)
157  {
158    pIter(a);
159    l++;
160  }
161  return l;
162}
163
164/*2
165* returns the length of a (numbers of monomials)
166*/
167PINLINE0 poly pLast(poly a, int &l)
168{
169  if (a == NULL)
170  {
171    l = 0;
172    return NULL;
173  }
174  l = 1;
175  while (pNext(a)!=NULL)
176  {
177    pIter(a);
178    l++;
179  }
180  return a;
181}
182
183#endif // PINLINE_CC
184
Note: See TracBrowser for help on using the repository browser.