1 | #ifndef BIGINTMAT_H |
---|
2 | #define BIGINTMAT_H |
---|
3 | /**************************************** |
---|
4 | * Computer Algebra System SINGULAR * |
---|
5 | ****************************************/ |
---|
6 | /* |
---|
7 | * ABSTRACT: class bigintmat: matrizes of big integers |
---|
8 | */ |
---|
9 | #include <string.h> |
---|
10 | #include <omalloc/omalloc.h> |
---|
11 | #include <coeffs/coeffs.h> |
---|
12 | #include <coeffs/longrat.h> |
---|
13 | #include <misc/intvec.h> |
---|
14 | |
---|
15 | |
---|
16 | class bigintmat |
---|
17 | { |
---|
18 | private: |
---|
19 | number *v; |
---|
20 | int row; |
---|
21 | int col; |
---|
22 | public: |
---|
23 | |
---|
24 | bigintmat() |
---|
25 | { |
---|
26 | row = 1; |
---|
27 | col = 0; |
---|
28 | v = NULL; |
---|
29 | } |
---|
30 | bigintmat(int r, int c); |
---|
31 | |
---|
32 | bigintmat(const bigintmat *m) |
---|
33 | { |
---|
34 | row = m->rows(); |
---|
35 | col = m->cols(); |
---|
36 | if (row*col>0) |
---|
37 | { |
---|
38 | v = (number *)omAlloc(sizeof(number)*row*col); |
---|
39 | for (int i=row*col-1; i>=0; i--) |
---|
40 | { |
---|
41 | v[i] = nlCopy((*m)[i],NULL); |
---|
42 | } |
---|
43 | } |
---|
44 | } |
---|
45 | |
---|
46 | |
---|
47 | inline number& operator[](int i) |
---|
48 | { |
---|
49 | #ifndef NDEBUG |
---|
50 | if((i<0)||(i>=row*col)) |
---|
51 | { |
---|
52 | Werror("wrong bigintmat index:%d\n",i); |
---|
53 | } |
---|
54 | #endif |
---|
55 | return v[i]; // Hier sollte imho kein nlCopy rein... |
---|
56 | } |
---|
57 | inline const number& operator[](int i) const |
---|
58 | { |
---|
59 | #ifndef NDEBUG |
---|
60 | if((i<0)||(i>=row*col)) |
---|
61 | { |
---|
62 | Werror("wrong bigintmat index:%d\n",i); |
---|
63 | } |
---|
64 | #endif |
---|
65 | return v[i]; |
---|
66 | } |
---|
67 | |
---|
68 | #define BIMATELEM(M,I,J) (M)[(I-1)*(M).cols()+J-1] |
---|
69 | void operator*=(int intop); |
---|
70 | void operator*=(number bintop); |
---|
71 | inline int cols() const { return col; } |
---|
72 | inline int rows() const { return row; } |
---|
73 | inline ~bigintmat() |
---|
74 | { |
---|
75 | if (v!=NULL) |
---|
76 | { |
---|
77 | for (int i=0; i<row*col; i++) { nlDelete(&(v[i]), NULL); } |
---|
78 | omFreeSize((ADDRESS)v,sizeof(number)*row*col); |
---|
79 | v=NULL; |
---|
80 | } |
---|
81 | } |
---|
82 | number get(int i, int j); |
---|
83 | number get(int i); |
---|
84 | void set(int i, int j, number n); |
---|
85 | void set(int i, number n); |
---|
86 | char * String(); |
---|
87 | void pprint(int maxwid); |
---|
88 | int compare(const bigintmat* op) const; |
---|
89 | int getwid(int maxwid); |
---|
90 | }; |
---|
91 | bool operator==(bigintmat & lhr, bigintmat & rhr); |
---|
92 | bool operator!=(bigintmat & lhr, bigintmat & rhr); |
---|
93 | bigintmat * bimAdd(bigintmat * a, bigintmat * b); |
---|
94 | bigintmat * bimSub(bigintmat * a, bigintmat * b); |
---|
95 | bigintmat * bimMult(bigintmat * a, bigintmat * b); |
---|
96 | intvec * bim2iv(bigintmat * b); |
---|
97 | bigintmat * bimCopy(const bigintmat * b); |
---|
98 | static void bimRowContent(bigintmat *bimat, int rowpos, int colpos); |
---|
99 | static void bimReduce(bigintmat *bimat, int rpiv, int colpos, |
---|
100 | int ready, int all); |
---|
101 | |
---|
102 | bigintmat * iv2bim(intvec * b); |
---|
103 | #endif |
---|