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 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 ()
 
- Public Member Functions inherited from omallocClass
void * operator new (size_t size) throw (std::bad_alloc)
 
void operator delete (void *block) throw ()
 
void * operator new[] (size_t size) throw (std::bad_alloc)
 
void operator delete[] (void *block) throw ()
 
void * operator new (size_t size, const std::nothrow_t &) throw ()
 
void * operator new[] (size_t size, const std::nothrow_t &) throw ()
 

Private Attributes

int * v
 
int row
 
int col
 

Detailed Description

Definition at line 14 of file intvec.h.

Constructor & Destructor Documentation

§ intvec() [1/4]

intvec::intvec ( int  l = 1)
inline

Definition at line 22 of file intvec.h.

23  {
24  assume(l >= 0);
25  if (l>0) v = (int *)omAlloc0(sizeof(int)*l);
26  else v = NULL;
27  row = l;
28  col = 1;
29  }
int * v
Definition: intvec.h:17
int row
Definition: intvec.h:18
#define assume(x)
Definition: mod2.h:394
int col
Definition: intvec.h:19
#define NULL
Definition: omList.c:10
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:94

§ intvec() [2/4]

intvec::intvec ( int  s,
int  e 
)

Definition at line 22 of file intvec.cc.

23 {
24  int inc;
25  col = 1;
26  if (s<e)
27  {
28  row = e-s+1;
29  inc = 1;
30  }
31  else
32  {
33  row = s-e+1;
34  inc = -1;
35  }
36  v = (int *)omAlloc(sizeof(int)*row);
37  for (int i=0; i<row; i++)
38  {
39  v[i] = s;
40  s+=inc;
41  }
42 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define omAlloc(size)
Definition: omAllocDecl.h:210
int * v
Definition: intvec.h:17
int row
Definition: intvec.h:18
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:19

§ intvec() [3/4]

intvec::intvec ( int  r,
int  c,
int  init 
)

Definition at line 44 of file intvec.cc.

45 {
46  row = r;
47  col = c;
48  int l = r*c;
49  if (l>0) /*(r>0) && (c>0) */
50  v = (int *)omAlloc(sizeof(int)*l);
51  else
52  v = NULL;
53  for (int i=0; i<l; i++)
54  {
55  v[i] = init;
56  }
57 }
#define omAlloc(size)
Definition: omAllocDecl.h:210
int * v
Definition: intvec.h:17
const ring r
Definition: syzextra.cc:208
int row
Definition: intvec.h:18
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:19
#define NULL
Definition: omList.c:10
int l
Definition: cfEzgcd.cc:94

§ intvec() [4/4]

intvec::intvec ( const intvec iv)
inline

Definition at line 32 of file intvec.h.

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

§ ~intvec()

intvec::~intvec ( )
inline

Definition at line 97 of file intvec.h.

98  {
99  assume(row>=0);
100  assume(col>=0);
101  if (v!=NULL)
102  {
103  omFreeSize((ADDRESS)v,sizeof(int)*row*col);
104  v=NULL;
105  }
106  }
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:115
int * v
Definition: intvec.h:17
int row
Definition: intvec.h:18
#define assume(x)
Definition: mod2.h:394
int col
Definition: intvec.h:19
#define NULL
Definition: omList.c:10

Member Function Documentation

§ cols()

int intvec::cols ( ) const
inline

Definition at line 87 of file intvec.h.

87 { return col; }
int col
Definition: intvec.h:19

§ compare() [1/2]

int intvec::compare ( const intvec o) const

Definition at line 207 of file intvec.cc.

208 {
209  if ((col!=1) ||(op->cols()!=1))
210  {
211  if((col!=op->cols())
212  || (row!=op->rows()))
213  return -2;
214  }
215  int i;
216  for (i=0; i<si_min(length(),op->length()); i++)
217  {
218  if (v[i] > (*op)[i])
219  return 1;
220  if (v[i] < (*op)[i])
221  return -1;
222  }
223  // this can only happen for intvec: (i.e. col==1)
224  for (; i<row; i++)
225  {
226  if (v[i] > 0)
227  return 1;
228  if (v[i] < 0)
229  return -1;
230  }
231  for (; i<op->rows(); i++)
232  {
233  if (0 > (*op)[i])
234  return 1;
235  if (0 < (*op)[i])
236  return -1;
237  }
238  return 0;
239 }
static int si_min(const int a, const int b)
Definition: auxiliary.h:121
int * v
Definition: intvec.h:17
int row
Definition: intvec.h:18
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:19
int length() const
Definition: intvec.h:86

§ compare() [2/2]

int intvec::compare ( int  o) const

Definition at line 240 of file intvec.cc.

241 {
242  for (int i=0; i<row*col; i++)
243  {
244  if (v[i] <o) return -1;
245  if (v[i] >o) return 1;
246  }
247  return 0;
248 }
int * v
Definition: intvec.h:17
int row
Definition: intvec.h:18
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:19

§ ivGetVec()

int* intvec::ivGetVec ( )
inline

Definition at line 124 of file intvec.h.

124 { return v; }
int * v
Definition: intvec.h:17

§ ivString()

char * intvec::ivString ( int  not_mat = 1,
int  spaces = 0,
int  dim = 2 
) const

Definition at line 59 of file intvec.cc.

60 {
61  //Print("ivString:this=%x,v=%x,row=%d\n",this,v,row);
62 #ifndef OM_NDEBUG
63  omCheckAddr((void *)this);
64  if (v!=NULL) omCheckAddr((void *)v);
65 #endif
66  StringSetS("");
67  if ((col == 1)&&(not_mat))
68  {
69  int i=0;
70  for (; i<row-1; i++)
71  {
72  StringAppend("%d,",v[i]);
73  }
74  if (i<row)
75  {
76  StringAppend("%d",v[i]);
77  }
78  }
79  else
80  {
81  for (int j=0; j<row; j++)
82  {
83  if (j<row-1)
84  {
85  for (int i=0; i<col; i++)
86  {
87  StringAppend("%d%c",v[j*col+i],',');
88  }
89  }
90  else
91  {
92  for (int i=0; i<col; i++)
93  {
94  StringAppend("%d%c",v[j*col+i],i<col-1 ? ',' : ' ');
95  }
96  }
97  if (j+1<row)
98  {
99  if (dim > 1) StringAppendS("\n");
100  if (spaces>0) StringAppend("%-*.*s",spaces,spaces," ");
101  }
102  }
103  }
104  return StringEndS();
105 }
char * StringEndS()
Definition: reporter.cc:151
int * v
Definition: intvec.h:17
int row
Definition: intvec.h:18
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:19
#define NULL
Definition: omList.c:10
#define omCheckAddr(addr)
Definition: omAllocDecl.h:328

§ ivTEST()

void intvec::ivTEST ( ) const
inline

Definition at line 107 of file intvec.h.

108  {
109  assume(row>=0);
110  assume(col>=0);
111  if (row>0) omCheckAddrSize((ADDRESS)v,sizeof(int)*row*col);
112  }
#define omCheckAddrSize(addr, size)
Definition: omAllocDecl.h:327
void * ADDRESS
Definition: auxiliary.h:115
int * v
Definition: intvec.h:17
int row
Definition: intvec.h:18
#define assume(x)
Definition: mod2.h:394
int col
Definition: intvec.h:19

§ length()

int intvec::length ( ) const
inline

Definition at line 86 of file intvec.h.

86 { return col*row; }
int row
Definition: intvec.h:18
int col
Definition: intvec.h:19

§ makeVector()

void intvec::makeVector ( )
inline

Definition at line 94 of file intvec.h.

94 { row*=col;col=1; }
int row
Definition: intvec.h:18
int col
Definition: intvec.h:19

§ min_in()

int intvec::min_in ( )
inline

Definition at line 113 of file intvec.h.

114  {
115  int m=0;
116  if (row>0)
117  {
118  m=v[0];
119  for (int i=row*col-1; i>0; i--) if (v[i]<m) m=v[i];
120  }
121  return m;
122  }
int * v
Definition: intvec.h:17
int row
Definition: intvec.h:18
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:19

§ operator%=()

void intvec::operator%= ( int  intop)

Definition at line 194 of file intvec.cc.

195 {
196  if (intop == 0) return;
197  int bb=ABS(intop);
198  for (int i=0; i<row*col; i++)
199  {
200  int r=v[i];
201  int c=r%bb;
202  if (c<0) c+=bb;
203  v[i]=c;
204  }
205 }
int * v
Definition: intvec.h:17
const ring r
Definition: syzextra.cc:208
int row
Definition: intvec.h:18
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:19
#define ABS(x)
Definition: auxiliary.h:111

§ operator*=()

void intvec::operator*= ( int  intop)

Definition at line 175 of file intvec.cc.

176 {
177  for (int i=0; i<row*col; i++) { v[i] *= intop; }
178 }
int * v
Definition: intvec.h:17
int row
Definition: intvec.h:18
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:19

§ operator+=()

void intvec::operator+= ( int  intop)

Definition at line 165 of file intvec.cc.

166 {
167  for (int i=0; i<row*col; i++) { v[i] += intop; }
168 }
int * v
Definition: intvec.h:17
int row
Definition: intvec.h:18
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:19

§ operator-=()

void intvec::operator-= ( int  intop)

Definition at line 170 of file intvec.cc.

171 {
172  for (int i=0; i<row*col; i++) { v[i] -= intop; }
173 }
int * v
Definition: intvec.h:17
int row
Definition: intvec.h:18
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:19

§ operator/=()

void intvec::operator/= ( int  intop)

Definition at line 180 of file intvec.cc.

181 {
182  if (intop == 0) return;
183  int bb=ABS(intop);
184  for (int i=0; i<row*col; i++)
185  {
186  int r=v[i];
187  int c=r%bb;
188  if (c<0) c+=bb;
189  r=(r-c)/intop;
190  v[i]=r;
191  }
192 }
int * v
Definition: intvec.h:17
const ring r
Definition: syzextra.cc:208
int row
Definition: intvec.h:18
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:19
#define ABS(x)
Definition: auxiliary.h:111

§ operator[]() [1/2]

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:17
int row
Definition: intvec.h:18
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:19
void Werror(const char *fmt,...)
Definition: reporter.cc:189

§ operator[]() [2/2]

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:17
int row
Definition: intvec.h:18
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:19
void Werror(const char *fmt,...)
Definition: reporter.cc:189

§ range() [1/2]

int intvec::range ( int  i) const
inline

Definition at line 51 of file intvec.h.

53  { return ((((unsigned)i)<((unsigned)row)) && (col==1)); }
int row
Definition: intvec.h:18
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:19

§ range() [2/2]

int intvec::range ( int  i,
int  j 
) const
inline

Definition at line 54 of file intvec.h.

56  { return ((((unsigned)i)<((unsigned)row)) && (((unsigned)j)<((unsigned)col))); }
int row
Definition: intvec.h:18
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int col
Definition: intvec.h:19

§ resize()

void intvec::resize ( int  new_length)

Definition at line 107 of file intvec.cc.

108 {
109  assume(new_length >= 0 && col == 1);
110  if (new_length==0)
111  {
112  if (v!=NULL)
113  {
114  omFreeSize(v, row*sizeof(int));
115  v=NULL;
116  }
117  }
118  else
119  {
120  if (v!=NULL)
121  v = (int*) omRealloc0Size(v, row*sizeof(int), new_length*sizeof(int));
122  else
123  v = (int*) omAlloc0(new_length*sizeof(int));
124  }
125  row = new_length;
126 }
#define omRealloc0Size(addr, o_size, size)
Definition: omAllocDecl.h:221
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
int * v
Definition: intvec.h:17
int row
Definition: intvec.h:18
#define assume(x)
Definition: mod2.h:394
int col
Definition: intvec.h:19
#define NULL
Definition: omList.c:10
#define omAlloc0(size)
Definition: omAllocDecl.h:211

§ rows()

int intvec::rows ( ) const
inline

Definition at line 88 of file intvec.h.

88 { return row; }
int row
Definition: intvec.h:18

§ show()

void intvec::show ( int  mat = 0,
int  spaces = 0 
) const

Definition at line 150 of file intvec.cc.

151 {
152  char *s=ivString(notmat,spaces);
153  if (spaces>0)
154  {
155  PrintNSpaces(spaces);
156  PrintS(s);
157  }
158  else
159  {
160  PrintS(s);
161  }
162  omFree(s);
163 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
char * ivString(int not_mat=1, int spaces=0, int dim=2) const
Definition: intvec.cc:59
#define omFree(addr)
Definition: omAllocDecl.h:261
void PrintS(const char *s)
Definition: reporter.cc:284
void PrintNSpaces(const int n)
Definition: reporter.cc:364

§ String()

char * intvec::String ( int  dim = 2) const

Definition at line 128 of file intvec.cc.

129 {
130  return ivString(1, 0, dim);
131 }
char * ivString(int not_mat=1, int spaces=0, int dim=2) const
Definition: intvec.cc:59
int dim(ideal I, ring r)

§ view()

void intvec::view ( ) const

Definition at line 135 of file intvec.cc.

136 {
137  Print ("intvec: {rows: %d, cols: %d, length: %d, Values: \n", rows(), cols(), length());
138 
139  for (int i = 0; i < rows(); i++)
140  {
141  Print ("Row[%3d]:", i);
142  for (int j = 0; j < cols(); j++)
143  Print (" %5d", this->operator[]((i)*cols()+j) );
144  PrintLn ();
145  }
146  PrintS ("}\n");
147 }
void PrintLn()
Definition: reporter.cc:310
#define Print
Definition: emacs.cc:83
int rows() const
Definition: intvec.h:88
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
void PrintS(const char *s)
Definition: reporter.cc:284
int length() const
Definition: intvec.h:86
int cols() const
Definition: intvec.h:87

Field Documentation

§ col

int intvec::col
private

Definition at line 19 of file intvec.h.

§ row

int intvec::row
private

Definition at line 18 of file intvec.h.

§ v

int* intvec::v
private

Definition at line 17 of file intvec.h.


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