source: git/libpolys/coeffs/bigintmat.h @ 84fc1f

spielwiese
Last change on this file since 84fc1f was 84fc1f, checked in by Oleksandr Motsak <motsak@…>, 11 years ago
moved Hans's bigintmat from libmisc to libcoeffs (almost verbatim)
  • Property mode set to 100644
File size: 2.3 KB
Line 
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
16class bigintmat
17{
18private:
19  number *v;
20  int row;
21  int col;
22public:
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};
91bool operator==(bigintmat & lhr, bigintmat & rhr);
92bool operator!=(bigintmat & lhr, bigintmat & rhr);
93bigintmat * bimAdd(bigintmat * a, bigintmat * b);
94bigintmat * bimSub(bigintmat * a, bigintmat * b);
95bigintmat * bimMult(bigintmat * a, bigintmat * b);
96intvec * bim2iv(bigintmat * b);
97bigintmat * bimCopy(const bigintmat * b);
98static void bimRowContent(bigintmat *bimat, int rowpos, int colpos);
99static void bimReduce(bigintmat *bimat, int rpiv, int colpos,
100                     int ready, int all);
101
102bigintmat * iv2bim(intvec * b);
103#endif
Note: See TracBrowser for help on using the repository browser.