Loading...
Searching...
No Matches
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 | 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 | max_in ()
intvec * | delete_pos (int p)
int * | ivGetVec () const
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 20 of file intvec.h.

## Constructor & Destructor Documentation

## intvec() [1/4]

intvec::intvec | ( | int | l = 1 | ) |

inline

Definition at line 31 of file intvec.h.

{
assume(l >= 0);
if (l>0) v = (int *)omAlloc0(sizeof(int)*l);
else v = NULL;
row = l;
col = 1;
}
l
int l
Definition cfEzgcd.cc:100
intvec::col
int col
Definition intvec.h:28
intvec::row
int row
Definition intvec.h:27
intvec::v
int * v
Definition intvec.h:26
assume
#define assume(x)
Definition mod2.h:389
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
NULL
#define NULL
Definition omList.c:12

## intvec() [2/4]

intvec::intvec | ( | int | s,
|  | int | e )

Definition at line 21 of file intvec.cc.

{
int inc;
col = 1;
if (s<e)
{
row = e-s+1;
inc = 1;
}
else
{
row = s-e+1;
inc = -1;
}
v = (int *)omAlloc(sizeof(int)*row);
for (int i=0; i<row; i++)
{
v[i] = s;
s+=inc;
}
}
i
int i
Definition cfEzgcd.cc:132
s
const CanonicalForm int s
Definition facAbsFact.cc:51
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210

## intvec() [3/4]

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

Definition at line 43 of file intvec.cc.

{
row = r;
col = c;
int l = r*c;
if (l>0) /*(r>0) && (c>0) */
v = (int *)omAlloc(sizeof(int)*l);
else
v = NULL;
for (int i=0; i<l; i++)
{
v[i] = init;
}
}
LinTree::init
void init()
Definition lintree.cc:864

## intvec() [4/4]

intvec::intvec | ( | const intvec * | iv | ) |

inline

Definition at line 41 of file intvec.h.

{
assume( iv != NULL );
row = iv->rows();
col = iv->cols();
assume(row >= 0);
assume(col >= 0);
if (row*col>0)
{
v = (int *)omAlloc(sizeof(int)*row*col);
for (int i=row*col-1;i>=0; i--)
{
v[i] = (*iv)[i];
}
}
else v=NULL;
}
intvec::cols
int cols() const
Definition intvec.h:96
intvec::rows
int rows() const
Definition intvec.h:97

## ~intvec()

intvec::~intvec | ( |  | ) |

inline

Definition at line 106 of file intvec.h.

{
assume(row>=0);
assume(col>=0);
if (v!=NULL)
{
omFreeSize((ADDRESS)v,sizeof(int)*row*col);
v=NULL;
}
}
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260

## Member Function Documentation

## cols()

int intvec::cols | ( |  | ) | const

inline

Definition at line 96 of file intvec.h.

{ return col; }

## compare() [1/2]

int intvec::compare | ( | const intvec * | o | ) | const

Definition at line 206 of file intvec.cc.

{
if ((col!=1) ||(op->cols()!=1))
{
if((col!=op->cols())
|| (row!=op->rows()))
return -2;
}
int i;
for (i=0; i<si_min(length(),op->length()); i++)
{
if (v[i] > (*op)[i])
return 1;
if (v[i] < (*op)[i])
return -1;
}
// this can only happen for intvec: (i.e. col==1)
for (; i<row; i++)
{
if (v[i] > 0)
return 1;
if (v[i] < 0)
return -1;
}
for (; i<op->rows(); i++)
{
if (0 > (*op)[i])
return 1;
if (0 < (*op)[i])
return -1;
}
return 0;
}
si_min
static int si_min(const int a, const int b)
Definition auxiliary.h:126
intvec::length
int length() const
Definition intvec.h:95

## compare() [2/2]

int intvec::compare | ( | int | o | ) | const

Definition at line 239 of file intvec.cc.

{
for (int i=0; i<row*col; i++)
{
if (v[i] <o) return -1;
if (v[i] >o) return 1;
}
return 0;
}

## delete_pos()

intvec * intvec::delete_pos | ( | int | p | ) |

Definition at line 842 of file intvec.cc.

{
if (!range(p)) return NULL;
intvec *iv=new intvec(rows()-1);
for(int i=0;i<p;i++) (*iv)[i]=v[i];
for(int i=p+1;i<rows();i++) (*iv)[i-1]=v[i];
return iv;
}
p
int p
Definition cfModGcd.cc:4086
intvec::intvec
intvec(int l=1)
Definition intvec.h:31
intvec::range
int range(int i) const
Definition intvec.h:60

## ivGetVec()

int * intvec::ivGetVec | ( |  | ) | const

inline

Definition at line 144 of file intvec.h.

{ return v; }

## ivString()

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

Definition at line 58 of file intvec.cc.

{
//Print("ivString:this=%x,v=%x,row=%d\n",this,v,row);
#ifndef OM_NDEBUG
omCheckAddr((void *)this);
if (v!=NULL) omCheckAddr((void *)v);
#endif
StringSetS("");
if ((col == 1)&&(not_mat))
{
int i=0;
for (; i<row-1; i++)
{
StringAppend("%d,",v[i]);
}
if (i<row)
{
StringAppend("%d",v[i]);
}
}
else
{
for (int j=0; j<row; j++)
{
if (j<row-1)
{
for (int i=0; i<col; i++)
{
StringAppend("%d%c",v[j*col+i],',');
}
}
else
{
for (int i=0; i<col; i++)
{
StringAppend("%d%c",v[j*col+i],i<col-1 ? ',' : ' ');
}
}
if (j+1<row)
{
if (dim > 1) StringAppendS("\n");
if (spaces>0) StringAppend("%-*.*s",spaces,spaces," ");
}
}
}
return StringEndS();
}
StringAppend
#define StringAppend
Definition emacs.cc:79
j
int j
Definition facHensel.cc:110
omCheckAddr
#define omCheckAddr(addr)
Definition omAllocDecl.h:328
StringSetS
void StringSetS(const char *st)
Definition reporter.cc:128
StringAppendS
void StringAppendS(const char *st)
Definition reporter.cc:107
StringEndS
char * StringEndS()
Definition reporter.cc:151
dim
int dim(ideal I, ring r)
Definition tropicalStrategy.cc:23

