source: git/Singular/pInline0.h @ 8cfee1c

spielwiese
Last change on this file since 8cfee1c was 2f436b, checked in by Olaf Bachmann <obachman@…>, 23 years ago
* version 1-3-13: sparsemat improivements git-svn-id: file:///usr/local/Singular/svn/trunk@5003 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.6 2000-12-31 15:14:37 obachman 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    while (pNext(p)!=NULL)
84    {
85      pIter(p);
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    while (pNext(p)!=NULL)
103    {
104      pIter(p);
105      i = p_GetComp(p, tailRing);
106      if (i>result) result = i;
107    }
108  }
109  return result;
110}
111
112BOOLEAN   p_IsConstantPoly(poly p, ring r)
113{
114  while(p!=NULL)
115  {
116    if (! p_LmIsConstantComp(p, r))
117      return FALSE;
118    pIter(p);
119  }
120  return TRUE;
121}
122
123/***************************************************************
124 *
125 * poly things which are independent of ring
126 *
127 ***************************************************************/
128PINLINE0 poly pReverse(poly p)
129{
130  if (p == NULL || pNext(p) == NULL) return p;
131
132  poly q = pNext(p), // == pNext(p)
133    qn;
134  pNext(p) = NULL;
135  do
136  {
137    qn = pNext(q);
138    pNext(q) = p;
139    p = q;
140    q = qn;
141  }
142  while (qn != NULL);
143  return p;
144}
145
146
147/*2
148* returns the length of a (numbers of monomials)
149*/
150PINLINE0 int pLength(poly a)
151{
152  int l = 0;
153
154  while (a!=NULL)
155  {
156    pIter(a);
157    l++;
158  }
159  return l;
160}
161
162/*2
163* returns the length of a (numbers of monomials)
164*/
165PINLINE0 poly pLast(poly a, int &l)
166{
167  if (a == NULL) 
168  {
169    l = 0;
170    return NULL;
171  }
172  l = 1;
173  while (pNext(a)!=NULL)
174  {
175    pIter(a);
176    l++;
177  }
178  return a;
179}
180
181#endif // PINLINE_CC
182
Note: See TracBrowser for help on using the repository browser.