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#include "coeffs/bigintmat.h"
16
17#include "reporter/reporter.h"
18
19
20class intvec
21#ifdef HAVE_OMALLOC
22 :public omallocClass
23#endif
24{
25private:
26 int *v;
27 int row;
28 int col;
29public:
30
31 inline intvec(int l = 1)
32 {
33 assume(l >= 0);
34 if (l>0) v = (int *)omAlloc0(sizeof(int)*l);
35 else v = NULL;
36 row = l;
37 col = 1;
38 }
39 intvec(int s, int e);
40 intvec(int r, int c, int init);
41 intvec(const intvec* iv)
42 {
43 assume( iv != NULL );
44 row = iv->rows();
45 col = iv->cols();
46 assume(row >= 0);
47 assume(col >= 0);
48 if (row*col>0)
49 {
50 v = (int *)omAlloc(sizeof(int)*row*col);
51 for (int i=row*col-1;i>=0; i--)
52 {
53 v[i] = (*iv)[i];
54 }
55 }
56 else v=NULL;
57 }
58
59 void resize(int new_length);
60 inline int range(int i) const
61 //{ return ((i<row) && (i>=0) && (col==1)); }
62 { return ((((unsigned)i)<((unsigned)row)) && (col==1)); }
63 inline int range(int i, int j) const
64 //{ return ((i<row) && (i>=0) && (j<col) && (j>=0)); }
65 { return ((((unsigned)i)<((unsigned)row)) && (((unsigned)j)<((unsigned)col))); }
66 inline int& operator[](int i)
67 {
68#ifndef SING_NDEBUG
69 if((i<0)||(i>=row*col))
70 {
71 Werror("wrong intvec index:%d\n",i);
72 }
73#endif
74 return v[i];
75 }
76 inline const int& operator[](int i) const
77 {
78#ifndef SING_NDEBUG
79 if((i<0)||(i>=row*col))
80 {
81 Werror("wrong intvec index:%d\n",i);
82 }
83#endif
84 return v[i];
85 }
86#define IMATELEM(M,I,J) (M)[(I-1)*(M).cols()+J-1]
87 void operator+=(int intop);
88 void operator-=(int intop);
89 void operator*=(int intop);
90 void operator/=(int intop);
91 void operator%=(int intop);
92 // -2: not compatible, -1: <, 0:=, 1: >
93 int compare(const intvec* o) const;
94 int compare(int o) const;
95 inline int length() const { return col*row; }
96 inline int cols() const { return col; }
97 inline int rows() const { return row; }
98 void show(int mat=0,int spaces=0) const;
99 #ifndef SING_NDEBUG
100 void view() const;
101 #endif
102
103 inline void makeVector() { row*=col;col=1; }
104 char * String(int dim = 2) const;
105 char * ivString(int not_mat=1,int spaces=0, int dim=2) const;
106 inline ~intvec()
107 {
108 assume(row>=0);
109 assume(col>=0);
110 if (v!=NULL)
111 {
112 omFreeSize((ADDRESS)v,sizeof(int)*row*col);
113 v=NULL;
114 }
115 }
116 inline void ivTEST() const
117 {
118 assume(row>=0);
119 assume(col>=0);
120 if (row>0) omCheckAddrSize((ADDRESS)v,sizeof(int)*row*col);
121 }
122 inline int min_in()
123 {
124 int m=0;
125 if (row>0)
126 {
127 m=v[0];
128 for (int i=row*col-1; i>0; i--) if (v[i]<m) m=v[i];
129 }
130 return m;
131 }
132 inline int max_in()
133 {
134 int m=0;
135 if (row>0)
136 {
137 m=v[0];
138 for (int i=row*col-1; i>0; i--) if (v[i]>m) m=v[i];
139 }
140 return m;
141 }
142 intvec* delete_pos(int p);
143 // keiner (ausser obachman) darf das folgenden benutzen !!!
144 inline int * ivGetVec() const { return v; }
145};
146inline intvec * ivCopy(const intvec * o)
147{
148 if( o != NULL )
149 return new intvec(o);
150 return NULL;
151}
152
153intvec * ivAdd(intvec * a, intvec * b);
154intvec * ivAddShift(intvec * a, intvec * b, int s);
155intvec * ivSub(intvec * a, intvec * b);
156intvec * ivTranp(intvec * o);
157int ivTrace(intvec * o);
158intvec * ivMult(intvec * a, intvec * b);
159//void ivTriangMat(intvec * imat);
160void ivTriangIntern(intvec * imat, int &ready, int &all);
161intvec * ivSolveKern(intvec * imat, int ready);
162intvec * ivConcat(intvec * a, intvec * b);
163
164bigintmat* iv2biv(intvec* hilb, const coeffs cf);
165
166#ifdef MDEBUG
167inline void ivTest(intvec * v)
168{
169 v->ivTEST();
170}
171#else
172#define ivTest(v) do {} while (0)
173#endif
174
175#undef INLINE_THIS
176
177#endif
All the auxiliary stuff.
void * ADDRESS
Definition auxiliary.h:120
int l
Definition cfEzgcd.cc:100
int m
Definition cfEzgcd.cc:128
int i
Definition cfEzgcd.cc:132
int p
Definition cfModGcd.cc:4086
CanonicalForm cf
Definition cfModGcd.cc:4091
CanonicalForm b
Definition cfModGcd.cc:4111
Matrices of numbers.
Definition bigintmat.h:51
void makeVector()
Definition intvec.h:103
int max_in()
Definition intvec.h:132
int & operator[](int i)
Definition intvec.h:66
~intvec()
Definition intvec.h:106
intvec(const intvec *iv)
Definition intvec.h:41
intvec * delete_pos(int p)
Definition intvec.cc:842
intvec(int l=1)
Definition intvec.h:31
int range(int i) const
Definition intvec.h:60
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:122
int col
Definition intvec.h:28
int length() const
Definition intvec.h:95
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:27
const int & operator[](int i) const
Definition intvec.h:76
int range(int i, int j) const
Definition intvec.h:63
int * v
Definition intvec.h:26
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:96
void ivTEST() const
Definition intvec.h:116
int rows() const
Definition intvec.h:97
int * ivGetVec() const
Definition intvec.h:144
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:146
int ivTrace(intvec *o)
Definition intvec.cc:339
bigintmat * iv2biv(intvec *hilb, const coeffs cf)
Definition intvec.cc:851
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:172
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
The main handler for Singular numbers which are suitable for Singular polynomials.
#define omFreeSize(addr, size)
#define omAlloc(size)
#define omCheckAddrSize(addr, size)
#define omAlloc0(size)
#define NULL
Definition omList.c:12
void Werror(const char *fmt,...)
Definition reporter.cc:189
static void view(const intvec *v)
Definition mod_main.cc:164
int dim(ideal I, ring r)