My Project
Loading...
Searching...
No Matches
intvec.h
Go to the documentation of this file.
1#ifndef INTVEC_H
2#define INTVEC_H
3/****************************************
4* Computer Algebra System SINGULAR *
5****************************************/
6/*
7* ABSTRACT: class intvec: lists/vectors of integers
8*/
9#include <string.h>
10#include "misc/auxiliary.h"
11#include "omalloc/omalloc.h"
12#ifdef HAVE_OMALLOC
14#endif
15
16#include "reporter/reporter.h"
17
18
19class intvec
20#ifdef HAVE_OMALLOC
21 :public omallocClass
22#endif
23{
24private:
25 int *v;
26 int row;
27 int col;
28public:
29
30 inline intvec(int l = 1)
31 {
32 assume(l >= 0);
33 if (l>0) v = (int *)omAlloc0(sizeof(int)*l);
34 else v = NULL;
35 row = l;
36 col = 1;
37 }
38 intvec(int s, int e);
39 intvec(int r, int c, int init);
40 intvec(const intvec* iv)
41 {
42 assume( iv != NULL );
43 row = iv->rows();
44 col = iv->cols();
45 assume(row >= 0);
46 assume(col >= 0);
47 if (row*col>0)
48 {
49 v = (int *)omAlloc(sizeof(int)*row*col);
50 for (int i=row*col-1;i>=0; i--)
51 {
52 v[i] = (*iv)[i];
53 }
54 }
55 else v=NULL;
56 }
57
58 void resize(int new_length);
59 inline int range(int i) const
60 //{ return ((i<row) && (i>=0) && (col==1)); }
61 { return ((((unsigned)i)<((unsigned)row)) && (col==1)); }
62 inline int range(int i, int j) const
63 //{ return ((i<row) && (i>=0) && (j<col) && (j>=0)); }
64 { return ((((unsigned)i)<((unsigned)row)) && (((unsigned)j)<((unsigned)col))); }
65 inline int& operator[](int i)
66 {
67#ifndef SING_NDEBUG
68 if((i<0)||(i>=row*col))
69 {
70 Werror("wrong intvec index:%d\n",i);
71 }
72#endif
73 return v[i];
74 }
75 inline const int& operator[](int i) const
76 {
77#ifndef SING_NDEBUG
78 if((i<0)||(i>=row*col))
79 {
80 Werror("wrong intvec index:%d\n",i);
81 }
82#endif
83 return v[i];
84 }
85#define IMATELEM(M,I,J) (M)[(I-1)*(M).cols()+J-1]
86 void operator+=(int intop);
87 void operator-=(int intop);
88 void operator*=(int intop);
89 void operator/=(int intop);
90 void operator%=(int intop);
91 // -2: not compatible, -1: <, 0:=, 1: >
92 int compare(const intvec* o) const;
93 int compare(int o) const;
94 inline int length() const { return col*row; }
95 inline int cols() const { return col; }
96 inline int rows() const { return row; }
97 void show(int mat=0,int spaces=0) const;
98 #ifndef SING_NDEBUG
99 void view() const;
100 #endif
101
102 inline void makeVector() { row*=col;col=1; }
103 char * String(int dim = 2) const;
104 char * ivString(int not_mat=1,int spaces=0, int dim=2) const;
105 inline ~intvec()
106 {
107 assume(row>=0);
108 assume(col>=0);
109 if (v!=NULL)
110 {
111 omFreeSize((ADDRESS)v,sizeof(int)*row*col);
112 v=NULL;
113 }
114 }
115 inline void ivTEST() const
116 {
117 assume(row>=0);
118 assume(col>=0);
119 if (row>0) omCheckAddrSize((ADDRESS)v,sizeof(int)*row*col);
120 }
121 inline int min_in()
122 {
123 int m=0;
124 if (row>0)
125 {
126 m=v[0];
127 for (int i=row*col-1; i>0; i--) if (v[i]<m) m=v[i];
128 }
129 return m;
130 }
131 inline int max_in()
132 {
133 int m=0;
134 if (row>0)
135 {
136 m=v[0];
137 for (int i=row*col-1; i>0; i--) if (v[i]>m) m=v[i];
138 }
139 return m;
140 }
141 intvec* delete_pos(int p);
142 // keiner (ausser obachman) darf das folgenden benutzen !!!
143 inline int * ivGetVec() const { return v; }
144};
145inline intvec * ivCopy(const intvec * o)
146{
147 if( o != NULL )
148 return new intvec(o);
149 return NULL;
150}
151
152intvec * ivAdd(intvec * a, intvec * b);
153intvec * ivAddShift(intvec * a, intvec * b, int s);
154intvec * ivSub(intvec * a, intvec * b);
155intvec * ivTranp(intvec * o);
156int ivTrace(intvec * o);
157intvec * ivMult(intvec * a, intvec * b);
158//void ivTriangMat(intvec * imat);
159void ivTriangIntern(intvec * imat, int &ready, int &all);
160intvec * ivSolveKern(intvec * imat, int ready);
161intvec * ivConcat(intvec * a, intvec * b);
162
163#ifdef MDEBUG
164inline void ivTest(intvec * v)
165{
166 v->ivTEST();
167}
168#else
169#define ivTest(v) do {} while (0)
170#endif
171
172#undef INLINE_THIS
173
174#endif
All the auxiliary stuff.
void * ADDRESS
Definition: auxiliary.h:119
int l
Definition: cfEzgcd.cc:100
int m
Definition: cfEzgcd.cc:128
int i
Definition: cfEzgcd.cc:132
int p
Definition: cfModGcd.cc:4078
CanonicalForm b
Definition: cfModGcd.cc:4103
Definition: intvec.h:23
void makeVector()
Definition: intvec.h:102
int max_in()
Definition: intvec.h:131
int & operator[](int i)
Definition: intvec.h:65
~intvec()
Definition: intvec.h:105
intvec(const intvec *iv)
Definition: intvec.h:40
intvec * delete_pos(int p)
Definition: intvec.cc:842
intvec(int l=1)
Definition: intvec.h:30
int range(int i) const
Definition: intvec.h:59
void resize(int new_length)
Definition: intvec.cc:106
void operator%=(int intop)
Definition: intvec.cc:193
void show(int mat=0, int spaces=0) const
Definition: intvec.cc:149
int min_in()
Definition: intvec.h:121
int col
Definition: intvec.h:27
int length() const
Definition: intvec.h:94
void operator/=(int intop)
Definition: intvec.cc:179
void operator+=(int intop)
Definition: intvec.cc:164
char * String(int dim=2) const
Definition: intvec.cc:127
int compare(const intvec *o) const
Definition: intvec.cc:206
int row
Definition: intvec.h:26
const int & operator[](int i) const
Definition: intvec.h:75
int range(int i, int j) const
Definition: intvec.h:62
int * v
Definition: intvec.h:25
char * ivString(int not_mat=1, int spaces=0, int dim=2) const
Definition: intvec.cc:58
void operator*=(int intop)
Definition: intvec.cc:174
void operator-=(int intop)
Definition: intvec.cc:169
int cols() const
Definition: intvec.h:95
void ivTEST() const
Definition: intvec.h:115
int rows() const
Definition: intvec.h:96
void view() const
Definition: intvec.cc:134
int * ivGetVec() const
Definition: intvec.h:143
const CanonicalForm int s
Definition: facAbsFact.cc:51
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
int j
Definition: facHensel.cc:110
intvec * ivSub(intvec *a, intvec *b)
Definition: intvec.cc:297
intvec * ivCopy(const intvec *o)
Definition: intvec.h:145
int ivTrace(intvec *o)
Definition: intvec.cc:339
intvec * ivSolveKern(intvec *imat, int ready)
Definition: intvec.cc:442
intvec * ivConcat(intvec *a, intvec *b)
Definition: intvec.cc:822
void ivTriangIntern(intvec *imat, int &ready, int &all)
Definition: intvec.cc:404
intvec * ivAddShift(intvec *a, intvec *b, int s)
Definition: intvec.cc:279
intvec * ivAdd(intvec *a, intvec *b)
Definition: intvec.cc:249
#define ivTest(v)
Definition: intvec.h:169
intvec * ivMult(intvec *a, intvec *b)
Definition: intvec.cc:349
intvec * ivTranp(intvec *o)
Definition: intvec.cc:327
#define assume(x)
Definition: mod2.h:389
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omCheckAddrSize(addr, size)
Definition: omAllocDecl.h:327
#define omAlloc0(size)
Definition: omAllocDecl.h:211
#define NULL
Definition: omList.c:12
void Werror(const char *fmt,...)
Definition: reporter.cc:189
int dim(ideal I, ring r)