source: git/Singular/pInline0.h @ f9aada

fieker-DuValspielwiese
Last change on this file since f9aada was 432a63, checked in by Hans Schönemann <hannes@…>, 23 years ago
*hannes: minor optim. git-svn-id: file:///usr/local/Singular/svn/trunk@5457 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.7 2001-05-22 13:24:32 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 "mod2.h"
21#include "p_polys.h"
22#include "ring.h"
23 
24PINLINE0 int p_SetCompP(poly p, int i, ring r)
25{
26  if (p == NULL) return 0;
27 
28#ifdef PDEBUG
29  poly q = p;
30#endif
31 
32  int l = 0;
33 
34  if (rOrd_SetCompRequiresSetm(r))
35  {
36    do
37    {
38      p_SetComp(p, i, r);
39      p_SetmComp(p, r);
40      l++;
41      pIter(p);
42    }
43    while (p != NULL);
44  }
45  else
46  {
47    do
48    {
49      p_SetComp(p, i, r);
50      l++;
51      pIter(p);
52    }
53    while(p != NULL);
54  }
55#ifdef PDEBUG
56  p_Test(q, r);
57  assume(l == pLength(q));
58#endif
59  return l;
60}
61
62PINLINE0 int p_SetCompP(poly p, int i, ring lmRing, ring tailRing)
63{
64  if (p != NULL)
65  {
66    p_SetComp(p, i, lmRing);
67    p_SetmComp(p, lmRing);
68    return p_SetCompP(pNext(p), i, tailRing) + 1;
69  }
70  else
71    return 0;
72}
73
74// returns minimal column number in the modul element a (or 0)
75PINLINE0 long p_MinComp(poly p, ring lmRing, ring tailRing)
76{
77  long result,i;
78
79  if(p==NULL) return 0;
80  result = p_GetComp(p,lmRing);
81  if (result != 0)
82  {
83    loop
84    {
85      pIter(p);
86      if(p==NULL) break;
87      i = p_GetComp(p,tailRing);
88      if (i<result) result = i;
89    }
90  }
91  return result;
92}
93
94// returns maximal column number in the modul element a (or 0)
95PINLINE0 long p_MaxComp(poly p, ring lmRing, ring tailRing)
96{
97  long result,i;
98
99  if(p==NULL) return 0;
100  result = p_GetComp(p, lmRing);
101  if (result != 0) 
102  {
103    loop
104    {
105      pIter(p);
106      if(p==NULL) break;
107      i = p_GetComp(p, tailRing);
108      if (i>result) result = i;
109    }
110  }
111  return result;
112}
113
114BOOLEAN   p_IsConstantPoly(poly p, ring r)
115{
116  while(p!=NULL)
117  {
118    if (! p_LmIsConstantComp(p, r))
119      return FALSE;
120    pIter(p);
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.