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