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