My Project  UNKNOWN_GIT_VERSION
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 ()
 
intvecdelete_pos (int p)
 
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 17 of file intvec.h.

Constructor & Destructor Documentation

◆ intvec() [1/4]

intvec::intvec ( int  l = 1)
inline

Definition at line 30 of file intvec.h.

39  {

◆ intvec() [2/4]

intvec::intvec ( int  s,
int  e 
)

Definition at line 21 of file intvec.cc.

22 {
23  int inc;
24  col = 1;
25  if (s<e)
26  {
27  row = e-s+1;
28  inc = 1;
29  }
30  else
31  {
32  row = s-e+1;
33  inc = -1;
34  }
35  v = (int *)omAlloc(sizeof(int)*row);
36  for (int i=0; i<row; i++)
37  {
38  v[i] = s;
39  s+=inc;
40  }
41 }

◆ intvec() [3/4]

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

Definition at line 43 of file intvec.cc.

44 {
45  row = r;
46  col = c;
47  int l = r*c;
48  if (l>0) /*(r>0) && (c>0) */
49  v = (int *)omAlloc(sizeof(int)*l);
50  else
51  v = NULL;
52  for (int i=0; i<l; i++)
53  {
54  v[i] = init;
55  }
56 }

◆ intvec() [4/4]

intvec::intvec ( const intvec iv)
inline

Definition at line 40 of file intvec.h.

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);

◆ ~intvec()

intvec::~intvec ( )
inline

Definition at line 105 of file intvec.h.

108  {
109  omFreeSize((ADDRESS)v,sizeof(int)*row*col);
110  v=NULL;
111  }
112  }
113  inline void ivTEST() const
114  {

Member Function Documentation

◆ cols()

int intvec::cols ( ) const
inline

Definition at line 95 of file intvec.h.

100 { row*=col;col=1; }

◆ compare() [1/2]

int intvec::compare ( const intvec o) const

Definition at line 206 of file intvec.cc.

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

◆ compare() [2/2]

int intvec::compare ( int  o) const

Definition at line 239 of file intvec.cc.

240 {
241  for (int i=0; i<row*col; i++)
242  {
243  if (v[i] <o) return -1;
244  if (v[i] >o) return 1;
245  }
246  return 0;
247 }

◆ delete_pos()

intvec * intvec::delete_pos ( int  p)

Definition at line 824 of file intvec.cc.

825 {
826  if (!range(p)) return NULL;
827  intvec *iv=new intvec(rows()-1);
828  for(int i=0;i<p;i++) (*iv)[i]=v[i];
829  for(int i=p+1;i<rows();i++) (*iv)[i-1]=v[i];
830  return iv;
831 }

◆ ivGetVec()

int* intvec::ivGetVec ( )
inline

Definition at line 133 of file intvec.h.

134 {

◆ ivString()

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

Definition at line 58 of file intvec.cc.

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

◆ ivTEST()

void intvec::ivTEST ( ) const
inline

Definition at line 115 of file intvec.h.

120  {

◆ length()

int intvec::length ( ) const
inline

Definition at line 94 of file intvec.h.

94 { return row; }

◆ makeVector()

void intvec::makeVector ( )
inline

Definition at line 102 of file intvec.h.

104 {

◆ min_in()

int intvec::min_in ( )
inline

Definition at line 121 of file intvec.h.

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 !!!

◆ operator%=()

void intvec::operator%= ( int  intop)

Definition at line 193 of file intvec.cc.

194 {
195  if (intop == 0) return;
196  int bb=ABS(intop);
197  for (int i=0; i<row*col; i++)
198  {
199  int r=v[i];
200  int c=r%bb;
201  if (c<0) c+=bb;
202  v[i]=c;
203  }
204 }

◆ operator*=()

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 }

◆ operator+=()

void intvec::operator+= ( int  intop)

Definition at line 164 of file intvec.cc.

165 {
166  for (int i=0; i<row*col; i++) { v[i] += intop; }
167 }

◆ operator-=()

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 }

◆ operator/=()

void intvec::operator/= ( int  intop)

Definition at line 179 of file intvec.cc.

180 {
181  if (intop == 0) return;
182  int bb=ABS(intop);
183  for (int i=0; i<row*col; i++)
184  {
185  int r=v[i];
186  int c=r%bb;
187  if (c<0) c+=bb;
188  r=(r-c)/intop;
189  v[i]=r;
190  }
191 }

◆ operator[]() [1/2]

int& intvec::operator[] ( int  i)
inline

Definition at line 65 of file intvec.h.

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  {

◆ operator[]() [2/2]

const int& intvec::operator[] ( int  i) const
inline

Definition at line 75 of file intvec.h.

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);

◆ range() [1/2]

int intvec::range ( int  i) const
inline

Definition at line 59 of file intvec.h.

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)); }

