My Project  debian-1:4.1.2-p1+ds-2
intvec.h
Go to the documentation of this file.
1 #ifndef INTVEC_H
2 #define INTVEC_H
3 /****************************************
4 * Computer Algebra System SINGULAR *
5 ****************************************/
6 /*
7 * ABSTRACT: class intvec: lists/vectors of integers
8 */
9 #include <string.h>
10 #include "misc/auxiliary.h"
11 #include "omalloc/omalloc.h"
12 #ifdef HAVE_OMALLOC
13 #include "omalloc/omallocClass.h"
14 #endif
15 
16 #include "reporter/reporter.h"
17 
18 
19 class intvec
20 #ifdef HAVE_OMALLOC
21  :public omallocClass
22 #endif
23 {
24 private:
25  int *v;
26  int row;
27  int col;
28 public:
29 
30  inline intvec(int l = 1)
31  {
32  assume(l >= 0);
33  if (l>0) v = (int *)omAlloc0(sizeof(int)*l);
34  else v = NULL;
35  row = l;
36  col = 1;
37  }
38  intvec(int s, int e);
39  intvec(int r, int c, int init);
40  intvec(const intvec* iv)
41  {
42  assume( iv != NULL );
43  row = iv->rows();
44  col = iv->cols();
45  assume(row >= 0);
46  assume(col >= 0);
47  if (row*col>0)
48  {
49  v = (int *)omAlloc(sizeof(int)*row*col);
50  for (int i=row*col-1;i>=0; i--)
51  {
52  v[i] = (*iv)[i];
53  }
54  }
55  else v=NULL;
56  }
57 
58  void resize(int new_length);
59  inline int range(int i) const
60  //{ return ((i<row) && (i>=0) && (col==1)); }
61  { return ((((unsigned)i)<((unsigned)row)) && (col==1)); }
62  inline int range(int i, int j) const
63  //{ return ((i<row) && (i>=0) && (j<col) && (j>=0)); }
64  { return ((((unsigned)i)<((unsigned)row)) && (((unsigned)j)<((unsigned)col))); }
65  inline int& operator[](int i)
66  {
67 #ifndef SING_NDEBUG
68  if((i<0)||(i>=row*col))
69  {
70  Werror("wrong intvec index:%d\n",i);
71  }
72 #endif
73  return v[i];
74  }
75  inline const int& operator[](int i) const
76  {
77 #ifndef SING_NDEBUG
78  if((i<0)||(i>=row*col))
79  {
80  Werror("wrong intvec index:%d\n",i);
81  }
82 #endif
83  return v[i];
84  }
85 #define IMATELEM(M,I,J) (M)[(I-1)*(M).cols()+J-1]
86  void operator+=(int intop);
87  void operator-=(int intop);
88  void operator*=(int intop);
89  void operator/=(int intop);
90  void operator%=(int intop);
91  // -2: not compatible, -1: <, 0:=, 1: >
92  int compare(const intvec* o) const;
93  int compare(int o) const;
94  inline int length() const { return col*row; }
95  inline int cols() const { return col; }
96  inline int rows() const { return row; }
97  void show(int mat=0,int spaces=0) const;
98  #ifndef SING_NDEBUG
99  void view() const;
100  #endif
101 
102  inline void makeVector() { row*=col;col=1; }
103  char * String(int dim = 2) const;
104  char * ivString(int not_mat=1,int spaces=0, int dim=2) const;
105  inline ~intvec()
106  {
107  assume(row>=0);
108  assume(col>=0);
109  if (v!=NULL)
110  {
111  omFreeSize((ADDRESS)v,sizeof(int)*row*col);
112  v=NULL;
113  }
114  }
115  inline void ivTEST() const
116  {
117  assume(row>=0);
118  assume(col>=0);
119  if (row>0) omCheckAddrSize((ADDRESS)v,sizeof(int)*row*col);
120  }
121  inline int min_in()
122  {
123  int m=0;
124  if (row>0)
125  {
126  m=v[0];
127  for (int i=row*col-1; i>0; i--) if (v[i]<m) m=v[i];
128  }
129  return m;
130  }
131  intvec* delete_pos(int p);
132  // keiner (ausser obachman) darf das folgenden benutzen !!!
133  inline int * ivGetVec() { return v; }
134 };
135 inline intvec * ivCopy(const intvec * o)
136 {
137  if( o != NULL )
138  return new intvec(o);
139  return NULL;
140 }
141 
142 intvec * ivAdd(intvec * a, intvec * b);
143 intvec * ivSub(intvec * a, intvec * b);
144 intvec * ivTranp(intvec * o);
145 int ivTrace(intvec * o);
146 intvec * ivMult(intvec * a, intvec * b);
147 //void ivTriangMat(intvec * imat);
148 void ivTriangIntern(intvec * imat, int &ready, int &all);
149 intvec * ivSolveKern(intvec * imat, int ready);
150 intvec * ivConcat(intvec * a, intvec * b);
151 
152 #ifdef MDEBUG
153 inline void ivTest(intvec * v)
154 {
155  v->ivTEST();
156 }
157 #else
158 #define ivTest(v) do {} while (0)
159 #endif
160 
161 #undef INLINE_THIS
162 
163 #endif
dim
int dim(ideal I, ring r)
Definition: tropicalStrategy.cc:22
ivTest
#define ivTest(v)
Definition: intvec.h:157
omCheckAddrSize
#define omCheckAddrSize(addr, size)
Definition: omAllocDecl.h:325
omalloc.h
ivSolveKern
intvec * ivSolveKern(intvec *imat, int ready)
Definition: intvec.cc:423
omallocClass.h
intvec::ivGetVec
int * ivGetVec()
Definition: intvec.h:133
j
int j
Definition: facHensel.cc:105
intvec::intvec
intvec(const intvec *iv)
Definition: intvec.h:40
ADDRESS
void * ADDRESS
Definition: auxiliary.h:135
intvec::col
int col
Definition: intvec.h:27
intvec::operator+=
void operator+=(int intop)
Definition: intvec.cc:163
auxiliary.h
reporter.h
b
CanonicalForm b
Definition: cfModGcd.cc:4044
ivConcat
intvec * ivConcat(intvec *a, intvec *b)
Definition: intvec.cc:803
intvec::intvec
intvec(int l=1)
Definition: intvec.h:30
intvec::ivTEST
void ivTEST() const
Definition: intvec.h:115
ivMult
intvec * ivMult(intvec *a, intvec *b)
Definition: intvec.cc:330
i
int i
Definition: cfEzgcd.cc:125
ivCopy
intvec * ivCopy(const intvec *o)
Definition: intvec.h:134
intvec::show
void show(int mat=0, int spaces=0) const
Definition: intvec.cc:148
intvec::operator-=
void operator-=(int intop)
Definition: intvec.cc:168
intvec::min_in
int min_in()
Definition: intvec.h:121
omFreeSize
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:258
intvec::compare
int compare(const intvec *o) const
Definition: intvec.cc:205
intvec::v
int * v
Definition: intvec.h:25
intvec
Definition: intvec.h:18
intvec::resize
void resize(int new_length)
Definition: intvec.cc:105
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:208
intvec::range
int range(int i, int j) const
Definition: intvec.h:62
ivTranp
intvec * ivTranp(intvec *o)
Definition: intvec.cc:308
intvec::makeVector
void makeVector()
Definition: intvec.h:102
intvec::operator[]
const int & operator[](int i) const
Definition: intvec.h:75
intvec::ivString
char * ivString(int not_mat=1, int spaces=0, int dim=2) const
Definition: intvec.cc:57
intvec::view
void view() const
Definition: intvec.cc:133
omallocClass
Definition: omallocClass.h:16
intvec::operator%=
void operator%=(int intop)
Definition: intvec.cc:192
intvec::String
char * String(int dim=2) const
Definition: intvec.cc:126
ivTrace
int ivTrace(intvec *o)
Definition: intvec.cc:320
ivSub
intvec * ivSub(intvec *a, intvec *b)
Definition: intvec.cc:278
ivAdd
intvec * ivAdd(intvec *a, intvec *b)
Definition: intvec.cc:248
intvec::cols
int cols() const
Definition: intvec.h:95
intvec::range
int range(int i) const
Definition: intvec.h:59
Werror
void Werror(const char *fmt,...)
Definition: reporter.cc:188
ivTriangIntern
void ivTriangIntern(intvec *imat, int &ready, int &all)
Definition: intvec.cc:385
intvec::~intvec
~intvec()
Definition: intvec.h:105
intvec::operator/=
void operator/=(int intop)
Definition: intvec.cc:178
m
int m
Definition: cfEzgcd.cc:121
assume
#define assume(x)
Definition: mod2.h:384
NULL
#define NULL
Definition: omList.c:11
l
int l
Definition: cfEzgcd.cc:93
intvec::operator[]
int & operator[](int i)
Definition: intvec.h:65
intvec::rows
int rows() const
Definition: intvec.h:96
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
p
int p
Definition: cfModGcd.cc:4019
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
intvec::delete_pos
intvec * delete_pos(int p)
Definition: intvec.cc:823
intvec::length
int length() const
Definition: intvec.h:94
intvec::row
int row
Definition: intvec.h:26
intvec::operator*=
void operator*=(int intop)
Definition: intvec.cc:173
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:209