flower-1.0.1
[lilypond.git] / smat.hh
blobc05d032d894c684378592c6c38fa83cb51cb2575
1 #ifndef SMAT_HH
2 #define SMAT_HH
3 #include "vray.hh"
4 #include "vsmat.hh"
5 #include "real.hh"
6 /// simplest matrix storage. refer to its baseclass for the doco.
7 class Full_storage : public virtual_smat
9 /// height, width
10 int h,w;
11 /// maxima.
12 int maxh, maxw;
14 /// the storage
15 Real** els;
16 void
17 init() {
18 els=0;
19 h=w=maxh=maxw=0;
23 bool valid(int i, int j) const {
24 return (i>=0 && i < h)
25 && (j < w && j >=0);
29 void resize_rows(int);
30 void resize_cols(int);
32 public:
33 virtual int rows() const {
34 return h;
36 virtual int cols() const {
37 return w;
41 virtual void set_size(int i, int j)
43 resize(i,j); //this could be more efficient.
46 virtual void set_size(int i) {
47 set_size(i,i);
49 virtual void resize(int i, int j);
50 virtual void resize(int i) {
51 resize(i,i);
54 virtual Real& elem(int i,int j) {
55 assert(valid(i,j));
56 return els[i][j];
58 virtual const Real& elem(int i, int j) const {
59 assert(valid(i,j));
60 return els[i][j];
62 virtual svec<Real> row(int i) const;
63 virtual svec<Real> column(int j) const;
65 Full_storage() {
66 init();
68 Full_storage(int i, int j) {
69 init();
70 set_size(i,j);
72 Full_storage(Full_storage&);
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);
82 virtual void delete_column(int k);
85 ~Full_storage();
86 virtual bool mult_ok(int i, int j)const;
87 virtual void mult_next(int &i, int &j) const ;
88 virtual bool trans_ok(int i, int j) const;
89 virtual void trans_next(int &i, int &j) const;
90 virtual virtual_smat * clone();
93 #endif