## ivTEST()

void intvec::ivTEST | ( |  | ) | const

inline

Definition at line 116 of file intvec.h.

{
assume(row>=0);
assume(col>=0);
if (row>0) omCheckAddrSize((ADDRESS)v,sizeof(int)*row*col);
}
omCheckAddrSize
#define omCheckAddrSize(addr, size)
Definition omAllocDecl.h:327

## length()

int intvec::length | ( |  | ) | const

inline

Definition at line 95 of file intvec.h.

{ return col*row; }

## makeVector()

void intvec::makeVector | ( |  | ) |

inline

Definition at line 103 of file intvec.h.

{ row*=col;col=1; }

## max_in()

int intvec::max_in | ( |  | ) |

inline

Definition at line 132 of file intvec.h.

{
int m=0;
if (row>0)
{
m=v[0];
for (int i=row*col-1; i>0; i--) if (v[i]>m) m=v[i];
}
return m;
}
m
int m
Definition cfEzgcd.cc:128

## min_in()

int intvec::min_in | ( |  | ) |

inline

Definition at line 122 of file intvec.h.

{
int m=0;
if (row>0)
{
m=v[0];
for (int i=row*col-1; i>0; i--) if (v[i]<m) m=v[i];
}
return m;
}

## operator%=()

void intvec::operator%= | ( | int | intop | ) |

Definition at line 193 of file intvec.cc.

{
if (intop == 0) return;
int bb=ABS(intop);
for (int i=0; i<row*col; i++)
{
int r=v[i];
int c=r%bb;
if (c<0) c+=bb;
v[i]=c;
}
}
ABS
static int ABS(int v)
Definition auxiliary.h:113

## operator*=()

void intvec::operator*= | ( | int | intop | ) |

Definition at line 174 of file intvec.cc.

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

## operator+=()

void intvec::operator+= | ( | int | intop | ) |

Definition at line 164 of file intvec.cc.

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

## operator-=()

void intvec::operator-= | ( | int | intop | ) |

Definition at line 169 of file intvec.cc.

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

## operator/=()

void intvec::operator/= | ( | int | intop | ) |

Definition at line 179 of file intvec.cc.

{
if (intop == 0) return;
int bb=ABS(intop);
for (int i=0; i<row*col; i++)
{
int r=v[i];
int c=r%bb;
if (c<0) c+=bb;
r=(r-c)/intop;
v[i]=r;
}
}

## operator[]() [1/2]

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

inline

Definition at line 66 of file intvec.h.

{
#ifndef SING_NDEBUG
if((i<0)||(i>=row*col))
{
Werror("wrong intvec index:%d\n",i);
}
#endif
return v[i];
}
Werror
void Werror(const char *fmt,...)
Definition reporter.cc:189

## operator[]() [2/2]

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

inline

Definition at line 76 of file intvec.h.

{
#ifndef SING_NDEBUG
if((i<0)||(i>=row*col))
{
Werror("wrong intvec index:%d\n",i);
}
#endif
return v[i];
}

## range() [1/2]

int intvec::range | ( | int | i | ) | const

inline

Definition at line 60 of file intvec.h.

{ return ((((unsigned)i)<((unsigned)row)) && (col==1)); }

## range() [2/2]

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

inline

Definition at line 63 of file intvec.h.

{ return ((((unsigned)i)<((unsigned)row)) && (((unsigned)j)<((unsigned)col))); }

## resize()

void intvec::resize | ( | int | new_length | ) |

Definition at line 106 of file intvec.cc.

{
assume(new_length >= 0 && col == 1);
if (new_length==0)
{
if (v!=NULL)
{
omFreeSize(v, row*sizeof(int));
v=NULL;
}
}
else
{
if (v!=NULL)
v = (int*) omRealloc0Size(v, row*sizeof(int), new_length*sizeof(int));
else
v = (int*) omAlloc0(new_length*sizeof(int));
}
row = new_length;
}
omRealloc0Size
#define omRealloc0Size(addr, o_size, size)
Definition omAllocDecl.h:221

## rows()

int intvec::rows | ( |  | ) | const

inline

Definition at line 97 of file intvec.h.

{ return row; }

## show()

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

Definition at line 149 of file intvec.cc.

{
char *s=ivString(notmat,spaces);
if (spaces>0)
{
PrintNSpaces(spaces);
PrintS(s);
}
else
{
PrintS(s);
}
omFree(s);
}
intvec::ivString
char * ivString(int not_mat=1, int spaces=0, int dim=2) const
Definition intvec.cc:58
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
PrintNSpaces
void PrintNSpaces(const int n)
Definition reporter.cc:368
PrintS
void PrintS(const char *s)
Definition reporter.cc:288

## String()

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

Definition at line 127 of file intvec.cc.

{
return ivString(1, 0, dim);
}

## Field Documentation

## col

int intvec::col

private

Definition at line 28 of file intvec.h.

## row

int intvec::row

private

Definition at line 27 of file intvec.h.

## v

int* intvec::v

private

Definition at line 26 of file intvec.h.

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

- libpolys/misc/intvec.h
- libpolys/misc/intvec.cc