Loading...
Searching...
No Matches
intvec.h
Go to the documentation of this file.
#ifndef INTVEC_H
#define INTVEC_H
/****************************************
* Computer Algebra System SINGULAR *
****************************************/
/*
* ABSTRACT: class intvec: lists/vectors of integers
*/
#include <string.h>
#include "misc/auxiliary.h"
#include "omalloc/omalloc.h"
#ifdef HAVE_OMALLOC
#include "omalloc/omallocClass.h"
#endif
#include "coeffs/bigintmat.h"
#include "reporter/reporter.h"
class intvec
#ifdef HAVE_OMALLOC
:public omallocClass
#endif
{
private:
int *v;
int row;
int col;
public:
inline intvec(int l = 1)
{
assume(l >= 0);
if (l>0) v = (int *)omAlloc0(sizeof(int)*l);
else v = NULL;
row = l;
col = 1;
}
intvec(int s, int e);
intvec(int r, int c, int init);
intvec(const intvec* iv)
{
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;
}
void resize(int new_length);
inline int range(int i) const
//{ return ((i<row) && (i>=0) && (col==1)); }
{ return ((((unsigned)i)<((unsigned)row)) && (col==1)); }
inline int range(int i, int j) const
//{ return ((i<row) && (i>=0) && (j<col) && (j>=0)); }
{ return ((((unsigned)i)<((unsigned)row)) && (((unsigned)j)<((unsigned)col))); }
inline int& operator[](int i)
{
#ifndef SING_NDEBUG
if((i<0)||(i>=row*col))
{
Werror("wrong intvec index:%d\n",i);
}
#endif
return v[i];
}
inline const int& operator[](int i) const
{
#ifndef SING_NDEBUG
if((i<0)||(i>=row*col))
{
Werror("wrong intvec index:%d\n",i);
}
#endif
return v[i];
}
#define IMATELEM(M,I,J) (M)[(I-1)*(M).cols()+J-1]
void operator+=(int intop);
void operator-=(int intop);
void operator*=(int intop);
void operator/=(int intop);
void operator%=(int intop);
// -2: not compatible, -1: <, 0:=, 1: >
int compare(const intvec* o) const;
int compare(int o) const;
inline int length() const { return col*row; }
inline int cols() const { return col; }
inline int rows() const { return row; }
void show(int mat=0,int spaces=0) const;
#ifndef SING_NDEBUG
void view() const;
#endif
inline void makeVector() { row*=col;col=1; }
char * String(int dim = 2) const;
char * ivString(int not_mat=1,int spaces=0, int dim=2) const;
inline ~intvec()
{
assume(row>=0);
assume(col>=0);
if (v!=NULL)
{
omFreeSize((ADDRESS)v,sizeof(int)*row*col);
v=NULL;
}
}
inline void ivTEST() const
{
assume(row>=0);
assume(col>=0);
if (row>0) omCheckAddrSize((ADDRESS)v,sizeof(int)*row*col);
}
inline int min_in()
{
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;
}
inline int max_in()
{
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;
}
intvec* delete_pos(int p);
// keiner (ausser obachman) darf das folgenden benutzen !!!
inline int * ivGetVec() const { return v; }
};
inline intvec * ivCopy(const intvec * o)
{
if( o != NULL )
return new intvec(o);
return NULL;
}
intvec * ivAdd(intvec * a, intvec * b);
intvec * ivAddShift(intvec * a, intvec * b, int s);
intvec * ivSub(intvec * a, intvec * b);
intvec * ivTranp(intvec * o);
int ivTrace(intvec * o);
intvec * ivMult(intvec * a, intvec * b);
//void ivTriangMat(intvec * imat);
void ivTriangIntern(intvec * imat, int &ready, int &all);
intvec * ivSolveKern(intvec * imat, int ready);
intvec * ivConcat(intvec * a, intvec * b);
bigintmat* iv2biv(intvec* hilb, const coeffs cf);
#ifdef MDEBUG
inline void ivTest(intvec * v)
{
v->ivTEST();
}
#else
#define ivTest(v) do {} while (0)
#endif
#undef INLINE_THIS
#endif
auxiliary.h
All the auxiliary stuff.
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
bigintmat.h
l
int l
Definition cfEzgcd.cc:100
m
int m
Definition cfEzgcd.cc:128
i
int i
Definition cfEzgcd.cc:132
p
int p
Definition cfModGcd.cc:4086
cf
CanonicalForm cf
Definition cfModGcd.cc:4091
b
CanonicalForm b
Definition cfModGcd.cc:4111
bigintmat
Matrices of numbers.
Definition bigintmat.h:51
intvec
Definition intvec.h:24
intvec::makeVector
void makeVector()
Definition intvec.h:103
intvec::max_in
int max_in()
Definition intvec.h:132
intvec::operator[]
int & operator[](int i)
Definition intvec.h:66
intvec::~intvec
~intvec()
Definition intvec.h:106
intvec::intvec
intvec(const intvec *iv)
Definition intvec.h:41
intvec::delete_pos
intvec * delete_pos(int p)
Definition intvec.cc:842
intvec::intvec
intvec(int l=1)
Definition intvec.h:31
intvec::range
int range(int i) const
Definition intvec.h:60
intvec::resize
void resize(int new_length)
Definition intvec.cc:106
intvec::operator%=
void operator%=(int intop)
Definition intvec.cc:193
intvec::show
void show(int mat=0, int spaces=0) const
Definition intvec.cc:149
intvec::min_in
int min_in()
Definition intvec.h:122
intvec::col
int col
Definition intvec.h:28
intvec::length
int length() const
Definition intvec.h:95
intvec::operator/=
void operator/=(int intop)
Definition intvec.cc:179
intvec::operator+=
void operator+=(int intop)
Definition intvec.cc:164
intvec::String
char * String(int dim=2) const
Definition intvec.cc:127
intvec::compare
int compare(const intvec *o) const
Definition intvec.cc:206
intvec::row
int row
Definition intvec.h:27
intvec::operator[]
const int & operator[](int i) const
Definition intvec.h:76
intvec::range
int range(int i, int j) const
Definition intvec.h:63
intvec::v
int * v
Definition intvec.h:26
intvec::ivString
char * ivString(int not_mat=1, int spaces=0, int dim=2) const
Definition intvec.cc:58
intvec::operator*=
void operator*=(int intop)
Definition intvec.cc:174
intvec::operator-=
void operator-=(int intop)
Definition intvec.cc:169
intvec::cols
int cols() const
Definition intvec.h:96
intvec::ivTEST
void ivTEST() const
Definition intvec.h:116
intvec::rows
int rows() const
Definition intvec.h:97
intvec::ivGetVec
int * ivGetVec() const
Definition intvec.h:144
omallocClass
Definition omallocClass.h:20
s
const CanonicalForm int s
Definition facAbsFact.cc:51
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
j
int j
Definition facHensel.cc:110
ivSub
intvec * ivSub(intvec *a, intvec *b)
Definition intvec.cc:297
ivCopy
intvec * ivCopy(const intvec *o)
Definition intvec.h:146
ivTrace
int ivTrace(intvec *o)
Definition intvec.cc:339
iv2biv
bigintmat * iv2biv(intvec *hilb, const coeffs cf)
Definition intvec.cc:851
ivSolveKern
intvec * ivSolveKern(intvec *imat, int ready)
Definition intvec.cc:442
ivConcat
intvec * ivConcat(intvec *a, intvec *b)
Definition intvec.cc:822
ivTriangIntern
void ivTriangIntern(intvec *imat, int &ready, int &all)
Definition intvec.cc:404
ivAddShift
intvec * ivAddShift(intvec *a, intvec *b, int s)
Definition intvec.cc:279
ivAdd
intvec * ivAdd(intvec *a, intvec *b)
Definition intvec.cc:249
ivTest
#define ivTest(v)
Definition intvec.h:172
ivMult
intvec * ivMult(intvec *a, intvec *b)
Definition intvec.cc:349
ivTranp
intvec * ivTranp(intvec *o)
Definition intvec.cc:327
assume
#define assume(x)
Definition mod2.h:389
coeffs
The main handler for Singular numbers which are suitable for Singular polynomials.
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210
omCheckAddrSize
#define omCheckAddrSize(addr, size)
Definition omAllocDecl.h:327
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
NULL
#define NULL
Definition omList.c:12
omallocClass.h
omalloc.h
Werror
void Werror(const char *fmt,...)
Definition reporter.cc:189
reporter.h
view
static void view(const intvec *v)
Definition mod_main.cc:164
dim
int dim(ideal I, ring r)
Definition tropicalStrategy.cc:23