/usr/include/singular/singular/misc/intvec.h is in libsingular4-dev-common 4.0.3+ds-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | #ifndef INTVEC_H
#define INTVEC_H
/****************************************
* Computer Algebra System SINGULAR *
****************************************/
/*
* ABSTRACT: class intvec: lists/vectors of integers
*/
#include <string.h>
#include <omalloc/omalloc.h>
#include <reporter/reporter.h>
//extern omBin intvec_bin;
class intvec
{
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)); }
inline int range(int i, int j) const
{ return ((i<row) && (i>=0) && (j<col) && (j>=0)); }
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; }
inline void length(int l) { row = l; col = 1; }
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;
}
#if 0
// TODO: no omalloc Bin (de-)/allocation?
void* operator new ( size_t size )
{
void* addr;
//omTypeAlloc(void*, addr, size);
addr=omAlloc0Bin(intvec_bin);
return addr;
}
void operator delete ( void* block )
{ //omfree( block );
omFreeBin((ADDRESS)block, intvec_bin);
}
#endif
// keiner (ausser obachman) darf das folgenden benutzen !!!
inline int * ivGetVec() { return v; }
};
inline intvec * ivCopy(const intvec * o)
{
if( o != NULL )
return new intvec(o);
return NULL;
}
intvec * ivAdd(intvec * a, intvec * b);
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);
#ifdef MDEBUG
inline void ivTest(intvec * v)
{
v->ivTEST();
}
#else
#define ivTest(v) do {} while (0)
#endif
#undef INLINE_THIS
#endif
|