Public Member Functions | Private Attributes
intvec Class Reference

#include <intvec.h>

Public Member Functions

 intvec (int l=1)
 
 intvec (int s, int e)
 
 intvec (int r, int c, int init)
 
 intvec (const intvec *iv)
 
void resize (int new_length)
 
int range (int i) const
 
int range (int i, int j) const
 
int & operator[] (int i)
 
const int & operator[] (int i) const
 
void operator+= (int intop)
 
void operator-= (int intop)
 
void operator*= (int intop)
 
void operator/= (int intop)
 
void operator%= (int intop)
 
int compare (const intvec *o) const
 
int compare (int o) const
 
int length () const
 
int cols () const
 
int rows () const
 
void length (int l)
 
void show (int mat=0, int spaces=0) const
 
void view () const
 
void makeVector ()
 
char * String (int dim=2) const
 
char * ivString (int not_mat=1, int spaces=0, int dim=2) const
 
 ~intvec ()
 
void ivTEST () const
 
int min_in ()
 
int * ivGetVec ()
 

Private Attributes

int * v
 
int row
 
int col
 

Detailed Description

Definition at line 16 of file intvec.h.

Constructor & Destructor Documentation

intvec::intvec ( int  l = 1)
inline

Definition at line 24 of file intvec.h.

25  {
26  assume(l >= 0);
27  if (l>0) v = (int *)omAlloc0(sizeof(int)*l);
28  else v = NULL;
29  row = l;
30  col = 1;
31  }
int * v
Definition: intvec.h:19
int row
Definition: intvec.h:20
#define assume(x)
Definition: mod2.h:405
int col
Definition: intvec.h:21
#define NULL
Definition: omList.c:10
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:94
intvec::intvec ( int  s,
int  e 
)

Definition at line 40 of file intvec.cc.

