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
|
// file: bigrational_vector.h
// update: 09/25/02
#ifndef _BIGRATIONAL_VECTOR_H
#define _BIGRATIONAL_VECTOR_H
#include <cassert>
#include <cstdlib>
#include <iostream>
#include "bigrational.h"
using namespace std;
class bigrational_vector
{
private:
unsigned long dim;
bigrational* rep;
// arithmetic
bigrational_vector add(const bigrational_vector&) const;
bigrational_vector sub(const bigrational_vector&) const;
bigrational_vector neg() const;
bigrational in_prod(const bigrational_vector&) const;
bigrational_vector scalar_mul(const bigrational&) const;
// comparison
int cmp(const bigrational_vector&) const;
int is_zero() const;
public:
// constructor, assignment and destructor
bigrational_vector(const unsigned long = 1);
bigrational_vector(const unsigned long, const bigrational*);
// bigrational_vector(const bigint_vector&);
bigrational_vector(int, int, int);
bigrational_vector(int, int);
bigrational_vector(const bigrational_vector&);
bigrational_vector& operator =(const bigrational_vector&);
~bigrational_vector();
// size
unsigned long get_dim() const;
// element
bigrational& operator [](const unsigned long) const;
// arithmetic
friend bigrational_vector operator +(const bigrational_vector&,
const bigrational_vector&);
friend bigrational_vector operator -(const bigrational_vector&,
const bigrational_vector&);
friend bigrational_vector operator -(const bigrational_vector&);
friend bigrational in_prod(const bigrational_vector&,
const bigrational_vector&);
friend bigrational_vector scalar_mul(const bigrational&,
const bigrational_vector&);
// comparison
friend int operator ==(const bigrational_vector&, const bigrational_vector&);
friend int operator !=(const bigrational_vector&, const bigrational_vector&);
friend int is_zero(const bigrational_vector&);
// arithemtic and assignment
bigrational_vector& operator +=(const bigrational_vector&);
bigrational_vector& operator -=(const bigrational_vector&);
// bigrational_vector& scalar_mul_assign(const bigrational&);
// stream
friend ostream& operator <<(ostream&, const bigrational_vector&);
};
inline unsigned long bigrational_vector :: get_dim() const
{
return dim;
}
inline
bigrational& bigrational_vector :: operator [](const unsigned long n) const
{
assert(n < dim);
return rep[n];
}
#endif
|