1 | #ifndef INT64VEC_H |
---|
2 | #define INT64VEC_H |
---|
3 | /**************************************** |
---|
4 | * Computer Algebra System SINGULAR * |
---|
5 | ****************************************/ |
---|
6 | /* |
---|
7 | * ABSTRACT: class intvec: lists/vectors of int64 |
---|
8 | */ |
---|
9 | #include <string.h> |
---|
10 | #include "misc/auxiliary.h" |
---|
11 | |
---|
12 | #include "misc/auxiliary.h" |
---|
13 | #ifdef HAVE_OMALLOC |
---|
14 | #include "omalloc/omalloc.h" |
---|
15 | #include "omalloc/omallocClass.h" |
---|
16 | #else |
---|
17 | #include "xalloc/omalloc.h" |
---|
18 | #endif |
---|
19 | |
---|
20 | #include "misc/intvec.h" |
---|
21 | |
---|
22 | class int64vec |
---|
23 | #ifdef HAVE_OMALLOC |
---|
24 | :public omallocClass |
---|
25 | #endif |
---|
26 | { |
---|
27 | private: |
---|
28 | int64 *v; |
---|
29 | int row; |
---|
30 | int col; |
---|
31 | public: |
---|
32 | |
---|
33 | int64vec(int l = 1) |
---|
34 | { |
---|
35 | v = (int64 *)omAlloc0(sizeof(int64)*l); |
---|
36 | row = l; |
---|
37 | col = 1; |
---|
38 | } |
---|
39 | int64vec(int r, int c, int64 init); |
---|
40 | int64vec(int64vec* iv); |
---|
41 | int64vec(intvec* iv); |
---|
42 | int64& operator[](int i) |
---|
43 | { |
---|
44 | #ifndef SING_NDEBUG |
---|
45 | if((i<0)||(i>=row*col)) |
---|
46 | { |
---|
47 | Werror("wrong int64vec index:%d\n",i); |
---|
48 | } |
---|
49 | #endif |
---|
50 | return v[i]; |
---|
51 | } |
---|
52 | inline const int64& operator[](int i) const |
---|
53 | { |
---|
54 | #ifndef SING_NDEBUG |
---|
55 | if((i<0)||(i>=row*col)) |
---|
56 | { |
---|
57 | Werror("wrong int64vec index:%d\n",i); |
---|
58 | } |
---|
59 | #endif |
---|
60 | return v[i]; |
---|
61 | } |
---|
62 | void operator*=(int64 intop); |
---|
63 | void operator/=(int64 intop); |
---|
64 | // -2: not compatible, -1: <, 0:=, 1: > |
---|
65 | int compare(const int64vec* o) const; |
---|
66 | int length() const { return col*row; } |
---|
67 | int cols() const { return col; } |
---|
68 | int rows() const { return row; } |
---|
69 | void show(int mat=0,int spaces=0); |
---|
70 | char * String(int dim = 2); |
---|
71 | char * iv64String(int not_mat=1,int mat=0,int spaces=0, int dim=2); |
---|
72 | int64 * iv64GetVec() { return v; } |
---|
73 | ~int64vec() |
---|
74 | { |
---|
75 | if (v!=NULL) |
---|
76 | { |
---|
77 | omFreeSize((ADDRESS)v,sizeof(int64)*row*col); |
---|
78 | v=NULL; |
---|
79 | } |
---|
80 | } |
---|
81 | void iv64TEST() |
---|
82 | { |
---|
83 | omCheckAddrSize((ADDRESS)v,sizeof(int64)*row*col); |
---|
84 | } |
---|
85 | }; |
---|
86 | inline int64vec * iv64Copy(int64vec * o) |
---|
87 | { |
---|
88 | int64vec * iv=new int64vec(o); |
---|
89 | return iv; |
---|
90 | } |
---|
91 | |
---|
92 | int64vec * iv64Add(int64vec * a, int64vec * b); |
---|
93 | int64vec * iv64Sub(int64vec * a, int64vec * b); |
---|
94 | |
---|
95 | #ifdef MDEBUG |
---|
96 | #define iv64Test(v) v->iv64TEST() |
---|
97 | #else |
---|
98 | #define iv64Test(v) do {} while (0) |
---|
99 | #endif |
---|
100 | |
---|
101 | #endif |
---|