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
 
intoperator[] (int i)
 
const intoperator[] (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 ()
 
intivGetVec ()
 

Private Attributes

intv
 
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  v = (int *)omAlloc0(sizeof(int)*l);
28  row = l;
29  col = 1;
30  }
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 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 33 of file intvec.h.

34  {
35  assume( iv != NULL );
36  row = iv->rows();
37  col = iv->cols();
38  assume(row > 0);
39  assume(col > 0);
40  if (row*col>0)
41  {
42  v = (int *)omAlloc(sizeof(int)*row*col);
43  for (int i=row*col-1;i>=0; i--)
44  {
45  v[i] = (*iv)[i];
46  }
47  }
48  else v=NULL;
49  }
#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:86
int rows() const
Definition: intvec.h:87
intvec::~intvec ( )
inline

Definition at line 97 of file intvec.h.

98  {
99  if (v!=NULL)
100  {
101  omFreeSize((ADDRESS)v,sizeof(int)*row*col);
102  v=NULL;
103  }
104  }
#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 86 of file intvec.h.

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

Definition at line 211 of file intvec.cc.

212 {
213  if ((col!=1) ||(op->cols()!=1))
214  {
215  if((col!=op->cols())
216  || (row!=op->rows()))
217  return -2;
218  }
219  int i;
220  for (i=0; i<si_min(length(),op->length()); i++)
221  {
222  if (v[i] > (*op)[i])
223  return 1;
224  if (v[i] < (*op)[i])
225  return -1;
226  }
227  // this can only happen for intvec: (i.e. col==1)
228  for (; i<row; i++)
229  {
230  if (v[i] > 0)
231  return 1;
232  if (v[i] < 0)
233  return -1;
234  }
235  for (; i<op->rows(); i++)
236  {
237  if (0 > (*op)[i])
238  return 1;
239  if (0 < (*op)[i])
240  return -1;
241  }
242  return 0;
243 }
static int si_min(const int a, const int b)
Definition: auxiliary.h:167
int length() const
Definition: intvec.h:85
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 244 of file intvec.cc.

245 {
246  for (int i=0; i<row*col; i++)
247  {
248  if (v[i] <o) return -1;
249  if (v[i] >o) return 1;
250  }
251  return 0;
252 }
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 130 of file intvec.h.

130 { 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 105 of file intvec.h.

106  {
107  omCheckAddrSize((ADDRESS)v,sizeof(int)*row*col);
108  }
#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 85 of file intvec.h.

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

Definition at line 88 of file intvec.h.

88 { 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 94 of file intvec.h.

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

Definition at line 109 of file intvec.h.

110  {
111  int m=v[0];
112  for (int i=row*col-1; i>0; i--) if (v[i]<m) m=v[i];
113  return m;
114  }
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 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  v[i]=c;
208  }
209 }
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 179 of file intvec.cc.

180 {
181  for (int i=0; i<row*col; i++) { v[i] *= intop; }
182 }
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 169 of file intvec.cc.

170 {
171  for (int i=0; i<row*col; i++) { v[i] += intop; }
172 }
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 174 of file intvec.cc.

175 {
176  for (int i=0; i<row*col; i++) { v[i] -= intop; }
177 }
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 184 of file intvec.cc.

185 {
186  if (intop == 0) return;
187  int bb=ABS(intop);
188  for (int i=0; i<row*col; i++)
189  {
190  int r=v[i];
191  int c=r%bb;
192  if (c<0) c+=bb;
193  r=(r-c)/intop;
194  v[i]=r;
195  }
196 }
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 56 of file intvec.h.

57  {
58 #ifndef SING_NDEBUG
59  if((i<0)||(i>=row*col))
60  {
61  Werror("wrong intvec index:%d\n",i);
62  }
63 #endif
64  return v[i];
65  }
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 66 of file intvec.h.

67  {
68 #ifndef SING_NDEBUG
69  if((i<0)||(i>=row*col))
70  {
71  Werror("wrong intvec index:%d\n",i);
72  }
73 #endif
74  return v[i];
75  }
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 52 of file intvec.h.

53  { 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 54 of file intvec.h.

55  { 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  v = (int*) omRealloc0Size(v, row*sizeof(int), new_length*sizeof(int));
129  row = new_length;
130 }
const const intvec const intvec const ring _currRing const const intvec const intvec const ring _currRing int
Definition: gb_hack.h:53
#define omRealloc0Size(addr, o_size, size)
Definition: omAllocDecl.h:221
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
int intvec::rows ( ) const
inline

Definition at line 87 of file intvec.h.

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

Definition at line 154 of file intvec.cc.

155 {
156  char *s=ivString(notmat,spaces);
157  if (spaces>0)
158  {
159  PrintNSpaces(spaces);
160  PrintS(s);
161  }
162  else
163  {
164  PrintS(s);
165  }
166  omFree(s);
167 }
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 132 of file intvec.cc.

133 {
134  return ivString(1, 0, dim);
135 }
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 139 of file intvec.cc.

140 {
141  Print ("intvec: {rows: %d, cols: %d, length: %d, Values: \n", rows(), cols(), length());
142 
143  for (int i = 0; i < rows(); i++)
144  {
145  Print ("Row[%3d]:", i);
146  for (int j = 0; j < cols(); j++)
147  Print (" %5d", this->operator[]((i)*cols()+j) );
148  PrintLn ();
149  }
150  PrintS ("}\n");
151 }
void PrintLn()
Definition: reporter.cc:322
#define Print
Definition: emacs.cc:83
int length() const
Definition: intvec.h:85
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:86
int rows() const
Definition: intvec.h:87

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: