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
|
#ifndef SMAT_HH
#define SMAT_HH
#include "vray.hh"
#include "vsmat.hh"
#include "real.hh"
/// simplest matrix storage. refer to its baseclass for the doco.
class Full_storage : public virtual_smat
{
/// height, width
int h,w;
/// maxima.
int maxh, maxw;
/// the storage
Real** els;
void
init() {
els=0;
h=w=maxh=maxw=0;
}
bool valid(int i, int j) const {
return (i>=0 && i < h)
&& (j < w && j >=0);
}
void resize_rows(int);
void resize_cols(int);
public:
virtual int rows() const {
return h;
}
virtual int cols() const {
return w;
}
virtual void set_size(int i, int j)
{
resize(i,j); //this could be more efficient.
}
virtual void set_size(int i) {
set_size(i,i);
}
virtual void resize(int i, int j);
virtual void resize(int i) {
resize(i,i);
}
virtual Real& elem(int i,int j) {
assert(valid(i,j));
return els[i][j];
}
virtual const Real& elem(int i, int j) const {
assert(valid(i,j));
return els[i][j];
}
virtual svec<Real> row(int i) const;
virtual svec<Real> column(int j) const;
Full_storage() {
init();
}
Full_storage(int i, int j) {
init();
set_size(i,j);
}
Full_storage(Full_storage&);
Full_storage(int i) {
init();
set_size(i);
}
void OK() const;
void operator=(Full_storage const &);
virtual void insert_row(int k);
virtual void delete_row(int k);
virtual void delete_column(int k);
~Full_storage();
virtual bool mult_ok(int i, int j)const;
virtual void mult_next(int &i, int &j) const ;
virtual bool trans_ok(int i, int j) const;
virtual void trans_next(int &i, int &j) const;
virtual virtual_smat * clone();
};
#endif
|