lilypond-0.0.27
[lilypond.git] / flower / tsmat.hh
blobe8dac44e6e617db2e14ad7e651bdb37130957fed
1 #ifndef SMAT_HH
2 #define SMAT_HH
3 #include "varray.hh"
4 #include "vsmat.hh"
6 /// simplest matrix storage. refer to its baseclass for the doco.
7 template<class T>
8 class Full_storage : public virtual_smat<T>
10 /// height, width
11 int h,w;
12 /// maxima.
13 int maxh, maxw;
15 /// the storage
16 T** els;
17 void
18 init() {
19 els=0;
20 h=w=maxh=maxw=0;
24 bool valid(int i, int j) const {
25 return (i>=0 && i < h)
26 && (j < w && j >=0);
30 void resize_rows(int);
31 void resize_cols(int);
33 public:
34 virtual int rows() const {
35 return h;
37 virtual int cols() const {
38 return w;
42 virtual void set_size(int i, int j)
44 resize(i,j); //this could be more efficient.
47 virtual void set_size(int i) {
48 set_size(i,i);
50 virtual void resize(int i, int j);
51 virtual void resize(int i) {
52 resize(i,i);
55 virtual T& elem(int i,int j) {
56 assert(valid(i,j));
57 return els[i][j];
59 virtual const T& elem(int i, int j) const {
60 assert(valid(i,j));
61 return els[i][j];
63 virtual Array<T> row(int i) const;
64 virtual Array<T> column(int j) const;
66 Full_storage() {
67 init();
69 Full_storage(int i, int j) {
70 init();
71 set_size(i,j);
73 Full_storage(int i) {
74 init();
75 set_size(i);
77 void OK() const;
78 void operator=(Full_storage const &);
80 virtual void insert_row(int k);
81 virtual void delete_row(int k);
84 ~Full_storage();
85 virtual bool mult_ok(int i, int j)const;
86 virtual void mult_next(int &i, int &j) const ;
87 virtual bool trans_ok(int i, int j) const;
88 virtual void trans_next(int &i, int &j) const;
92 #endif