◆ range() [2/2]

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

Definition at line 62 of file intvec.h.

62  { return ((((unsigned)i)<((unsigned)row)) && (((unsigned)j)<((unsigned)col))); }
63  inline int& operator[](int i)
64  {

◆ resize()

void intvec::resize ( int  new_length)

Definition at line 106 of file intvec.cc.

107 {
108  assume(new_length >= 0 && col == 1);
109  if (new_length==0)
110  {
111  if (v!=NULL)
112  {
113  omFreeSize(v, row*sizeof(int));
114  v=NULL;
115  }
116  }
117  else
118  {
119  if (v!=NULL)
120  v = (int*) omRealloc0Size(v, row*sizeof(int), new_length*sizeof(int));
121  else
122  v = (int*) omAlloc0(new_length*sizeof(int));
123  }
124  row = new_length;
125 }

◆ rows()

int intvec::rows ( ) const
inline

Definition at line 96 of file intvec.h.

100 { row*=col;col=1; }

◆ show()

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

Definition at line 149 of file intvec.cc.

150 {
151  char *s=ivString(notmat,spaces);
152  if (spaces>0)
153  {
154  PrintNSpaces(spaces);
155  PrintS(s);
156  }
157  else
158  {
159  PrintS(s);
160  }
161  omFree(s);
162 }

◆ String()

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

Definition at line 127 of file intvec.cc.

128 {
129  return ivString(1, 0, dim);
130 }

◆ view()

void intvec::view ( ) const

Definition at line 134 of file intvec.cc.

135 {
136  Print ("intvec: {rows: %d, cols: %d, length: %d, Values: \n", rows(), cols(), length());
137 
138  for (int i = 0; i < rows(); i++)
139  {
140  Print ("Row[%3d]:", i);
141  for (int j = 0; j < cols(); j++)
142  Print (" %5d", this->operator[]((i)*cols()+j) );
143  PrintLn ();
144  }
145  PrintS ("}\n");
146 }

Field Documentation

◆ col

int intvec::col
private

Definition at line 27 of file intvec.h.

◆ row

int intvec::row
private

Definition at line 26 of file intvec.h.

◆ v

int* intvec::v
private

Definition at line 25 of file intvec.h.


The documentation for this class was generated from the following files:
dim
int dim(ideal I, ring r)
Definition: tropicalStrategy.cc:23
si_min
static int si_min(const int a, const int b)
Definition: auxiliary.h:139
StringAppendS
void StringAppendS(const char *st)
Definition: reporter.cc:107
j
int j
Definition: facHensel.cc:105
omFree
#define omFree(addr)
Definition: omAllocDecl.h:261
ADDRESS
void * ADDRESS
Definition: auxiliary.h:133
intvec::col
int col
Definition: intvec.h:27
intvec::operator+=
void operator+=(int intop)
Definition: intvec.cc:164
StringEndS
char * StringEndS()
Definition: reporter.cc:151
ABS
static int ABS(int v)
Definition: auxiliary.h:110
intvec::intvec
intvec(int l=1)
Definition: intvec.h:30
intvec::ivTEST
void ivTEST() const
Definition: intvec.h:115
i
int i
Definition: cfEzgcd.cc:125
PrintS
void PrintS(const char *s)
Definition: reporter.cc:284
omFreeSize
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
intvec::v
int * v
Definition: intvec.h:25
intvec
Definition: intvec.h:21
intvec::resize
void resize(int new_length)
Definition: intvec.cc:106
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:210
intvec::ivString
char * ivString(int not_mat=1, int spaces=0, int dim=2) const
Definition: intvec.cc:58
StringSetS
void StringSetS(const char *st)
Definition: reporter.cc:128
Print
#define Print
Definition: emacs.cc:80
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:189
m
int m
Definition: cfEzgcd.cc:121
assume
#define assume(x)
Definition: mod2.h:390
NULL
#define NULL
Definition: omList.c:10
l
int l
Definition: cfEzgcd.cc:93
omRealloc0Size
#define omRealloc0Size(addr, o_size, size)
Definition: omAllocDecl.h:221
intvec::operator[]
int & operator[](int i)
Definition: intvec.h:65
intvec::rows
int rows() const
Definition: intvec.h:96
StringAppend
#define StringAppend
Definition: emacs.cc:79
omCheckAddr
#define omCheckAddr(addr)
Definition: omAllocDecl.h:328
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:824
PrintLn
void PrintLn()
Definition: reporter.cc:310
intvec::length
int length() const
Definition: intvec.h:94
intvec::row
int row
Definition: intvec.h:26
PrintNSpaces
void PrintNSpaces(const int n)
Definition: reporter.cc:364
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:211