source: git/Singular/pInline0.h @ 2166892

fieker-DuValspielwiese
Last change on this file since 2166892 was fc83e4, checked in by Olaf Bachmann <obachman@…>, 24 years ago
* bug fixes for tailRing git-svn-id: file:///usr/local/Singular/svn/trunk@4705 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.2 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.4 2000-11-08 15:34:59 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 
23PINLINE0 void p_SetCompP(poly p, int i, ring r)
24{
25  while (p != NULL)
26  {
27    p_SetComp(p, i, r);
28    p_SetmComp(p, r);
29    pIter(p);
30  }
31}
32
33PINLINE0 void p_SetCompP(poly p, int i, ring lmRing, ring tailRing)
34{
35  if (p != NULL)
36  {
37    p_SetComp(p, i, lmRing);
38    p_SetmComp(p, lmRing);
39    p_SetCompP(pNext(p), i, tailRing);
40  }
41}
42
43
44// returns minimal column number in the modul element a (or 0)
45PINLINE0 int p_MinComp(poly p, ring r)
46{
47  int result,i;
48
49  if(p==NULL) return 0;
50  result = p_GetComp(p,r);
51  while (pNext(p)!=NULL)
52  {
53    pIter(p);
54    i = p_GetComp(p,r);
55    if (i<result) result = i;
56  }
57  return result;
58}
59
60// returns maximal column number in the modul element a (or 0)
61PINLINE0 long p_MaxComp(poly p, ring lmRing, ring tailRing)
62{
63  int result,i;
64
65  if(p==NULL) return 0;
66  result = p_GetComp(p, lmRing);
67  while (pNext(p)!=NULL)
68  {
69    pIter(p);
70    i = p_GetComp(p, tailRing);
71    if (i>result) result = i;
72  }
73  return result;
74}
75
76/***************************************************************
77 *
78 * poly things which are independent of ring
79 *
80 ***************************************************************/
81PINLINE0 poly pReverse(poly p)
82{
83  if (p == NULL || pNext(p) == NULL) return p;
84
85  poly q = pNext(p), // == pNext(p)
86    qn;
87  pNext(p) = NULL;
88  do
89  {
90    qn = pNext(q);
91    pNext(q) = p;
92    p = q;
93    q = qn;
94  }
95  while (qn != NULL);
96  return p;
97}
98
99
100/*2
101* returns the length of a (numbers of monomials)
102*/
103PINLINE0 int pLength(poly a)
104{
105  int l = 0;
106
107  while (a!=NULL)
108  {
109    pIter(a);
110    l++;
111  }
112  return l;
113}
114
115#endif // PINLINE_CC
116
Note: See TracBrowser for help on using the repository browser.