summaryrefslogtreecommitdiff
path: root/esolid/wrapper/include/bigint_matrix.h
blob: b9c0c6f64a36a010bcc927ab746b8a2869e861d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//  file:    bigint_matrix.h
//  update:  09/25/02

#ifndef _BIGINT_MATRIX_H
#define _BIGINT_MATRIX_H

#include <cassert>
#include <cstdlib>
#include <iostream>

#include "bigint.h"

using namespace std;

class bigint_matrix
{
friend class bigrational_matrix;
  
private:
  
  unsigned long num_row;
  unsigned long num_col;
  bigint*       rep;
  
  //  arithmetic
  
  bigint_matrix add(const bigint_matrix&) const;
  bigint_matrix sub(const bigint_matrix&) const;
  bigint_matrix mul(const bigint_matrix&) const;
  
  bigint_matrix neg() const;
  
//  bigint_matrix scalar_mul(const bigint&) const;
  
  //  comparison
  
  int cmp(const bigint_matrix&) const;
  
  //  square matrix
  
  int    is_identity() const;
  bigint det() const;
  
public:
  
  //  constructor, assignment and destructor
  
  bigint_matrix(const unsigned long = 1, const unsigned long = 1);
  bigint_matrix(const unsigned long, const unsigned long, const bigint*);
  
  bigint_matrix(const bigint_matrix&);
  bigint_matrix& operator =(const bigint_matrix&);
  
  ~bigint_matrix();
  
  //  size
  
  unsigned long get_num_row() const;
  unsigned long get_num_col() const;
  
  //  element
  
  bigint& operator ()(const unsigned long, const unsigned long) const;
  
  //  arithmetic
  
  friend bigint_matrix operator +(const bigint_matrix&, const bigint_matrix&);
  friend bigint_matrix operator -(const bigint_matrix&, const bigint_matrix&);
  friend bigint_matrix operator *(const bigint_matrix&, const bigint_matrix&);
  
  friend bigint_matrix operator -(const bigint_matrix&);
  
//  friend bigint_matrix scalar_mul(const bigint&, const bigint_matrix&);
  
  //  comparison
  
  friend int operator ==(const bigint_matrix&, const bigint_matrix&);
  friend int operator !=(const bigint_matrix&, const bigint_matrix&);
  
  //  arithemtic and assignment
  
  bigint_matrix& operator +=(const bigint_matrix&);
  bigint_matrix& operator -=(const bigint_matrix&);
  
//  bigint_matrix& scalar_mul_assign(const bigint&);
  
  //  square matrix
  
  friend bigint det(const bigint_matrix&);
  
  //  stream
  
  friend ostream& operator <<(ostream&, const bigint_matrix&);
};

inline unsigned long bigint_matrix :: get_num_row() const
{
  return num_row;
}

inline unsigned long bigint_matrix :: get_num_col() const
{
  return num_col;
}

inline bigint& bigint_matrix :: operator ()(const unsigned long r,
                                            const unsigned long c) const
{
  return rep[r * num_col + c];
}

#endif