41 {
42  int inc;
43  col = 1;
44  if (s<e)
45  {
46  row = e-s+1;
47  inc = 1;
48  }
49  else
50  {
51  row = s-e+1;
52  inc = -1;
53  }
54  v = (int *)omAlloc(sizeof(int)*row);
55  for (int i=0; i<row; i++)
56  {
57  v[i] = s;
58  s+=inc;
59  }
60 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define omAlloc(size)
Definition: omAllocDecl.h:210
int * v
Definition: intvec.h:19
int row
Definition: intvec.h:20
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:21
intvec::intvec ( int  r,
int  c,
int  init 
)

Definition at line 62 of file intvec.cc.

63 {
64  row = r;
65  col = c;
66  int l = r*c;
67  if (l>0) /*(r>0) && (c>0) */
68  v = (int *)omAlloc(sizeof(int)*l);
69  else
70  v = NULL;
71  for (int i=0; i<l; i++)
72  {
73  v[i] = init;
74  }
75 }
#define omAlloc(size)
Definition: omAllocDecl.h:210
int * v
Definition: intvec.h:19
const ring r
Definition: syzextra.cc:208
int row
Definition: intvec.h:20
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:21
#define NULL
Definition: omList.c:10
int l
Definition: cfEzgcd.cc:94
intvec::intvec ( const intvec iv)
inline

Definition at line 34 of file intvec.h.

35  {
36  assume( iv != NULL );
37  row = iv->rows();
38  col = iv->cols();
39  assume(row >= 0);
40  assume(col > 0);
41  if (row*col>0)
42  {
43  v = (int *)omAlloc(sizeof(int)*row*col);
44  for (int i=row*col-1;i>=0; i--)
45  {
46  v[i] = (*iv)[i];
47  }
48  }
49  else v=NULL;
50  }
#define omAlloc(size)
Definition: omAllocDecl.h:210
int * v
Definition: intvec.h:19
int row
Definition: intvec.h:20
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:21
#define NULL
Definition: omList.c:10
int cols() const
Definition: intvec.h:87
int rows() const
Definition: intvec.h:88
intvec::~intvec ( )
inline

Definition at line 98 of file intvec.h.

99  {
100  if (v!=NULL)
101  {
102  omFreeSize((ADDRESS)v,sizeof(int)*row*col);
103  v=NULL;
104  }
105  }
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:161
int * v
Definition: intvec.h:19
int row
Definition: intvec.h:20
int col
Definition: intvec.h:21
#define NULL
Definition: omList.c:10

Member Function Documentation

int intvec::cols ( ) const
inline

Definition at line 87 of file intvec.h.

87 { return col; }
int col
Definition: intvec.h:21
int intvec::compare ( const intvec o) const

Definition at line 225 of file intvec.cc.

226 {
227  if ((col!=1) ||(op->cols()!=1))
228  {
229  if((col!=op->cols())
230  || (row!=op->rows()))
231  return -2;
232  }
233  int i;
234  for (i=0; i<si_min(length(),op->length()); i++)
235  {
236  if (v[i] > (*op)[i])
237  return 1;
238  if (v[i] < (*op)[i])
239  return -1;
240  }
241  // this can only happen for intvec: (i.e. col==1)
242  for (; i<row; i++)
243  {
244  if (v[i] > 0)
245  return 1;
246  if (v[i] < 0)
247  return -1;
248  }
249  for (; i<op->rows(); i++)
250  {
251  if (0 > (*op)[i])
252  return 1;
253  if (0 < (*op)[i])
254  return -1;
255  }
256  return 0;
257 }
static int si_min(const int a, const int b)
Definition: auxiliary.h:167
int length() const
Definition: intvec.h:86
int * v
Definition: intvec.h:19
int row
Definition: intvec.h:20
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:21
int intvec::compare ( int  o) const

Definition at line 258 of file intvec.cc.

259 {
260  for (int i=0; i<row*col; i++)
261  {
262  if (v[i] <o) return -1;
263  if (v[i] >o) return 1;
264  }
265  return 0;
266 }
int * v
Definition: intvec.h:19
int row
Definition: intvec.h:20
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:21
int* intvec::ivGetVec ( )
inline

Definition at line 135 of file intvec.h.

135 { return v; }
int * v
Definition: intvec.h:19
char * intvec::ivString ( int  not_mat = 1,
int  spaces = 0,
int  dim = 2 
) const

Definition at line 77 of file intvec.cc.

78 {
79  //Print("ivString:this=%x,v=%x,row=%d\n",this,v,row);
80 #ifndef OM_NDEBUG
81  omCheckAddr((void *)this);
82  if (v!=NULL) omCheckAddr((void *)v);
83 #endif
84  StringSetS("");
85  if ((col == 1)&&(not_mat))
86  {
87  int i=0;
88  for (; i<row-1; i++)
89  {
90  StringAppend("%d,",v[i]);
91  }
92  if (i<row)
93  {
94  StringAppend("%d",v[i]);
95  }
96  }
97  else
98  {
99  for (int j=0; j<row; j++)
100  {
101  if (j<row-1)
102  {
103  for (int i=0; i<col; i++)
104  {
105  StringAppend("%d%c",v[j*col+i],',');
106  }
107  }
108  else
109  {
110  for (int i=0; i<col; i++)
111  {
112  StringAppend("%d%c",v[j*col+i],i<col-1 ? ',' : ' ');
113  }
114  }
115  if (j+1<row)
116  {
117  if (dim > 1) StringAppendS("\n");
118  if (spaces>0) StringAppend("%-*.*s",spaces,spaces," ");
119  }
120  }
121  }
122  return StringEndS();
123 }
char * StringEndS()
Definition: reporter.cc:151
int * v
Definition: intvec.h:19
int row
Definition: intvec.h:20
int j
Definition: myNF.cc:70
void StringSetS(const char *st)
Definition: reporter.cc:128
void StringAppendS(const char *st)
Definition: reporter.cc:107
int dim(ideal I, ring r)
#define StringAppend
Definition: emacs.cc:82
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:21
#define NULL
Definition: omList.c:10
#define omCheckAddr(addr)
Definition: omAllocDecl.h:328
void intvec::ivTEST ( ) const
inline

Definition at line 106 of file intvec.h.

107  {
108  if (row>0) omCheckAddrSize((ADDRESS)v,sizeof(int)*row*col);
109  }
#define omCheckAddrSize(addr, size)
Definition: omAllocDecl.h:327
void * ADDRESS
Definition: auxiliary.h:161
int * v
Definition: intvec.h:19
int row
Definition: intvec.h:20
int col
Definition: intvec.h:21
int intvec::length ( ) const
inline

Definition at line 86 of file intvec.h.

86 { return col*row; }
int row
Definition: intvec.h:20
int col
Definition: intvec.h:21
void intvec::length ( int  l)
inline

Definition at line 89 of file intvec.h.

89 { row = l; col = 1; }
int row
Definition: intvec.h:20
int col
Definition: intvec.h:21
int l
Definition: cfEzgcd.cc:94
void intvec::makeVector ( )
inline

Definition at line 95 of file intvec.h.

95 { row*=col;col=1; }
int row
Definition: intvec.h:20
int col
Definition: intvec.h:21
int intvec::min_in ( )
inline

Definition at line 110 of file intvec.h.

111  {
112  int m=0;
113  if (row>0)
114  {
115  m=v[0];
116  for (int i=row*col-1; i>0; i--) if (v[i]<m) m=v[i];
117  }
118  return m;
119  }
int * v
Definition: intvec.h:19
int row
Definition: intvec.h:20
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:21
void intvec::operator%= ( int  intop)

Definition at line 212 of file intvec.cc.

213 {
214  if (intop == 0) return;
215  int bb=ABS(intop);
216  for (int i=0; i<row*col; i++)
217  {
218  int r=v[i];
219  int c=r%bb;
220  if (c<0) c+=bb;
221  v[i]=c;
222  }
223 }
int * v
Definition: intvec.h:19
const ring r
Definition: syzextra.cc:208
int row
Definition: intvec.h:20
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:21
#define ABS(x)
Definition: auxiliary.h:157
void intvec::operator*= ( int  intop)

Definition at line 193 of file intvec.cc.

194 {
195  for (int i=0; i<row*col; i++) { v[i] *= intop; }
196 }
int * v
Definition: intvec.h:19
int row
Definition: intvec.h:20
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:21
void intvec::operator+= ( int  intop)

Definition at line 183 of file intvec.cc.

184 {
185  for (int i=0; i<row*col; i++) { v[i] += intop; }
186 }
int * v
Definition: intvec.h:19
int row
Definition: intvec.h:20
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:21
void intvec::operator-= ( int  intop)

Definition at line 188 of file intvec.cc.

189 {
190  for (int i=0; i<row*col; i++) { v[i] -= intop; }
191 }
int * v
Definition: intvec.h:19
int row
Definition: intvec.h:20
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:21
void intvec::operator/= ( int  intop)

Definition at line 198 of file intvec.cc.

199 {
200  if (intop == 0) return;
201  int bb=ABS(intop);
202  for (int i=0; i<row*col; i++)
203  {
204  int r=v[i];
205  int c=r%bb;
206  if (c<0) c+=bb;
207  r=(r-c)/intop;
208  v[i]=r;
209  }
210 }
int * v
Definition: intvec.h:19
const ring r
Definition: syzextra.cc:208
int row
Definition: intvec.h:20
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:21
#define ABS(x)
Definition: auxiliary.h:157
int& intvec::operator[] ( int  i)
inline

Definition at line 57 of file intvec.h.

58  {
59 #ifndef SING_NDEBUG
60  if((i<0)||(i>=row*col))
61  {
62  Werror("wrong intvec index:%d\n",i);
63  }
64 #endif
65  return v[i];
66  }
int * v
Definition: intvec.h:19
int row
Definition: intvec.h:20
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:21
void Werror(const char *fmt,...)
Definition: reporter.cc:199
const int& intvec::operator[] ( int  i) const
inline

Definition at line 67 of file intvec.h.

68  {
69 #ifndef SING_NDEBUG
70  if((i<0)||(i>=row*col))
71  {
72  Werror("wrong intvec index:%d\n",i);
73  }
74 #endif
75  return v[i];
76  }
int * v
Definition: intvec.h:19
int row
Definition: intvec.h:20
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:21
void Werror(const char *fmt,...)
Definition: reporter.cc:199
int intvec::range ( int  i) const
inline

Definition at line 53 of file intvec.h.

54  { return ((i<row) && (i>=0) && (col==1)); }
int row
Definition: intvec.h:20
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:21
int intvec::range ( int  i,
int  j 
) const
inline

Definition at line 55 of file intvec.h.

56  { return ((i<row) && (i>=0) && (j<col) && (j>=0)); }
int row
Definition: intvec.h:20
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:21
void intvec::resize ( int  new_length)

Definition at line 125 of file intvec.cc.

126 {
127  assume(new_length >= 0 && col == 1);
128  if (new_length==0)
129  {
130  if (v!=NULL)
131  {
132  omFreeSize(v, row*sizeof(int));
133  v=NULL;
134  }
135  }
136  else
137  {
138  if (v!=NULL)
139  v = (int*) omRealloc0Size(v, row*sizeof(int), new_length*sizeof(int));
140  else
141  v = (int*) omAlloc0(new_length*sizeof(int));
142  }
143  row = new_length;
144 }
#define omRealloc0Size(addr, o_size, size)
Definition: omAllocDecl.h:221
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
int * v
Definition: intvec.h:19
int row
Definition: intvec.h:20
#define assume(x)
Definition: mod2.h:405
int col
Definition: intvec.h:21
#define NULL
Definition: omList.c:10
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int intvec::rows ( ) const
inline

Definition at line 88 of file intvec.h.

88 { return row; }
int row
Definition: intvec.h:20
void intvec::show ( int  mat = 0,
int  spaces = 0 
) const

Definition at line 168 of file intvec.cc.

169 {
170  char *s=ivString(notmat,spaces);
171  if (spaces>0)
172  {
173  PrintNSpaces(spaces);
174  PrintS(s);
175  }
176  else
177  {
178  PrintS(s);
179  }
180  omFree(s);
181 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define omFree(addr)
Definition: omAllocDecl.h:261
void PrintS(const char *s)
Definition: reporter.cc:294
char * ivString(int not_mat=1, int spaces=0, int dim=2) const
Definition: intvec.cc:77
void PrintNSpaces(const int n)
Definition: reporter.cc:376
char * intvec::String ( int  dim = 2) const

Definition at line 146 of file intvec.cc.

147 {
148  return ivString(1, 0, dim);
149 }
int dim(ideal I, ring r)
char * ivString(int not_mat=1, int spaces=0, int dim=2) const
Definition: intvec.cc:77
void intvec::view ( ) const

Definition at line 153 of file intvec.cc.

154 {
155  Print ("intvec: {rows: %d, cols: %d, length: %d, Values: \n", rows(), cols(), length());
156 
157  for (int i = 0; i < rows(); i++)
158  {
159  Print ("Row[%3d]:", i);
160  for (int j = 0; j < cols(); j++)
161  Print (" %5d", this->operator[]((i)*cols()+j) );
162  PrintLn ();
163  }
164  PrintS ("}\n");
165 }
void PrintLn()
Definition: reporter.cc:322
#define Print
Definition: emacs.cc:83
int length() const
Definition: intvec.h:86
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
void PrintS(const char *s)
Definition: reporter.cc:294
int cols() const
Definition: intvec.h:87
int rows() const
Definition: intvec.h:88

Field Documentation

int intvec::col
private

Definition at line 21 of file intvec.h.

int intvec::row
private

Definition at line 20 of file intvec.h.

int* intvec::v
private

Definition at line 19 of file intvec.h.


The documentation for this class was generated from the following files: