summaryrefslogtreecommitdiff
path: root/esolid/wrapper/include/bigrational_matrix.h
blob: 68916ff2ca95f40e08de0b06e8f2fa00a04d6c23 (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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//  file:    bigrational_matrix.h
//  update:  09/25/02

#ifndef _BIGRATIONAL_MATRIX_H
#define _BIGRATIONAL_MATRIX_H

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

#include "bigrational.h"

using namespace std;

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

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

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

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

#endif